Skip to content

Commit

Permalink
Add checkbox to hide accrual transactions on deposits
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Alberto Hernandez committed Jan 12, 2024
1 parent 53d8436 commit cfa7d60
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<div class="tab-container mat-typography">

<div fxLayoutAlign="start">
<div class="m-b-20">
<h3>{{"labels.heading.All Transactions" | translate }}</h3>
</div>
</div>

<div class="mat-elevation-z1 m-b-25">
<div fxLayout="row" fxLayoutAlign="start">
<div class="m-b-20">
<h3>{{"labels.heading.All Transactions" | translate }}</h3>
</div>
<div class="action-button m-b-20" fxLayout="row" fxLayoutGap="20px" *ngIf="checkStatus()">
<mat-checkbox [formControl]="hideAccrualsParam" (click)="hideAccruals()" class="accruals">
{{"labels.inputs.Hide Accruals" | translate}}</mat-checkbox>
</div>
</div>

<table mat-table [dataSource]="dataSource">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
h3 {
margin:1% auto;
}
.action-button {
margin-left: auto;
}
table {
width: 100%;
color: $black;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { UntypedFormControl } from '@angular/forms';
import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router';

Expand All @@ -13,8 +14,13 @@ import { ActivatedRoute, Router } from '@angular/router';
})
export class TransactionsTabComponent implements OnInit {

status: any;
/** Transactions Data */
transactionsData: any;
/** Temporary Transaction Data */
tempTransaction: any;
/** Form control to handle accural parameter */
hideAccrualsParam: UntypedFormControl;
/** Columns to be displayed in transactions table. */
displayedColumns: string[] = ['id', 'transactionDate', 'transactionType', 'debit', 'credit', 'balance', 'actions'];
/** Data source for transactions table. */
Expand All @@ -29,11 +35,34 @@ export class TransactionsTabComponent implements OnInit {
private router: Router) {
this.route.parent.data.subscribe((data: { fixedDepositsAccountData: any }) => {
this.transactionsData = data.fixedDepositsAccountData.transactions;
this.tempTransaction = this.transactionsData;
this.status = data.fixedDepositsAccountData.status.value;
});
}

ngOnInit() {
this.hideAccrualsParam = new UntypedFormControl(false);
this.dataSource = new MatTableDataSource(this.transactionsData);
this.tempTransaction.forEach((element: any) => {
if (this.isAccrual(element.transactionType)) {
this.tempTransaction = this.removeItem(this.tempTransaction, element);
}
});
}

private removeItem(arr: any, item: any) {
return arr.filter((f: any) => f !== item);
}

/**
* Checks transaction status.
*/
checkStatus() {
if (this.status === 'Active' || this.status === 'Closed' || this.status === 'Transfer in progress' ||
this.status === 'Transfer on hold' || this.status === 'Premature Closed' || this.status === 'Matured') {
return true;
}
return false;
}

/**
Expand Down Expand Up @@ -71,6 +100,14 @@ export class TransactionsTabComponent implements OnInit {
return (transactionType.accrual);
}

hideAccruals() {
if (!this.hideAccrualsParam.value) {
this.dataSource = new MatTableDataSource(this.tempTransaction);
} else {
this.dataSource = new MatTableDataSource(this.transactionsData);
}
}

/**
* Stops the propagation to view pages.
* @param $event Mouse Event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ export class ViewTransactionComponent {
public dialog: MatDialog,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { fixedDepositsAccountTransaction: any }) => {
console.log(this.route.parent.snapshot.params);
this.accountId = this.route.parent.snapshot.params['fixedDepositAccountId'];

this.transactionData = data.fixedDepositsAccountTransaction;
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<div class="tab-container mat-typography">

<div class="mat-elevation-z1 m-b-25">
<div fxLayout="row" fxLayoutAlign="start">
<div class="m-b-20">
<h3>{{"labels.heading.All Transactions" | translate }}</h3>
</div>
<div class="action-button m-b-20" fxLayout="row" fxLayoutGap="20px" *ngIf="checkStatus()">
<mat-checkbox [formControl]="hideAccrualsParam" (click)="hideAccruals()" class="accruals">
{{"labels.inputs.Hide Accruals" | translate}}</mat-checkbox>
</div>
</div>

<table mat-table [dataSource]="dataSource">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@
h3 {
margin:1% auto;
}
.action-button {
margin-left: auto;
}
table {
width: 100%;
.account-action-button{
min-width: 26px;
padding: 0 0 3px 0;
margin: 0 10%;
line-height: 25px;
.accruals {
padding-top: 1%;
}
}
.select-row:hover {
cursor: pointer;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { UntypedFormControl } from '@angular/forms';
import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router';

Expand All @@ -17,6 +18,10 @@ export class TransactionsTabComponent implements OnInit {
status: any;
/** Transactions Data */
transactionsData: any;
/** Temporary Transaction Data */
tempTransaction: any;
/** Form control to handle accural parameter */
hideAccrualsParam: UntypedFormControl;
/** Columns to be displayed in transactions table. */
displayedColumns: string[] = ['id', 'transactionDate', 'transactionType', 'debit', 'credit', 'balance'];
/** Data source for transactions table. */
Expand All @@ -30,12 +35,23 @@ export class TransactionsTabComponent implements OnInit {
private router: Router) {
this.route.parent.data.subscribe((data: { recurringDepositsAccountData: any }) => {
this.transactionsData = data.recurringDepositsAccountData.transactions;
this.tempTransaction = this.transactionsData;
this.status = data.recurringDepositsAccountData.status.value;
});
}

ngOnInit() {
this.dataSource = new MatTableDataSource(this.transactionsData);
this.hideAccrualsParam = new UntypedFormControl(false);
this.tempTransaction.forEach((element: any) => {
if (this.isAccrual(element.transactionType)) {
this.tempTransaction = this.removeItem(this.tempTransaction, element);
}
});
}

private removeItem(arr: any, item: any) {
return arr.filter((f: any) => f !== item);
}

/**
Expand All @@ -47,6 +63,29 @@ export class TransactionsTabComponent implements OnInit {
|| transactionType.overdraftInterest === true || transactionType.withholdTax === true;
}

isAccrual(transactionType: any): boolean {
return (transactionType.accrual || transactionType.code === 'savingsAccountTransactionType.accrual');
}

hideAccruals() {
if (!this.hideAccrualsParam.value) {
this.dataSource = new MatTableDataSource(this.tempTransaction);
} else {
this.dataSource = new MatTableDataSource(this.transactionsData);
}
}

/**
* Checks transaction status.
*/
checkStatus() {
if (this.status === 'Active' || this.status === 'Closed' || this.status === 'Transfer in progress' ||
this.status === 'Transfer on hold' || this.status === 'Premature Closed' || this.status === 'Matured') {
return true;
}
return false;
}

/**
* Show Transactions Details
* @param transactionsData Transactions Data
Expand Down

0 comments on commit cfa7d60

Please sign in to comment.