Add payable filter to sales invoices and enhance invoice status handling

- Introduced a new `payable` filter in the `ListSalesInvoicesFilters` and `ListSalesInvoicesQuery` types to allow querying of invoices based on their payable status.
- Updated the `SalesInvoicesRepository` to incorporate logic for filtering invoices that are payable, checking both status and balance.
- Enhanced the `SalesInvoicesService` to support the new `payable` filter in query handling.
- Modified the `SalesInvoiceDto` to include the `payable` property for better API response representation.
- Added unit tests to validate the new filter functionality and ensure proper handling of invoice statuses during updates.
- Updated e2e tests to cover scenarios involving the new payable filter and status transitions for invoices.
This commit is contained in:
shancheas
2026-08-31 15:15:06 +07:00
parent afed5ff0f5
commit 5579cf6566
11 changed files with 141 additions and 9 deletions
+11
View File
@@ -147,6 +147,11 @@ describe('Sales payments (e2e)', () => {
})
.expect(201);
invoiceId = (invoice.body as { id: string }).id;
await request(app.getHttpServer())
.patch(`/sales-invoices/${invoiceId}/status`)
.set(auth)
.send({ status: 'processed' })
.expect(200);
});
afterAll(async () => {
@@ -182,6 +187,12 @@ describe('Sales payments (e2e)', () => {
.send({ status: 'approved' })
.expect(400);
await request(app.getHttpServer())
.patch(`/sales-payments/${id}/status`)
.set('Authorization', `Bearer ${token}`)
.send({ status: 'pending' })
.expect(200);
await request(app.getHttpServer())
.patch(`/sales-payments/${id}/status`)
.set('Authorization', `Bearer ${token}`)