سامانه صدور فاکتور و حسابداری
test(stage3 audit): require positive net income/purchase amount even with fixed VAT
davoodmehraban89 committed
Oct 23, 2026 at 11:17 UTC
b38306099355f0dc74225efcfe8d418c85163c81
1 file changed
+10
scripts/stage3-legacy-source-audit.test.mjs
+10
@@ -52,6 +52,16 @@ assert.ok(!JSON.stringify(result).includes('Secret-Client-Name'),'Never leak nam
52
assert.ok(!JSON.stringify(result).includes('LEGACY_POSTED'),'Never leak IDs');
53
assert.throws(()=>auditSourceRecords({}),/FINORA_AUDIT_SOURCE_ARRAY_REQUIRED/);
54
assert.throws(()=>auditSourceRecords([{collection:'unknown',data:{}}]),/FINORA_AUDIT_INVALID_SOURCE_SHAPE/);
55
+// SQL-v1 requires a positive net line even if a fixed VAT creates a positive gross.
56
+// A fully discounted source must not become apparently eligible for auto-posting.
57
+const fullDiscount=clone(sale);
58
+fullDiscount.discountInput=200;
59
+fullDiscount.discount=200;
60
+fullDiscount.vatType='fixed';
61
+fullDiscount.vatRate=10;
62
+fullDiscount.vat=10;
63
+fullDiscount.grandTotal=10;
64
+assert.equal(auditSourceRecords([wrap('invoices',fullDiscount,'FULL_DISCOUNT')]).contractMismatch,1);
65
// A zero-VAT historic document with no vatMode is NOT automatically fixed.
66
assert.equal(auditSourceRecords([wrap('invoices',zeroVat,'ZERO')]).reconciliationRequired,1);
67
console.log('FINORA_STAGE3_LEGACY_CLASSIFIER_PASS '+JSON.stringify({