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
+11 -1
View File
@@ -61,6 +61,16 @@ describe('BillingService', () => {
amountCents: 20,
}),
);
expect(
service.estimateSmsCost({ tenantId: 'tenant-1', content: '四位小数单价', phoneCount: 2, unitPrice: 325 }),
).toEqual(
expect.objectContaining({
unitPrice: 325,
totalBillingUnits: 2,
amountCents: 650,
}),
);
});
it('allows sending only when cash balance plus credit is greater than zero', async () => {
@@ -81,7 +91,7 @@ describe('BillingService', () => {
await expect(service.checkAccount({ tenantId: 'tenant-1', amountCents: 999999 })).resolves.toEqual(
expect.objectContaining({ availableAmount: 1500, creditCents: 500, canSend: true }),
);
await expect(service.updateCreditLimit('tenant-1', { creditCents: 1.5 })).rejects.toThrow('授信额度必须为整数金额');
await expect(service.updateCreditLimit('tenant-1', { creditCents: 1.5 })).rejects.toThrow('授信额度最多支持人民币小数点后 4 位');
expect(prisma.operationLog.create).toHaveBeenCalledWith({
data: expect.objectContaining({
action: 'billing.credit_limit_updated',