@davoodmehraban89 / Factor-easy / commits / 261107d
Fork 0

سامانه صدور فاکتور و حسابداری

Verify duplicate rejection is mutation-free

davoodmehraban89 committed Sep 29, 2026 at 22:28 UTC 261107d0b8831dd4e982d8a7db09dfa7cfc6b6dd
1 file changed +1 -1
scripts/phase3-behavior-check.mjs
+1 -1
@@ -29,7 +29,7 @@ assert(v.status==='posted','receipt must post');
29 const lines=datastore.journalLines.filter(x=>x.voucherId===v.id);
30 assert(lines.reduce((s,x)=>s+x.debit,0)===lines.reduce((s,x)=>s+x.credit,0),'receipt must balance');
31 assert(v.fiscalYearId==='FY1','Jalali fiscal year resolution failed');
32 -let dup=false;try{ctx.jePostSourceRecord('receipt',{...receipt,journalVoucherId:''})}catch(_){dup=true}assert(dup,'duplicate source/version must fail');
32 +const voucherCountBeforeDup=datastore.journalVouchers.length,lineCountBeforeDup=datastore.journalLines.length;let dup=false;try{ctx.jePostSourceRecord('receipt',{...receipt,journalVoucherId:''})}catch(_){dup=true}assert(dup,'duplicate source/version must fail');assert(datastore.journalVouchers.length===voucherCountBeforeDup&&datastore.journalLines.length===lineCountBeforeDup,'duplicate source rejection must not leave orphan draft/lines');
33 const rv=ctx.jeReverse(v.id,'1405/07/08','test reversal');
34 assert(v.status==='reversed'&&rv.status==='posted','reversal lifecycle failed');
35 let mutationBlocked=false;try{ctx.jeGuardSourceMutation(receipt,'receipt')}catch(_){mutationBlocked=true}assert(mutationBlocked,'reversed source mutation must fail');