fix: harden dependencies and downstream delivery
This commit is contained in:
@@ -105,7 +105,12 @@ describe('TenantsService', () => {
|
||||
}));
|
||||
expect(prisma.accountTransaction.groupBy).toHaveBeenCalledWith(expect.objectContaining({
|
||||
by: ['tenantId'],
|
||||
where: expect.objectContaining({ transactionType: 'refunded' }),
|
||||
where: expect.objectContaining({
|
||||
OR: [
|
||||
{ transactionType: 'refunded' },
|
||||
{ transactionType: 'released', relatedType: 'sms_message_record' },
|
||||
],
|
||||
}),
|
||||
_sum: { amountCents: true },
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ export class TenantsService {
|
||||
}),
|
||||
this.prisma.accountTransaction.groupBy({
|
||||
by: ['tenantId'],
|
||||
where: { transactionType: 'refunded', createdAt: { gte: sinceToday } },
|
||||
where: returnedTransactionWhere(sinceToday),
|
||||
_sum: { amountCents: true },
|
||||
}),
|
||||
]);
|
||||
@@ -201,6 +201,16 @@ function startOfToday() {
|
||||
return date;
|
||||
}
|
||||
|
||||
function returnedTransactionWhere(since: Date): Prisma.AccountTransactionWhereInput {
|
||||
return {
|
||||
createdAt: { gte: since },
|
||||
OR: [
|
||||
{ transactionType: 'refunded' },
|
||||
{ transactionType: 'released', relatedType: 'sms_message_record' },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function generateTenantCode(data: CreateTenantDto) {
|
||||
const source = data.creditCode?.trim() || data.name.trim();
|
||||
const normalized = source.replace(/[^\da-zA-Z]/g, '').toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user