fix: invalidate preparation approval for changed portfolio products
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// Compare declared product facts only; field order and unrelated metadata do not
|
||||
// invalidate a review. Missing/duplicate identities cannot establish provenance.
|
||||
export function portfolioRevision(item) {
|
||||
if (!item || typeof item !== 'object') return null;
|
||||
return JSON.stringify(['id','group','brand','model','kind','utsStatus','utsReference','serviceCapacity'].map(key=>String(item[key] ?? '')));
|
||||
}
|
||||
export function portfolioSelectionProblem(check, portfolio) {
|
||||
if (!check?.portfolioId) return null;
|
||||
if (!Array.isArray(portfolio)) return 'Firma portföyü doğrulanamadı; güncel profili kontrol edin.';
|
||||
const matches=portfolio.filter(item=>item?.id===check.portfolioId);
|
||||
if (matches.length!==1) return 'Seçilen portföy kaydı kaldırılmış veya kimliği belirsiz; ürünü yeniden seçin.';
|
||||
if (check.portfolioSnapshot?.id!==check.portfolioId || portfolioRevision(check.portfolioSnapshot)!==portfolioRevision(matches[0]))
|
||||
return 'Firma portföyündeki ürün bilgileri değişti; güncel ürünü seçip uygunluk kontrollerini yeniden yapın.';
|
||||
return null;
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import {portfolioSelectionProblem} from './portfolioRevision.js';
|
||||
export const HEALTH_CHECKS = [
|
||||
['uts', 'ÜTS / ürün kaydı'],
|
||||
['sample', 'Numune / demonstrasyon'],
|
||||
@@ -37,6 +38,8 @@ export function preparationBlockers(rows, documents, checks = {}, vault) {
|
||||
}
|
||||
for (const row of rows) {
|
||||
const c = checks.products?.[row.priceKey] || {};
|
||||
const portfolioProblem=portfolioSelectionProblem(c,vault?.healthPortfolio);
|
||||
if(portfolioProblem)errors.push(`${row.name}: ${portfolioProblem}`);
|
||||
if (c.status !== 'suitable' || !c.product?.trim() || !c.source?.trim())
|
||||
errors.push(`${row.name}: ürün/hizmet uygunluğu ve teknik kaynak eksik veya uygun değil.`);
|
||||
for (const [key, label] of HEALTH_CHECKS) {
|
||||
|
||||
Reference in New Issue
Block a user