فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A01): exercise authorized refund correction via installed Windows WebView2 UI
davoodmehraban89 committed
Oct 20, 2026 at 17:30 UTC
71f78d233c5a8a0ca4ff650cc2505ae20d3c01b2
1 file changed
+66
-1
tests/windows-vm-native-functional-matrix.cjs
+66
-1
@@ -651,8 +651,73 @@ async function nativeReturnCashSettlementGuardrails() {
651
toast.querySelector('.toast-close')?.click();FINORA.Modal.close();
652
check(!document.querySelector('.toast-error')&&!document.querySelector('.modal-backdrop'),
653
'Native A01 cash cap left an error toast/modal');
654
+
655
+ // Establish a real, paid customer credit in the installed WebView2 app:
656
+ // sale 600, cash received 400, total returns 400 -> refund cap 200.
657
+ // Post a second 200-rial return through the actual invoice UI.
658
+ const contact=await db.get('contacts',sale.contactId);
659
+ const product=(await db.getAll('products')).find(p=>p.code==='VM-E2E-100');
660
+ check(contact&&product,'Native positive refund requires customer and product');
661
+ await FINORA.Router.go('invoices');await wait(180);
662
+ await window.InvoiceFormView.open();await wait(160);
663
+ document.getElementById('invKind').value='sale_return';
664
+ await window.InvoiceFormView._onKindChange();
665
+ const original=document.getElementById('invOriginalInvoice');
666
+ check(original&&[...original.options].some(x=>x.value===sale.id),
667
+ 'Native positive refund original invoice selector absent');
668
+ original.value=sale.id;
669
+ document.getElementById('invDate').value='1405/07/18';
670
+ const contactSearch=document.getElementById('invContactSearch');
671
+ contactSearch.value=contact.name;
672
+ window.InvoiceFormView._showContactOptions(true);
673
+ const contactItem=document.querySelector('.contact-option[data-id="'+contact.id+'"]');
674
+ check(contactItem,'Native positive refund contact missing');
675
+ contactItem.dispatchEvent(new MouseEvent('mousedown',{bubbles:true}));
676
+ const productSearch=document.querySelector('.row-product-search');
677
+ productSearch.value=product.code;
678
+ window.InvoiceFormView._showProductOptions(0,true);
679
+ const productItem=document.querySelector('.product-option[data-id="'+product.id+'"]');
680
+ check(productItem,'Native positive refund product missing');
681
+ productItem.dispatchEvent(new MouseEvent('mousedown',{bubbles:true}));
682
+ document.querySelector('.row-qty').value='1';
683
+ window.InvoiceFormView._onFieldChange(0,'qty','1');
684
+ document.querySelector('.row-price').value='200';
685
+ window.InvoiceFormView._onFieldChange(0,'price','200');
686
+ document.getElementById('invPayment').value='credit';
687
+ window.InvoiceFormView._onPaymentChange();
688
+ await window.InvoiceFormView._save(false);await wait(170);
689
+ check(!document.querySelector('.toast-error'),'Second synthetic return failed in native UI');
690
+ const second=(await db.getAll('invoices')).find(x=>
691
+ x.kind==='sale_return'&&x.originalInvoiceId===sale.id&&x.id!==returned.id);
692
+ check(second?.grandTotal===200&&second.paidAmount===0,
693
+ 'Second posted customer credit document missing');
694
+ await FINORA.Router.go('treasury');await wait(170);
695
+ await view.openPaymentModal();
696
+ const select=document.getElementById('txInvoiceRef');
697
+ check(select&&[...select.options].some(x=>x.value===second.id),
698
+ 'Native positive refund return not selectable in treasury UI');
699
+ select.value=second.id;view._onInvoiceSelection();
700
+ document.getElementById('txAmount').value='100';
701
+ document.getElementById('txDate').value='1405/07/18';
702
+ await view._saveTransaction('payment');await wait(170);
703
+ 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');
706
+ const correction=(await db.getAll('document_corrections')).find(x=>
707
+ x.correctionType==='settlement_refund'&&x.sourceId===second.id&&
708
+ x.resultId===refund?.id);
709
+ const audit=(await db.getAll('audit_events')).find(x=>
710
+ x.sourceId===refund?.journalId&&x.correlationId===correction?.correlationId);
711
+ check(refund?.amount===100&&correction?.amount===100&&
712
+ correction.reasonCode==='customer_credit_refund'&&
713
+ correction.actorId===FINORA.Auth.current()?.id&&audit&&
714
+ (await db.get('invoices',second.id))?.paidAmount===100,
715
+ 'Native refund correction, treasury, audit or invoice linkage is invalid');
716
+ check(!document.querySelector('.modal-backdrop'),
717
+ 'Native refund left an unexpected payment dialog');
718
return {overcollectionRejectedWithoutWrites:true,netReceiptAccepted:true,
655
- nonexistentRefundCreditRejected:true,realTreasuryInvoiceSelector:true};
719
+ nonexistentRefundCreditRejected:true,realTreasuryInvoiceSelector:true,
720
+ authorizedRefundTracedInInstalledWebView2:true};
721
}
722
723
async function nativeBackupRestore() {