فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A08): bulk synthetic cheque reconciliation forbids per-cheque linear treasury scans
davoodmehraban89 committed
Oct 23, 2026 at 10:58 UTC
69af051d6244d33132e5de53057850e0c1ecbe59
1 file changed
+47
tests/reconciliation.test.mjs
+47
@@ -240,3 +240,50 @@ test('A05: endorsed cheque reconciliation validates drawer and endorsee GL dimen
240
assert.equal(before.cheques[0].endorseeContactId,'supplier-2',
241
'Read-only checker must not mutate original references');
242
});
243
+
244
+test('A08: cheque bank reconciliation indexes account rows once, without per-cheque linear searches',()=>{
245
+ const f=fixture();
246
+ f.accounts.push(
247
+ {id:'cheque-receivable',code:'105'},
248
+ {id:'customer-receivable',code:'102'},
249
+ {id:'bank-gl',code:'101001',parentCode:'101'}
250
+ );
251
+ f.transactions.push({
252
+ id:'selected-bank',recordType:'account',ledgerAccountId:'bank-gl'
253
+ });
254
+ for(let i=0;i<600;i++){
255
+ f.transactions.push({id:'unused-account-'+i,recordType:'account',ledgerAccountId:'bank-gl'});
256
+ }
257
+ for(let i=0;i<250;i++){
258
+ const id='cheque-'+i,origin='origin-'+i,final='final-'+i;
259
+ f.journals.push(
260
+ {id:origin,status:'posted',sourceType:'cheque',sourceId:id,debit:15,credit:15},
261
+ {id:final,status:'posted',sourceType:'cheque_status',sourceId:id,debit:15,credit:15}
262
+ );
263
+ f.journalLines.push(
264
+ {id:'cheque-dr-'+i,journalId:origin,accountId:'cheque-receivable',debit:15,credit:0},
265
+ {id:'cheque-cr-'+i,journalId:origin,accountId:'customer-receivable',debit:0,credit:15},
266
+ {id:'clear-dr-'+i,journalId:final,accountId:'bank-gl',debit:15,credit:0},
267
+ {id:'clear-cr-'+i,journalId:final,accountId:'cheque-receivable',debit:0,credit:15}
268
+ );
269
+ f.cheques=(f.cheques||[]);
270
+ f.cheques.push({id,financePosted:true,direction:'inbound',
271
+ contactId:'customer',status:'cleared',amount:15,
272
+ journalId:origin,statusJournalId:final,clearingAccountId:'selected-bank'});
273
+ f.transactions.push({id:'receipt-'+i,recordType:'transaction',refChequeId:id,
274
+ type:'receipt',amount:15,journalId:final,
275
+ toAccountId:'selected-bank',financePosted:true});
276
+ }
277
+ const guarded=new Proxy(f.transactions,{
278
+ get(target,key,receiver){
279
+ if(key==='find')throw Error('Per-cheque linear treasury lookup is forbidden');
280
+ return Reflect.get(target,key,receiver);
281
+ }
282
+ });
283
+ const result=reconcileFinancialData({...f,transactions:guarded});
284
+ assert.equal(result.counts.cheques,250);
285
+ assert.equal(result.counts.issues,0,JSON.stringify(result.issues.slice(0,3)));
286
+ assert.equal(result.totals.inventoryBook,100);
287
+ assert.equal(result.totals.inventoryLedger,100);
288
+ assert.equal(f.transactions.length,851);
289
+});