From fede9005928cd15e2ae5a83a010c64e0166ef49b Mon Sep 17 00:00:00 2001 From: Dragos-Paul Strat Date: Thu, 29 Aug 2024 16:51:38 +0300 Subject: [PATCH] fix: [438] prevent generation of reports for organizations that have the yearCreated the current year --- .../src/modules/organization/services/crons.service.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/src/modules/organization/services/crons.service.ts b/backend/src/modules/organization/services/crons.service.ts index 85687dd9..6c5e5c60 100644 --- a/backend/src/modules/organization/services/crons.service.ts +++ b/backend/src/modules/organization/services/crons.service.ts @@ -41,10 +41,16 @@ export class OrganizationCronsService { @Cron('0 5 1 1 *') // 1st of January, 5:00 AM async generateFinancialDataAndReportsForPreviousYear() { - const lastYear = new Date().getFullYear() - 1; + const thisYear = new Date().getFullYear(); + const lastYear = thisYear - 1; // 1. Get all organizations with are missing the previous year the financial data and reports const organizations = await this.organizationRepository.getMany({ + where: { + organizationGeneral: { + yearCreated: Not(thisYear), + }, + }, relations: { organizationFinancial: true, organizationGeneral: true,