feat: add loan transactions tab actions (#1206)
- add export transaction - add view transactions - add edit transactions - add undo transactions - add view receipt Fixes: #1205
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import {FormControl} from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
@@ -11,20 +11,27 @@ export class TransactionsTabComponent implements OnInit {
|
||||
|
||||
/** Loan Details Data */
|
||||
transactions: any;
|
||||
showTransactions: any;
|
||||
/** Show Transactions Data */
|
||||
showTransactionsData: any;
|
||||
/** Temporary Transaction Data */
|
||||
tempTransaction: any;
|
||||
/** Form control to handle accural parameter */
|
||||
hideAccrualsParam: FormControl;
|
||||
/** Stores the status of the loan account */
|
||||
status: string;
|
||||
/** Columns to be displayed in original schedule table. */
|
||||
displayedColumns: string[] = ['id', 'office', 'transactionDate', 'transactionType', 'amount', 'principal', 'interest', 'fee', 'penalties', 'loanBalance', 'actions'];
|
||||
hideAccrualsParam: FormControl;
|
||||
|
||||
/**
|
||||
* Retrieves the loans with associations data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { loanDetailsAssociationData: any }) => {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.route.parent.data.subscribe(( data: { loanDetailsAssociationData: any }) => {
|
||||
this.transactions = data.loanDetailsAssociationData.transactions;
|
||||
this.tempTransaction = data.loanDetailsAssociationData.transactions;
|
||||
this.status = data.loanDetailsAssociationData.status.value;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,14 +42,25 @@ export class TransactionsTabComponent implements OnInit {
|
||||
this.tempTransaction = this.removeItem(this.tempTransaction, element);
|
||||
}
|
||||
});
|
||||
this.showTransactions = this.transactions;
|
||||
this.showTransactionsData = this.transactions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks Status of the loan account
|
||||
*/
|
||||
checkStatus() {
|
||||
if (this.status === 'Active' || this.status === 'Closed (obligations met)' || this.status === 'Overpaid' ||
|
||||
this.status === 'Closed (rescheduled)' || this.status === 'Closed (written off)') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
hideAccruals() {
|
||||
if (!this.hideAccrualsParam.value) {
|
||||
this.showTransactions = this.tempTransaction;
|
||||
this.showTransactionsData = this.tempTransaction;
|
||||
} else {
|
||||
this.showTransactions = this.transactions;
|
||||
this.showTransactionsData = this.transactions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,4 +68,22 @@ export class TransactionsTabComponent implements OnInit {
|
||||
return arr.filter((f: any) => f !== item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Transactions Details
|
||||
* @param transactionsData Transactions Data
|
||||
*/
|
||||
showTransactions(transactionsData: any) {
|
||||
if (transactionsData.type.id === 2 || transactionsData.type.id === 4 || transactionsData.type.id === 1) {
|
||||
this.router.navigate([transactionsData.id], { relativeTo: this.route });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the propagation to view pages.
|
||||
* @param $event Mouse Event
|
||||
*/
|
||||
routeEdit($event: MouseEvent) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user