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

Scope purchase invoices to active company

davoodmehraban89 committed Sep 28, 2026 at 15:17 UTC dbd9ff33c73c717b1fa9669aaf521e4ef528be51
1 file changed +1 -1
js/purchases.js
+1 -1
@@ -124,7 +124,7 @@
124 const editId=$('pur-edit-id')?.value||'';
125 const purNumber=$('pur-number').value.trim();
126 if(purNumber&&myPurchases().some(p=>p.id!==editId&&p.supplierId===supSel.value&&String(p.number||'').trim()===purNumber)){alert('این شماره فاکتور برای تأمین‌کننده انتخاب‌شده قبلاً ثبت شده است.');return;}
127 - const payload={number:purNumber,date:$('pur-date').value.trim()||getJalaliNumeric(),supplierId:supSel.value,supplierName:supSel.options[supSel.selectedIndex].text,costCenterId:ccSel.value,costCenterLabel:ccSel.value?ccSel.options[ccSel.selectedIndex].text:'',contractNumber:$('pur-contract').value.trim(),paymentMethod,paymentMethodLabel:paymentMethod==='credit'?'نسیه':'نقدی',items,subtotal:t.sub,discount:t.disc,vat:t.vat,grandTotal:t.grand,description:$('pur-desc').value.trim()};
127 + const activeCompanyId=getMySettings().default_company_id||getMyCompanies()[0]?.id||'';const payload={number:purNumber,date:$('pur-date').value.trim()||getJalaliNumeric(),companyId:activeCompanyId,supplierId:supSel.value,supplierName:supSel.options[supSel.selectedIndex].text,costCenterId:ccSel.value,costCenterLabel:ccSel.value?ccSel.options[ccSel.selectedIndex].text:'',contractNumber:$('pur-contract').value.trim(),paymentMethod,paymentMethodLabel:paymentMethod==='credit'?'نسیه':'نقدی',items,subtotal:t.sub,discount:t.disc,vat:t.vat,grandTotal:t.grand,description:$('pur-desc').value.trim()};
128 if(editId){
129 const old=datastore.purchases.find(p=>p.id===editId&&p.ownerUserId===currentUser.id);
130 if(!old){alert('فاکتور خرید پیدا نشد.');return;}