diff --git a/src/app/loans/loans-view/loans-view.component.ts b/src/app/loans/loans-view/loans-view.component.ts
index 7c18f9550..8a29573a6 100644
--- a/src/app/loans/loans-view/loans-view.component.ts
+++ b/src/app/loans/loans-view/loans-view.component.ts
@@ -147,6 +147,17 @@ export class LoansViewComponent implements OnInit {
});
}
+ if (!this.loanDetailsData.chargedOff) {
+ // Charge-Off only when there is not Interest Recalculation and the Interest Rate is zero
+ if (!this.loanDetailsData.chargedOff && !this.loanDetailsData.isInterestRecalculationEnabled && this.loanDetailsData.interestRatePerPeriod === 0) {
+ this.buttonConfig.addButton({
+ name: 'Charge-Off',
+ icon: 'coins',
+ taskPermissionName: 'CHARGEOFF_LOAN'
+ });
+ }
+ }
+
}
}
@@ -187,6 +198,13 @@ export class LoansViewComponent implements OnInit {
});
}
+ iconLoanStatusColor() {
+ if (this.loanDetailsData.chargedOff) {
+ return 'loanStatusType.chargeoff';
+ }
+ return this.loanDetailsData.status.code;
+ }
+
/**
* Delete loan Account
*/
diff --git a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html
index 5991aa209..42aec7183 100644
--- a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html
+++ b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html
@@ -1,7 +1,8 @@
diff --git a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.scss b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.scss
index 4433e9c4d..eb3da1edc 100644
--- a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.scss
+++ b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.scss
@@ -32,6 +32,9 @@
.accrual {
color: $msg-default;
}
+ .chargeoff {
+ color: $status-chargeoff;
+ }
}
}
diff --git a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts
index a82401186..a598be1a4 100644
--- a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts
+++ b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts
@@ -4,6 +4,11 @@ import { FormControl } from '@angular/forms';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
+import { Dates } from 'app/core/utils/dates';
+import { LoansService } from 'app/loans/loans.service';
+import { MatDialog } from '@angular/material/dialog';
+import { SettingsService } from 'app/settings/settings.service';
+import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component';
@Component({
selector: 'mifosx-transactions-tab',
@@ -32,7 +37,11 @@ export class TransactionsTabComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute,
- private router: Router) {
+ private dateUtils: Dates,
+ private router: Router,
+ private dialog: MatDialog,
+ private loansService: LoansService,
+ private settingsService: SettingsService) {
this.route.parent.parent.data.subscribe((data: { loanDetailsData: any }) => {
this.transactions = data.loanDetailsData.transactions;
this.tempTransaction = data.loanDetailsData.transactions;
@@ -42,6 +51,14 @@ export class TransactionsTabComponent implements OnInit {
ngOnInit() {
this.hideAccrualsParam = new FormControl(false);
+ this.setLoanTransactions(this.transactions);
+ }
+
+ setLoanTransactions(transactions: any) {
+ this.transactions = transactions;
+ this.transactions.forEach((element: any) => {
+ element.date = this.dateUtils.parseDate(element.date);
+ });
this.dataSource = new MatTableDataSource(this.transactions);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
@@ -99,16 +116,26 @@ export class TransactionsTabComponent implements OnInit {
}
}
- loanTransactionColor(loanTransaction: any): string {
- if (loanTransaction.manuallyReversed) {
+ allowUndoTransaction(transaction: any) {
+ if (transaction.manuallyReversed) {
+ return false;
+ }
+ return ([27].includes(transaction.type.id));
+ }
+
+ loanTransactionColor(transaction: any): string {
+ if (transaction.manuallyReversed) {
return 'strike';
}
- if (loanTransaction.transactionRelations && loanTransaction.transactionRelations.length > 0) {
+ if (transaction.transactionRelations && transaction.transactionRelations.length > 0) {
return 'linked';
}
- if (this.isAccrual(loanTransaction.type)) {
+ if (this.isAccrual(transaction.type)) {
return 'accrual';
}
+ if (this.isChargeOff(transaction.type)) {
+ return 'chargeoff';
+ }
return '';
}
@@ -120,8 +147,59 @@ export class TransactionsTabComponent implements OnInit {
$event.stopPropagation();
}
+ /**
+ * Stops the propagation to view pages.
+ * @param $event Mouse Event
+ */
+ undoTransaction(transaction: any, $event: MouseEvent) {
+ $event.stopPropagation();
+ const locale = this.settingsService.language.code;
+ const dateFormat = this.settingsService.dateFormat;
+ const loanId = this.route.parent.parent.snapshot.params['loanId'];
+ let command = 'undo';
+ let operationDate = transaction.date;
+ let payload = {};
+ if (this.isChargeOff(transaction.type)) {
+ command = 'undo-charge-off';
+ operationDate = this.settingsService.businessDate;
+ }
+ payload = {
+ transactionDate: this.dateUtils.formatDate(operationDate && new Date(operationDate), dateFormat),
+ transactionAmount: 0,
+ dateFormat,
+ locale
+ };
+
+ const undoTransactionAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {
+ data: { heading: 'Undo Transaction', dialogContext: `Are you sure you want undo the transaction type ${transaction.type.value} with id ${transaction.id}` }
+ });
+ undoTransactionAccountDialogRef.afterClosed().subscribe((response: { confirm: any }) => {
+ if (response.confirm) {
+ let transactionId = transaction.id;
+ if (this.isChargeOff(transaction.type)) {
+ transactionId = null;
+ }
+ this.loansService.executeLoansAccountTransactionsCommand(loanId, command, payload, transactionId).subscribe((responseCmd: any) => {
+ transaction.manuallyReversed = true;
+ this.reload();
+ });
+ }
+ });
+ }
+
private isAccrual(transactionType: any): boolean {
return (transactionType.accrual || transactionType.code === 'loanTransactionType.overdueCharge');
}
+ private isChargeOff(transactionType: any): boolean {
+ return (transactionType.chargeoff || transactionType.code === 'loanTransactionType.chargeOff');
+ }
+
+ private reload() {
+ const clientId = this.route.parent.parent.snapshot.params['clientId'];
+ const loanId = this.route.parent.parent.snapshot.params['loanId'];
+ const url: string = this.router.url;
+ this.router.navigateByUrl(`/clients/${clientId}/loans-accounts`, { skipLocationChange: true })
+ .then(() => this.router.navigate([url]));
+ }
}
diff --git a/src/app/loans/loans.module.ts b/src/app/loans/loans.module.ts
index af3ac3e15..10edfbf75 100644
--- a/src/app/loans/loans.module.ts
+++ b/src/app/loans/loans.module.ts
@@ -74,6 +74,7 @@ import { DisburseToSavingsAccountComponent } from './loans-view/loan-account-act
import { LoansAccountDatatableStepComponent } from './loans-account-stepper/loans-account-datatable-step/loans-account-datatable-step.component';
import { RescheduleLoanTabComponent } from './loans-view/reschedule-loan-tab/reschedule-loan-tab.component';
import { AdjustLoanChargeComponent } from './loans-view/loan-account-actions/adjust-loan-charge/adjust-loan-charge.component';
+import { ChargeOffComponent } from './loans-view/loan-account-actions/charge-off/charge-off.component';
/**
* Loans Module
@@ -146,7 +147,8 @@ import { AdjustLoanChargeComponent } from './loans-view/loan-account-actions/adj
DisburseToSavingsAccountComponent,
LoansAccountDatatableStepComponent,
RescheduleLoanTabComponent,
- AdjustLoanChargeComponent
+ AdjustLoanChargeComponent,
+ ChargeOffComponent
],
providers: [ ],
})
diff --git a/src/app/loans/loans.service.ts b/src/app/loans/loans.service.ts
index 75a69d3f1..37b6d2725 100644
--- a/src/app/loans/loans.service.ts
+++ b/src/app/loans/loans.service.ts
@@ -589,7 +589,6 @@ export class LoansService {
delete loansAccountData.principalAmount;
return loansAccountData;
-
}
}
diff --git a/src/app/organization/sms-campaigns/sms-campaign-stepper/campaign-message-step/campaign-message-step.component.html b/src/app/organization/sms-campaigns/sms-campaign-stepper/campaign-message-step/campaign-message-step.component.html
index 6f22d869a..3fa0f591b 100644
--- a/src/app/organization/sms-campaigns/sms-campaign-stepper/campaign-message-step/campaign-message-step.component.html
+++ b/src/app/organization/sms-campaigns/sms-campaign-stepper/campaign-message-step/campaign-message-step.component.html
@@ -20,8 +20,8 @@
Previous
diff --git a/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.html b/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.html
index c537f2477..cb9dfc259 100644
--- a/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.html
+++ b/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.html
@@ -59,7 +59,7 @@
Previous