src/app/pipes/payments-filter.pipe.ts
Name | paymentsFilter |
searchAmount |
searchAmount(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:178
|
Returns :
boolean
|
searchAmountFormatted |
searchAmountFormatted(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:168
|
Returns :
boolean
|
searchDate |
searchDate(date: string, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:160
|
Returns :
boolean
|
searchDeliveryDate |
searchDeliveryDate(date: string, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:164
|
Returns :
boolean
|
searchMemo |
searchMemo(value: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:150
|
Returns :
boolean
|
searchPayFrom |
searchPayFrom(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:70
|
Returns :
boolean
|
searchPayFromAccountDisplayName |
searchPayFromAccountDisplayName(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:90
|
Returns :
boolean
|
searchPayFromAccountName |
searchPayFromAccountName(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:80
|
Returns :
boolean
|
searchPayFromAccountNumber |
searchPayFromAccountNumber(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:130
|
Returns :
boolean
|
searchPayment |
searchPayment(value: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:24
|
Returns :
boolean
|
searchPayToAccountNumber |
searchPayToAccountNumber(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:140
|
Returns :
boolean
|
searchPayToBankAccount |
searchPayToBankAccount(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:120
|
Returns :
boolean
|
searchPayToDisplayName |
searchPayToDisplayName(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:110
|
Returns :
boolean
|
searchPayToName |
searchPayToName(payment: Payment, target: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:100
|
Returns :
boolean
|
transform |
transform(input: Payment[], targetRaw: string)
|
Defined in src/app/pipes/payments-filter.pipe.ts:10
|
Returns :
Payment[]
|
import { DatePipe } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';
import { LOCALE } from '../app.constants';
import { Payment } from '../models';
@Pipe({
name: 'paymentsFilter'
})
export class PaymentsFilterPipe implements PipeTransform {
transform(input: Payment[], targetRaw: string): Payment[] {
if (
input === null ||
input === undefined ||
targetRaw === null ||
targetRaw === undefined
) {
return input;
}
const target = targetRaw.toLowerCase();
const pmts = input.filter(value => this.searchPayment(value, target));
return pmts;
}
searchPayment(value: Payment, target: string) {
const datePipe = new DatePipe(LOCALE);
const dateStr = value.paymentDateFormatted;
const shortDate = dateStr
? datePipe.transform(new Date(dateStr), 'shortDate')
: null;
const mediumDate = dateStr
? datePipe.transform(new Date(dateStr), 'mediumDate').toLowerCase()
: null;
const longDate = dateStr
? datePipe.transform(new Date(dateStr), 'longDate').toLowerCase()
: null;
const deliveryDateStr = value.expectedDeliveryDate;
const shortDeliveryDate = deliveryDateStr
? datePipe.transform(new Date(deliveryDateStr), 'shortDate')
: null;
const mediumDeliveryDate = deliveryDateStr
? datePipe
.transform(new Date(deliveryDateStr), 'mediumDate')
.toLowerCase()
: null;
const longDeliveryDate = deliveryDateStr
? datePipe.transform(new Date(deliveryDateStr), 'longDate').toLowerCase()
: null;
return (
this.searchPayToName(value, target) ||
this.searchPayToDisplayName(value, target) ||
this.searchPayToAccountNumber(value, target) ||
this.searchPayToBankAccount(value, target) ||
this.searchPayFrom(value, target) ||
this.searchPayFromAccountName(value, target) ||
this.searchPayFromAccountDisplayName(value, target) ||
this.searchPayFromAccountNumber(value, target) ||
this.searchMemo(value, target) ||
this.searchDate(shortDate, target) ||
this.searchDate(mediumDate, target) ||
this.searchDate(longDate, target) ||
this.searchDeliveryDate(shortDeliveryDate, target) ||
this.searchDeliveryDate(mediumDeliveryDate, target) ||
this.searchDeliveryDate(longDeliveryDate, target) ||
this.searchAmount(value, target) ||
this.searchAmountFormatted(value, target)
);
}
searchPayFrom(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.payFrom !== null &&
payment.payFrom !== undefined &&
payment.payFrom.toLowerCase().includes(target)
);
}
searchPayFromAccountName(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.payFromAccountName !== null &&
payment.payFromAccountName !== undefined &&
payment.payFromAccountName.toLowerCase().includes(target)
);
}
searchPayFromAccountDisplayName(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.payFromAccountDisplayName !== null &&
payment.payFromAccountDisplayName !== undefined &&
payment.payFromAccountDisplayName.toLowerCase().includes(target)
);
}
searchPayToName(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.payToName !== null &&
payment.payToName !== undefined &&
payment.payToName.toLowerCase().includes(target)
);
}
searchPayToDisplayName(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.displayName !== null &&
payment.displayName !== undefined &&
payment.displayName.toLowerCase().includes(target)
);
}
searchPayToBankAccount(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.payToBankAccount !== null &&
payment.payToBankAccount !== undefined &&
payment.payToBankAccount.toLowerCase().includes(target)
);
}
searchPayFromAccountNumber(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.payFromAccount !== null &&
payment.payFromAccount !== undefined &&
payment.payFromAccount.toLowerCase().includes(target)
);
}
searchPayToAccountNumber(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.payToBankAccount !== null &&
payment.payToBankAccount !== undefined &&
payment.payToBankAccount.toLowerCase().includes(target)
);
}
searchMemo(value: Payment, target: string): boolean {
return (
value !== null &&
value !== undefined &&
value.memo !== null &&
value.memo !== undefined &&
value.memo.toLowerCase().includes(target)
);
}
searchDate(date: string, target: string): boolean {
return date != null && date !== undefined && date.includes(target);
}
searchDeliveryDate(date: string, target: string): boolean {
return date != null && date !== undefined && date.includes(target);
}
searchAmountFormatted(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.amountFormatted !== null &&
payment.amountFormatted !== undefined &&
payment.amountFormatted.includes(target)
);
}
searchAmount(payment: Payment, target: string): boolean {
return (
payment !== null &&
payment !== undefined &&
payment.amount !== null &&
payment.amount !== undefined &&
payment.amount.toString().includes(target)
);
}
}