feat: improve application access and money precision

This commit is contained in:
hectorzhao
2026-07-16 17:54:05 +08:00
parent 9d5c507007
commit faa716b8d0
49 changed files with 1699 additions and 489 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { moneyToNumber } from '../common/money';
import { PrismaService } from '../prisma/prisma.service';
export interface CreateTenantDto {
@@ -64,8 +65,8 @@ export class TenantsService {
}),
]);
const accountsByTenant = new Map(accounts.map((account) => [account.tenantId, account]));
const todaySpendByTenant = new Map(todaySpendGroups.map((group) => [group.tenantId, group._sum.amountCents ?? 0]));
const todayRefundByTenant = new Map(todayRefundGroups.map((group) => [group.tenantId, group._sum.amountCents ?? 0]));
const todaySpendByTenant = new Map(todaySpendGroups.map((group) => [group.tenantId, moneyToNumber(group._sum.amountCents)]));
const todayRefundByTenant = new Map(todayRefundGroups.map((group) => [group.tenantId, moneyToNumber(group._sum.amountCents)]));
return tenants.map((tenant) => ({
...withEnterpriseProfile(tenant),
account: accountsByTenant.get(tenant.id) ?? null,