سامانه صدور فاکتور و حسابداری
test: assert immutable posted history and idempotent reversal replay (#216)
davoodmehraban89 committed
Nov 18, 2026 at 21:24 UTC
777a24f7a32d8767add4b82832b22fd2c1b77fac
1 file changed
+6
-3
scripts/accounting-document-workflow.spec.js
+6
-3
@@ -382,7 +382,8 @@ test('posted sale can be returned to an editable corrective draft; original vouc
382
await expect.poll(()=>remoteInvoices(server).find(x=>x.id===result)?.accountingStatus,{timeout:13000}).toBe('posted');
383
const later=[...server.records.values()].filter(x=>x.collection==='journalVouchers');
384
expect(later).toHaveLength(3);
385
- expect(later.find(x=>x.id===originalVoucherId).data.status).toBe('reversed');
385
+ expect(later.find(x=>x.id===originalVoucherId).data.status).toBe('posted');
386
+ expect(server.reversalStatuses.find(x=>x.voucher_id===originalVoucherId)?.effective_status).toBe('reversed');
387
const lines=[...server.records.values()].filter(x=>x.collection==='journalLines');
388
for(const v of later){
389
const subset=lines.filter(l=>l.data.voucherId===v.id);
@@ -448,7 +449,8 @@ test('pilot cancellation preserves posted invoice record while only unposted dra
449
const status=await page.evaluate(id=>invoiceDocumentStatus(getMyInvoices().find(x=>x.id===id)),invoiceId);
450
expect(status).toBe('reversed');
451
const bad=await page.evaluate(async id=>{try{await reopenPostedInvoiceAsDraft(id,'تکرار');return 'unexpected'}catch(e){return String(e.message)}},invoiceId);
451
- expect(bad).not.toBe('unexpected');
452
+ expect(bad).toBe('unexpected');
453
+ expect(server.reverseCount).toBe(1);
454
// A separate never-posted invoice may be deleted; posted history stays intact.
455
await fillInvoice(page,'PILOT-DELETE-DRAFT-001',1);await page.evaluate(()=>commitSaveInvoice());
456
await expect.poll(()=>remoteInvoices(server).length,{timeout:13000}).toBe(2);
@@ -517,7 +519,8 @@ test('pilot purchase: posted to corrective draft to edited balanced repost via d
519
expect(await page.evaluate(()=>productMovement('QA_PROD').available)).toBe(3);
520
const journal=[...server.records.values()].filter(x=>x.collection==='journalVouchers');
521
expect(journal).toHaveLength(3);
520
- expect(journal.find(x=>x.id===voucher).data.status).toBe('reversed');
522
+ expect(journal.find(x=>x.id===voucher).data.status).toBe('posted');
523
+ expect(server.reversalStatuses.find(x=>x.voucher_id===voucher)?.effective_status).toBe('reversed');
524
expect(untouched).toEqual([...server.records.values()].filter(x=>x.collection==='journalLines'&&x.data.voucherId===voucher).map(copy));
525
for(const v of journal){
526
const lines=[...server.records.values()].filter(x=>x.collection==='journalLines'&&x.data.voucherId===v.id);