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 }); }