diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b5e4332..37030f9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -105,6 +105,7 @@ import { LenderAaaIncomeComponent } from './pay-in/lender-aaa-income/lender-aaa- import { LenderConnectiveIncomeComponent } from './pay-in/lender-connective-income/lender-connective-income.component'; import { LenderResimacXlsIncomeComponent } from './pay-in/lender-resimac-xls-income/lender-resimac-xls-income.component'; import { LenderResimacPdfIncomeComponent } from './pay-in/lender-resimac-pdf-income/lender-resimac-pdf-income.component'; +import { LenderPepperIncomeComponent } from './pay-in/lender-pepper-income/lender-pepper-income.component'; @@ -179,6 +180,7 @@ export function initializeApp(appConfig: AppConfig): () => Promise { LenderConnectiveIncomeComponent, LenderResimacXlsIncomeComponent, LenderResimacPdfIncomeComponent, + LenderPepperIncomeComponent, ], imports: [ BrowserModule, diff --git a/src/app/list-all-loans/list-all-loans.component.html b/src/app/list-all-loans/list-all-loans.component.html index a2282a1..85263cd 100644 --- a/src/app/list-all-loans/list-all-loans.component.html +++ b/src/app/list-all-loans/list-all-loans.component.html @@ -100,7 +100,8 @@ - + -   Monthly Income +   Income of this Loan - + + + diff --git a/src/app/loan-edit/trail-income/trail-income.component.ts b/src/app/loan-edit/trail-income/trail-income.component.ts index 5b65cfd..8f6fdd5 100644 --- a/src/app/loan-edit/trail-income/trail-income.component.ts +++ b/src/app/loan-edit/trail-income/trail-income.component.ts @@ -9,7 +9,8 @@ import {Router} from '@angular/router'; const createFormGroup = dataItem => new FormGroup({ Id: new FormControl({value: dataItem.Id, disabled: true}, Validators.required), - Trail : new FormControl(dataItem.Trail, Validators.required), + IncomeAmount : new FormControl(dataItem.IncomeAmount, Validators.required), + IncomeType : new FormControl(dataItem.IncomeType, Validators.required), Ts: new FormControl(dataItem.Ts, Validators.required), Balance: new FormControl(dataItem.Balance, Validators.required), OffsetBalance: new FormControl(dataItem.OffsetBalance, Validators.required), @@ -57,7 +58,8 @@ export class TrailIncomeComponent implements OnInit { this.formGroup = createFormGroup({ Id: 0, - Trail: 168, + IncomeAmount: 168, + IncomeType: 'Trail', Ts: new Date(), Balance: balance, OffsetBalance: offsetBalance, @@ -107,7 +109,8 @@ export class TrailIncomeComponent implements OnInit { pi.LoanNumber = this.Loan.LenderLoanNumber; pi.OffsetBalance = v.OffsetBalance; pi.Settlement = this.Loan.Settlement; - pi.IncomeAmount = v.Trail; //TODO: rename Trail to incomeAmount and add IncomeType + pi.IncomeAmount = v.IncomeAmount; + pi.IncomeType = v.IncomeType; pi.Ts = new Date(v.Ts); pi.UploadId = v.UploadId; diff --git a/src/app/main-menu-items.ts b/src/app/main-menu-items.ts index e095272..c5f87af 100644 --- a/src/app/main-menu-items.ts +++ b/src/app/main-menu-items.ts @@ -23,9 +23,6 @@ export const mainMenuItems: any[] = [ { text: 'list income', icon: 'dollar', url: './#list-income' }, { text: '--', separator: 'true' }, { text: 'Uploads', icon: 'dollar', url: './#lender-uploads' }, - { text: '--', separator: 'true' }, - { text: 'Test Uploads by Id', icon: 'dollar', url: './#upload-details/1' }, - { text: 'Test Pay-in', icon: 'dollar', url: './#pay-in' }, ] }, { diff --git a/src/app/models/pay-in-connective.model.ts b/src/app/models/pay-in-connective.model.ts index 0109133..931dcbb 100644 --- a/src/app/models/pay-in-connective.model.ts +++ b/src/app/models/pay-in-connective.model.ts @@ -30,7 +30,7 @@ export class PayInConnectiveModel extends PayInLenderIncomeModel { this.Balance = payload.Balance || 0; this.Associate = payload.Associate || ''; this.Comm = payload.Comm || 0; - this.Type = payload.Type || ''; + this.Type = this.mapIncomeType(payload.Type || ''); this.Percent = payload.Percent || 0; this.Paid = payload.Paid || 0; this.GST = payload.GST || 0; @@ -38,6 +38,18 @@ export class PayInConnectiveModel extends PayInLenderIncomeModel { this.matchedPayIn = payload.matchedPayIn || -1; } + private mapIncomeType( input: string ): string { + const myMap = new Map(); + myMap.set('tc', 'Trail'); + myMap.set('ufc', 'Upfront'); + + if ( myMap.has(input.toLowerCase()) ) { + return myMap.get(input.toLowerCase()); + }else{ + return input; + } + } + private ensureLenderHasAgencyNameAppended(): void { if ( this.Lender.indexOf(this.AgencyName) === -1 ){ this.Lender += '_' + this.AgencyName; diff --git a/src/app/models/pay-in-pepper.model.ts b/src/app/models/pay-in-pepper.model.ts new file mode 100644 index 0000000..eb34433 --- /dev/null +++ b/src/app/models/pay-in-pepper.model.ts @@ -0,0 +1,98 @@ +import {PayInLenderIncomeModel} from '../abstract/pay-in-lender.income.model'; +import {PayInModel} from './pay-in.model'; + +export class PayInPepperModel extends PayInLenderIncomeModel { + public InvoiceDate: Date; + + // Shared Fields for both upfront and Trailer + public LoanNumber: string; + public Customer: string; + public PrimaryIntroducer: string; + public NextGenNumber: string; + public Settlement: Date; + public NetAmount: number; + public GST: number; + public GrossAmount: number; + + + // Trailer Only + public Period: Date; + public Balance: number; + public SettlementAmount: number; + public TrailerMargin: number; + + + // Upfront only + public UpfrontRate: number; + + // Derived + public IncomeType: string; + public IncomeAmount: number; + + constructor(payload: Partial) { + super('Pepper', payload); + if ( payload.InvoiceDate !== undefined && payload.InvoiceDate !== null){ + this.InvoiceDate = new Date(payload.InvoiceDate); + }else{ + this.InvoiceDate = new Date('1800-01-01'); // some invalid date before 1900-01-01 + } + this.LoanNumber = payload.LoanNumber || ''; + this.Customer = payload.Customer || ''; + this.PrimaryIntroducer = payload.PrimaryIntroducer || ''; + this.NextGenNumber = payload.NextGenNumber || ''; + + if ( payload.Settlement !== undefined && payload.Settlement !== null){ + this.Settlement = new Date(payload.Settlement); + }else{ + this.Settlement = new Date('1800-01-01'); // some invalid date before 1900-01-01 + } + + this.NetAmount = payload.NetAmount || 0; + this.GST = payload.GST || 0; + this.GrossAmount = payload.GrossAmount || 0; + + // Trailer only + if ( payload.Period !== undefined && payload.Period !== null){ + this.Period = new Date(payload.Period); + }else{ + this.Period = new Date('1800-01-01'); // some invalid date before 1900-01-01 + } + this.Balance = payload.Balance || 0; + this.SettlementAmount = payload.SettlementAmount || 0; + this.TrailerMargin = payload.TrailerMargin || 0; + + // Upfront only + this.UpfrontRate = payload.UpfrontRate || 0; + + // Derived + this.IncomeType = payload.IncomeType || ''; + this.IncomeAmount = payload.IncomeAmount || 0; + } + + public convertToPayIn(): PayInModel { + const pi = new PayInModel({}); + pi.Lender = 'Pepper'; + pi.LoanNumber = this.LoanNumber; + pi.Amount = this.SettlementAmount; + pi.Settlement = this.Settlement; + pi.IncomeAmount = this.IncomeAmount; + pi.IncomeType = this.IncomeType; + pi.Balance = this.Balance; + pi.OffsetBalance = -1; + if ( this.IncomeType.toLowerCase() === 'upfront' ){ + pi.Ts = this.InvoiceDate; + }else{ + pi.Ts = this.Period; + } + + return pi; + } + + public isMatch(pi: PayInModel): boolean{ + return this.LoanNumber === pi.LoanNumber && this.LoanNumber !== '' && + this.AgencyName === pi.Lender && this.AgencyName !== '' && + this.IncomeAmount === pi.IncomeAmount && + this.Balance === pi.Balance && + this.IncomeType.toLowerCase() === pi.IncomeType.toLowerCase(); + } +} diff --git a/src/app/models/upload.analysis.model.ts b/src/app/models/upload.analysis.model.ts index 1d99d55..e89fe81 100644 --- a/src/app/models/upload.analysis.model.ts +++ b/src/app/models/upload.analysis.model.ts @@ -4,6 +4,7 @@ import {PayInAAARowModel} from './Pay.In.AAA.Row.model'; import {PayInConnectiveModel} from './pay-in-connective.model'; import {PayInResimacXlsModel} from './pay-in-resimac-xls.mode'; import {PayInResimacPdfModel} from './pay-in-resimac-pdf.model'; +import {PayInPepperModel} from './pay-in-pepper.model'; @@ -17,6 +18,7 @@ export class UploadAnalysisModel { public Connective?: PayInConnectiveModel[]; public ResimacXls?: PayInResimacXlsModel[]; public ResimacPdf?: PayInResimacPdfModel[]; + public Pepper?: PayInPepperModel[]; public IsDuplicate: boolean; public Uid?: string; // client side unique id when upload @@ -57,6 +59,10 @@ export class UploadAnalysisModel { if (Array.isArray(payload.ResimacPdf)){ payload.ResimacPdf.forEach( v => { this.ResimacPdf.push(new PayInResimacPdfModel(v)); }); } + this.Pepper = []; + if (Array.isArray(payload.Pepper)){ + payload.Pepper.forEach(v => { this.Pepper.push (new PayInPepperModel(v)); }); + } this.IsDuplicate = payload.IsDuplicate || false; this.Uid = payload.Uid || '' ; 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 index f7153af..91a8fd9 100644 --- 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 @@ -15,7 +15,7 @@ - + diff --git a/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.html b/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.html new file mode 100644 index 0000000..0183864 --- /dev/null +++ b/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.html @@ -0,0 +1,39 @@ + + + {{ AgencyName }} - {{InvoiceDate | date:'longDate'}} + + + + + + + + + + +
+ {{ dataItem.Settlement | date: 'yyyy-MM-dd' }} +
+
+
+ + + + + + + + + + + + + + + + + {{ dataItem.matchedPayIn === -1? 'Not matched': dataItem.matchedPayIn.Id}} + + + +
diff --git a/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.scss b/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.scss new file mode 100644 index 0000000..5b7a4d8 --- /dev/null +++ b/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.scss @@ -0,0 +1,3 @@ +kendo-grid{ + height: 100%; +} diff --git a/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.spec.ts b/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.spec.ts new file mode 100644 index 0000000..3860be8 --- /dev/null +++ b/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LenderPepperIncomeComponent } from './lender-pepper-income.component'; + +describe('LenderPepperIncomeComponent', () => { + let component: LenderPepperIncomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LenderPepperIncomeComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(LenderPepperIncomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.ts b/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.ts new file mode 100644 index 0000000..1ee1178 --- /dev/null +++ b/src/app/pay-in/lender-pepper-income/lender-pepper-income.component.ts @@ -0,0 +1,30 @@ +import {Component, OnChanges, OnInit} from '@angular/core'; + +import {LenderIncomeAbstractDirective} from '../../abstract/lender-income-abstract.directive'; +import {PayInPepperModel} from '../../models/pay-in-pepper.model'; + +@Component({ + selector: 'app-lender-pepper-income', + templateUrl: './lender-pepper-income.component.html', + styleUrls: ['./lender-pepper-income.component.scss'] +}) +export class LenderPepperIncomeComponent extends LenderIncomeAbstractDirective implements OnInit, OnChanges { + InvoiceDate = new Date(); + IncomeType = ''; + Epoc = new Date('1900-01-01'); + constructor() { super('Pepper'); } + + ngOnInit(): void { + this.analysis.Pepper.forEach(v => { + v.matchedPayIn = this.matchPayIn(v); + this.IncomeType = v.IncomeType.toLowerCase(); + this.InvoiceDate = v.InvoiceDate; + console.log(v.InvoiceDate, this.InvoiceDate); + this.data.push(new PayInPepperModel(v)); + }); + } + + ngOnChanges(changes): void { + super.OnChanges(changes); + } +} diff --git a/src/app/upload-detail/upload-detail.component.html b/src/app/upload-detail/upload-detail.component.html index bb5e2f3..51d1ba6 100644 --- a/src/app/upload-detail/upload-detail.component.html +++ b/src/app/upload-detail/upload-detail.component.html @@ -75,6 +75,12 @@ [newPayInUpdate]="newPayInUpdateSubject | async" (Selected)="onSelected($event)"> + +