feat: enhance consumer and partner middleware with Redis caching

- Added Redis caching to ConsumerMiddleware and PartnerMiddleware to improve performance by reducing database calls for consumer and partner data.
- Implemented logic to check for cached data before querying the database.
- Updated the InvoicesService to include settlement_type in the selected fields.
- Removed unnecessary console logs from CustomersService.
- Modified SalesInvoicesService to optimize query logic and improve performance.
- Updated StatisticsService to streamline data retrieval and processing.
- Created a new migration to add last_attempt_no and last_tsp_status columns to sales_invoices for better tracking of TSP attempts.
This commit is contained in:
2026-06-09 13:31:58 +03:30
parent f61100bf25
commit 47a27fb54f
19 changed files with 482 additions and 134 deletions
@@ -201,6 +201,7 @@ export class SalesInvoicesService {
business_activity_id: posInfo.business_id,
},
},
referenced_by: null,
}
if (query.invoice_number) {
@@ -330,15 +331,16 @@ export class SalesInvoicesService {
if (query.status) {
if (query.status === TspProviderResponseStatus.NOT_SEND) {
where.tsp_attempts = {
none: {},
}
} else {
where.tsp_attempts = {
some: {
status: query.status,
where.OR = [
{
last_tsp_status: null,
},
}
{
last_tsp_status: TspProviderResponseStatus.NOT_SEND,
},
]
} else {
where.last_tsp_status = query.status
}
}