Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
feat: add tenant scoped application dashboard service
Davood Mehraban committed
Oct 5, 2026 at 17:18 UTC
9bc83a753fa1342fcf1bfc7a1491fc9a354a3ad1
2 files changed
+4
src/platform/application/dashboard-service.test.ts
new
+2
@@ -0,0 +1,2 @@
1
+import {describe,expect,it} from 'vitest';import {InMemoryOperationsRepository,getDashboard} from './dashboard-service';
2
+describe('dashboard service',()=>{it('returns only request tenant data',async()=>{const repo=new InMemoryOperationsRepository([{tenantId:'t1',state:'UNKNOWN',amountIrr:100},{tenantId:'t2',state:'SETTLED',amountIrr:900}]);expect(await getDashboard({userId:'u1',tenantId:'t1',roles:['MAKER']},repo)).toEqual({total:1,totalIrr:100,unknown:1,settled:0,needsReview:0})})});
src/platform/application/dashboard-service.ts
new
+2
@@ -0,0 +1,2 @@
1
+import {dashboard,type OperationalPayment} from '../../domain/operations/dashboard';import type {RequestContext} from '../identity/request-context';
2
+export interface OperationsRepository{listPayments(tenantId:string):Promise<OperationalPayment[]>}export class InMemoryOperationsRepository implements OperationsRepository{constructor(private readonly rows:OperationalPayment[]){}async listPayments(tenantId:string){return this.rows.filter(x=>x.tenantId===tenantId)}}export async function getDashboard(ctx:RequestContext,repo:OperationsRepository){return dashboard(ctx.tenantId,await repo.listPayments(ctx.tenantId))}