فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(Q01): expand installed UI coverage for invoices, print, expenses and stocktake
davoodmehraban89 committed
Nov 1, 2026 at 11:02 UTC
7d435d34c624cc0c8c2618a97d545bd5e694f3b2
5 files changed
+442
-2
scripts/q01-native-action-coverage.cjs
+25
-1
@@ -8,7 +8,8 @@ const RULES=[
8
{match:'window.StockKardexModal.openAdjustModal(',scenarios:['legacy-stock-adjustment-form-and-validation','integrated-stock-adjustment-guard'],kind:'native-ui-guarded-action',note:'اصلاح دستی در حالت قدیمی و جلوگیری از نمایش/فراخوانی آن در حسابداری یکپارچه'},
9
{match:'window.StockKardexModal.saveAdjust(',scenarios:['legacy-stock-adjustment-form-and-validation'],kind:'native-ui-stock-posting',note:'رد مقدار منفی و دقت بیش از سه رقم و ثبت موجودی واقعی در نصب ویندوز'},
10
{match:'window.TreasuryView.saveAccount(null)',scenarios:['partial-sale-and-inventory'],kind:'native-fixture-create',note:'ایجاد حساب خزانه در سناریوی فروش'},
11
-{match:"window.TreasuryView._saveTransaction('transfer')",scenarios:['inactive-treasury-cheque-settlement'],kind:'native-negative-guard-only',note:'فقط رد انتقال به حساب غیرفعال؛ مسیر مثبت مستقل نیست'},
11
+{match:'window.TreasuryView.saveAccount(',scenarios:['inactive-treasury-cheque-settlement'],kind:'native-ui-create-and-update',note:'ایجاد و ویرایش حساب خزانه از فرم واقعی در شرکت ساختگی'},
12
+{match:"window.TreasuryView._saveTransaction('transfer')",scenarios:['inactive-treasury-cheque-settlement'],kind:'native-fixture-positive-and-negative',note:'رد انتقال به حساب غیرفعال و ثبت موفق انتقال بین دو حساب فعال'},
13
{match:"window.TreasuryView._saveTransaction('receipt')",scenarios:['return-cash-settlement-net-credit'],kind:'native-fixture-positive-and-negative',note:'رد دریافت بیش از مانده و ثبت دریافت مجاز'},
14
{match:"window.TreasuryView._saveTransaction('payment')",scenarios:['return-cash-settlement-net-credit'],kind:'native-fixture-positive-and-negative',note:'رد بازپرداخت غیرمجاز و ثبت بازپرداخت تأییدشده'},
15
{match:'window.ChequesView.saveCheque(null)',scenarios:['inactive-treasury-cheque-settlement','cheque-third-party-endorsement'],kind:'native-fixture-create',note:'ایجاد چک و اتصال دفتر کل'},
@@ -16,6 +17,29 @@ const RULES=[
17
{match:'window.AccountingView.savePeriod()',scenarios:['activate-accounting-and-inventory','fiscal-close-atomic-guardrails'],kind:'native-fixture-create',note:'ایجاد دوره مالی در نصب واقعی و آزمون بستن دوره'},
18
{match:'window.AccountingView.saveWarehouse()',scenarios:['activate-accounting-and-inventory'],kind:'native-fixture-create',note:'ایجاد انبار ساختگی و بررسی ماندگاری'},
19
{match:'window.AccountingView.previewOpeningFile()',scenarios:['positive-opening-ledger-and-idempotency','opening-dry-run-rejects-existing-postings'],kind:'native-fixture-positive-and-negative',note:'پیشنمایش و ثبت افتتاحیه، جلوگیری از تکرار و رد داده ناسازگار'},
20
+
21
+{match:'window.InvoiceFormView._save(true)',scenarios:['invoice-quick-add-and-save-print'],kind:'native-ui-create-and-print',note:'ثبت فاکتور از فرم و بازشدن تنظیمات چاپ با کالای و شخصی که در همان فرم سریع ساخته شدهاند'},
22
+{match:'window.InvoiceFormView._saveQuickContact()',scenarios:['invoice-quick-add-and-save-print'],kind:'native-ui-nested-create',note:'ساخت شخص از پنجره سریع و انتخاب آن در فاکتور والد'},
23
+{match:'window.InvoiceFormView._saveQuickProduct()',scenarios:['invoice-quick-add-and-save-print'],kind:'native-ui-nested-create',note:'ساخت خدمت از پنجره سریع و افزودن آن به ردیف فاکتور والد'},
24
+{match:'window.InvoicePrint._print()',scenarios:['invoice-quick-add-and-save-print'],kind:'native-rtl-print-render',note:'ساخت HTML چاپ فاکتور ذخیرهشده با محتوای فارسی و راستبهچپ؛ چاپگر فیزیکی آزمایش نشده'},
25
+{match:'window.StockKardexModal._printKardex(',scenarios:['auxiliary-rtl-print-rendering'],kind:'native-rtl-print-render',note:'تولید و ارسال سند چاپ راستبهچپ کاردکس برای کالاهای ساختگی'},
26
+{match:'window.ContactLedgerModal._printLedger(',scenarios:['auxiliary-rtl-print-rendering'],kind:'native-rtl-print-render',note:'تولید سند چاپ راستبهچپ دفتر اشخاص برای اشخاص ساختگی'},
27
+{match:'window.ReportsView._printReport()',scenarios:['auxiliary-rtl-print-rendering'],kind:'native-rtl-print-render',note:'تولید سند چاپ راستبهچپ گزارش مالی؛ چاپگر فیزیکی آزمایش نشده'},
28
+{match:'window.ExpensesView._promptNewCategory()',scenarios:['expense-form-category-and-posting'],kind:'native-ui-category-create',note:'افزودن سرفصل ساختگی در فرم هزینه و انتخاب آن قبل از ثبت'},
29
+{match:'window.ExpensesView.saveExpense(null)',scenarios:['expense-form-category-and-posting'],kind:'native-ui-financial-posting',note:'ثبت هزینه از فرم واقعی و تطبیق سند قطعی دفتر کل'},
30
+{match:'window.TreasuryView.saveAccount(',scenarios:['inactive-treasury-cheque-settlement'],kind:'native-ui-create-and-update',note:'ایجاد و ویرایش حساب خزانه از فرم واقعی در شرکت ساختگی'},
31
+{match:"window.AccountingView.addJournalRow()",scenarios:['manual-journal-reversal-and-exports'],kind:'native-ui-row-edit',note:'افزودن ردیف به فرم سند دستی حسابداری'},
32
+{match:"window.AccountingView.saveJournal('draft')",scenarios:['manual-journal-reversal-and-exports'],kind:'native-ui-draft-posting',note:'ثبت پیشنویس سند دستی در دوره باز'},
33
+{match:"window.AccountingView.saveJournal('posted')",scenarios:['manual-journal-reversal-and-exports'],kind:'native-ui-final-posting',note:'قطعیسازی سند دستی متوازن از پیشنویس'},
34
+{match:'window.AccountingView.saveReversal()',scenarios:['manual-journal-reversal-and-exports'],kind:'native-ui-reversal-posting',note:'ثبت سند معکوس مستقل و حفظ سند اصلی'},
35
+{match:'window.AccountingView.saveAccount()',scenarios:['manual-journal-reversal-and-exports'],kind:'native-ui-chart-account-create',note:'ایجاد گروه کدینگ ساختگی از فرم حسابداری'},
36
+{match:'window.AccountingView.exportReports()',scenarios:['manual-journal-reversal-and-exports'],kind:'native-csv-export',note:'خروجی CSV دفتر کل با سند ساختگی قطعی'},
37
+{match:'window.AccountingView.exportReconciliation()',scenarios:['manual-journal-reversal-and-exports'],kind:'native-csv-export',note:'خروجی CSV کنترل مغایرت با شمای مورد انتظار'},
38
+{match:'window.AccountingView.saveTransfer()',scenarios:['inventory-transfer-and-stocktake'],kind:'native-ui-inventory-transfer',note:'انتقال مقدار دقیق کالا بین دو انبار واقعی ساختگی'},
39
+{match:'window.AccountingView.createStocktake()',scenarios:['inventory-transfer-and-stocktake'],kind:'native-ui-stocktake-create',note:'ایجاد جلسه انبارگردانی از فرم واقعی'},
40
+{match:'window.AccountingView.saveStocktake()',scenarios:['inventory-transfer-and-stocktake'],kind:'native-ui-stocktake-save',note:'ذخیره شمارش همه اقلام جلسه ساختگی'},
41
+{match:'window.AccountingView.finishStocktake()',scenarios:['inventory-transfer-and-stocktake'],kind:'native-ui-stocktake-finalize',note:'تأیید نهایی شمارش همسان با موجودی و بستن جلسه'}
42
+,
43
{match:'window.SettingsView.downloadBackup()',flag:'encryptedCompanyBackup',kind:'native-encrypted-backup-ui',note:'خروجی رمزگذاریشده fbackup از رابط تنظیمات'},
44
{match:'window.SettingsView.restoreBackup()',flag:'encryptedCompanyBackup',kind:'native-encrypted-backup-ui',note:'بازیابی رابط کاربری، رد رمز و فایل خراب و rollback تراکنشی'}
45
];
scripts/windows-vm-native-lab.ps1
+5
@@ -174,6 +174,11 @@ try {
174
'positive-opening-ledger-and-idempotency',
175
'purchase-and-post-ledger',
176
'partial-sale-and-inventory',
177
+ 'invoice-quick-add-and-save-print',
178
+ 'auxiliary-rtl-print-rendering',
179
+ 'expense-form-category-and-posting',
180
+ 'manual-journal-reversal-and-exports',
181
+ 'inventory-transfer-and-stocktake',
182
'inactive-treasury-cheque-settlement',
183
'cheque-third-party-endorsement',
184
'treasury-cheque-reconciliation-readonly',
tests/q01-native-action-coverage.test.mjs
+52
@@ -69,3 +69,55 @@ test('Q01 coverage never converts an unclicked control into a clicked control',(
69
assert.equal(audit.uniqueActions[0].fixtureCoverage.kind,'native-fixture-positive-and-negative');
70
assert.equal(audit.uniqueActions[1].fixtureCoverage,null);
71
});
72
+
73
+
74
+test('Q01 maps quick invoice creation and print handlers only to the installed quick-add scenario',()=>{
75
+ const evidence={nativeFunctional:{'invoice-quick-add-and-save-print':{
76
+ quickContactCreated:true,quickProductCreated:true,saveAndPrintOpened:true,
77
+ invoicePrintRendered:true,invoicePosted:true
78
+ }}};
79
+ for(const handler of [
80
+ 'window.InvoiceFormView._save(true)','window.InvoiceFormView._saveQuickContact()',
81
+ 'window.InvoiceFormView._saveQuickProduct()','window.InvoicePrint._print()'
82
+ ]) assert.ok(coverageFor(handler,evidence),handler);
83
+});
84
+
85
+test('Q01 maps native print, expense and ledger operations only after their installed fixtures pass',()=>{
86
+ const evidence={nativeFunctional:{
87
+ 'auxiliary-rtl-print-rendering':{kardexPrints:4,contactLedgerPrints:7,reportsPrintRendered:true,allDocumentsRtl:true},
88
+ 'expense-form-category-and-posting':{expenseCreatedThroughForm:true,customCategorySelected:true,expenseJournalPosted:true},
89
+ 'manual-journal-reversal-and-exports':{chartAccountCreated:true,journalRowAdded:true,draftJournalSaved:true,journalPosted:true,reversalPosted:true,ledgerCsvExported:true,reconciliationCsvExported:true}
90
+ }};
91
+ assert.equal(coverageFor("window.StockKardexModal._printKardex('prod_1')",evidence).kind,'native-rtl-print-render');
92
+ assert.equal(coverageFor('window.ContactLedgerModal._printLedger("contact_1")',evidence).kind,'native-rtl-print-render');
93
+ assert.equal(coverageFor('window.ReportsView._printReport()',evidence).kind,'native-rtl-print-render');
94
+ assert.equal(coverageFor('window.ExpensesView._promptNewCategory()',evidence).kind,'native-ui-category-create');
95
+ assert.equal(coverageFor('window.ExpensesView.saveExpense(null)',evidence).kind,'native-ui-financial-posting');
96
+ assert.equal(coverageFor("window.AccountingView.saveJournal('posted')",evidence).kind,'native-ui-final-posting');
97
+ assert.equal(coverageFor('window.AccountingView.saveReversal()',evidence).kind,'native-ui-reversal-posting');
98
+ assert.equal(coverageFor('window.AccountingView.exportReports()',evidence).kind,'native-csv-export');
99
+ assert.equal(coverageFor('window.AccountingView.exportReconciliation()',evidence).kind,'native-csv-export');
100
+});
101
+
102
+test('Q01 transfer coverage requires both rejected inactive and successful active-account transfer evidence',()=>{
103
+ const evidence={nativeFunctional:{'inactive-treasury-cheque-settlement':{
104
+ inactiveTransferRejected:true,validTransferPosted:true,treasuryAccountEditPersisted:true
105
+ }}};
106
+ assert.equal(coverageFor("window.TreasuryView._saveTransaction('transfer')",evidence).kind,
107
+ 'native-fixture-positive-and-negative');
108
+ assert.equal(coverageFor('window.TreasuryView.saveAccount("acc_1")',evidence).kind,
109
+ 'native-ui-create-and-update');
110
+ evidence.nativeFunctional['inactive-treasury-cheque-settlement'].validTransferPosted=false;
111
+ assert.equal(coverageFor("window.TreasuryView._saveTransaction('transfer')",evidence),null);
112
+});
113
+
114
+test('Q01 maps stock transfer and stocktake UI actions only to exact balance-preserving native evidence',()=>{
115
+ const evidence={nativeFunctional:{'inventory-transfer-and-stocktake':{
116
+ secondWarehouseCreated:true,transferPosted:true,exactInventoryMoved:true,
117
+ stocktakeCreated:true,stocktakeCountsSaved:true,stocktakeFinalized:true
118
+ }}};
119
+ for(const handler of [
120
+ 'window.AccountingView.saveTransfer()','window.AccountingView.createStocktake()',
121
+ 'window.AccountingView.saveStocktake()','window.AccountingView.finishStocktake()'
122
+ ]) assert.ok(coverageFor(handler,evidence),handler);
123
+});
tests/windows-vm-native-functional-matrix.cjs
+338
-1
@@ -800,9 +800,15 @@ async function nativeInactiveBankSettlementGuard() {
800
document.getElementById('accName').value='VM-only inactive bank A05';
801
document.getElementById('accInitialBalance').value='0';
802
await tv.saveAccount(null);
803
- const secondary=(await db.getAll('treasury')).find(x=>
803
+ let secondary=(await db.getAll('treasury')).find(x=>
804
x.companyId===company.id&&x.recordType==='account'&&x.name==='VM-only inactive bank A05');
805
check(secondary?.ledgerAccountId,'Actual treasury account creation failed');
806
+ await tv.openAccountModal(secondary.id);
807
+ document.getElementById('accOwnerName').value='VM-only treasury account owner edit';
808
+ await tv.saveAccount(secondary.id);
809
+ secondary=await db.get('treasury',secondary.id);
810
+ check(secondary.ownerName==='VM-only treasury account owner edit',
811
+ 'Treasury account edit did not persist through the installed form');
812
await db.put('treasury',{...secondary,isActive:false});
813
const counts=async()=>({
814
journals:(await db.getAll('journal_entries')).length,
@@ -861,6 +867,24 @@ async function nativeInactiveBankSettlementGuard() {
867
FINORA.Modal.close();
868
await db.put('treasury',active);
869
await db.put('treasury',{...secondary,isActive:true});
870
+ await FINORA.Router.go('treasury');await wait(180);await tv.reload();
871
+ const transferCountBefore=(await db.getAll('treasury')).filter(x=>
872
+ x.companyId===company.id&&x.recordType==='transaction'&&x.type==='transfer').length;
873
+ tv.openTransferModal();
874
+ check(document.getElementById('txFromAccount')&&document.getElementById('txToAccount'),
875
+ 'Native positive transfer form did not open');
876
+ document.getElementById('txDate').value='1405/07/21';
877
+ document.getElementById('txAmount').value='1';
878
+ document.getElementById('txFromAccount').value=active.id;
879
+ document.getElementById('txToAccount').value=secondary.id;
880
+ await tv._saveTransaction('transfer');
881
+ const transfer=(await db.getAll('treasury')).find(x=>
882
+ x.companyId===company.id&&x.recordType==='transaction'&&x.type==='transfer'&&
883
+ x.amount===1&&x.fromAccountId===active.id&&x.toAccountId===secondary.id);
884
+ check(transfer&&(await db.getAll('treasury')).filter(x=>
885
+ x.companyId===company.id&&x.recordType==='transaction'&&x.type==='transfer').length===transferCountBefore+1,
886
+ 'Valid transfer between active accounts did not persist exactly once');
887
+ await FINORA.Router.go('cheques');await wait(180);await cv.reload();
888
await cv.changeStatus(cheque.id);
889
document.getElementById('newStatus').value='cleared';
890
document.getElementById('chqEventDate').value='1405/07/20';
@@ -897,6 +921,7 @@ async function nativeInactiveBankSettlementGuard() {
921
check(!document.querySelector('.toast-error')&&!document.querySelector('.modal-backdrop'),
922
'A05 native treasury scenario left error toast/modal');
923
return { inactiveTransferRejected:true, invalidTransferRolledBack:true,
924
+ validTransferPosted:true,treasuryAccountEditPersisted:true,
925
disabledChequeClearingRejected:true, validChequeClearedExactlyOnce:true,
926
chequeEventDateDifferentFromDueDate:true,
927
explicitNondefaultClearingAccount:true,confirmationRequiredBeforeCash:true };
@@ -1434,6 +1459,313 @@ async function openingDryRunWithExistingActivity() {
1459
};
1460
}
1461
1462
+
1463
+
1464
+async function nativeInvoiceQuickAddAndPrint() {
1465
+ const wait=ms=>new Promise(resolve=>setTimeout(resolve,ms));
1466
+ const check=(ok,msg)=>{if(!ok)throw Error(msg);};
1467
+ const db=FINORA.Storage,company=await FINORA.Company.current();
1468
+ check(company?.id&&FINORA.Auth.isAdmin(),'Q01 invoice quick-add test requires the synthetic administrator');
1469
+ await FINORA.Router.go('invoices');await wait(160);
1470
+ await window.InvoiceFormView.open();await wait(120);
1471
+ window.InvoiceFormView._openQuickContact();
1472
+ document.getElementById('qcName').value='VM-only Q01 quick contact';
1473
+ document.getElementById('qcMobile').value='09120000001';
1474
+ await window.InvoiceFormView._saveQuickContact();
1475
+ const contactId=document.getElementById('invContact').value;
1476
+ check(contactId&&document.getElementById('invContactSearch').value==='VM-only Q01 quick contact',
1477
+ 'Quick contact was not selected in the parent invoice');
1478
+ window.InvoiceFormView._openQuickProduct();
1479
+ document.getElementById('qpCode').value='VM-Q01-QUICK-PRODUCT';
1480
+ document.getElementById('qpName').value='VM-only Q01 quick service';
1481
+ document.getElementById('qpUnit').value='عدد';
1482
+ document.getElementById('qpBuyPrice').value='100';
1483
+ document.getElementById('qpSellPrice').value='500';
1484
+ document.getElementById('qpTrackInventory').checked=false;
1485
+ await window.InvoiceFormView._saveQuickProduct();
1486
+ const productId=document.querySelector('#itemsBody .row-product')?.value;
1487
+ check(productId&&document.querySelector('.row-product-search')?.value==='VM-only Q01 quick service',
1488
+ 'Quick product was not selected in the parent invoice');
1489
+ document.getElementById('invDate').value='1405/07/18';
1490
+ document.getElementById('invDescription').value='VM-only Q01 quick invoice print';
1491
+ document.querySelector('.row-qty').value='2';
1492
+ window.InvoiceFormView._onFieldChange(0,'qty','2');
1493
+ document.querySelector('.row-price').value='500';
1494
+ window.InvoiceFormView._onFieldChange(0,'price','500');
1495
+ await window.InvoiceFormView._save(true);
1496
+ await wait(550);
1497
+ const invoice=(await db.getAll('invoices')).find(x=>
1498
+ x.companyId===company.id&&x.contactId===contactId&&
1499
+ x.description==='VM-only Q01 quick invoice print');
1500
+ check(invoice?.financePosted&&invoice.items?.some(x=>x.productId===productId),
1501
+ 'Save-and-print did not commit the quick invoice and its quick-added product');
1502
+ check(window.InvoicePrint?.currentInvoiceId===invoice.id&&document.getElementById('prPaper'),
1503
+ 'Save-and-print did not open the actual invoice print settings modal');
1504
+ const original=window.InvoicePrint._openPrintWindow;
1505
+ let rendered='';
1506
+ try {
1507
+ window.InvoicePrint._openPrintWindow=html=>{rendered=String(html);};
1508
+ await window.InvoicePrint._print();
1509
+ } finally {
1510
+ window.InvoicePrint._openPrintWindow=original;
1511
+ }
1512
+ check(rendered.includes('dir="rtl"')&&rendered.includes('VM-only Q01 quick contact')&&
1513
+ rendered.includes('VM-only Q01 quick service'),
1514
+ 'Actual invoice print handler did not render the saved invoice in RTL');
1515
+ check(!document.querySelector('.modal-backdrop'),'Invoice print test left a modal open');
1516
+ return {quickContactCreated:true,quickProductCreated:true,saveAndPrintOpened:true,
1517
+ invoicePrintRendered:true,invoicePosted:true};
1518
+}
1519
+
1520
+async function nativeAuxiliaryPrintRendering() {
1521
+ const wait=ms=>new Promise(resolve=>setTimeout(resolve,ms));
1522
+ const check=(ok,msg)=>{if(!ok)throw Error(msg);};
1523
+ const company=await FINORA.Company.current(),db=FINORA.Storage;
1524
+ const products=(await db.getAll('products')).filter(x=>x.companyId===company.id);
1525
+ const contacts=(await db.getAll('contacts')).filter(x=>x.companyId===company.id);
1526
+ check(products.length>0&&contacts.length>0,'Synthetic product/contact fixtures are missing for print rendering');
1527
+ const originalOpen=window.open;
1528
+ let capture=null,productPrints=0,contactPrints=0;
1529
+ window.open=()=>({
1530
+ document:{
1531
+ write(value){capture.html+=String(value);},
1532
+ close(){capture.closed=true;}
1533
+ },
1534
+ focus(){capture.focused=true;},
1535
+ print(){capture.printed=true;}
1536
+ });
1537
+ try {
1538
+ for(const product of products) {
1539
+ capture={html:'',closed:false,focused:false,printed:false};
1540
+ await window.StockKardexModal._printKardex(product.id);
1541
+ await wait(650);
1542
+ check(capture.html.includes('<html lang="fa" dir="rtl">')&&
1543
+ capture.html.includes('کاردکس کالا')&&capture.html.includes(product.name)&&
1544
+ capture.closed&&capture.printed,
1545
+ 'Kardex print did not produce a complete RTL document for '+product.id);
1546
+ productPrints++;
1547
+ }
1548
+ for(const contact of contacts) {
1549
+ capture={html:'',closed:false,focused:false,printed:false};
1550
+ await window.ContactLedgerModal._printLedger(contact.id);
1551
+ await wait(650);
1552
+ check(capture.html.includes('<html lang="fa" dir="rtl">')&&
1553
+ capture.html.includes('صورتحساب شخص')&&capture.html.includes(contact.name)&&
1554
+ capture.closed&&capture.printed,
1555
+ 'Contact ledger print did not produce a complete RTL document for '+contact.id);
1556
+ contactPrints++;
1557
+ }
1558
+ await FINORA.Router.go('reports');await wait(260);
1559
+ capture={html:'',closed:false,focused:false,printed:false};
1560
+ window.ReportsView._printReport();
1561
+ await wait(650);
1562
+ check(capture.html.includes('<html lang="fa" dir="rtl">')&&
1563
+ capture.html.includes('گزارش سود و زیان')&&capture.closed&&capture.printed,
1564
+ 'Reports print did not produce a complete RTL document');
1565
+ } finally {
1566
+ window.open=originalOpen;
1567
+ }
1568
+ return {kardexPrints:productPrints,contactLedgerPrints:contactPrints,
1569
+ reportsPrintRendered:true,allDocumentsRtl:true,physicalPrinter:'not-tested'};
1570
+}
1571
+
1572
+async function nativeExpenseFormAndCategory() {
1573
+ const wait=ms=>new Promise(resolve=>setTimeout(resolve,ms));
1574
+ const check=(ok,msg)=>{if(!ok)throw Error(msg);};
1575
+ const db=FINORA.Storage,company=await FINORA.Company.current();
1576
+ check(company?.id&&FINORA.Auth.isAdmin(),'Expense UI test requires a synthetic administrator');
1577
+ await FINORA.Router.go('expenses');await wait(160);
1578
+ const view=window.ExpensesView;
1579
+ await view.openExpenseModal();
1580
+ const originalPrompt=window.prompt;
1581
+ try {
1582
+ window.prompt=()=> 'VM-only Q01 expense category';
1583
+ await view._promptNewCategory();
1584
+ } finally {
1585
+ window.prompt=originalPrompt;
1586
+ }
1587
+ check(document.getElementById('expCategory')?.value==='VM-only Q01 expense category',
1588
+ 'New expense category was not selected in the form');
1589
+ document.getElementById('expDate').value='1405/07/18';
1590
+ document.getElementById('expAmount').value='1234';
1591
+ document.getElementById('expMethod').value='cash';
1592
+ document.getElementById('expRef').value='Q01-EXPENSE-001';
1593
+ document.getElementById('expDesc').value='VM-only Q01 expense form';
1594
+ await view.saveExpense(null);await wait(180);
1595
+ const expense=(await db.getAll('expenses')).find(x=>
1596
+ x.companyId===company.id&&x.refNumber==='Q01-EXPENSE-001');
1597
+ check(expense?.amount===1234&&expense.kind==='expense'&&
1598
+ expense.category==='VM-only Q01 expense category'&&expense.financePosted===true,
1599
+ 'Expense UI did not persist and post the synthetic expense');
1600
+ check((await db.getAll('journal_entries')).some(x=>
1601
+ x.companyId===company.id&&x.sourceId===expense.id&&x.status==='posted'),
1602
+ 'Expense UI did not create its posted journal');
1603
+ return {expenseCreatedThroughForm:true,customCategorySelected:true,
1604
+ expenseJournalPosted:true};
1605
+}
1606
+
1607
+async function nativeAccountingJournalAndExports() {
1608
+ const check=(ok,msg)=>{if(!ok)throw Error(msg);};
1609
+ const db=FINORA.Storage,company=await FINORA.Company.current();
1610
+ check(company?.id&&FINORA.Auth.isAdmin(),'Manual journal UI test requires a synthetic administrator');
1611
+ await FINORA.Router.go('accounting');
1612
+ const view=window.AccountingView;
1613
+ await view.refresh();
1614
+ const period=view.periods.find(x=>!x.closed);
1615
+ check(period,'An open fiscal period is required for manual journal UI testing');
1616
+ const postable=view.accounts.filter(a=>a.level!=='group'&&a.active!==false&&
1617
+ a.postable!==false&&!view.accounts.some(child=>child.parentCode===a.code));
1618
+ check(postable.length>=2,'Two postable accounts are required for a balanced manual journal');
1619
+ const used=new Set(view.accounts.map(a=>String(a.code)));
1620
+ const groupCode=['9','8','7','6','0'].find(x=>!used.has(x));
1621
+ check(groupCode,'No unused synthetic group account code available');
1622
+ view.openAccountModal();
1623
+ document.getElementById('acCode').value=groupCode;
1624
+ document.getElementById('acName').value='VM-only Q01 journal test group';
1625
+ document.getElementById('acLevel').value='group';
1626
+ document.getElementById('acType').value='expense';
1627
+ view.toggleParent();
1628
+ await view.saveAccount();
1629
+ check(view.accounts.some(x=>String(x.code)===groupCode&&x.level==='group'),
1630
+ 'Manual chart-of-accounts form did not persist the synthetic group');
1631
+ const description='VM-only Q01 manual journal draft';
1632
+ await view.openJournalModal();
1633
+ check(document.getElementById('acJournalLines'),'Manual journal form did not open');
1634
+ const initialRows=document.querySelectorAll('#acJournalLines .ac-journal-line');
1635
+ check(initialRows.length===2,'Manual journal must start with two rows');
1636
+ view.addJournalRow();
1637
+ check(document.querySelectorAll('#acJournalLines .ac-journal-line').length===3,
1638
+ 'Add journal row did not append a third line');
1639
+ document.querySelectorAll('#acJournalLines .ac-journal-line')[2].remove();
1640
+ document.getElementById('acJournalPeriod').value=period.id;
1641
+ document.getElementById('acJournalDate').value=period.startDate;
1642
+ document.getElementById('acJournalDescription').value=description;
1643
+ const rows=[...document.querySelectorAll('#acJournalLines .ac-journal-line')];
1644
+ rows[0].querySelector('.ac-line-account').value=postable[0].id;
1645
+ rows[0].querySelector('.ac-line-debit').value='100';
1646
+ rows[0].querySelector('.ac-line-credit').value='0';
1647
+ rows[1].querySelector('.ac-line-account').value=postable[1].id;
1648
+ rows[1].querySelector('.ac-line-debit').value='0';
1649
+ rows[1].querySelector('.ac-line-credit').value='100';
1650
+ await view.saveJournal('draft');
1651
+ let draft=(await db.getAll('journal_entries')).find(x=>
1652
+ x.companyId===company.id&&x.description===description&&x.status==='draft');
1653
+ check(draft,'Manual journal draft did not persist');
1654
+ const postedDescription='VM-only Q01 manual journal posted';
1655
+ await view.openJournalModal(draft.id);
1656
+ document.getElementById('acJournalDescription').value=postedDescription;
1657
+ await view.saveJournal('posted');
1658
+ const posted=(await db.getAll('journal_entries')).find(x=>
1659
+ x.companyId===company.id&&x.description===postedDescription&&x.status==='posted');
1660
+ check(posted&&posted.debit===100&&posted.credit===100,
1661
+ 'Balanced draft was not posted through the manual journal form');
1662
+ view.openReversal(posted.id);
1663
+ check(document.getElementById('acReversalId'),'Manual journal reversal form did not open');
1664
+ document.getElementById('acReversalPeriod').value=period.id;
1665
+ document.getElementById('acReversalDate').value=period.startDate;
1666
+ await view.saveReversal();
1667
+ const originalAfter=await db.get('journal_entries',posted.id);
1668
+ const reversal=(await db.getAll('journal_entries')).find(x=>
1669
+ x.companyId===company.id&&x.reversalOfId===posted.id&&x.status==='posted');
1670
+ check(originalAfter?.reversedById===reversal?.id&&reversal?.debit===100&&reversal?.credit===100,
1671
+ 'Manual journal reversal did not preserve the original and post a balanced reversal');
1672
+ const downloads=[],originalClick=HTMLAnchorElement.prototype.click;
1673
+ try {
1674
+ HTMLAnchorElement.prototype.click=function(){
1675
+ downloads.push({filename:this.download,url:this.href});
1676
+ };
1677
+ await view.exportReports();
1678
+ await view.exportReconciliation();
1679
+ check(downloads.length===2,'Accounting report and reconciliation exports did not both download');
1680
+ const content=await Promise.all(downloads.map(async item=>{
1681
+ const response=await fetch(item.url);
1682
+ if(!response.ok)throw Error('CSV blob URL could not be read');
1683
+ return {filename:item.filename,text:await response.text()};
1684
+ }));
1685
+ check(content.some(x=>x.filename==='factor-easypro-ledger.csv'&&
1686
+ x.text.includes('account_code')&&x.text.includes(postedDescription)),
1687
+ 'Ledger CSV export omitted the posted synthetic journal');
1688
+ check(content.some(x=>x.filename==='factor-easypro-reconciliation.csv'&&
1689
+ x.text.includes('code')&&x.text.includes('reference')),
1690
+ 'Reconciliation CSV export omitted its expected schema');
1691
+ } finally {
1692
+ HTMLAnchorElement.prototype.click=originalClick;
1693
+ }
1694
+ return {chartAccountCreated:true,journalRowAdded:true,draftJournalSaved:true,
1695
+ journalPosted:true,reversalPosted:true,ledgerCsvExported:true,
1696
+ reconciliationCsvExported:true};
1697
+}
1698
+
1699
+async function nativeInventoryTransferAndStocktake() {
1700
+ const check=(ok,msg)=>{if(!ok)throw Error(msg);};
1701
+ const db=FINORA.Storage,company=await FINORA.Company.current();
1702
+ check(company?.id&&FINORA.Auth.isAdmin(),'Inventory transfer UI test requires a synthetic administrator');
1703
+ const balances=(await db.getAll('inventory_balances')).filter(x=>
1704
+ x.companyId===company.id&&x.quantityUnits>0);
1705
+ check(balances.length,'No positive synthetic inventory balance exists for transfer');
1706
+ const sourceBalance=balances[0];
1707
+ const product=await db.get('products',sourceBalance.productId);
1708
+ const warehouses=(await db.getAll('warehouses')).filter(x=>x.companyId===company.id);
1709
+ const source=warehouses.find(x=>x.id===sourceBalance.warehouseId);
1710
+ check(product?.trackInventory!==false&&source,'Transfer source product/warehouse is invalid');
1711
+ await FINORA.Router.go('accounting');
1712
+ const view=window.AccountingView;
1713
+ await view.refresh();
1714
+ const secondName='VM-only Q01 transfer destination';
1715
+ view.openWarehouse();
1716
+ document.getElementById('acWhName').value=secondName;
1717
+ await view.saveWarehouse();
1718
+ const destination=(await db.getAll('warehouses')).find(x=>
1719
+ x.companyId===company.id&&x.name===secondName);
1720
+ check(destination,'Second warehouse was not created through the UI');
1721
+ const quantity=Math.min(0.1,sourceBalance.quantityUnits/1000);
1722
+ const transferUnits=Math.round(quantity*1000);
1723
+ const beforeRows=await db.getAll('inventory_balances');
1724
+ const beforeFrom=beforeRows.find(x=>x.companyId===company.id&&
1725
+ x.warehouseId===source.id&&x.productId===product.id)?.quantityUnits||0;
1726
+ const beforeTo=beforeRows.find(x=>x.companyId===company.id&&
1727
+ x.warehouseId===destination.id&&x.productId===product.id)?.quantityUnits||0;
1728
+ await view.openTransfer();
1729
+ check(document.getElementById('acTrProduct')&&document.getElementById('acTrFrom')&&
1730
+ document.getElementById('acTrTo'),'Stock transfer form did not open');
1731
+ document.getElementById('acTrProduct').value=product.id;
1732
+ document.getElementById('acTrFrom').value=source.id;
1733
+ document.getElementById('acTrTo').value=destination.id;
1734
+ document.getElementById('acTrQty').value=String(quantity);
1735
+ document.getElementById('acTrDate').value='1405/07/22';
1736
+ await view.saveTransfer();
1737
+ const afterRows=await db.getAll('inventory_balances');
1738
+ const afterFrom=afterRows.find(x=>x.companyId===company.id&&
1739
+ x.warehouseId===source.id&&x.productId===product.id)?.quantityUnits||0;
1740
+ const afterTo=afterRows.find(x=>x.companyId===company.id&&
1741
+ x.warehouseId===destination.id&&x.productId===product.id)?.quantityUnits||0;
1742
+ check(afterFrom===beforeFrom-transferUnits&&afterTo===beforeTo+transferUnits,
1743
+ 'Stock transfer did not move the exact milli-unit quantity between warehouses');
1744
+ await view.openStocktakeCreate();
1745
+ document.getElementById('acStWarehouse').value=source.id;
1746
+ document.getElementById('acStDate').value='1405/07/23';
1747
+ await view.createStocktake();
1748
+ const stocktakeId=document.getElementById('acStocktakeId')?.value;
1749
+ check(stocktakeId,'Stocktake create action did not open the count sheet');
1750
+ const countRows=[...document.querySelectorAll('#acTakeRows tr[data-product]')];
1751
+ check(countRows.length>0,'Stocktake did not snapshot the source warehouse balances');
1752
+ for(const row of countRows){
1753
+ const expected=Number(row.querySelector('td:nth-child(2)').textContent.trim());
1754
+ row.querySelector('.ac-count').value=String(expected);
1755
+ }
1756
+ await view.saveStocktake();
1757
+ await view.openStocktake(stocktakeId);
1758
+ await view.finishStocktake();
1759
+ const stocktake=await db.get('stocktakes',stocktakeId);
1760
+ const lines=await db.getAll('stocktake_lines');
1761
+ const ownLines=lines.filter(x=>x.companyId===company.id&&x.stocktakeId===stocktakeId);
1762
+ check(stocktake?.status==='posted'&&ownLines.length>0&&
1763
+ ownLines.every(x=>x.countedUnits===x.expectedUnits),
1764
+ 'Stocktake did not save all counts and finalize without an inventory delta');
1765
+ return {secondWarehouseCreated:true,transferPosted:true,exactInventoryMoved:true,
1766
+ stocktakeCreated:true,stocktakeCountsSaved:true,stocktakeFinalized:true};
1767
+}
1768
+
1769
module.exports = async function nativeFunctionalMatrix(cdp) {
1770
const phases = [
1771
['legacy-stock-adjustment-form-and-validation', legacyStockAdjustmentFormAndValidation],
@@ -1444,6 +1776,11 @@ module.exports = async function nativeFunctionalMatrix(cdp) {
1776
['positive-opening-ledger-and-idempotency', nativePositiveOpeningLedger],
1777
['purchase-and-post-ledger', purchaseInvoice],
1778
['partial-sale-and-inventory', saleInvoice],
1779
+ ['invoice-quick-add-and-save-print', nativeInvoiceQuickAddAndPrint],
1780
+ ['auxiliary-rtl-print-rendering', nativeAuxiliaryPrintRendering],
1781
+ ['expense-form-category-and-posting', nativeExpenseFormAndCategory],
1782
+ ['manual-journal-reversal-and-exports', nativeAccountingJournalAndExports],
1783
+ ['inventory-transfer-and-stocktake', nativeInventoryTransferAndStocktake],
1784
['inactive-treasury-cheque-settlement', nativeInactiveBankSettlementGuard],
1785
['cheque-third-party-endorsement', nativeChequeThirdPartyEndorsement],
1786
['treasury-cheque-reconciliation-readonly', nativeTreasuryChequeReconciliation],
tests/windows-vm-native-performance-contract.test.mjs
+22
@@ -24,3 +24,25 @@ test('A08 installed VM runner rejects incomplete report or encrypted-backup meas
24
assert.match(lab,/\$encryptedBackup\.bytes -lt 100000/);
25
assert.match(lab,/reportsRendered = 4/);
26
});
27
+
28
+
29
+test('Q01 Windows native matrix requires the additional invoice, print, expense, ledger and stocktake workflows',()=>{
30
+ const matrix=read('tests/windows-vm-native-functional-matrix.cjs');
31
+ const lab=read('scripts/windows-vm-native-lab.ps1');
32
+ const scenarios=[
33
+ 'invoice-quick-add-and-save-print',
34
+ 'auxiliary-rtl-print-rendering',
35
+ 'expense-form-category-and-posting',
36
+ 'manual-journal-reversal-and-exports',
37
+ 'inventory-transfer-and-stocktake'
38
+ ];
39
+ for(const scenario of scenarios){
40
+ assert.ok(matrix.includes("['"+scenario+"'"),'Native functional matrix omitted '+scenario);
41
+ assert.ok(lab.includes("'"+scenario+"'"),'Windows VM mandatory acceptance omitted '+scenario);
42
+ }
43
+ assert.match(matrix,/window\.InvoiceFormView\._save\(true\)/);
44
+ assert.match(matrix,/window\.StockKardexModal\._printKardex/);
45
+ assert.match(matrix,/window\.ContactLedgerModal\._printLedger/);
46
+ assert.match(matrix,/window\.AccountingView\.saveTransfer/);
47
+ assert.match(matrix,/window\.AccountingView\.finishStocktake/);
48
+});