سامانه صدور فاکتور و حسابداری
fix(pilot): enforce posted purchase status for payment allocation and forbid unlinked history deletion
davoodmehraban89 committed
Oct 14, 2026 at 08:56 UTC
524ff9ed1d737374a47aeceb87f6c28ef877084a
1 file changed
+1
-1
js/purchases.js
+1
-1
@@ -278,7 +278,7 @@
278
if(typeof localizePrintTextNodes==='function')localizePrintTextNodes(w.document.body);
279
};
280
window.purDelete=function(id){
281
- const source=myPurchases().find(x=>x.id===id);if(source?.accountingStatus==='draft')return purDeleteDraftUi(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;}
281
+ const source=myPurchases().find(x=>x.id===id);if(!source)return;if(purchaseDocumentStatus(source)==='draft')return purDeleteDraftUi(id);if(purchaseDocumentStatus(source)!=='draft')return alert('فقط نسخه موقت بدون سابقه حسابداری قابل حذف است؛ سند قطعی را از مسیر ابطال قابلردیابی اصلاح کنید.');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;}
282
if(!requireWrite()||!confirm('این فاکتور خرید حذف شود؟'))return;
283
datastore.purchases=datastore.purchases.filter(p=>!(p.id===id&&p.ownerUserId===currentUser.id));
284
saveDatastore();refreshAllSurfaces();