feat: improve application access and money precision
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user