Skip to content

Commit

Permalink
Merge pull request #458 from RJ-SMTR/feature/relatorio_sintetico
Browse files Browse the repository at this point in the history
fix: ignore Gratuidade to check if isPago
  • Loading branch information
williamfl2007 authored Sep 10, 2024
2 parents 437a63f + 670d0cb commit 12f87b9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/bank-statements/bank-statements.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ export class BankStatementsService {
const revenuesWeek = revenuesResponse.data.filter((i) => new Date(i.date) >= dateInterval.startDate && new Date(i.date) <= dateInterval.endDate);
const weekAmount = revenuesWeek.reduce((sum, i) => sum + i.transactionValueSum, 0);
const weekToPayAmount = revenuesWeek.reduce((sum, i) => sum + i.paidValueSum, 0);
/** Se todos os itens não vazios foram pagos */
const nonEmptyRevenues = revenuesWeek.filter((i) => i.count);
/** Se todos os itens não vazios e com valor foram pagos */
const nonEmptyRevenues = revenuesWeek.filter((i) => (i.transactionValueSum || i.paidValueSum) && i.count);
const isPago = nonEmptyRevenues.length > 0 && nonEmptyRevenues.every((i) => i.isPago === true);
const errors = [...new Set(revenuesWeek.reduce((l, i) => [...l, ...i.errors], []))];
const amount = Number(weekAmount.toFixed(2));
Expand Down
2 changes: 1 addition & 1 deletion src/ticket-revenues/ticket-revenues.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class TicketRevenuesRepositoryService {
`;
const queryRunner = this.dataSource.createQueryRunner();
await queryRunner.connect();
let result: any[] = await queryRunner.query(compactQuery(query));
const result: any[] = await queryRunner.query(compactQuery(query));
queryRunner.release();
const revenueIndividuals = result.map((r) => new TicketRevenueDTO(r));
return revenueIndividuals;
Expand Down
3 changes: 1 addition & 2 deletions src/ticket-revenues/ticket-revenues.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ export class TicketRevenuesService {
aux_epochWeek: nthWeek,
aux_nthWeeks: [],
aux_groupDateTime: itemDate.toISOString(),
/** Se encontrar 1 item não pago, muda para falso */
isPago: true,
isPago: revenue.isPago,
errors: errors,
});
group[dateGroup] = newGroup;
Expand Down

0 comments on commit 12f87b9

Please sign in to comment.