feat(cards): support inclusive date range queries
This commit is contained in:
@@ -733,4 +733,39 @@ describe('Manual bank cards configured HTTP and real SQLite', () => {
|
||||
.paymentSystem,
|
||||
).toBe('mastercard');
|
||||
});
|
||||
it('filters journal and summary inclusively across months and rejects invalid periods', async () => {
|
||||
const card = await createCard();
|
||||
const dates = ['2026-07-30', '2026-07-31', '2026-08-01', '2026-08-02'];
|
||||
for (const date of dates)
|
||||
await createOp(op(card.id, 'expense', '10', { date }));
|
||||
const range = 'from=2026-07-31&to=2026-08-01';
|
||||
const history = (
|
||||
await auth('get', `/${card.id}/operations?${range}&limit=1`).expect(200)
|
||||
).body as BankOperationsPageDto;
|
||||
expect(history.total).toBe(2);
|
||||
expect(history.items.map((item) => item.date)).toEqual(['2026-08-01']);
|
||||
expect(history.hasNext).toBe(true);
|
||||
const result = (
|
||||
await auth('get', `/summary?cardId=${card.id}&${range}`).expect(200)
|
||||
).body as BankSummaryDto;
|
||||
expect(result.net.value).toBe('20');
|
||||
const single = (
|
||||
await auth(
|
||||
'get',
|
||||
`/${card.id}/operations?from=2026-07-31&to=2026-07-31`,
|
||||
).expect(200)
|
||||
).body as BankOperationsPageDto;
|
||||
expect(single.total).toBe(1);
|
||||
for (const invalid of [
|
||||
'',
|
||||
'from=2026-07-31',
|
||||
'to=2026-08-01',
|
||||
'from=2026-08-02&to=2026-08-01',
|
||||
'from=2026-02-30&to=2026-08-01',
|
||||
`${range}&month=2026-08`,
|
||||
]) {
|
||||
await auth('get', `/${card.id}/operations?${invalid}`).expect(400);
|
||||
await auth('get', `/summary?${invalid}`).expect(400);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user