فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

A02: reject mapped invoice headers missing from nonempty line-item extracts

davoodmehraban89 committed Oct 23, 2026 at 10:54 UTC 009bd944a24c837aa0d913c33f7b5cc5bb2a4365
1 file changed +17
src/core/HolooMigrationPreflight.mjs
+17
@@ -109,6 +109,23 @@ export function previewHolooExtract(input = {}, { maxIssues = 100 } = {}) {
109 // plausible. Report this safely without inspecting personal data.
110 if (counts.invoices > 0 && counts.invoiceLines === 0) {
111 add('INVOICE_LINES_REQUIRED', 'invoiceLines');
112 + } else if (counts.invoices > 0 && counts.invoiceLines > 0 &&
113 + typeof mappings.invoices?.sourceId === 'string' &&
114 + typeof mappings.invoiceLines?.invoiceId === 'string') {
115 + // A nonempty line-item export can still omit whole invoices. Report
116 + // uncovered header row indexes, not source IDs, names or invoice values.
117 + // Invalid/unknown source references are checked separately below.
118 + const linked = new Set(datasets.invoiceLines
119 + .filter(row=>row && typeof row === 'object' && !Array.isArray(row))
120 + .map(row=>identity(field('invoiceLines',row,'invoiceId')))
121 + .filter(Boolean));
122 + datasets.invoices.forEach((row,i)=>{
123 + if (!row || typeof row !== 'object' || Array.isArray(row)) return;
124 + const invoiceId=identity(field('invoices',row,'sourceId'));
125 + if (invoiceId && !linked.has(invoiceId)) {
126 + add('INVOICE_WITHOUT_LINES','invoices',i);
127 + }
128 + });
129 }
130
131 // Referential checks run only when both involved key maps are present.