فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

A01: enforce actual cheque event posting date and retain it on status

davoodmehraban89 committed Oct 21, 2026 at 09:12 UTC 95b0991b6aa2cb7e861c5d2c9060868c9855a000
1 file changed +8 -2
src/core/RetailPostingService.js
+8 -2
@@ -582,7 +582,13 @@ class RetailPostingServiceImpl {
582 if(cheque.status!=='pending')throw Error('تنها چک در جریان قابل تعیین تکلیف است');
583 if(!['cleared','bounced','returned','spent'].includes(status))throw Error('وضعیت چک نامعتبر است');
584 if(status==='spent'&&cheque.direction!=='inbound')throw Error('فقط چک دریافتی قابل خرج‌کرد است');
585 - const ctx=await this.context(tx,company,options.date||cheque.dueDate);
585 + // The actual cheque event is posted in an open period, which may be
586 + // later than its contractual due date (including when that period closed).
587 + // An explicitly blank date must fail rather than silently fall back.
588 + const ctx=await this.context(tx,company,options.date??cheque.dueDate);
589 + if(ctx.date<cheque.issueDate) {
590 + throw Error('تاریخ رویداد مالی چک نمی‌تواند پیش از تاریخ صدور باشد');
591 + }
592 const sum=amount(cheque.amount),inbound=cheque.direction==='inbound';
593 const ref={contactId:cheque.contactId};
594 const accounts=(await tx.getAll('treasury')).filter(a=>a.companyId===company&&
@@ -602,7 +608,7 @@ class RetailPostingServiceImpl {
608 [postLine(chequeAccount,sum,0,ref),postLine(target,0,sum,ref)];
609 const journal=await this.journal(tx,ctx,'cheque_status',id,lines,'تغییر وضعیت چک '+status,2);
610 const updated={...cheque,status,statusVersion:2,
605 - statusJournalId:journal.id,statusChangedAt:today()};
611 + statusJournalId:journal.id,statusBusinessDate:ctx.date,statusChangedAt:today()};
612 await tx.put('cheques',updated);
613 if(status==='cleared'){
614 if(!bank)throw Error('بانک یا صندوق چک مشخص نیست');