@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / 95b0cd2
Fork 0

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

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 4, 00:30 UTC

fix(accounting): initialize correction reason before reversal

davoodmehraban89 committed Nov 17, 2026 at 23:36 UTC 95b0cd2fc4b38799e93c0ffc77d85f33f521ae39
2 files changed +2 -2
js/invoices.js
+1 -1
@@ -471,7 +471,7 @@ async function reopenPostedInvoiceAsDraft(invoiceId,reason){
471 const number=invoicePilotCorrectionNumber(inv);
472 const id=afId('INV'),now=new Date().toISOString();
473 const draft={...inv,id,number,createdAt:now,updatedAt:now,documentStatus:'draft',accountingStatus:'draft',documentVersion:1,accountingVersion:1,
474 - correctsInvoiceId:inv.id,correctsVoucherId:v.id,correctionReason:String(reversal.reversalReason||why).trim(),
474 + correctsInvoiceId:inv.id,correctsVoucherId:v.id,correctionReason:why,
475 correctionOriginalNumber:inv.number};
476 for(const key of ['journalVoucherId','accountingPostedAt','documentPostedAt','documentPostedBy','postedAt','postedBy','reversalVoucherId'])delete draft[key];
477 // The reversal RPC creates the compensating voucher without mutating posted journal rows.
js/purchases.js
+1 -1
@@ -161,7 +161,7 @@
161 }
162 const number=purchasePilotNumber(p),now=new Date().toISOString(),newId=afId('PUR');
163 const draft={...p,id:newId,number,date:getJalaliNumeric(),documentStatus:'draft',accountingStatus:'draft',createdAt:now,updatedAt:now,
164 - accountingVersion:1,documentVersion:1,correctsPurchaseId:p.id,correctsVoucherId:v.id,correctionOriginalNumber:p.number,correctionReason:String(reversal.reversalReason||why).trim()};
164 + accountingVersion:1,documentVersion:1,correctsPurchaseId:p.id,correctsVoucherId:v.id,correctionOriginalNumber:p.number,correctionReason:why};
165 for(const k of ['journalVoucherId','accountingPostedAt','documentPostedAt','postedAt','postedBy','reversalVoucherId'])delete draft[k];
166 // This is a balanced POSTED compensating entry; the old source is not rewritten.
167 const reversal=await jeRpcReverse(v.id,getJalaliNumeric(),why);draft.correctionReversalId=reversal.id;