سامانه صدور فاکتور و حسابداری
Integrate purchases with Phase 3 automatic posting
davoodmehraban89 committed
Sep 28, 2026 at 18:33 UTC
e3722acb7a110b5083579f0e3e62a820c3ccdbdb
1 file changed
+5
-3
js/purchases.js
+5
-3
@@ -128,11 +128,13 @@
128
if(editId){
129
const old=datastore.purchases.find(p=>p.id===editId&&p.ownerUserId===currentUser.id);
130
if(!old){alert('فاکتور خرید پیدا نشد.');return;}
131
+ if(typeof jeGuardSourceMutation==='function'){try{jeGuardSourceMutation(old,'فاکتور خرید');}catch(e){alert(e.message);return;}}
132
Object.assign(old,payload);
133
alert('فاکتور خرید اصلاح شد.');
134
}else{
134
- datastore.purchases.push({id:'PUR_'+Date.now(),ownerUserId:currentUser.id,...payload});
135
- alert('فاکتور خرید ثبت شد.');
135
+ const record={id:'PUR_'+Date.now(),ownerUserId:currentUser.id,...payload};datastore.purchases.push(record);
136
+ if(typeof jePostSourceRecord==='function'){try{jePostSourceRecord('purchase',record);}catch(e){datastore.purchases=datastore.purchases.filter(x=>x.id!==record.id);alert('فاکتور خرید ثبت نشد: '+e.message);return;}}
137
+ alert('فاکتور خرید و سند حسابداری ثبت شد.');
138
}
139
saveDatastore();
140
purCancelEdit();
@@ -169,7 +171,7 @@
171
w.document.close();
172
};
173
window.purDelete=function(id){
172
- if(typeof getMyPayments==='function'&&getMyPayments().some(p=>p.invoiceType==='purchase'&&p.invoiceId===id)){alert('برای این فاکتور پرداخت ثبت شده است؛ برای حفظ سابقه مالی ابتدا تخصیص پرداخت را اصلاح کنید.');return;}
174
+ const source=myPurchases().find(x=>x.id===id);if(typeof jeGuardSourceMutation==='function'){try{jeGuardSourceMutation(source,'فاکتور خرید');}catch(e){alert(e.message);return;}}if(typeof getMyPayments==='function'&&getMyPayments().some(p=>p.invoiceType==='purchase'&&p.invoiceId===id)){alert('برای این فاکتور پرداخت ثبت شده است؛ برای حفظ سابقه مالی ابتدا تخصیص پرداخت را اصلاح کنید.');return;}
175
if(!requireWrite()||!confirm('این فاکتور خرید حذف شود؟'))return;
176
datastore.purchases=datastore.purchases.filter(p=>!(p.id===id&&p.ownerUserId===currentUser.id));
177
saveDatastore();refreshAllSurfaces();