Skip to content

Commit

Permalink
fix: [438] Send "Invalid" financial information from "Refetch ANAF Da…
Browse files Browse the repository at this point in the history
…ta CRON" to "Persoana in relatia cu ONG"
  • Loading branch information
radulescuandrew committed Sep 4, 2024
1 parent 475a81b commit 3051e8c
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { In, Not } from 'typeorm';
import { EVENTS } from 'src/modules/notifications/constants/events.contants';
import InvalidFinancialReportsEvent from 'src/modules/notifications/events/invalid-financial-reports-event.class';
import { OrganizationStatus } from '../enums/organization-status.enum';
import { ContactPerson } from '../interfaces/contact-person.interface';

@Injectable()
export class OrganizationFinancialService {
Expand Down Expand Up @@ -286,7 +287,11 @@ export class OrganizationFinancialService {
type OrganizationsWithMissingANAFData = {
id: number;
organizationFinancial: OrganizationFinancial[];
organizationGeneral: { cui: string; email: string };
organizationGeneral: {
cui: string;
email: string;
contact: ContactPerson;
};
};

const data: OrganizationsWithMissingANAFData[] =
Expand All @@ -306,6 +311,9 @@ export class OrganizationFinancialService {
organizationGeneral: {
cui: true,
email: true,
contact: {
email: true,
},
},
organizationFinancial: true,
},
Expand Down Expand Up @@ -398,10 +406,15 @@ export class OrganizationFinancialService {
}

// In case one of the report is invalid, we notify the ADMIN to modify them
if (sendNotificationForInvalidData) {
if (
sendNotificationForInvalidData &&
org.organizationGeneral?.contact?.email
) {
this.eventEmitter.emit(
EVENTS.INVALID_FINANCIAL_REPORTS,
new InvalidFinancialReportsEvent(org.organizationGeneral.email),
new InvalidFinancialReportsEvent(
org.organizationGeneral?.contact?.email,
),
);
}
} catch (err) {
Expand Down

0 comments on commit 3051e8c

Please sign in to comment.