feat: add create loan product component (#434)
- Add loan product stepper components - Add create loan product component - Add charges penalty filter pipe - Add charges filter pipe - Add find pipe Fixes: #188
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { ChargesFilterPipe } from './charges-filter.pipe';
|
||||
|
||||
describe('ChargesFilterPipe', () => {
|
||||
it('create an instance', () => {
|
||||
const pipe = new ChargesFilterPipe();
|
||||
expect(pipe).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'chargesFilter'
|
||||
})
|
||||
export class ChargesFilterPipe implements PipeTransform {
|
||||
|
||||
transform(charges: any, chargesDataSource: any, currencyCode: string, multiDisburseLoan?: boolean): any {
|
||||
if (charges) {
|
||||
charges = charges.filter((charge: any) => {
|
||||
if ((charge.currency.code !== currencyCode) || (!!multiDisburseLoan && charge.chargeTimeType.id === 12) || chargesDataSource.includes(charge)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return charges;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { ChargesPenaltyFilterPipe } from './charges-penalty-filter.pipe';
|
||||
|
||||
describe('ChargesPenaltyFilterPipe', () => {
|
||||
it('create an instance', () => {
|
||||
const pipe = new ChargesPenaltyFilterPipe();
|
||||
expect(pipe).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'chargesPenaltyFilter'
|
||||
})
|
||||
export class ChargesPenaltyFilterPipe implements PipeTransform {
|
||||
|
||||
transform(charges: any, penalty: boolean): any {
|
||||
if (charges) {
|
||||
charges = charges.filter((charge: any) => {
|
||||
if (charge.penalty === penalty) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return charges;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { FindPipe } from './find.pipe';
|
||||
|
||||
describe('FindPipe', () => {
|
||||
it('create an instance', () => {
|
||||
const pipe = new FindPipe();
|
||||
expect(pipe).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'find'
|
||||
})
|
||||
export class FindPipe implements PipeTransform {
|
||||
|
||||
transform(value: any, options: any, key: string, property: string): any {
|
||||
const optionFound = options.find((option: any) => option[key] === value);
|
||||
return optionFound ? optionFound[property] : '';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,15 +2,16 @@ import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { StatusLookupPipe } from './status-lookup.pipe';
|
||||
import { AccountsFilterPipe } from './accounts-filter.pipe';
|
||||
|
||||
|
||||
import { ChargesFilterPipe } from './charges-filter.pipe';
|
||||
import { ChargesPenaltyFilterPipe } from './charges-penalty-filter.pipe';
|
||||
import { FindPipe } from './find.pipe';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
declarations: [StatusLookupPipe, AccountsFilterPipe],
|
||||
providers: [StatusLookupPipe, AccountsFilterPipe],
|
||||
exports: [StatusLookupPipe, AccountsFilterPipe]
|
||||
declarations: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe],
|
||||
providers: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe],
|
||||
exports: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe]
|
||||
})
|
||||
export class PipesModule { }
|
||||
|
||||
Reference in New Issue
Block a user