سامانه صدور فاکتور و حسابداری
fix(ux): preserve internal revision ID when saving an old corrective draft
davoodmehraban89 committed
Oct 14, 2026 at 09:54 UTC
e79e21cd8ec1d5e0260b03ecaaf3d91841aef9c5
1 file changed
+6
-1
js/invoices.js
+6
-1
@@ -511,7 +511,7 @@ function commitSaveInvoice(){
511
const contactSelect=document.getElementById('invoice-contact-id');
512
const contactId=contactSelect?contactSelect.value:'';
513
const contactName=contactSelect?.options[contactSelect.selectedIndex]?.text||'مشتری آزاد';
514
- const number=document.getElementById('invoice-number')?.value.trim()||('PINV-'+(getMyInvoices().length+31));
514
+ let number=document.getElementById('invoice-number')?.value.trim()||('PINV-'+(getMyInvoices().length+31));
515
const date=document.getElementById('invoice-date-input')?.value.trim()||getJalaliNumeric();
516
const kind=document.getElementById('invoice-kind')?.value||'non_formal';
517
const description=document.getElementById('invoice-desc-input')?.value.trim()||'';
@@ -519,6 +519,11 @@ function commitSaveInvoice(){
519
const paymentMethodLabel=paymentMethod==='credit'?'نسیه':'نقدی';
520
const warehouseId=document.getElementById('invoice-warehouse-id')?.value||'';
521
const editId=document.getElementById('edit-invoice-id')?.value;
522
+ const previousDraft=getMyInvoices().find(i=>i.id===editId);
523
+ // Old in-progress correction drafts show the original business number;
524
+ // preserve their private unique storage number while updating them.
525
+ if(previousDraft?.correctsInvoiceId&&invoiceDocumentStatus(previousDraft)==='draft'
526
+ &&number===invoiceVisibleNumber(previousDraft))number=previousDraft.number;
527
if(getMyInvoices().some(i=>i.id!==editId&&i.companyId===companyId&&String(i.number||'').trim()===number)&&!(finoraSaleAmendmentId===editId&&invoiceVisibleNumber(getMyInvoices().find(i=>i.id===editId))===number)){alert('شماره فاکتور برای این شرکت قبلاً ثبت شده است.');return;}
528
if(kind==='non_formal'){document.getElementById('invoice-vat-mode').value='none';}
529