@davoodmehraban89 / Factor-easy / commits / 894ab15
Fork 0

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

Test forbidden and duplicate analytic assignments

davoodmehraban89 committed Sep 29, 2026 at 22:27 UTC 894ab15abc4704bb5cec31f16c1c3097e4bfeed6
1 file changed +3
scripts/phase3-behavior-check.mjs
+3
@@ -20,6 +20,9 @@ let unbalanced=false;try{ctx.jeCreateDraft({date:'1405/07/07',description:'bad',
20 dimensions.push({id:'D_PARTY',sourceEntity:'contact',active:true});dimensionValues.push({id:'CUST1',dimensionTypeId:'D_PARTY',postable:true},{id:'OTHER',dimensionTypeId:'D_PARTY',postable:false});rules.push({accountId:'ar',dimensionTypeId:'D_PARTY',applicability:'required',active:true});
21 let missingDim=false;try{ctx.jeCreateDraft({date:'1405/07/07',description:'missing dim',sourceType:'manual',sourceId:'BAD2',lines:[{accountId:'ar',debit:100,credit:0,dimensions:[]},{accountId:'rev',debit:0,credit:100,dimensions:[]}]})}catch(_){missingDim=true}assert(missingDim,'required analytic dimension must be enforced');
22 let invalidDim=false;try{ctx.jeCreateDraft({date:'1405/07/07',description:'invalid dim',sourceType:'manual',sourceId:'BAD3',lines:[{accountId:'ar',debit:100,credit:0,dimensions:[{dimensionTypeId:'D_PARTY',dimensionValueId:'OTHER'}]},{accountId:'rev',debit:0,credit:100,dimensions:[]}]})}catch(_){invalidDim=true}assert(invalidDim,'non-postable analytic value must be rejected');
23 +rules.push({accountId:'rev',dimensionTypeId:'D_PARTY',applicability:'unavailable',active:true});
24 +let forbiddenDim=false;try{ctx.jeCreateDraft({date:'1405/07/07',description:'forbidden dim',sourceType:'manual',sourceId:'BAD4',lines:[{accountId:'cash',debit:100,credit:0,dimensions:[]},{accountId:'rev',debit:0,credit:100,dimensions:[{dimensionTypeId:'D_PARTY',dimensionValueId:'CUST1'}]}]})}catch(_){forbiddenDim=true}assert(forbiddenDim,'unavailable analytic dimension must be rejected');
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 const receipt={id:'PAY1',date:'1405/07/07',amount:125000,contactId:'CUST1'};
27 const v=ctx.jePostSourceRecord('receipt',receipt);
28 assert(v.status==='posted','receipt must post');