فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
fix(A02): fail closed on skipped CSV rows and ambiguous source mappings
davoodmehraban89 committed
Oct 18, 2026 at 07:09 UTC
2f219331a1fa5698bdf5237026c04b86edc4e955
1 file changed
+13
-5
src/core/HolooDelimitedExportPreflight.mjs
+13
-5
@@ -47,10 +47,12 @@ export function parseStrictDelimitedRows(text, { delimiter = ',' } = {}) {
47
};
48
const submitRecord = () => {
49
submitCell();
50
- if (!(record.length === 1 && record[0] === '')) {
51
- rows.push(record);
52
- if (rows.length > MAX_DATA_ROWS + 1) reject('CSV_TOO_MANY_ROWS');
53
- }
50
+ // Silently skipping empty records would undercount source rows and hide
51
+ // gaps in a migration extract. Only the terminal newline is implicit.
52
+ if (record.length === 1 && record[0].trim() === '')
53
+ reject('CSV_EMPTY_RECORD');
54
+ rows.push(record);
55
+ if (rows.length > MAX_DATA_ROWS + 1) reject('CSV_TOO_MANY_ROWS');
56
record = [];
57
};
58
const input = text.charCodeAt(0) === 0xFEFF ? text.slice(1) : text;
@@ -115,6 +117,7 @@ function compareDeclaredControlTotals(datasets, mappings, declared, maxIssues) {
117
return { checks: 0, issueCount: 0, issues: [] };
118
}
119
if (!validMap(declared)) reject('CONTROL_TOTALS_INVALID');
120
+ if (!Object.keys(declared).length) reject('CONTROL_TOTALS_SCHEMA_INVALID');
121
let checks = 0, issueCount = 0;
122
const issues = [];
123
const add = (code, table) => {
@@ -177,7 +180,12 @@ export function previewHolooDelimitedExport({
180
!validMap(mappings[table])) reject('CSV_TABLE_CONFIGURATION_REQUIRED');
181
const parsed = parseStrictDelimitedRows(item.text, { delimiter: item.delimiter });
182
const mapped = mappings[table];
180
- for (const column of Object.values(mapped)) {
183
+ const mappedColumns = Object.values(mapped);
184
+ // Mapping two canonical fields to one source column is ambiguous for
185
+ // financial reconciliation, even when the source headers are unique.
186
+ if (new Set(mappedColumns).size !== mappedColumns.length)
187
+ reject('CSV_DUPLICATE_SOURCE_COLUMN_MAPPING');
188
+ for (const column of mappedColumns) {
189
if (typeof column !== 'string' || !parsed.headers.includes(column))
190
reject('CSV_MAPPED_COLUMN_ABSENT');
191
}