From 057492e59e9f1deb7ca86631c93585060344c607 Mon Sep 17 00:00:00 2001 From: Patrick Sun Date: Sat, 1 May 2021 02:53:57 +1000 Subject: [PATCH] funder connective analyzed --- src/app/app.module.ts | 4 +- src/app/models/pay-in-connective.model.ts | 70 ++++++++++++++++ src/app/models/upload.analysis.model.ts | 7 ++ .../lender-aaa-income.component.html | 1 - .../lender-connective-income.component.html | 30 +++++++ .../lender-connective-income.component.scss | 3 + ...lender-connective-income.component.spec.ts | 25 ++++++ .../lender-connective-income.component.ts | 82 +++++++++++++++++++ src/app/pay-in/pay-in.component.html | 1 + .../upload-detail.component.html | 5 ++ .../upload-detail.component.scss | 4 + 11 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 src/app/models/pay-in-connective.model.ts create mode 100644 src/app/pay-in/lender-connective-income/lender-connective-income.component.html create mode 100644 src/app/pay-in/lender-connective-income/lender-connective-income.component.scss create mode 100644 src/app/pay-in/lender-connective-income/lender-connective-income.component.spec.ts create mode 100644 src/app/pay-in/lender-connective-income/lender-connective-income.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b0b4b08..b5ff0ce 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -102,6 +102,7 @@ import {PopupModule} from '@progress/kendo-angular-popup'; import { LoansAllComponent } from './loans-all/loans-all.component'; import {LenderNameService} from './service/lender-name.service'; import { LenderAaaIncomeComponent } from './pay-in/lender-aaa-income/lender-aaa-income.component'; +import { LenderConnectiveIncomeComponent } from './pay-in/lender-connective-income/lender-connective-income.component'; @@ -172,7 +173,8 @@ export function initializeApp(appConfig: AppConfig): () => Promise { UploadingProgressCardComponent, LoanSelectComponent, LoansAllComponent, - LenderAaaIncomeComponent + LenderAaaIncomeComponent, + LenderConnectiveIncomeComponent, ], imports: [ BrowserModule, diff --git a/src/app/models/pay-in-connective.model.ts b/src/app/models/pay-in-connective.model.ts new file mode 100644 index 0000000..81b0c6a --- /dev/null +++ b/src/app/models/pay-in-connective.model.ts @@ -0,0 +1,70 @@ +import {PayInModel} from './pay-in.model'; + +export class PayInConnectiveModel { + private AgencyName = 'Connective'; + public LoanAccount: string; + public Name: string; + public Settled: Date; + public Lender: string; + public LoanAmount: number; + public Balance: number; + public Associate: string; + public Comm: number; + public Type: string; + public Percent: number; + public Paid: number; + public GST: number; + public Total: number; + + public Period: Date; + + public matchedPayIn?: PayInModel | -1; + + constructor(payload: Partial){ + this.Period = new Date(payload.Period); + this.LoanAccount = payload.LoanAccount || ''; + this.Name = payload.Name || ''; + this.Settled = new Date(payload.Settled); + this.Lender = payload.Lender || ''; + if ( this.Lender.indexOf(this.AgencyName) === -1 ){ + this.Lender += '_' + this.AgencyName; + } + + this.LoanAmount = payload.LoanAmount || 0; + this.Balance = payload.Balance || 0; + this.Associate = payload.Associate || ''; + this.Comm = payload.Comm || 0; + this.Type = payload.Type || ''; + this.Percent = payload.Percent || 0; + this.Paid = payload.Paid || 0; + this.GST = payload.GST || 0; + this.Total = payload.Total || 0; + this.matchedPayIn = payload.matchedPayIn || -1; + } + + public asPayIn(): PayInModel { + if ( this.matchedPayIn !== undefined && this.matchedPayIn !== -1 ) { + return this.matchedPayIn; + } + const pi = new PayInModel({}); + pi.Lender = this.Lender; + pi.LoanNumber = this.LoanAccount; + pi.Amount = this.LoanAmount; + pi.Settlement = this.Settled; + pi.IncomeAmount = this.Comm; + pi.IncomeType = this.Type; + pi.Balance = this.Balance; + pi.OffsetBalance = -1; + pi.Ts = this.Period; + + return pi; + } + + public isMatch(pi: PayInModel): boolean { + return this.LoanAccount === pi.LoanNumber && this.LoanAccount !== '' && + this.Lender === pi.Lender && this.Lender !== '' && + this.Comm === pi.IncomeAmount && + this.Balance === pi.Balance && + this.Type === pi.IncomeType; + } +} diff --git a/src/app/models/upload.analysis.model.ts b/src/app/models/upload.analysis.model.ts index 3a2b8d0..7dcb16e 100644 --- a/src/app/models/upload.analysis.model.ts +++ b/src/app/models/upload.analysis.model.ts @@ -1,6 +1,7 @@ import {UploadMetaModel} from './uploadMetaModel'; import {PayInModel} from './pay-in.model'; import {PayInAAARowModel} from './Pay.In.AAA.Row.model'; +import {PayInConnectiveModel} from './pay-in-connective.model'; @@ -11,6 +12,7 @@ export class UploadAnalysisModel { public PayIn: PayInModel[]; public AAA?: PayInAAARowModel[]; + public Connective?: PayInConnectiveModel[]; public IsDuplicate: boolean; public Uid?: string; // client side unique id when upload @@ -39,6 +41,11 @@ export class UploadAnalysisModel { payload.AAA.forEach( v => { this.AAA.push(new PayInAAARowModel(v)); }); } + this.Connective = []; + if ( payload.Connective ) { + payload.Connective.forEach( v => { this.Connective.push(new PayInConnectiveModel(v)); }); + } + this.IsDuplicate = payload.IsDuplicate || false; this.Uid = payload.Uid || '' ; this.Input = new UploadMetaModel(payload.Input || {}); diff --git a/src/app/pay-in/lender-aaa-income/lender-aaa-income.component.html b/src/app/pay-in/lender-aaa-income/lender-aaa-income.component.html index c26acdf..34a0d7e 100644 --- a/src/app/pay-in/lender-aaa-income/lender-aaa-income.component.html +++ b/src/app/pay-in/lender-aaa-income/lender-aaa-income.component.html @@ -1,4 +1,3 @@ - AAA diff --git a/src/app/pay-in/lender-connective-income/lender-connective-income.component.html b/src/app/pay-in/lender-connective-income/lender-connective-income.component.html new file mode 100644 index 0000000..1891612 --- /dev/null +++ b/src/app/pay-in/lender-connective-income/lender-connective-income.component.html @@ -0,0 +1,30 @@ + + + Connective + + + + + + + + + + + + + + + + + + + + + {{ dataItem.matchedPayIn === -1? 'Not matched': dataItem.matchedPayIn.Id}} + + + diff --git a/src/app/pay-in/lender-connective-income/lender-connective-income.component.scss b/src/app/pay-in/lender-connective-income/lender-connective-income.component.scss new file mode 100644 index 0000000..5b7a4d8 --- /dev/null +++ b/src/app/pay-in/lender-connective-income/lender-connective-income.component.scss @@ -0,0 +1,3 @@ +kendo-grid{ + height: 100%; +} diff --git a/src/app/pay-in/lender-connective-income/lender-connective-income.component.spec.ts b/src/app/pay-in/lender-connective-income/lender-connective-income.component.spec.ts new file mode 100644 index 0000000..acedcff --- /dev/null +++ b/src/app/pay-in/lender-connective-income/lender-connective-income.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LenderConnectiveIncomeComponent } from './lender-connective-income.component'; + +describe('LenderConnectiveIncomeComponent', () => { + let component: LenderConnectiveIncomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LenderConnectiveIncomeComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(LenderConnectiveIncomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pay-in/lender-connective-income/lender-connective-income.component.ts b/src/app/pay-in/lender-connective-income/lender-connective-income.component.ts new file mode 100644 index 0000000..f2f2e85 --- /dev/null +++ b/src/app/pay-in/lender-connective-income/lender-connective-income.component.ts @@ -0,0 +1,82 @@ +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {UploadAnalysisModel} from '../../models/upload.analysis.model'; +import {PayInModel} from '../../models/pay-in.model'; +import {CellCloseEvent} from '@progress/kendo-angular-grid'; +import {PayInConnectiveModel} from '../../models/pay-in-connective.model'; +import {DataResult, GroupDescriptor, process} from '@progress/kendo-data-query'; + +@Component({ + selector: 'app-lender-connective-income', + templateUrl: './lender-connective-income.component.html', + styleUrls: ['./lender-connective-income.component.scss'] +}) +export class LenderConnectiveIncomeComponent implements OnInit { + + private Lender = 'Connective'; + @Input() public analysis = new UploadAnalysisModel({}); + @Input() newPayInUpdate: PayInModel; + @Output() Selected: EventEmitter = new EventEmitter(); + public data: PayInConnectiveModel[] = []; + private payInCandidates: PayInModel[] = []; + + public groups: GroupDescriptor[] = [{ field: 'Lender' }]; + public gridView: DataResult; + constructor() { } + + ngOnInit(): void { + this.analysis.Connective.forEach(v => { + v.matchedPayIn = this.matchPayIn(v); + this.data.push(new PayInConnectiveModel(v)); + }); + this.gridView = process(this.data, { group: this.groups }); + } + + ngOnChanges(changes): void { // Todo: build super class for common features + if (changes.newPayInUpdate){ + const piNew = changes.newPayInUpdate.currentValue as PayInModel; + this.data.forEach(v => { + // remove old matches + if (v.matchedPayIn !== -1 && v.matchedPayIn.Id === piNew.Id){ + v.matchedPayIn = -1; + } + + // add new matches + if ( this.isMatch(v, changes.newPayInUpdate.currentValue) ){ + v.matchedPayIn = changes.newPayInUpdate.currentValue; + } + }); + } + } + + public onCellClick(event: CellCloseEvent): void{ + this.Selected.emit(event.dataItem.asPayIn()); + } + + private matchPayIn(v: PayInConnectiveModel): PayInModel | -1 { + const idx = this.payInCandidates.findIndex( pi => this.isMatch(v, pi) ); + if ( idx === -1 ) { return -1; } + return this.payInCandidates[idx]; + } + + private isMatch( v: PayInConnectiveModel, pi: PayInModel): boolean { + if ( v === null || pi === null ){ + return false; + } + return v.isMatch(pi); + } + + + @Input() set payIn(pis: PayInModel[]) { + this.payInCandidates = []; + pis.forEach( v => this.payInCandidates.push(new PayInModel(v))); + + this.data.forEach( v => { + v.matchedPayIn = this.matchPayIn(v); + }); + + } + + get PayIn(): PayInModel[] { + return this.payInCandidates; + } +} diff --git a/src/app/pay-in/pay-in.component.html b/src/app/pay-in/pay-in.component.html index 29b9083..7966c3a 100644 --- a/src/app/pay-in/pay-in.component.html +++ b/src/app/pay-in/pay-in.component.html @@ -62,6 +62,7 @@ diff --git a/src/app/upload-detail/upload-detail.component.html b/src/app/upload-detail/upload-detail.component.html index 9fdb008..0fc38fb 100644 --- a/src/app/upload-detail/upload-detail.component.html +++ b/src/app/upload-detail/upload-detail.component.html @@ -58,6 +58,11 @@ [newPayInUpdate]="newPayInUpdateSubject | async" (Selected)="onSelected($event)"> + + diff --git a/src/app/upload-detail/upload-detail.component.scss b/src/app/upload-detail/upload-detail.component.scss index 4e2fd49..4409dfa 100644 --- a/src/app/upload-detail/upload-detail.component.scss +++ b/src/app/upload-detail/upload-detail.component.scss @@ -191,4 +191,8 @@ div.analysis-result{ kendo-grid{ height: 100%; } + app-lender-connective-income, + app-lender-aaa-income { + height:100%; + } }