فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
A01: require explicit reason and confirmation before return cash settlement
davoodmehraban89 committed
Oct 21, 2026 at 08:42 UTC
f5bc7edc988fbe78f13868c9572592c3a3343660
1 file changed
+16
-2
src/core/RetailPostingService.js
+16
-2
@@ -396,6 +396,18 @@ class RetailPostingServiceImpl {
396
if (kind==='sale_return' && info.type==='payment' && !Auth.isAdmin()) {
397
throw Error('استرداد وجه مرجوعی فروش فقط توسط مدیر مجاز است');
398
}
399
+ if (kind==='sale_return' || kind==='purchase_return') {
400
+ // Explicit approval is a user action, not inferred from posting a
401
+ // return invoice. Require a structured business reason before any
402
+ // treasury, GL, settlement, correction or audit writes are committed.
403
+ const reasons=new Set(['goods_return','quality_issue','pricing_dispute']);
404
+ if (!reasons.has(info.reasonCode)) {
405
+ throw Error('دلیل ساختاریافته تسویه مرجوعی باید انتخاب شود');
406
+ }
407
+ if (info.explicitlyApproved!==true) {
408
+ throw Error('تأیید صریح پرداخت یا دریافت وجه مرجوعی الزامی است');
409
+ }
410
+ }
411
const expected=isReceipt?['sale','non_formal','purchase_return']:['purchase','sale_return'];
412
if(!expected.includes(kind))throw Error('جهت دریافت/پرداخت با فاکتور مطابقت ندارد');
413
if(kind==='purchase_return')otherCode=LEDGER_CODES.payable;
@@ -468,9 +480,11 @@ class RetailPostingServiceImpl {
480
idempotencyKey:JSON.stringify([ctx.companyId,'settlement_refund',id]),
481
actorId:actor(),occurredAtUtc:today(),businessDate:ctx.date,
482
documentVersion:1,schemaVersion:1,
471
- reasonCode:related.kind==='sale_return'
483
+ actionCode:related.kind==='sale_return'
484
? 'customer_credit_refund' : 'supplier_credit_recovery',
473
- amount:sum
485
+ reasonCode:info.reasonCode,
486
+ approvalMethod:'explicit_confirmation',approvedBy:actor(),
487
+ approvedAtUtc:today(),amount:sum
488
});
489
}
490
}