سامانه صدور فاکتور و حسابداری
Attach contract dimension to contractor postings
davoodmehraban89 committed
Sep 29, 2026 at 22:14 UTC
39470402c87281af5c78147ad10e130db0364be3
1 file changed
+1
-1
js/phase4-contracting.js
+1
-1
@@ -39,7 +39,7 @@ function p4PostStatement(id){
39
try{
40
const ar=jeAccountByCode('1102'),rev=jeAccountByCode('4301')||jeRevenueAccount(),gross=p4Num(s.grossAmount),ded=p4Num(s.deductionAmount),net=gross-ded;
41
if(!ar||!rev)throw new Error('حساب دریافتنی و درآمد پیمان در کدینگ تکمیل نیست.');
42
- const ctx={contactId:c.employerId,projectId:c.projectId},dims=a=>jeDimensionAssignmentsForContext(a,ctx),lines=[{accountId:ar.id,debit:net,credit:0,description:'مطالبات صورتوضعیت '+s.number,dimensions:dims(ar.id)},{accountId:rev.id,debit:0,credit:gross,description:'درآمد پیمان '+s.number,dimensions:dims(rev.id)}];
42
+ const ctx={contactId:c.employerId,projectId:c.projectId,contractId:c.id},dims=a=>jeDimensionAssignmentsForContext(a,ctx),lines=[{accountId:ar.id,debit:net,credit:0,description:'مطالبات صورتوضعیت '+s.number,dimensions:dims(ar.id)},{accountId:rev.id,debit:0,credit:gross,description:'درآمد پیمان '+s.number,dimensions:dims(rev.id)}];
43
const map={retention:'1105',insurance:'1106',withholding_tax:'1107',advance_recovery:'2105',penalty:'6109',other:'1105'};(s.deductionLines||[{type:'retention',title:'کسورات پیمان',amount:ded}]).filter(x=>p4Num(x.amount)>0).forEach(x=>{const a=jeAccountByCode(map[x.type]||'1105');if(!a)throw new Error('حساب متناظر کسور '+x.title+' در کدینگ تعریف نشده است.');if(x.type==='advance_recovery')lines.push({accountId:a.id,debit:p4Num(x.amount),credit:0,description:x.title+' '+s.number,dimensions:dims(a.id)});else lines.push({accountId:a.id,debit:p4Num(x.amount),credit:0,description:x.title+' '+s.number,dimensions:dims(a.id)})});
44
const v=jeCreateDraft({date:s.date,description:'صورتوضعیت پیمان '+s.number,sourceType:'contract_statement',sourceId:s.id,sourceVersion:s.accountingVersion,lines});jePost(v.id);s.status='posted';s.journalVoucherId=v.id;s.postedAt=v.postedAt;p4Audit('statement',s.id,'posted',v.id);saveDatastore();renderPhase4();
45
}catch(e){alert(e.message)}