فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(holoo): audit duplicate invoice numbers and missing accounting codes
Davood Mehraban committed
Nov 22, 2026 at 21:02 UTC
7b9a00e81e72da2a7e0ee3239d65b535c2693db8
2 files changed
+10
-1
scripts/holoo-schema-audit.ps1
+8
@@ -32,6 +32,13 @@ try {
32
$integrity | Add-Member -NotePropertyName candidateSentinelRows -NotePropertyValue $r.GetInt64(1)
33
$integrity | Add-Member -NotePropertyName missingReferencedAccountingDocuments -NotePropertyValue $r.GetInt64(2)
34
} finally {$r.Close()}
35
+ $q.CommandText="SELECT (SELECT COUNT_BIG(*) FROM (SELECT Fac_Type,Fac_Code_C FROM dbo.FACTURE WHERE Fac_Code_C IS NOT NULL GROUP BY Fac_Type,Fac_Code_C HAVING COUNT_BIG(*)>1) d),(SELECT COUNT_BIG(*) FROM dbo.FACTURE WHERE Sanad_Code IS NULL OR Sanad_Code=0)"
36
+ $r=$q.ExecuteReader()
37
+ try {
38
+ if(-not $r.Read()){throw 'Invoice numbering audit returned no row'}
39
+ $integrity | Add-Member -NotePropertyName duplicateInvoiceTypeNumberGroups -NotePropertyValue $r.GetInt64(0)
40
+ $integrity | Add-Member -NotePropertyName invoiceHeadersWithoutAccountingCode -NotePropertyValue $r.GetInt64(1)
41
+ } finally {$r.Close()}
42
$result=[pscustomobject]@{schemaVersion=1;database='HolooBackup_050808_LAB_20261110';readOnlyAudit=$true;tables=$tables;integrity=$integrity;complete=($tables.Count -eq 3);note='Candidate sentinel classification is unverified; raw orphan count retained. No application-level invariants or concurrency claims'}
43
if($Json){$result|ConvertTo-Json -Depth 6}else{$tables|Format-Table -AutoSize;Write-Output ('COMPLETE='+$result.complete)}
44
if(-not $result.complete){exit 2}
@@ -39,3 +46,4 @@ try {
46
47
48
49
+
tests/holoo-schema-audit.test.mjs
+2
-1
@@ -21,7 +21,7 @@ test('real lab structural audit returns three complete primary-keyed tables', {s
21
assert.equal(audit.readOnlyAudit, true);
22
for (const key of ['invoiceHeaders','invoiceLines','accountingDocuments','orphanInvoiceLines']) assert.ok(Number.isSafeInteger(audit.integrity[key]) && audit.integrity[key] >= 0, key);
23
assert.ok(audit.integrity.orphanInvoiceLines <= audit.integrity.invoiceLines);
24
- for(const key of ['orphanInvoiceLinesExcludingCandidateSentinel','candidateSentinelRows','missingReferencedAccountingDocuments']) assert.ok(Number.isSafeInteger(audit.integrity[key]) && audit.integrity[key] >= 0, key);
24
+ for(const key of ['orphanInvoiceLinesExcludingCandidateSentinel','candidateSentinelRows','missingReferencedAccountingDocuments','duplicateInvoiceTypeNumberGroups','invoiceHeadersWithoutAccountingCode']) assert.ok(Number.isSafeInteger(audit.integrity[key]) && audit.integrity[key] >= 0, key);
25
assert.ok(audit.integrity.orphanInvoiceLinesExcludingCandidateSentinel <= audit.integrity.orphanInvoiceLines);
26
assert.deepEqual(audit.tables.map(t => t.table), ['FACTART','FACTURE','SANAD']);
27
for (const table of audit.tables) {
@@ -31,3 +31,4 @@ test('real lab structural audit returns three complete primary-keyed tables', {s
31
});
32
33
34
+