فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
A02: fail closed for incomplete invoice lines, orphan cheque contacts and malformed Holoo master data
davoodmehraban89 committed
Oct 23, 2026 at 02:40 UTC
eebe115a29985b361722474788ff226e84fbb71b
1 file changed
+20
-2
src/core/HolooMigrationPreflight.mjs
+20
-2
@@ -72,11 +72,22 @@ export function previewHolooExtract(input = {}, { maxIssues = 100 } = {}) {
72
return;
73
}
74
for (const key of rules.required) {
75
- if (!nonempty(field(table, record, key))) add('REQUIRED_FIELD_EMPTY', table, i);
75
+ const value=field(table,record,key);
76
+ // Names are human labels, not numeric identifiers: a numeric
77
+ // value must not masquerade as a valid source master-data name.
78
+ const valid=key==='name'
79
+ ? typeof value==='string' && value.trim().length>0
80
+ : nonempty(value);
81
+ if (!valid) add('REQUIRED_FIELD_EMPTY', table, i);
82
}
83
for (const key of rules.money) {
84
if (!money(field(table, record, key))) add('AMOUNT_NOT_INTEGER_RIAL', table, i);
85
}
86
+ if (table === 'cheques' &&
87
+ money(field(table, record, 'amount')) &&
88
+ field(table, record, 'amount') === 0) {
89
+ add('ZERO_VALUE_CHEQUE', table, i);
90
+ }
91
if (table === 'invoices' &&
92
money(field(table, record, 'paidAmount')) &&
93
money(field(table, record, 'grandTotal')) &&
@@ -93,6 +104,12 @@ export function previewHolooExtract(input = {}, { maxIssues = 100 } = {}) {
104
sets[table] = ids;
105
}
106
if (rowTotal === 0) add('SOURCE_HAS_NO_MAPPED_ROWS', 'source');
107
+ // A source invoice without its line-item extract is not a complete
108
+ // accounting migration source, even if the invoice header totals look
109
+ // plausible. Report this safely without inspecting personal data.
110
+ if (counts.invoices > 0 && counts.invoiceLines === 0) {
111
+ add('INVOICE_LINES_REQUIRED', 'invoiceLines');
112
+ }
113
114
// Referential checks run only when both involved key maps are present.
115
// Missing datasets do not prove missing source objects; this is not a
@@ -100,7 +117,8 @@ export function previewHolooExtract(input = {}, { maxIssues = 100 } = {}) {
117
const references = [
118
{ table: 'invoices', key: 'contactId', parent: 'contacts' },
119
{ table: 'invoiceLines', key: 'invoiceId', parent: 'invoices' },
103
- { table: 'invoiceLines', key: 'productId', parent: 'products' }
120
+ { table: 'invoiceLines', key: 'productId', parent: 'products' },
121
+ { table: 'cheques', key: 'contactId', parent: 'contacts' }
122
];
123
for (const { table, key, parent } of references) {
124
const rows = datasets[table] || [];