Skip to content

Commit 4d0db11

Browse files
author
Jose Alberto Hernandez
committed
Merge branch 'upstream_master' into advancly
2 parents 9e6aae0 + d252544 commit 4d0db11

File tree

8 files changed

+91
-60
lines changed

8 files changed

+91
-60
lines changed

src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ <h3 class="mat-h3" fxFlexFill>Loan Schedule</h3>
356356
</span>
357357
</div>
358358

359-
<div fxFlexFill *ngIf="isAdvancedPaymentAllocation">
359+
<div fxFlexFill *ngIf="isAdvancedPaymentAllocation && creditAllocations.length > 0">
360360
<span fxFlex="47%">Advanced Credit Allocation Transactions:</span>
361361
<span fxFlex="53%">
362362
<mat-accordion>

src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { LoanProductAccountingStepComponent } from '../loan-product-stepper/loan
1414
import { ProductsService } from 'app/products/products.service';
1515
import { GlobalConfiguration } from 'app/system/configurations/global-configurations-tab/configuration.model';
1616
import { LoanProducts } from '../loan-products';
17-
import { AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocation, PaymentAllocation, PaymentAllocationOrder, PaymentAllocationTransactionTypes } from '../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model';
17+
import { AdvancedCreditAllocation, AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocation, PaymentAllocation, PaymentAllocationOrder, PaymentAllocationTransactionTypes } from '../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model';
1818

1919
@Component({
2020
selector: 'mifosx-edit-loan-product',
@@ -39,7 +39,7 @@ export class EditLoanProductComponent implements OnInit {
3939
paymentAllocation: PaymentAllocation[] = [];
4040
creditAllocation: CreditAllocation[] = [];
4141
advancedPaymentAllocations: AdvancedPaymentAllocation[] = [];
42-
advancedCreditAllocations: AdvancedPaymentAllocation[] = [];
42+
advancedCreditAllocations: AdvancedCreditAllocation[] = [];
4343

4444
/**
4545
* @param {ActivatedRoute} route Activated Route.
@@ -97,7 +97,6 @@ export class EditLoanProductComponent implements OnInit {
9797
buildAdvancedPaymentAllocation(): void {
9898
this.advancedPaymentAllocations = this.advancedPaymentStrategy.buildAdvancedPaymentAllocationList(this.loanProductAndTemplate);
9999
this.advancedCreditAllocations = this.advancedPaymentStrategy.buildAdvancedCreditAllocationList(this.loanProductAndTemplate);
100-
console.log(this.advancedCreditAllocations);
101100
}
102101

103102
setPaymentAllocation(paymentAllocation: PaymentAllocation[]): void {

src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ <h4 class="m-b-15 right" fxFlex="90%">You can drag and drop the rows to set a Pa
2424
<td mat-cell *matCellDef="let paymentAllocation; let rowIndex = index"> {{ (rowIndex + 1) }} </td>
2525
</ng-container>
2626

27-
<ng-container matColumnDef="paymentAllocation">
28-
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Payment Allocation' | translate }}</th>
27+
<ng-container matColumnDef="allocationRule">
28+
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Payment Allocation Rule' | translate }}</th>
2929
<td mat-cell *matCellDef="let paymentAllocation"> {{ paymentAllocation.value }} </td>
3030
</ng-container>
3131

@@ -34,7 +34,7 @@ <h4 class="m-b-15 right" fxFlex="90%">You can drag and drop the rows to set a Pa
3434
</table>
3535
</div>
3636

37-
<div class="mat-elevation-z8 container m-t-15" *ngIf="creditAllocationsData">
37+
<div class="mat-elevation-z8 container m-t-15 m-b-15" *ngIf="creditAllocationsData">
3838
<table mat-table [dataSource]="creditAllocationsData" #table cdkDropList
3939
[cdkDropListData]="creditAllocationsData" (cdkDropListDropped)="dropTable($event, true)">
4040

@@ -50,8 +50,8 @@ <h4 class="m-b-15 right" fxFlex="90%">You can drag and drop the rows to set a Pa
5050
<td mat-cell *matCellDef="let creditAllocation; let rowIndex = index"> {{ (rowIndex + 1) }} </td>
5151
</ng-container>
5252

53-
<ng-container matColumnDef="paymentAllocation">
54-
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Payment Allocation' | translate }}</th>
53+
<ng-container matColumnDef="allocationRule">
54+
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Credit Allocation Rule' | translate }}</th>
5555
<td mat-cell *matCellDef="let creditAllocation"> {{ creditAllocation.value }} </td>
5656
</ng-container>
5757

src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/advance-payment-allocation-tab/advance-payment-allocation-tab.component.ts

+23-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
2-
import { AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocationOrder, FutureInstallmentAllocationRule, PaymentAllocationOrder, PaymentAllocationTransactionType } from '../payment-allocation-model';
2+
import { AdvancedCreditAllocation, AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocationOrder, FutureInstallmentAllocationRule, PaymentAllocationOrder, PaymentAllocationTransactionType } from '../payment-allocation-model';
33
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
44
import { MatTable } from '@angular/material/table';
55
import { MatDialog } from '@angular/material/dialog';
@@ -14,15 +14,16 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
1414
export class AdvancePaymentAllocationTabComponent implements OnInit {
1515

1616
@Input() advancedPaymentAllocation: AdvancedPaymentAllocation;
17+
@Input() advancedCreditAllocation: AdvancedCreditAllocation;
1718

18-
@Output() paymentAllocationChange = new EventEmitter<boolean>();
19+
@Output() allocationChanged = new EventEmitter<boolean>();
1920
@Output() transactionTypeRemoved = new EventEmitter<PaymentAllocationTransactionType>();
2021

2122
paymentAllocationsData: PaymentAllocationOrder[] | null = null;
2223
creditAllocationsData: CreditAllocationOrder[] | null = null;
2324

2425
/** Columns to be displayed in the table. */
25-
displayedColumns: string[] = ['actions', 'order', 'paymentAllocation'];
26+
displayedColumns: string[] = ['actions', 'order', 'allocationRule'];
2627

2728
futureInstallmentAllocationRule = new UntypedFormControl('', Validators.required);
2829

@@ -32,22 +33,21 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
3233
private advancedPaymentStrategy: AdvancedPaymentStrategy) { }
3334

3435
ngOnInit(): void {
35-
console.log(this.advancedPaymentAllocation);
36+
if (this.advancedCreditAllocation) {
37+
this.creditAllocationsData = this.advancedCreditAllocation?.creditAllocationOrder;
38+
}
39+
3640
if (this.advancedPaymentAllocation) {
37-
if (this.advancedPaymentAllocation.creditAllocationOrder) {
38-
this.creditAllocationsData = this.advancedPaymentAllocation.creditAllocationOrder;
39-
}
40-
if (this.advancedPaymentAllocation.paymentAllocationOrder) {
41-
this.paymentAllocationsData = this.advancedPaymentAllocation.paymentAllocationOrder;
42-
}
41+
this.paymentAllocationsData = this.advancedPaymentAllocation?.paymentAllocationOrder;
42+
4343
if (this.advancedPaymentAllocation.futureInstallmentAllocationRule) {
4444
this.futureInstallmentAllocationRule.patchValue(this.advancedPaymentAllocation.futureInstallmentAllocationRule.code);
4545
}
4646
this.futureInstallmentAllocationRule.valueChanges.subscribe((value: any) => {
4747
this.advancedPaymentAllocation.futureInstallmentAllocationRules.forEach((item: FutureInstallmentAllocationRule) => {
4848
if (value === item.code) {
4949
this.advancedPaymentAllocation.futureInstallmentAllocationRule = item;
50-
this.paymentAllocationChange.emit(true);
50+
this.allocationChanged.emit(true);
5151
}
5252
});
5353
});
@@ -61,14 +61,14 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
6161
this.paymentAllocationsData = [...this.paymentAllocationsData];
6262
this.advancedPaymentAllocation.paymentAllocationOrder = this.paymentAllocationsData;
6363
this.table.renderRows();
64-
this.paymentAllocationChange.emit(true);
64+
this.allocationChanged.emit(true);
6565
} else {
6666
const prevIndex = this.creditAllocationsData.findIndex((d: any) => d === event.item.data);
6767
moveItemInArray(this.creditAllocationsData, prevIndex, event.currentIndex);
6868
this.creditAllocationsData = [...this.creditAllocationsData];
69-
this.advancedPaymentAllocation.creditAllocationOrder = this.creditAllocationsData;
69+
this.advancedCreditAllocation.creditAllocationOrder = this.creditAllocationsData;
7070
this.table.renderRows();
71-
this.paymentAllocationChange.emit(true);
71+
this.allocationChanged.emit(true);
7272
}
7373
}
7474

@@ -80,12 +80,19 @@ export class AdvancePaymentAllocationTabComponent implements OnInit {
8080
}
8181

8282
removeTransaction(): void {
83+
let transaction: PaymentAllocationTransactionType = null;
84+
if (this.advancedPaymentAllocation && this.advancedPaymentAllocation.transaction) {
85+
transaction = this.advancedPaymentAllocation.transaction;
86+
} else if (this.advancedCreditAllocation && this.advancedCreditAllocation.transaction) {
87+
transaction = this.advancedCreditAllocation.transaction;
88+
transaction.credit = true;
89+
}
8390
const dialogRef = this.dialog.open(DeleteDialogComponent, {
84-
data: { deleteContext: ` the Transaction Type ${this.advancedPaymentAllocation.transaction.value}` }
91+
data: { deleteContext: ` the Transaction Type ${transaction.value}` }
8592
});
8693
dialogRef.afterClosed().subscribe((response: any) => {
8794
if (response.delete) {
88-
this.transactionTypeRemoved.emit(this.advancedPaymentAllocation.transaction);
95+
this.transactionTypeRemoved.emit(transaction);
8996
}
9097
});
9198
}

src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.html

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
<mat-tab-group animationDuration="0ms" fxLayout="row wrap" fxLayoutGap="2%"
22
fxLayout.lt-md="column">
33

4-
<mat-tab *ngFor="let advancedPaymentAllocation of advancedAllocations">
4+
<mat-tab *ngFor="let advancedPaymentAllocation of advancedPaymentAllocations">
55
<ng-template mat-tab-label>
66
{{advancedPaymentAllocation.transaction.code}}
77
</ng-template>
88
<mifosx-advance-payment-allocation-tab [advancedPaymentAllocation]="advancedPaymentAllocation"
9-
(paymentAllocationChange)="paymentAllocationChanged($event)"
9+
(allocationChange)="allocationChanged($event)"
10+
(transactionTypeRemoved)="transactionTypeRemoved($event)">
11+
</mifosx-advance-payment-allocation-tab>
12+
</mat-tab>
13+
14+
<mat-tab *ngFor="let advancedCreditAllocation of advancedCreditAllocations">
15+
<ng-template mat-tab-label>
16+
{{advancedCreditAllocation.transaction.code}}
17+
</ng-template>
18+
<mifosx-advance-payment-allocation-tab [advancedCreditAllocation]="advancedCreditAllocation"
19+
(allocationChange)="allocationChanged($event)"
1020
(transactionTypeRemoved)="transactionTypeRemoved($event)">
1121
</mifosx-advance-payment-allocation-tab>
1222
</mat-tab>

src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
2-
import { AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocation, PaymentAllocation, PaymentAllocationOrder, PaymentAllocationTransactionType } from './payment-allocation-model';
2+
import { AdvancedCreditAllocation, AdvancedPaymentAllocation, AdvancedPaymentStrategy, CreditAllocation, CreditAllocationOrder, PaymentAllocation, PaymentAllocationOrder, PaymentAllocationTransactionType } from './payment-allocation-model';
33
import { MatDialog } from '@angular/material/dialog';
44
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
55
import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
@@ -14,13 +14,12 @@ import { TranslateService } from '@ngx-translate/core';
1414
})
1515
export class LoanProductPaymentStrategyStepComponent implements OnInit {
1616

17-
advancedAllocations: AdvancedPaymentAllocation[] = [];
1817
@Input() advancedPaymentAllocations: AdvancedPaymentAllocation[] = [];
19-
@Input() advancedCreditAllocations: AdvancedPaymentAllocation[] = [];
18+
@Input() advancedCreditAllocations: AdvancedCreditAllocation[] = [];
2019
@Input() advancedPaymentAllocationTransactionTypes: PaymentAllocationTransactionType[] = [];
2120
@Input() paymentAllocationOrderDefault: PaymentAllocationOrder[];
2221
@Input() advancedCreditAllocationTransactionTypes: PaymentAllocationTransactionType[] = [];
23-
@Input() creditAllocationOrderDefault: PaymentAllocationOrder[];
22+
@Input() creditAllocationOrderDefault: CreditAllocationOrder[];
2423

2524
@Output() paymentAllocationChange = new EventEmitter<boolean>();
2625
@Output() setPaymentAllocation = new EventEmitter<PaymentAllocation[]>();
@@ -33,18 +32,15 @@ export class LoanProductPaymentStrategyStepComponent implements OnInit {
3332
private translateService: TranslateService) { }
3433

3534
ngOnInit(): void {
36-
this.advancedAllocations = this.advancedPaymentAllocations.concat(this.advancedCreditAllocations);
3735
this.sendAllocations();
3836
}
3937

4038
sendAllocations(): void {
4139
this.setPaymentAllocation.emit(this.advancedPaymentStrategy.buildPaymentAllocations(this.advancedPaymentAllocations));
42-
if (this.advancedCreditAllocations?.length > 0) {
43-
this.setCreditAllocation.emit(this.advancedPaymentStrategy.buildCreditAllocations(this.advancedCreditAllocations));
44-
}
40+
this.setCreditAllocation.emit(this.advancedPaymentStrategy.buildCreditAllocations(this.advancedCreditAllocations));
4541
}
4642

47-
paymentAllocationChanged(changed: boolean): void {
43+
allocationChanged(changed: boolean): void {
4844
this.paymentAllocationChange.emit(changed);
4945
this.sendAllocations();
5046
}
@@ -105,8 +101,6 @@ export class LoanProductPaymentStrategyStepComponent implements OnInit {
105101
);
106102
}
107103
this.paymentAllocationChange.emit(true);
108-
this.advancedAllocations = this.advancedPaymentAllocations.concat(this.advancedCreditAllocations);
109-
this.tabGroup.selectedIndex = (this.advancedAllocations.length - 1);
110104
this.sendAllocations();
111105
}
112106
});

0 commit comments

Comments
 (0)