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

test(A01): verify linked treasury/refund UI in installed Windows WebView2

davoodmehraban89 committed Oct 17, 2026 at 00:45 UTC 373c9c681cd4cb1921dcd32ea40b43aa138163b9
1 file changed +57
tests/windows-vm-native-functional-matrix.cjs
+57
@@ -599,6 +599,62 @@ async function nativeTreasuryChequeReconciliation() {
599 reportingReadOnly:true,fixtureRemoved:true};
600 }
601
602 +async function nativeReturnCashSettlementGuardrails() {
603 + const wait=ms=>new Promise(r=>setTimeout(r,ms));
604 + const check=(ok,msg)=>{if(!ok)throw Error(msg);};
605 + const db=FINORA.Storage,company=await FINORA.Company.current();
606 + const sale=(await db.getAll('invoices')).find(x=>
607 + x.companyId===company.id&&x.kind==='sale'&&x.grandTotal===600);
608 + const returned=(await db.getAll('invoices')).find(x=>
609 + x.companyId===company.id&&x.kind==='sale_return'&&x.originalInvoiceId===sale?.id);
610 + check(sale?.paidAmount===200&&returned?.grandTotal===200,
611 + 'A01 net-refund native sale/return prerequisite absent');
612 + await FINORA.Router.go('treasury');await wait(170);
613 + const view=window.TreasuryView;
614 + const before=()=>Promise.all(['journal_entries','treasury','settlements'].map(async name=>
615 + (await db.getAll(name)).length));
616 + const testReceipt=async(amount)=>{
617 + view.openReceiptModal();
618 + const sel=document.getElementById('txInvoiceRef');
619 + check(sel&&[...sel.options].some(x=>x.value===sale.id),
620 + 'Real treasury UI does not list the unpaid original sale');
621 + sel.value=sale.id;view._onInvoiceSelection();
622 + document.getElementById('txAmount').value=String(amount);
623 + document.getElementById('txDate').value='1405/07/18';
624 + await view._saveTransaction('receipt');
625 + };
626 + const start=await before();
627 + await testReceipt(201);
628 + let toast=[...document.querySelectorAll('.toast-error')].find(x=>x.textContent.includes('مانده خالص'));
629 + check(toast,'Overcollection after posted return not visibly rejected');
630 + check(JSON.stringify(await before())===JSON.stringify(start),
631 + 'Rejected overcollection wrote a ledger, treasury or settlement');
632 + toast.querySelector('.toast-close')?.click();
633 + FINORA.Modal.close();
634 + await testReceipt(200);
635 + check((await db.get('invoices',sale.id)).paidAmount===400,
636 + 'Allowed residual collection did not reach net post-return amount');
637 + view.openPaymentModal();
638 + const sel=document.getElementById('txInvoiceRef');
639 + check(sel&&[...sel.options].some(x=>x.value===returned.id),
640 + 'Real treasury UI cannot select the customer return');
641 + sel.value=returned.id;view._onInvoiceSelection();
642 + document.getElementById('txAmount').value='1';
643 + document.getElementById('txDate').value='1405/07/18';
644 + const preRefund=await before();
645 + await view._saveTransaction('payment');
646 + toast=[...document.querySelectorAll('.toast-error')].find(x=>
647 + x.textContent.includes('بازپرداخت مجاز'));
648 + check(toast,'Cash refund with zero actual paid customer credit was not rejected');
649 + check(JSON.stringify(await before())===JSON.stringify(preRefund),
650 + 'Rejected customer refund wrote a ledger, treasury or settlement');
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 + return {overcollectionRejectedWithoutWrites:true,netReceiptAccepted:true,
655 + nonexistentRefundCreditRejected:true,realTreasuryInvoiceSelector:true};
656 +}
657 +
658 async function nativeBackupRestore() {
659 const check = (value, message) => { if (!value) throw Error(message); };
660 const S = FINORA.Storage;
@@ -864,6 +920,7 @@ module.exports = async function nativeFunctionalMatrix(cdp) {
920 ['treasury-cheque-reconciliation-readonly', nativeTreasuryChequeReconciliation],
921 ['sale-return-immutable-stock-and-ledger', nativeSaleReturnGuardrails],
922 ['purchase-return-and-stock-guardrails', nativePurchaseReturnGuardrails],
923 + ['return-cash-settlement-net-credit', nativeReturnCashSettlementGuardrails],
924 ['append-only-history-bulk-clear-protection', nativeHistoryClearFailClosed],
925 ['backup-and-atomic-rejection', nativeBackupRestore],
926 ['rtl-invoice-print-settings', invoicePrintLayout],