From 22d979321ffd54a9034b61d1ea219bf171eecc3c Mon Sep 17 00:00:00 2001 From: Alessandro Alterno <28725795+lexinor@users.noreply.github.com> Date: Sun, 6 Nov 2022 15:47:04 +0100 Subject: [PATCH] refactor: Added parameters to the db requests to fit usage - Added some ordering paramters to properly fit usage. We are now showing the UNPAID and latest Invoices instead of showing the PAID and oldest - Changed default expiring date from TWO WEEKS to ONE WEEK --- src/server/services/invoice/invoice.db.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/services/invoice/invoice.db.ts b/src/server/services/invoice/invoice.db.ts index 4f71bda3..01a60d4b 100644 --- a/src/server/services/invoice/invoice.db.ts +++ b/src/server/services/invoice/invoice.db.ts @@ -7,14 +7,14 @@ import { Transaction } from 'sequelize/types'; @singleton() export class InvoiceDB { async getAllInvoices(): Promise { - return await InvoiceModel.findAll(); + return await InvoiceModel.findAll({ order: [['status', 'DESC'], ['createdAt', 'DESC']]}); } async getAllReceivingInvoices( identifier: string, pagination: GetInvoicesInput, ): Promise { - return await InvoiceModel.findAll({ where: { toIdentifier: identifier }, ...pagination }); + return await InvoiceModel.findAll({ order: [["status", "DESC"], ["createdAt", "DESC"]], where: { toIdentifier: identifier }, ...pagination }); } async getReceivedInvoicesCount(identifier: string): Promise { @@ -34,7 +34,7 @@ export class InvoiceDB { async createInvoice(input: CreateInvoiceInput): Promise { const expiresAt = input.expiresAt ? input.expiresAt - : new Date(Date.now() + MS_TWO_WEEKS).toString(); + : new Date(Date.now() + MS_ONE_WEEK).toString(); return await InvoiceModel.create({ ...input, expiresAt }); }