diff --git a/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.html b/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.html
index 455b49554c..dc425cc80e 100644
--- a/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.html
+++ b/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.html
@@ -356,7 +356,7 @@
+
0">
Advanced Credit Allocation Transactions:
diff --git a/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts b/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts
index f7889656c3..a612948638 100644
--- a/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts
+++ b/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts
@@ -14,7 +14,7 @@ import { LoanProductAccountingStepComponent } from '../loan-product-stepper/loan
import { ProductsService } from 'app/products/products.service';
import { GlobalConfiguration } from 'app/system/configurations/global-configurations-tab/configuration.model';
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({
selector: 'mifosx-edit-loan-product',
@@ -39,7 +39,7 @@ export class EditLoanProductComponent implements OnInit {
paymentAllocation: PaymentAllocation[] = [];
creditAllocation: CreditAllocation[] = [];
advancedPaymentAllocations: AdvancedPaymentAllocation[] = [];
- advancedCreditAllocations: AdvancedPaymentAllocation[] = [];
+ advancedCreditAllocations: AdvancedCreditAllocation[] = [];
/**
* @param {ActivatedRoute} route Activated Route.
@@ -97,7 +97,6 @@ export class EditLoanProductComponent implements OnInit {
buildAdvancedPaymentAllocation(): void {
this.advancedPaymentAllocations = this.advancedPaymentStrategy.buildAdvancedPaymentAllocationList(this.loanProductAndTemplate);
this.advancedCreditAllocations = this.advancedPaymentStrategy.buildAdvancedCreditAllocationList(this.loanProductAndTemplate);
- console.log(this.advancedCreditAllocations);
}
setPaymentAllocation(paymentAllocation: PaymentAllocation[]): void {
diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.html
index 489414f672..6b2bef9cb1 100644
--- a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.html
+++ b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.html
@@ -24,8 +24,8 @@ You can drag and drop the rows to set a Pa
{{ (rowIndex + 1) }} |
-
- {{ 'labels.inputs.Payment Allocation' | translate }} |
+
+ {{ 'labels.inputs.Payment Allocation Rule' | translate }} |
{{ paymentAllocation.value }} |
@@ -34,7 +34,7 @@ You can drag and drop the rows to set a Pa
-
+
@@ -50,8 +50,8 @@ You can drag and drop the rows to set a Pa
{{ (rowIndex + 1) }} |
-
- {{ 'labels.inputs.Payment Allocation' | translate }} |
+
+ {{ 'labels.inputs.Credit Allocation Rule' | translate }} |
{{ creditAllocation.value }} |
diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.ts
index 6da2b901c3..fd3b1a8d12 100644
--- a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.ts
+++ b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.ts
@@ -1,5 +1,5 @@
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 { MatTable } from '@angular/material/table';
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 {
@Input() advancedPaymentAllocation: AdvancedPaymentAllocation;
+ @Input() advancedCreditAllocation: AdvancedCreditAllocation;
- @Output() paymentAllocationChange = new EventEmitter();
+ @Output() allocationChanged = new EventEmitter();
@Output() transactionTypeRemoved = new EventEmitter();
paymentAllocationsData: PaymentAllocationOrder[] | null = null;
creditAllocationsData: CreditAllocationOrder[] | null = null;
/** Columns to be displayed in the table. */
- displayedColumns: string[] = ['actions', 'order', 'paymentAllocation'];
+ displayedColumns: string[] = ['actions', 'order', 'allocationRule'];
futureInstallmentAllocationRule = new UntypedFormControl('', Validators.required);
@@ -32,14 +33,13 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
private advancedPaymentStrategy: AdvancedPaymentStrategy) { }
ngOnInit(): void {
- console.log(this.advancedPaymentAllocation);
+ if (this.advancedCreditAllocation) {
+ this.creditAllocationsData = this.advancedCreditAllocation?.creditAllocationOrder;
+ }
+
if (this.advancedPaymentAllocation) {
- if (this.advancedPaymentAllocation.creditAllocationOrder) {
- this.creditAllocationsData = this.advancedPaymentAllocation.creditAllocationOrder;
- }
- if (this.advancedPaymentAllocation.paymentAllocationOrder) {
- this.paymentAllocationsData = this.advancedPaymentAllocation.paymentAllocationOrder;
- }
+ this.paymentAllocationsData = this.advancedPaymentAllocation?.paymentAllocationOrder;
+
if (this.advancedPaymentAllocation.futureInstallmentAllocationRule) {
this.futureInstallmentAllocationRule.patchValue(this.advancedPaymentAllocation.futureInstallmentAllocationRule.code);
}
@@ -47,7 +47,7 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
this.advancedPaymentAllocation.futureInstallmentAllocationRules.forEach((item: FutureInstallmentAllocationRule) => {
if (value === item.code) {
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.advancedPaymentAllocation.paymentAllocationOrder = this.paymentAllocationsData;
this.table.renderRows();
- this.paymentAllocationChange.emit(true);
+ this.allocationChanged.emit(true);
} else {
const prevIndex = this.creditAllocationsData.findIndex((d: any) => d === event.item.data);
moveItemInArray(this.creditAllocationsData, prevIndex, event.currentIndex);
this.creditAllocationsData = [...this.creditAllocationsData];
- this.advancedPaymentAllocation.creditAllocationOrder = this.creditAllocationsData;
+ this.advancedCreditAllocation.creditAllocationOrder = this.creditAllocationsData;
this.table.renderRows();
- this.paymentAllocationChange.emit(true);
+ this.allocationChanged.emit(true);
}
}
@@ -80,12 +80,19 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
}
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, {
- data: { deleteContext: ` the Transaction Type ${this.advancedPaymentAllocation.transaction.value}` }
+ data: { deleteContext: ` the Transaction Type ${transaction.value}` }
});
dialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
- this.transactionTypeRemoved.emit(this.advancedPaymentAllocation.transaction);
+ this.transactionTypeRemoved.emit(transaction);
}
});
}
diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.html
index 56f300dc27..25466cfda2 100644
--- a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.html
+++ b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.html
@@ -1,12 +1,22 @@
-
+
{{advancedPaymentAllocation.transaction.code}}
+
+
+
+
+
+ {{advancedCreditAllocation.transaction.code}}
+
+
diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts
index ff205a149c..8a7717b006 100644
--- a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts
+++ b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts
@@ -1,5 +1,5 @@
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 { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-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 {
- advancedAllocations: AdvancedPaymentAllocation[] = [];
@Input() advancedPaymentAllocations: AdvancedPaymentAllocation[] = [];
- @Input() advancedCreditAllocations: AdvancedPaymentAllocation[] = [];
+ @Input() advancedCreditAllocations: AdvancedCreditAllocation[] = [];
@Input() advancedPaymentAllocationTransactionTypes: PaymentAllocationTransactionType[] = [];
@Input() paymentAllocationOrderDefault: PaymentAllocationOrder[];
@Input() advancedCreditAllocationTransactionTypes: PaymentAllocationTransactionType[] = [];
- @Input() creditAllocationOrderDefault: PaymentAllocationOrder[];
+ @Input() creditAllocationOrderDefault: CreditAllocationOrder[];
@Output() paymentAllocationChange = new EventEmitter();
@Output() setPaymentAllocation = new EventEmitter();
@@ -33,18 +32,15 @@ export class LoanProductPaymentStrategyStepComponent implements OnInit {
private translateService: TranslateService) { }
ngOnInit(): void {
- this.advancedAllocations = this.advancedPaymentAllocations.concat(this.advancedCreditAllocations);
this.sendAllocations();
}
sendAllocations(): void {
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.sendAllocations();
}
@@ -105,8 +101,6 @@ export class LoanProductPaymentStrategyStepComponent implements OnInit {
);
}
this.paymentAllocationChange.emit(true);
- this.advancedAllocations = this.advancedPaymentAllocations.concat(this.advancedCreditAllocations);
- this.tabGroup.selectedIndex = (this.advancedAllocations.length - 1);
this.sendAllocations();
}
});
diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model.ts
index aa3249525d..82c34acc6f 100644
--- a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model.ts
+++ b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model.ts
@@ -48,9 +48,13 @@ export class PaymentAllocationTransactionTypes {
export class AdvancedPaymentAllocation {
transaction: PaymentAllocationTransactionType;
- paymentAllocationOrder?: PaymentAllocationOrder[];
- futureInstallmentAllocationRule?: FutureInstallmentAllocationRule;
- futureInstallmentAllocationRules?: FutureInstallmentAllocationRule[];
+ paymentAllocationOrder: PaymentAllocationOrder[];
+ futureInstallmentAllocationRule: FutureInstallmentAllocationRule;
+ futureInstallmentAllocationRules: FutureInstallmentAllocationRule[];
+}
+
+export class AdvancedCreditAllocation {
+ transaction: PaymentAllocationTransactionType;
creditAllocationOrder?: CreditAllocationOrder[];
}
@@ -65,21 +69,21 @@ export class AdvancePaymentAllocationData {
})
export class AdvancedPaymentStrategy {
- public buildAdvancedCreditAllocationList(loanProduct: any): AdvancedPaymentAllocation[] {
- const advancedPaymentAllocation: AdvancedPaymentAllocation[] = [];
+ public buildAdvancedCreditAllocationList(loanProduct: any): AdvancedCreditAllocation[] {
+ const advancedCreditAllocation: AdvancedCreditAllocation[] = [];
const advancedCreditAllocationTransactionTypes: PaymentAllocationTransactionType[] =
loanProduct.creditAllocationTransactionTypes;
const advancedPaymentAllocationTypes: CreditAllocationOrder[] = loanProduct.creditAllocationAllocationTypes;
if (loanProduct.creditAllocation) {
loanProduct.creditAllocation.forEach((item: CreditAllocation) => {
- advancedPaymentAllocation.push({
+ advancedCreditAllocation.push({
transaction: this.getItemByCode(item.transactionType, advancedCreditAllocationTransactionTypes),
creditAllocationOrder: this.buildCurrentCreditAllocationOrder(item.creditAllocationOrder,
advancedPaymentAllocationTypes),
});
});
}
- return advancedPaymentAllocation;
+ return advancedCreditAllocation;
}
public buildAdvancedPaymentAllocationList(loanProduct: any): AdvancedPaymentAllocation[] {
@@ -125,10 +129,10 @@ export class AdvancedPaymentStrategy {
}
public buildAdvancedCreditAllocation(transaction: PaymentAllocationTransactionType,
- currentItems: PaymentAllocationOrder[]): AdvancedPaymentAllocation {
+ currentItems: CreditAllocationOrder[]): AdvancedCreditAllocation {
return {
transaction: transaction,
- paymentAllocationOrder: this.buildPaymentAllocationTransactionOrder(true, currentItems, currentItems)
+ creditAllocationOrder: this.buildCreditAllocationTransactionOrder(true, currentItems, currentItems)
};
}
@@ -148,22 +152,40 @@ export class AdvancedPaymentStrategy {
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[] {
const paymentAllocations: PaymentAllocation[] = [];
advancedPaymentAllocations.forEach((paymentAllocation: AdvancedPaymentAllocation) => {
- paymentAllocations.push({
- transactionType: paymentAllocation.transaction.code,
- paymentAllocationOrder: this.buildPaymentAllocationOrder(paymentAllocation.paymentAllocationOrder),
- futureInstallmentAllocationRule: paymentAllocation.futureInstallmentAllocationRule.code
- });
+ if (paymentAllocation.paymentAllocationOrder) {
+ paymentAllocations.push({
+ transactionType: paymentAllocation.transaction.code,
+ paymentAllocationOrder: this.buildPaymentAllocationOrder(paymentAllocation.paymentAllocationOrder),
+ futureInstallmentAllocationRule: paymentAllocation.futureInstallmentAllocationRule.code
+ });
+ }
});
return paymentAllocations;
}
- public buildCreditAllocations(advancedCreditAllocations: AdvancedPaymentAllocation[]): CreditAllocation[] {
+ public buildCreditAllocations(advancedCreditAllocations: AdvancedCreditAllocation[]): CreditAllocation[] {
const creditAllocations: CreditAllocation[] = [];
- advancedCreditAllocations.forEach((creditAllocation: AdvancedPaymentAllocation) => {
+ advancedCreditAllocations.forEach((creditAllocation: AdvancedCreditAllocation) => {
creditAllocations.push({
transactionType: creditAllocation.transaction.code,
creditAllocationOrder: this.buildCreditAllocationOrder(creditAllocation.creditAllocationOrder)
@@ -173,7 +195,7 @@ export class AdvancedPaymentStrategy {
return creditAllocations;
}
- public buildPaymentAllocationOrder(paymentAllocationOrder: PaymentAllocationOrder[]): PaymentAllocationOrder[] {
+ private buildPaymentAllocationOrder(paymentAllocationOrder: PaymentAllocationOrder[]): PaymentAllocationOrder[] {
const paymentAllocations: any[] = [];
paymentAllocationOrder.forEach((item: any, index: number) => {
paymentAllocations.push({
@@ -185,7 +207,7 @@ export class AdvancedPaymentStrategy {
return paymentAllocations;
}
- public buildCreditAllocationOrder(creditAllocationOrder: CreditAllocationOrder[]): CreditAllocationOrder[] {
+ private buildCreditAllocationOrder(creditAllocationOrder: CreditAllocationOrder[]): CreditAllocationOrder[] {
const creditAllocations: CreditAllocationOrder[] = [];
creditAllocationOrder.forEach((item: any, index: number) => {
creditAllocations.push({
@@ -197,7 +219,7 @@ export class AdvancedPaymentStrategy {
return creditAllocations;
}
- public buildCurrentPaymentAllocationOrder(currentItems: any[], defaultItems: PaymentAllocationOrder[]):
+ private buildCurrentPaymentAllocationOrder(currentItems: any[], defaultItems: PaymentAllocationOrder[]):
PaymentAllocationOrder[] {
const paymentAllocationOrder: PaymentAllocationOrder[] = [];
currentItems.forEach((item: any) => {
@@ -206,7 +228,7 @@ export class AdvancedPaymentStrategy {
return paymentAllocationOrder;
}
- public buildCurrentCreditAllocationOrder(currentItems: any[], defaultItems: CreditAllocationOrder[]):
+ private buildCurrentCreditAllocationOrder(currentItems: any[], defaultItems: CreditAllocationOrder[]):
CreditAllocationOrder[] {
const creditAllocationOrder: CreditAllocationOrder[] = [];
currentItems.forEach((item: any) => {
@@ -215,7 +237,7 @@ export class AdvancedPaymentStrategy {
return creditAllocationOrder;
}
- public getItemByCode(code: string,
+ private getItemByCode(code: string,
options: any[]): any {
let transaction: any;
options.forEach((option: any) => {
diff --git a/src/app/search/search-page/search-page.component.ts b/src/app/search/search-page/search-page.component.ts
index 33254c7f58..e5666613c5 100644
--- a/src/app/search/search-page/search-page.component.ts
+++ b/src/app/search/search-page/search-page.component.ts
@@ -32,7 +32,6 @@ export class SearchPageComponent {
constructor(private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe(( data: { searchResults: any }) => {
- console.log(data.searchResults);
this.dataSource = new MatTableDataSource(data.searchResults);
this.dataSource.paginator = this.paginator;
this.hasResults = (data.searchResults.length > 0);