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

fix: retain project context in contact ledger rows

JVK committed Nov 13, 2026 at 09:25 UTC 4e421da90c2bb11a13ea7b445b8da0c5674b6788
2 files changed +3 -2
PROJECT_STATE.md
+1
@@ -269,3 +269,4 @@ Owner requests layer-by-layer click/functional testing of all controls and compa
269 - Contact summary reproduced two real failures before implementation, then both directions and real unallocated-payment save/reload PASS. Summary now uses exact active company, posted trade invoices and effective payments once, ignores reversed/corrected ancestors, excludes invalid allocations and unposted cheque payments, retains signed advances and displays reconciliation/opening-balance limitations. Posted cheque settlement rows count once even if the register also lists the instrument. No production rows changed.
270 - Initial static invariant required a named net expression; retained the expression and updated its description, without weakening financial assertions. A synthetic foreign-company purchase fixture originally shared the first company's voucher; corrected its company-specific voucher instead of accepting the invalid link. Three focused source/Pages cases passed; final expanded assertions/full regression and exact-head CI are separate gates recorded in this PR.
271 - Cheque registration still has no posting adapter. The existing generic payment profile credits cash even for cheque method; the staged server helper cannot yet accept entity-backed counterparty dimensions. Do not claim that changing the contact display repairs missing journals. Next: authoritative cheque issuance plus linked settlement, lifecycle/duplicate guards, entity-dimension contract and historical reconciliation; no automatic backfill, production migration or G1 approval requested.
272 +- Local contact verification completed245/245 full Chromium(5.8m),3/3 generated Pages including final linked-cheque double-count assertions(5.3s), and51 existing static/server commands with the named-net check rerun PASS. Root final review retained the prior project/cost-centre descriptions in ledger rows; final generated Pages and exact-head CI cover this preservation. No independent reviewer was available; none claimed. Exact SHA/CI/merge/deployment readback is maintained in PR199, not inferred here.
js/drilldown.js
+2 -2
@@ -55,8 +55,8 @@ function contactSummaryNotice(summary){
55 window.openContactLedger=function(contactId){
56 const c=getMyContacts().find(x=>x.id===contactId);if(!c)return;
57 const summary=contactOperationalSummary(contactId),rows=[];
58 - summary.sales.forEach(i=>rows.push({date:i.date,type:'فروش '+(i.paymentMethod==='credit'?'نسیه':'نقدی'),ref:i.number,name:c.name,amount:i.grandTotal,action:invAction(i)}));
59 - summary.purchases.forEach(p=>rows.push({date:p.date,type:'خرید '+(p.paymentMethod==='credit'?'نسیه':'نقدی'),ref:p.number,name:c.name,amount:p.grandTotal,action:purAction(p)}));
58 + summary.sales.forEach(i=>rows.push({date:i.date,type:'فروش '+(i.paymentMethod==='credit'?'نسیه':'نقدی'),ref:i.number,name:(i.projectName?i.projectName+' — ':'')+(i.description||c.name),amount:i.grandTotal,action:invAction(i)}));
59 + summary.purchases.forEach(p=>rows.push({date:p.date,type:'خرید '+(p.paymentMethod==='credit'?'نسیه':'نقدی'),ref:p.number,name:(p.costCenterLabel?p.costCenterLabel+' — ':'')+(p.description||c.name),amount:p.grandTotal,action:purAction(p)}));
60 summary.payments.forEach(p=>rows.push({date:p.date,type:(p.direction==='outbound'?'پرداخت':'دریافت')+(p.invoiceId?' — تخصیص به فاکتور':' — بدون تخصیص'),ref:p.reference,name:c.name,amount:p.amount,action:''}));
61 summary.cheques.forEach(q=>rows.push({date:q.due_date,type:(q.direction==='inbound'?'چک دریافتی':'چک پرداختی')+' — '+(q.status==='cleared'?'وصول/پرداخت شده':q.status==='bounced'?'برگشتی':q.status==='cancelled'?'باطل':'در جریان'),ref:q.sayad_id,name:q.bank||c.name,amount:q.amount,action:chqAction(q)}));
62 const kpi=(label,value)=>'<div class="kpi-unit"><div><div class="kpi-lbl">'+label+'</div><div class="kpi-val">'+fmt(Math.abs(value))+'</div></div></div>';