@davoodmehraban89 / Factor-easy / commits / 845e756
Fork 0

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

Keep trading route test isolated from reversal reconciliation

davoodmehraban89 committed Sep 29, 2026 at 22:41 UTC 845e7562b5519eeec8232aadf8328419939f5f48
1 file changed +2 -2
scripts/phase3-behavior-check.mjs
+2 -2
@@ -25,8 +25,6 @@ let forbiddenDim=false;try{ctx.jeCreateDraft({date:'1405/07/07',description:'for
25 let duplicateDim=false;try{ctx.jeCreateDraft({date:'1405/07/07',description:'duplicate dim',sourceType:'manual',sourceId:'BAD5',lines:[{accountId:'ar',debit:100,credit:0,dimensions:[{dimensionTypeId:'D_PARTY',dimensionValueId:'CUST1'},{dimensionTypeId:'D_PARTY',dimensionValueId:'CUST1'}]},{accountId:'rev',debit:0,credit:100,dimensions:[]}]})}catch(_){duplicateDim=true}assert(duplicateDim,'duplicate analytic assignment must be rejected');
26 rules.push({accountId:'cash',dimensionTypeId:'D_PARTY',applicability:'optional',active:true});assert(ctx.jeValidateDimensions('cash',[])===true,'optional analytic dimension must allow omission');
27 let unknownDim=false;try{ctx.jeValidateDimensions('cash',[{dimensionTypeId:'UNKNOWN',dimensionValueId:'CUST1'}])}catch(_){unknownDim=true}assert(unknownDim,'undefined analytic dimension must be rejected');
28 -const saleTrading=ctx.jePostSourceRecord('sale',{id:'SALE_TRADING',date:'1405/07/07',grandTotal:100,vat:0,paymentMethod:'cash'});assert(datastore.journalLines.some(x=>x.voucherId===saleTrading.id&&x.accountId==='revTrading'&&x.credit===100),'trading sale did not use activity-specific revenue account');
29 -const purchaseTrading=ctx.jePostSourceRecord('purchase',{id:'PUR_TRADING',date:'1405/07/07',grandTotal:80,vat:0,paymentMethod:'cash'});assert(datastore.journalLines.some(x=>x.voucherId===purchaseTrading.id&&x.accountId==='buyTrading'&&x.debit===80),'trading purchase did not use activity-specific purchase account');
28 const receipt={id:'PAY1',date:'1405/07/07',amount:125000,contactId:'CUST1'};
29 const v=ctx.jePostSourceRecord('receipt',receipt);
30 assert(v.status==='posted','receipt must post');
@@ -39,6 +37,8 @@ assert(v.status==='reversed'&&rv.status==='posted','reversal lifecycle failed');
37 let mutationBlocked=false;try{ctx.jeGuardSourceMutation(receipt,'receipt')}catch(_){mutationBlocked=true}assert(mutationBlocked,'reversed source mutation must fail');
38 let repostBlocked=false;try{ctx.jePostSourceRecord('receipt',receipt)}catch(_){repostBlocked=true}assert(repostBlocked,'reversed source repost must fail');
39 assert(ctx.jeTrialBalance().every(x=>Math.abs(x.balance)<0.0001),'reversal must net original ledger to zero');
40 +const saleTrading=ctx.jePostSourceRecord('sale',{id:'SALE_TRADING',date:'1405/07/07',grandTotal:100,vat:0,paymentMethod:'cash'});assert(datastore.journalLines.some(x=>x.voucherId===saleTrading.id&&x.accountId==='revTrading'&&x.credit===100),'trading sale did not use activity-specific revenue account');
41 +const purchaseTrading=ctx.jePostSourceRecord('purchase',{id:'PUR_TRADING',date:'1405/07/07',grandTotal:80,vat:0,paymentMethod:'cash'});assert(datastore.journalLines.some(x=>x.voucherId===purchaseTrading.id&&x.accountId==='buyTrading'&&x.debit===80),'trading purchase did not use activity-specific purchase account');
42 const ev=ctx.jePostSourceRecord('expense',{id:'EXP_OK',date:'1405/07/08',amount:700});assert(ev.status==='posted','expense source must post');const iv=ctx.jePostSourceRecord('income',{id:'INC_OK',date:'1405/07/08',amount:900});assert(iv.status==='posted','income source must post');
43 fiscal[0].status='locked';let locked=false;try{ctx.jePostSourceRecord('expense',{id:'EXP1',date:'1405/07/09',amount:1000})}catch(_){locked=true}assert(locked,'locked fiscal year must reject posting');
44 console.log('Phase 3 behavioral accounting scenarios passed.');