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

fix(finance): preserve reversal status and block direct deletion of finalized/legacy invoices

davoodmehraban89 committed Oct 11, 2026 at 21:02 UTC f0204b3a165a23f3a7c2fc32d4b0e0521dbfe27c
1 file changed +3 -2
js/invoices.js
+3 -2
@@ -296,8 +296,9 @@ function saveElectronicDocToPending(){
296 function invoiceCreatesAccountingEntry(kind){return kind==='formal'||kind==='non_formal';}
297 function invoiceDocumentStatus(inv){
298 if(!inv)return 'unknown';
299 - if(inv.journalVoucherId||inv.accountingStatus==='posted'||inv.documentStatus==='posted')return 'posted';
300 - if(inv.accountingStatus==='reversed'||inv.documentStatus==='reversed')return 'reversed';
299 + const linked=inv.journalVoucherId&&typeof jeSourceVoucher==='function'?jeSourceVoucher(inv):null;
300 + if(linked?.status==='reversed'||inv.accountingStatus==='reversed'||inv.documentStatus==='reversed')return 'reversed';
301 + if(linked?.status==='posted'||inv.journalVoucherId||inv.accountingStatus==='posted'||inv.documentStatus==='posted')return 'posted';
302 if(inv.documentStatus==='draft'||inv.accountingStatus==='draft')return 'draft';
303 if(invoiceCreatesAccountingEntry(inv.kind))return 'legacy_review';
304 return 'operational';