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

test(A01): verify native refund UI reason and confirmation before posting

davoodmehraban89 committed Oct 21, 2026 at 08:45 UTC d7a0320df0bbd459f0b53b0b6ec495c16ef8c368
1 file changed +29 -7
tests/windows-vm-native-functional-matrix.cjs
+29 -7
@@ -642,9 +642,17 @@ async function nativeReturnCashSettlementGuardrails() {
642 document.getElementById('txAmount').value='1';
643 document.getElementById('txDate').value='1405/07/18';
644 const preRefund=await before();
645 + document.getElementById('txReturnReason').value='goods_return';
646 await view._saveTransaction('payment');
646 - toast=[...document.querySelectorAll('.toast-error')].find(x=>
647 - x.textContent.includes('بازپرداخت مجاز'));
647 + let approve=document.querySelector('.modal-footer [data-action="confirm"]');
648 + check(approve,'Native refund must explicitly ask for confirmation');
649 + approve.click();
650 + for(let i=0;i<30;i++){
651 + toast=[...document.querySelectorAll('.toast-error')].find(x=>
652 + x.textContent.includes('بازپرداخت مجاز'));
653 + if(toast)break;
654 + await wait(100);
655 + }
656 check(toast,'Cash refund with zero actual paid customer credit was not rejected');
657 check(JSON.stringify(await before())===JSON.stringify(preRefund),
658 'Rejected customer refund wrote a ledger, treasury or settlement');
@@ -699,18 +707,32 @@ async function nativeReturnCashSettlementGuardrails() {
707 select.value=second.id;view._onInvoiceSelection();
708 document.getElementById('txAmount').value='100';
709 document.getElementById('txDate').value='1405/07/18';
702 - await view._saveTransaction('payment');await wait(170);
710 + document.getElementById('txReturnReason').value='quality_issue';
711 + const beforeApproval=await before();
712 + await view._saveTransaction('payment');
713 + approve=document.querySelector('.modal-footer [data-action="confirm"]');
714 + check(approve,'Native accepted refund missing explicit confirmation dialog');
715 + check(JSON.stringify(await before())===JSON.stringify(beforeApproval),
716 + 'Opening approval dialog must not post cash or journal');
717 + approve.click();
718 + let refund=null;
719 + for(let i=0;i<40;i++){
720 + refund=(await db.getAll('treasury')).find(x=>
721 + x.recordType==='transaction'&&x.refInvoiceId===second.id&&x.type==='payment');
722 + if(refund)break;
723 + await wait(100);
724 + }
725 check(!document.querySelector('.toast-error'),'Authorized native customer refund failed');
704 - const refund=(await db.getAll('treasury')).find(x=>
705 - x.recordType==='transaction'&&x.refInvoiceId===second.id&&x.type==='payment');
726 const correction=(await db.getAll('document_corrections')).find(x=>
727 x.correctionType==='settlement_refund'&&x.sourceId===second.id&&
728 x.resultId===refund?.id);
729 const audit=(await db.getAll('audit_events')).find(x=>
730 x.sourceId===refund?.journalId&&x.correlationId===correction?.correlationId);
731 check(refund?.amount===100&&correction?.amount===100&&
712 - correction.reasonCode==='customer_credit_refund'&&
713 - correction.actorId===FINORA.Auth.current()?.id&&audit&&
732 + correction.reasonCode==='quality_issue'&&
733 + correction.actionCode==='customer_credit_refund'&&
734 + correction.approvedBy===FINORA.Auth.current()?.id&&
735 + correction.approvalMethod==='explicit_confirmation'&&audit&&
736 (await db.get('invoices',second.id))?.paidAmount===100,
737 'Native refund correction, treasury, audit or invoice linkage is invalid');
738 check(!document.querySelector('.modal-backdrop'),