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

test(holoo): distinguish candidate sentinel from true orphan lines

Davood Mehraban committed Nov 22, 2026 at 21:01 UTC 0cd8fb6f9455ced35a05a821b2c26377af481e09
2 files changed +13 -1
scripts/holoo-schema-audit.ps1
+10 -1
@@ -24,9 +24,18 @@ try {
24 if(-not $r.Read()){throw 'Data integrity query returned no row'}
25 $integrity=[pscustomobject]@{invoiceHeaders=$r.GetInt64(0);invoiceLines=$r.GetInt64(1);accountingDocuments=$r.GetInt64(2);orphanInvoiceLines=$r.GetInt64(3)}
26 } finally {$r.Close()}
27 - $result=[pscustomobject]@{schemaVersion=1;database='HolooBackup_050808_LAB_20261110';readOnlyAudit=$true;tables=$tables;integrity=$integrity;complete=($tables.Count -eq 3);note='Structural audit only; no claim of application-level invariants or concurrency safety'}
27 + $q.CommandText="SELECT (SELECT COUNT_BIG(*) FROM dbo.FACTART a LEFT JOIN dbo.FACTURE f ON a.Fac_Code=f.Fac_Code AND a.Fac_Type=f.Fac_Type WHERE f.Fac_Code IS NULL AND NOT (a.Fac_Code='000000' AND a.Fac_Type='L' AND a.A_Code='0000000' AND a.A_Index=0)),(SELECT COUNT_BIG(*) FROM dbo.FACTART WHERE Fac_Code='000000' AND Fac_Type='L' AND A_Code='0000000' AND A_Index=0),(SELECT COUNT_BIG(*) FROM dbo.FACTURE f LEFT JOIN dbo.SANAD s ON f.Sanad_Code=s.Sanad_Code WHERE f.Sanad_Code IS NOT NULL AND f.Sanad_Code<>0 AND s.Sanad_Code IS NULL)"
28 + $r=$q.ExecuteReader()
29 + try {
30 + if(-not $r.Read()){throw 'Detailed integrity query returned no row'}
31 + $integrity | Add-Member -NotePropertyName orphanInvoiceLinesExcludingCandidateSentinel -NotePropertyValue $r.GetInt64(0)
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 + $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'}
36 if($Json){$result|ConvertTo-Json -Depth 6}else{$tables|Format-Table -AutoSize;Write-Output ('COMPLETE='+$result.complete)}
37 if(-not $result.complete){exit 2}
38 } finally {$c.Dispose()}
39
40
41 +
tests/holoo-schema-audit.test.mjs
+3
@@ -21,6 +21,8 @@ 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);
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) {
28 assert.equal(table.primaryKeys, 1);
@@ -28,3 +30,4 @@ test('real lab structural audit returns three complete primary-keyed tables', {s
30 }
31 });
32
33 +