فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A05): validate real Windows UI blocked-bank transfers and cheque clearance
davoodmehraban89 committed
Oct 17, 2026 at 00:07 UTC
ba3fb41f7f7532fda1e315a37e47a7735f7f95f5
1 file changed
+78
tests/windows-vm-native-functional-matrix.cjs
+78
@@ -482,6 +482,83 @@ async function nativeHistoryClearFailClosed() {
482
historyUnchanged: true };
483
}
484
485
+async function nativeInactiveBankSettlementGuard() {
486
+ const wait=ms=>new Promise(r=>setTimeout(r,ms));
487
+ const check=(ok,msg)=>{if(!ok)throw Error(msg);};
488
+ const db=FINORA.Storage,company=await FINORA.Company.current();
489
+ check(company?.id&&FINORA.Auth.isAdmin(),'A05 native admin required');
490
+ const contact=(await db.getAll('contacts')).find(c=>c.companyId===company.id&&c.name==='مشتری آزمایشی ویندوز');
491
+ const active=(await db.getAll('treasury')).find(x=>x.companyId===company.id&&x.recordType==='account'&&x.ledgerAccountId&&x.isActive!==false);
492
+ check(contact&&active,'Treasury fixtures absent');
493
+ await FINORA.Router.go('treasury');await wait(180);
494
+ const tv=window.TreasuryView;
495
+ await tv.openAccountModal();
496
+ document.getElementById('accName').value='VM-only inactive bank A05';
497
+ document.getElementById('accInitialBalance').value='0';
498
+ await tv.saveAccount(null);
499
+ const secondary=(await db.getAll('treasury')).find(x=>
500
+ x.companyId===company.id&&x.recordType==='account'&&x.name==='VM-only inactive bank A05');
501
+ check(secondary?.ledgerAccountId,'Actual treasury account creation failed');
502
+ await db.put('treasury',{...secondary,isActive:false});
503
+ const counts=async()=>({
504
+ journals:(await db.getAll('journal_entries')).length,
505
+ payments:(await db.getAll('treasury')).filter(x=>x.recordType==='transaction').length
506
+ });
507
+ const before=await counts();
508
+ tv.openTransferModal();
509
+ check(document.getElementById('txToAccount'),'Native transfer form not open');
510
+ document.getElementById('txDate').value='1405/07/18';
511
+ document.getElementById('txAmount').value='40';
512
+ document.getElementById('txFromAccount').value=active.id;
513
+ document.getElementById('txToAccount').value=secondary.id;
514
+ await tv._saveTransaction('transfer');
515
+ let toast=[...document.querySelectorAll('.toast-error')].find(x=>x.textContent.includes('غیرفعال'));
516
+ check(toast,'Inactive bank transfer did not display rejection');
517
+ check(JSON.stringify(await counts())===JSON.stringify(before),'Rejected transfer wrote journals or cash');
518
+ toast.querySelector('.toast-close')?.click();
519
+ FINORA.Modal.close();
520
+ check(!document.querySelector('.toast-error'),'Expected transfer toast not dismissed');
521
+
522
+ // With no active bank, the real cheque status UI must reject settlement
523
+ // without changing posted status or writing a cash receipt.
524
+ await db.put('treasury',{...active,isActive:false});
525
+ await FINORA.Router.go('cheques');await wait(200);
526
+ const cv=window.ChequesView;
527
+ await cv.openChequeModal();
528
+ check(document.getElementById('chqSayad'),'Native cheque form absent');
529
+ document.getElementById('chqDirection').value='inbound';
530
+ document.getElementById('chqContact').value=contact.id;
531
+ document.getElementById('chqSayad').value='1234567890123489';
532
+ document.getElementById('chqAmount').value='90';
533
+ document.getElementById('chqIssueDate').value='1405/07/18';
534
+ document.getElementById('chqDueDate').value='1405/07/18';
535
+ await cv.saveCheque(null);
536
+ const cheque=(await db.getAll('cheques')).find(x=>x.companyId===company.id&&x.sayadNumber==='1234567890123489');
537
+ check(cheque?.financePosted&&cheque.status==='pending','Native cheque posting failed');
538
+ const journalCount=(await db.getAll('journal_entries')).length;
539
+ await cv.changeStatus(cheque.id);
540
+ check(document.getElementById('newStatus'),'Cheque status form missing');
541
+ document.getElementById('newStatus').value='cleared';
542
+ await cv._applyStatusChange(cheque.id);
543
+ toast=[...document.querySelectorAll('.toast-error')].find(x=>
544
+ x.textContent.includes('حساب بانک یا صندوق برای وصول چک مشخص نیست'));
545
+ check(toast,'Cheque clearing with all banks inactive did not reject');
546
+ check((await db.get('cheques',cheque.id)).status==='pending'&&
547
+ (await db.getAll('journal_entries')).length===journalCount&&
548
+ !(await db.getAll('treasury')).some(t=>t.refChequeId===cheque.id),
549
+ 'Rejected cheque clearance modified ledger or treasury');
550
+ toast.querySelector('.toast-close')?.click();
551
+ await db.put('treasury',active);
552
+ await cv._applyStatusChange(cheque.id);
553
+ check((await db.get('cheques',cheque.id)).status==='cleared'&&
554
+ (await db.getAll('treasury')).filter(t=>t.refChequeId===cheque.id).length===1,
555
+ 'Restoring active bank did not clear cheque exactly once');
556
+ check(!document.querySelector('.toast-error')&&!document.querySelector('.modal-backdrop'),
557
+ 'A05 native treasury scenario left error toast/modal');
558
+ return { inactiveTransferRejected:true, invalidTransferRolledBack:true,
559
+ disabledChequeClearingRejected:true, validChequeClearedExactlyOnce:true };
560
+}
561
+
562
async function nativeBackupRestore() {
563
const check = (value, message) => { if (!value) throw Error(message); };
564
const S = FINORA.Storage;
@@ -743,6 +820,7 @@ module.exports = async function nativeFunctionalMatrix(cdp) {
820
['positive-opening-ledger-and-idempotency', nativePositiveOpeningLedger],
821
['purchase-and-post-ledger', purchaseInvoice],
822
['partial-sale-and-inventory', saleInvoice],
823
+ ['inactive-treasury-cheque-settlement', nativeInactiveBankSettlementGuard],
824
['sale-return-immutable-stock-and-ledger', nativeSaleReturnGuardrails],
825
['purchase-return-and-stock-guardrails', nativePurchaseReturnGuardrails],
826
['append-only-history-bulk-clear-protection', nativeHistoryClearFailClosed],