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

fix(company): port reviewed active-company isolation in js/phase4-contracting.js

davoodmehraban89 committed Oct 14, 2026 at 13:14 UTC 3cf383910c189d9e81f5efb236e6fa7372d46070
1 file changed +7 -1
js/phase4-contracting.js
+7 -1
@@ -1,5 +1,11 @@
1 /* Phase 4 — contracts, deductions, guarantees and contractor accounting */
2 -function p4Owned(k){const cid=afCompanyId();return(datastore[k]||[]).filter(x=>x.ownerUserId===currentUser?.id&&(!x.companyId||x.companyId===cid))}
2 +function p4Owned(k){
3 + if(typeof finoraScopedRows==='function')return finoraScopedRows(k);
4 + // Standalone domain-contract harnesses load this module without sync.js.
5 + const cid=afCompanyId(),single=typeof getMyCompanies!=='function'||getMyCompanies().length===1;
6 + return (datastore[k]||[]).filter(x=>x.ownerUserId===currentUser?.id&&
7 + (x.companyId===cid||(single&&!x.companyId)));
8 +}
9 function getMyContracts(){return p4Owned('contracts')} function getMyContractAmendments(){return p4Owned('contractAmendments')}
10 function getMyContractParties(){return p4Owned('contractParties')} function getMyContractDeductions(){return p4Owned('contractDeductions')}
11 function getMyGuarantees(){return p4Owned('guarantees')} function getMyGuaranteeEvents(){return p4Owned('guaranteeEvents')}