import { Pipe, PipeTransform } from '@angular/core'; import { PayrollReportTableResponse } from '../models/payroll-report-tables.type'; import { CurrencyPipe } from '@angular/common'; @Pipe({ standalone: true, name: 'includedCount', pure: false, }) export class IncludedCountPipe implements PipeTransform { constructor(private currencyPipe: CurrencyPipe) {} transform( includedArray: PayrollReportTableResponse[], isOpen: boolean ): string | null { const totalCount = includedArray.reduce((current, next) => { return (current += +next.subtotal!); }, 0); if (!totalCount && !isOpen) return null; return this.currencyPipe.transform(totalCount); } }