Fix: Loan product edition with Adv Allocation for Payment and Credit

This commit is contained in:
Jose Alberto Hernandez
2024-02-09 11:31:27 +01:00
committed by Adam Saghy
parent f643b15949
commit d2525445db
8 changed files with 91 additions and 60 deletions
@@ -356,7 +356,7 @@
</span> </span>
</div> </div>
<div fxFlexFill *ngIf="isAdvancedPaymentAllocation"> <div fxFlexFill *ngIf="isAdvancedPaymentAllocation && creditAllocations.length > 0">
<span fxFlex="47%">Advanced Credit Allocation Transactions:</span> <span fxFlex="47%">Advanced Credit Allocation Transactions:</span>
<span fxFlex="53%"> <span fxFlex="53%">
<mat-accordion> <mat-accordion>
@@ -14,7 +14,7 @@ import { LoanProductAccountingStepComponent } from '../loan-product-stepper/loan
import { ProductsService } from 'app/products/products.service'; import { ProductsService } from 'app/products/products.service';
import { GlobalConfiguration } from 'app/system/configurations/global-configurations-tab/configuration.model'; import { GlobalConfiguration } from 'app/system/configurations/global-configurations-tab/configuration.model';
import { LoanProducts } from '../loan-products'; import { LoanProducts } from '../loan-products';
import { AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocation, PaymentAllocation, PaymentAllocationOrder, PaymentAllocationTransactionTypes } from '../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model'; import { AdvancedCreditAllocation, AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocation, PaymentAllocation, PaymentAllocationOrder, PaymentAllocationTransactionTypes } from '../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model';
@Component({ @Component({
selector: 'mifosx-edit-loan-product', selector: 'mifosx-edit-loan-product',
@@ -39,7 +39,7 @@ export class EditLoanProductComponent implements OnInit {
paymentAllocation: PaymentAllocation[] = []; paymentAllocation: PaymentAllocation[] = [];
creditAllocation: CreditAllocation[] = []; creditAllocation: CreditAllocation[] = [];
advancedPaymentAllocations: AdvancedPaymentAllocation[] = []; advancedPaymentAllocations: AdvancedPaymentAllocation[] = [];
advancedCreditAllocations: AdvancedPaymentAllocation[] = []; advancedCreditAllocations: AdvancedCreditAllocation[] = [];
/** /**
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
@@ -97,7 +97,6 @@ export class EditLoanProductComponent implements OnInit {
buildAdvancedPaymentAllocation(): void { buildAdvancedPaymentAllocation(): void {
this.advancedPaymentAllocations = this.advancedPaymentStrategy.buildAdvancedPaymentAllocationList(this.loanProductAndTemplate); this.advancedPaymentAllocations = this.advancedPaymentStrategy.buildAdvancedPaymentAllocationList(this.loanProductAndTemplate);
this.advancedCreditAllocations = this.advancedPaymentStrategy.buildAdvancedCreditAllocationList(this.loanProductAndTemplate); this.advancedCreditAllocations = this.advancedPaymentStrategy.buildAdvancedCreditAllocationList(this.loanProductAndTemplate);
console.log(this.advancedCreditAllocations);
} }
setPaymentAllocation(paymentAllocation: PaymentAllocation[]): void { setPaymentAllocation(paymentAllocation: PaymentAllocation[]): void {
@@ -24,8 +24,8 @@
<td mat-cell *matCellDef="let paymentAllocation; let rowIndex = index"> {{ (rowIndex + 1) }} </td> <td mat-cell *matCellDef="let paymentAllocation; let rowIndex = index"> {{ (rowIndex + 1) }} </td>
</ng-container> </ng-container>
<ng-container matColumnDef="paymentAllocation"> <ng-container matColumnDef="allocationRule">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Payment Allocation' | translate }}</th> <th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Payment Allocation Rule' | translate }}</th>
<td mat-cell *matCellDef="let paymentAllocation"> {{ paymentAllocation.value }} </td> <td mat-cell *matCellDef="let paymentAllocation"> {{ paymentAllocation.value }} </td>
</ng-container> </ng-container>
@@ -34,7 +34,7 @@
</table> </table>
</div> </div>
<div class="mat-elevation-z8 container m-t-15" *ngIf="creditAllocationsData"> <div class="mat-elevation-z8 container m-t-15 m-b-15" *ngIf="creditAllocationsData">
<table mat-table [dataSource]="creditAllocationsData" #table cdkDropList <table mat-table [dataSource]="creditAllocationsData" #table cdkDropList
[cdkDropListData]="creditAllocationsData" (cdkDropListDropped)="dropTable($event, true)"> [cdkDropListData]="creditAllocationsData" (cdkDropListDropped)="dropTable($event, true)">
@@ -50,8 +50,8 @@
<td mat-cell *matCellDef="let creditAllocation; let rowIndex = index"> {{ (rowIndex + 1) }} </td> <td mat-cell *matCellDef="let creditAllocation; let rowIndex = index"> {{ (rowIndex + 1) }} </td>
</ng-container> </ng-container>
<ng-container matColumnDef="paymentAllocation"> <ng-container matColumnDef="allocationRule">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Payment Allocation' | translate }}</th> <th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Credit Allocation Rule' | translate }}</th>
<td mat-cell *matCellDef="let creditAllocation"> {{ creditAllocation.value }} </td> <td mat-cell *matCellDef="let creditAllocation"> {{ creditAllocation.value }} </td>
</ng-container> </ng-container>
@@ -1,5 +1,5 @@
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import { AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocationOrder, FutureInstallmentAllocationRule, PaymentAllocationOrder, PaymentAllocationTransactionType } from '../payment-allocation-model'; import { AdvancedCreditAllocation, AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocationOrder, FutureInstallmentAllocationRule, PaymentAllocationOrder, PaymentAllocationTransactionType } from '../payment-allocation-model';
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { MatTable } from '@angular/material/table'; import { MatTable } from '@angular/material/table';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@@ -14,15 +14,16 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
export class AdvancePaymentAllocationTabComponent implements OnInit { export class AdvancePaymentAllocationTabComponent implements OnInit {
@Input() advancedPaymentAllocation: AdvancedPaymentAllocation; @Input() advancedPaymentAllocation: AdvancedPaymentAllocation;
@Input() advancedCreditAllocation: AdvancedCreditAllocation;
@Output() paymentAllocationChange = new EventEmitter<boolean>(); @Output() allocationChanged = new EventEmitter<boolean>();
@Output() transactionTypeRemoved = new EventEmitter<PaymentAllocationTransactionType>(); @Output() transactionTypeRemoved = new EventEmitter<PaymentAllocationTransactionType>();
paymentAllocationsData: PaymentAllocationOrder[] | null = null; paymentAllocationsData: PaymentAllocationOrder[] | null = null;
creditAllocationsData: CreditAllocationOrder[] | null = null; creditAllocationsData: CreditAllocationOrder[] | null = null;
/** Columns to be displayed in the table. */ /** Columns to be displayed in the table. */
displayedColumns: string[] = ['actions', 'order', 'paymentAllocation']; displayedColumns: string[] = ['actions', 'order', 'allocationRule'];
futureInstallmentAllocationRule = new UntypedFormControl('', Validators.required); futureInstallmentAllocationRule = new UntypedFormControl('', Validators.required);
@@ -32,14 +33,13 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
private advancedPaymentStrategy: AdvancedPaymentStrategy) { } private advancedPaymentStrategy: AdvancedPaymentStrategy) { }
ngOnInit(): void { ngOnInit(): void {
console.log(this.advancedPaymentAllocation); if (this.advancedCreditAllocation) {
this.creditAllocationsData = this.advancedCreditAllocation?.creditAllocationOrder;
}
if (this.advancedPaymentAllocation) { if (this.advancedPaymentAllocation) {
if (this.advancedPaymentAllocation.creditAllocationOrder) { this.paymentAllocationsData = this.advancedPaymentAllocation?.paymentAllocationOrder;
this.creditAllocationsData = this.advancedPaymentAllocation.creditAllocationOrder;
}
if (this.advancedPaymentAllocation.paymentAllocationOrder) {
this.paymentAllocationsData = this.advancedPaymentAllocation.paymentAllocationOrder;
}
if (this.advancedPaymentAllocation.futureInstallmentAllocationRule) { if (this.advancedPaymentAllocation.futureInstallmentAllocationRule) {
this.futureInstallmentAllocationRule.patchValue(this.advancedPaymentAllocation.futureInstallmentAllocationRule.code); this.futureInstallmentAllocationRule.patchValue(this.advancedPaymentAllocation.futureInstallmentAllocationRule.code);
} }
@@ -47,7 +47,7 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
this.advancedPaymentAllocation.futureInstallmentAllocationRules.forEach((item: FutureInstallmentAllocationRule) => { this.advancedPaymentAllocation.futureInstallmentAllocationRules.forEach((item: FutureInstallmentAllocationRule) => {
if (value === item.code) { if (value === item.code) {
this.advancedPaymentAllocation.futureInstallmentAllocationRule = item; this.advancedPaymentAllocation.futureInstallmentAllocationRule = item;
this.paymentAllocationChange.emit(true); this.allocationChanged.emit(true);
} }
}); });
}); });
@@ -61,14 +61,14 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
this.paymentAllocationsData = [...this.paymentAllocationsData]; this.paymentAllocationsData = [...this.paymentAllocationsData];
this.advancedPaymentAllocation.paymentAllocationOrder = this.paymentAllocationsData; this.advancedPaymentAllocation.paymentAllocationOrder = this.paymentAllocationsData;
this.table.renderRows(); this.table.renderRows();
this.paymentAllocationChange.emit(true); this.allocationChanged.emit(true);
} else { } else {
const prevIndex = this.creditAllocationsData.findIndex((d: any) => d === event.item.data); const prevIndex = this.creditAllocationsData.findIndex((d: any) => d === event.item.data);
moveItemInArray(this.creditAllocationsData, prevIndex, event.currentIndex); moveItemInArray(this.creditAllocationsData, prevIndex, event.currentIndex);
this.creditAllocationsData = [...this.creditAllocationsData]; this.creditAllocationsData = [...this.creditAllocationsData];
this.advancedPaymentAllocation.creditAllocationOrder = this.creditAllocationsData; this.advancedCreditAllocation.creditAllocationOrder = this.creditAllocationsData;
this.table.renderRows(); this.table.renderRows();
this.paymentAllocationChange.emit(true); this.allocationChanged.emit(true);
} }
} }
@@ -80,12 +80,19 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
} }
removeTransaction(): void { removeTransaction(): void {
let transaction: PaymentAllocationTransactionType = null;
if (this.advancedPaymentAllocation && this.advancedPaymentAllocation.transaction) {
transaction = this.advancedPaymentAllocation.transaction;
} else if (this.advancedCreditAllocation && this.advancedCreditAllocation.transaction) {
transaction = this.advancedCreditAllocation.transaction;
transaction.credit = true;
}
const dialogRef = this.dialog.open(DeleteDialogComponent, { const dialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: ` the Transaction Type ${this.advancedPaymentAllocation.transaction.value}` } data: { deleteContext: ` the Transaction Type ${transaction.value}` }
}); });
dialogRef.afterClosed().subscribe((response: any) => { dialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) { if (response.delete) {
this.transactionTypeRemoved.emit(this.advancedPaymentAllocation.transaction); this.transactionTypeRemoved.emit(transaction);
} }
}); });
} }
@@ -1,12 +1,22 @@
<mat-tab-group animationDuration="0ms" fxLayout="row wrap" fxLayoutGap="2%" <mat-tab-group animationDuration="0ms" fxLayout="row wrap" fxLayoutGap="2%"
fxLayout.lt-md="column"> fxLayout.lt-md="column">
<mat-tab *ngFor="let advancedPaymentAllocation of advancedAllocations"> <mat-tab *ngFor="let advancedPaymentAllocation of advancedPaymentAllocations">
<ng-template mat-tab-label> <ng-template mat-tab-label>
{{advancedPaymentAllocation.transaction.code}} {{advancedPaymentAllocation.transaction.code}}
</ng-template> </ng-template>
<mifosx-advance-payment-allocation-tab [advancedPaymentAllocation]="advancedPaymentAllocation" <mifosx-advance-payment-allocation-tab [advancedPaymentAllocation]="advancedPaymentAllocation"
(paymentAllocationChange)="paymentAllocationChanged($event)" (allocationChange)="allocationChanged($event)"
(transactionTypeRemoved)="transactionTypeRemoved($event)">
</mifosx-advance-payment-allocation-tab>
</mat-tab>
<mat-tab *ngFor="let advancedCreditAllocation of advancedCreditAllocations">
<ng-template mat-tab-label>
{{advancedCreditAllocation.transaction.code}}
</ng-template>
<mifosx-advance-payment-allocation-tab [advancedCreditAllocation]="advancedCreditAllocation"
(allocationChange)="allocationChanged($event)"
(transactionTypeRemoved)="transactionTypeRemoved($event)"> (transactionTypeRemoved)="transactionTypeRemoved($event)">
</mifosx-advance-payment-allocation-tab> </mifosx-advance-payment-allocation-tab>
</mat-tab> </mat-tab>
@@ -1,5 +1,5 @@
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import { AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocation, PaymentAllocation, PaymentAllocationOrder, PaymentAllocationTransactionType } from './payment-allocation-model'; import { AdvancedCreditAllocation, AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocation, CreditAllocationOrder, PaymentAllocation, PaymentAllocationOrder, PaymentAllocationTransactionType } from './payment-allocation-model';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base'; import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base'; import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
@@ -14,13 +14,12 @@ import { TranslateService } from '@ngx-translate/core';
}) })
export class LoanProductPaymentStrategyStepComponent implements OnInit { export class LoanProductPaymentStrategyStepComponent implements OnInit {
advancedAllocations: AdvancedPaymentAllocation[] = [];
@Input() advancedPaymentAllocations: AdvancedPaymentAllocation[] = []; @Input() advancedPaymentAllocations: AdvancedPaymentAllocation[] = [];
@Input() advancedCreditAllocations: AdvancedPaymentAllocation[] = []; @Input() advancedCreditAllocations: AdvancedCreditAllocation[] = [];
@Input() advancedPaymentAllocationTransactionTypes: PaymentAllocationTransactionType[] = []; @Input() advancedPaymentAllocationTransactionTypes: PaymentAllocationTransactionType[] = [];
@Input() paymentAllocationOrderDefault: PaymentAllocationOrder[]; @Input() paymentAllocationOrderDefault: PaymentAllocationOrder[];
@Input() advancedCreditAllocationTransactionTypes: PaymentAllocationTransactionType[] = []; @Input() advancedCreditAllocationTransactionTypes: PaymentAllocationTransactionType[] = [];
@Input() creditAllocationOrderDefault: PaymentAllocationOrder[]; @Input() creditAllocationOrderDefault: CreditAllocationOrder[];
@Output() paymentAllocationChange = new EventEmitter<boolean>(); @Output() paymentAllocationChange = new EventEmitter<boolean>();
@Output() setPaymentAllocation = new EventEmitter<PaymentAllocation[]>(); @Output() setPaymentAllocation = new EventEmitter<PaymentAllocation[]>();
@@ -33,18 +32,15 @@ export class LoanProductPaymentStrategyStepComponent implements OnInit {
private translateService: TranslateService) { } private translateService: TranslateService) { }
ngOnInit(): void { ngOnInit(): void {
this.advancedAllocations = this.advancedPaymentAllocations.concat(this.advancedCreditAllocations);
this.sendAllocations(); this.sendAllocations();
} }
sendAllocations(): void { sendAllocations(): void {
this.setPaymentAllocation.emit(this.advancedPaymentStrategy.buildPaymentAllocations(this.advancedPaymentAllocations)); this.setPaymentAllocation.emit(this.advancedPaymentStrategy.buildPaymentAllocations(this.advancedPaymentAllocations));
if (this.advancedCreditAllocations?.length > 0) { this.setCreditAllocation.emit(this.advancedPaymentStrategy.buildCreditAllocations(this.advancedCreditAllocations));
this.setCreditAllocation.emit(this.advancedPaymentStrategy.buildCreditAllocations(this.advancedCreditAllocations));
}
} }
paymentAllocationChanged(changed: boolean): void { allocationChanged(changed: boolean): void {
this.paymentAllocationChange.emit(changed); this.paymentAllocationChange.emit(changed);
this.sendAllocations(); this.sendAllocations();
} }
@@ -105,8 +101,6 @@ export class LoanProductPaymentStrategyStepComponent implements OnInit {
); );
} }
this.paymentAllocationChange.emit(true); this.paymentAllocationChange.emit(true);
this.advancedAllocations = this.advancedPaymentAllocations.concat(this.advancedCreditAllocations);
this.tabGroup.selectedIndex = (this.advancedAllocations.length - 1);
this.sendAllocations(); this.sendAllocations();
} }
}); });
@@ -48,9 +48,13 @@ export class PaymentAllocationTransactionTypes {
export class AdvancedPaymentAllocation { export class AdvancedPaymentAllocation {
transaction: PaymentAllocationTransactionType; transaction: PaymentAllocationTransactionType;
paymentAllocationOrder?: PaymentAllocationOrder[]; paymentAllocationOrder: PaymentAllocationOrder[];
futureInstallmentAllocationRule?: FutureInstallmentAllocationRule; futureInstallmentAllocationRule: FutureInstallmentAllocationRule;
futureInstallmentAllocationRules?: FutureInstallmentAllocationRule[]; futureInstallmentAllocationRules: FutureInstallmentAllocationRule[];
}
export class AdvancedCreditAllocation {
transaction: PaymentAllocationTransactionType;
creditAllocationOrder?: CreditAllocationOrder[]; creditAllocationOrder?: CreditAllocationOrder[];
} }
@@ -65,21 +69,21 @@ export class AdvancePaymentAllocationData {
}) })
export class AdvancedPaymentStrategy { export class AdvancedPaymentStrategy {
public buildAdvancedCreditAllocationList(loanProduct: any): AdvancedPaymentAllocation[] { public buildAdvancedCreditAllocationList(loanProduct: any): AdvancedCreditAllocation[] {
const advancedPaymentAllocation: AdvancedPaymentAllocation[] = []; const advancedCreditAllocation: AdvancedCreditAllocation[] = [];
const advancedCreditAllocationTransactionTypes: PaymentAllocationTransactionType[] = const advancedCreditAllocationTransactionTypes: PaymentAllocationTransactionType[] =
loanProduct.creditAllocationTransactionTypes; loanProduct.creditAllocationTransactionTypes;
const advancedPaymentAllocationTypes: CreditAllocationOrder[] = loanProduct.creditAllocationAllocationTypes; const advancedPaymentAllocationTypes: CreditAllocationOrder[] = loanProduct.creditAllocationAllocationTypes;
if (loanProduct.creditAllocation) { if (loanProduct.creditAllocation) {
loanProduct.creditAllocation.forEach((item: CreditAllocation) => { loanProduct.creditAllocation.forEach((item: CreditAllocation) => {
advancedPaymentAllocation.push({ advancedCreditAllocation.push({
transaction: this.getItemByCode(item.transactionType, advancedCreditAllocationTransactionTypes), transaction: this.getItemByCode(item.transactionType, advancedCreditAllocationTransactionTypes),
creditAllocationOrder: this.buildCurrentCreditAllocationOrder(item.creditAllocationOrder, creditAllocationOrder: this.buildCurrentCreditAllocationOrder(item.creditAllocationOrder,
advancedPaymentAllocationTypes), advancedPaymentAllocationTypes),
}); });
}); });
} }
return advancedPaymentAllocation; return advancedCreditAllocation;
} }
public buildAdvancedPaymentAllocationList(loanProduct: any): AdvancedPaymentAllocation[] { public buildAdvancedPaymentAllocationList(loanProduct: any): AdvancedPaymentAllocation[] {
@@ -125,10 +129,10 @@ export class AdvancedPaymentStrategy {
} }
public buildAdvancedCreditAllocation(transaction: PaymentAllocationTransactionType, public buildAdvancedCreditAllocation(transaction: PaymentAllocationTransactionType,
currentItems: PaymentAllocationOrder[]): AdvancedPaymentAllocation { currentItems: CreditAllocationOrder[]): AdvancedCreditAllocation {
return { return {
transaction: transaction, transaction: transaction,
paymentAllocationOrder: this.buildPaymentAllocationTransactionOrder(true, currentItems, currentItems) creditAllocationOrder: this.buildCreditAllocationTransactionOrder(true, currentItems, currentItems)
}; };
} }
@@ -148,22 +152,40 @@ export class AdvancedPaymentStrategy {
return paymentAllocationOrder; return paymentAllocationOrder;
} }
public buildCreditAllocationTransactionOrder(forDefault: boolean, currentItems: CreditAllocationOrder[], defaultItems: CreditAllocationOrder[]): CreditAllocationOrder[] {
const paymentAllocationOrder: CreditAllocationOrder[] = [];
if (forDefault) {
return defaultItems;
} else {
currentItems.forEach((currentItem: CreditAllocationOrder) => {
defaultItems.forEach((item: CreditAllocationOrder) => {
if (currentItem.id === item.id) {
paymentAllocationOrder.push(item);
}
});
});
}
return paymentAllocationOrder;
}
public buildPaymentAllocations(advancedPaymentAllocations: AdvancedPaymentAllocation[]): PaymentAllocation[] { public buildPaymentAllocations(advancedPaymentAllocations: AdvancedPaymentAllocation[]): PaymentAllocation[] {
const paymentAllocations: PaymentAllocation[] = []; const paymentAllocations: PaymentAllocation[] = [];
advancedPaymentAllocations.forEach((paymentAllocation: AdvancedPaymentAllocation) => { advancedPaymentAllocations.forEach((paymentAllocation: AdvancedPaymentAllocation) => {
paymentAllocations.push({ if (paymentAllocation.paymentAllocationOrder) {
transactionType: paymentAllocation.transaction.code, paymentAllocations.push({
paymentAllocationOrder: this.buildPaymentAllocationOrder(paymentAllocation.paymentAllocationOrder), transactionType: paymentAllocation.transaction.code,
futureInstallmentAllocationRule: paymentAllocation.futureInstallmentAllocationRule.code paymentAllocationOrder: this.buildPaymentAllocationOrder(paymentAllocation.paymentAllocationOrder),
}); futureInstallmentAllocationRule: paymentAllocation.futureInstallmentAllocationRule.code
});
}
}); });
return paymentAllocations; return paymentAllocations;
} }
public buildCreditAllocations(advancedCreditAllocations: AdvancedPaymentAllocation[]): CreditAllocation[] { public buildCreditAllocations(advancedCreditAllocations: AdvancedCreditAllocation[]): CreditAllocation[] {
const creditAllocations: CreditAllocation[] = []; const creditAllocations: CreditAllocation[] = [];
advancedCreditAllocations.forEach((creditAllocation: AdvancedPaymentAllocation) => { advancedCreditAllocations.forEach((creditAllocation: AdvancedCreditAllocation) => {
creditAllocations.push({ creditAllocations.push({
transactionType: creditAllocation.transaction.code, transactionType: creditAllocation.transaction.code,
creditAllocationOrder: this.buildCreditAllocationOrder(creditAllocation.creditAllocationOrder) creditAllocationOrder: this.buildCreditAllocationOrder(creditAllocation.creditAllocationOrder)
@@ -173,7 +195,7 @@ export class AdvancedPaymentStrategy {
return creditAllocations; return creditAllocations;
} }
public buildPaymentAllocationOrder(paymentAllocationOrder: PaymentAllocationOrder[]): PaymentAllocationOrder[] { private buildPaymentAllocationOrder(paymentAllocationOrder: PaymentAllocationOrder[]): PaymentAllocationOrder[] {
const paymentAllocations: any[] = []; const paymentAllocations: any[] = [];
paymentAllocationOrder.forEach((item: any, index: number) => { paymentAllocationOrder.forEach((item: any, index: number) => {
paymentAllocations.push({ paymentAllocations.push({
@@ -185,7 +207,7 @@ export class AdvancedPaymentStrategy {
return paymentAllocations; return paymentAllocations;
} }
public buildCreditAllocationOrder(creditAllocationOrder: CreditAllocationOrder[]): CreditAllocationOrder[] { private buildCreditAllocationOrder(creditAllocationOrder: CreditAllocationOrder[]): CreditAllocationOrder[] {
const creditAllocations: CreditAllocationOrder[] = []; const creditAllocations: CreditAllocationOrder[] = [];
creditAllocationOrder.forEach((item: any, index: number) => { creditAllocationOrder.forEach((item: any, index: number) => {
creditAllocations.push({ creditAllocations.push({
@@ -197,7 +219,7 @@ export class AdvancedPaymentStrategy {
return creditAllocations; return creditAllocations;
} }
public buildCurrentPaymentAllocationOrder(currentItems: any[], defaultItems: PaymentAllocationOrder[]): private buildCurrentPaymentAllocationOrder(currentItems: any[], defaultItems: PaymentAllocationOrder[]):
PaymentAllocationOrder[] { PaymentAllocationOrder[] {
const paymentAllocationOrder: PaymentAllocationOrder[] = []; const paymentAllocationOrder: PaymentAllocationOrder[] = [];
currentItems.forEach((item: any) => { currentItems.forEach((item: any) => {
@@ -206,7 +228,7 @@ export class AdvancedPaymentStrategy {
return paymentAllocationOrder; return paymentAllocationOrder;
} }
public buildCurrentCreditAllocationOrder(currentItems: any[], defaultItems: CreditAllocationOrder[]): private buildCurrentCreditAllocationOrder(currentItems: any[], defaultItems: CreditAllocationOrder[]):
CreditAllocationOrder[] { CreditAllocationOrder[] {
const creditAllocationOrder: CreditAllocationOrder[] = []; const creditAllocationOrder: CreditAllocationOrder[] = [];
currentItems.forEach((item: any) => { currentItems.forEach((item: any) => {
@@ -215,7 +237,7 @@ export class AdvancedPaymentStrategy {
return creditAllocationOrder; return creditAllocationOrder;
} }
public getItemByCode(code: string, private getItemByCode(code: string,
options: any[]): any { options: any[]): any {
let transaction: any; let transaction: any;
options.forEach((option: any) => { options.forEach((option: any) => {
@@ -32,7 +32,6 @@ export class SearchPageComponent {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router) { private router: Router) {
this.route.data.subscribe(( data: { searchResults: any }) => { this.route.data.subscribe(( data: { searchResults: any }) => {
console.log(data.searchResults);
this.dataSource = new MatTableDataSource(data.searchResults); this.dataSource = new MatTableDataSource(data.searchResults);
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
this.hasResults = (data.searchResults.length > 0); this.hasResults = (data.searchResults.length > 0);