Savings account transactions with check to hide accrual transactions
This commit is contained in:
committed by
Adam Saghy
parent
9600e8ed56
commit
af97eba60b
@@ -7,6 +7,8 @@
|
|||||||
<h3>All Transactions</h3>
|
<h3>All Transactions</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="action-button m-b-20" fxLayout="row" fxLayoutGap="20px" *ngIf="checkStatus()">
|
<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>
|
||||||
<button mat-raised-button color="primary" [routerLink]="['/accounting', 'journal-entries']">View Journal Entries</button>
|
<button mat-raised-button color="primary" [routerLink]="['/accounting', 'journal-entries']">View Journal Entries</button>
|
||||||
<button mat-raised-button color="primary" [routerLink]="['export']">Export</button>
|
<button mat-raised-button color="primary" [routerLink]="['export']">Export</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
padding: 0 0 3px 0;
|
padding: 0 0 3px 0;
|
||||||
margin: 0 10%;
|
margin: 0 10%;
|
||||||
line-height: 25px;
|
line-height: 25px;
|
||||||
|
.accruals {
|
||||||
|
padding-top: 1%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.select-row:hover {
|
.select-row:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/** Angular Imports */
|
/** Angular Imports */
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { UntypedFormControl } from '@angular/forms';
|
||||||
import { MatPaginator } from '@angular/material/paginator';
|
import { MatPaginator } from '@angular/material/paginator';
|
||||||
import { MatSort } from '@angular/material/sort';
|
import { MatSort } from '@angular/material/sort';
|
||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
@@ -19,6 +20,10 @@ export class TransactionsTabComponent implements OnInit {
|
|||||||
status: any;
|
status: any;
|
||||||
/** Transactions Data */
|
/** Transactions Data */
|
||||||
transactionsData: any;
|
transactionsData: any;
|
||||||
|
/** Temporary Transaction Data */
|
||||||
|
tempTransaction: any;
|
||||||
|
/** Form control to handle accural parameter */
|
||||||
|
hideAccrualsParam: UntypedFormControl;
|
||||||
/** Columns to be displayed in transactions table. */
|
/** Columns to be displayed in transactions table. */
|
||||||
displayedColumns: string[] = ['id', 'date', 'transactionType', 'debit', 'credit', 'balance', 'actions'];
|
displayedColumns: string[] = ['id', 'date', 'transactionType', 'debit', 'credit', 'balance', 'actions'];
|
||||||
/** Data source for transactions table. */
|
/** Data source for transactions table. */
|
||||||
@@ -36,15 +41,30 @@ export class TransactionsTabComponent implements OnInit {
|
|||||||
private router: Router) {
|
private router: Router) {
|
||||||
this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => {
|
this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => {
|
||||||
this.transactionsData = data.savingsAccountData.transactions?.filter((transaction: any) => !transaction.reversed);
|
this.transactionsData = data.savingsAccountData.transactions?.filter((transaction: any) => !transaction.reversed);
|
||||||
|
this.tempTransaction = this.transactionsData;
|
||||||
this.status = data.savingsAccountData.status.value;
|
this.status = data.savingsAccountData.status.value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.hideAccrualsParam = new UntypedFormControl(false);
|
||||||
|
this.setTransactions();
|
||||||
|
}
|
||||||
|
|
||||||
|
setTransactions(): void {
|
||||||
this.dataSource = new MatTableDataSource(this.transactionsData);
|
this.dataSource = new MatTableDataSource(this.transactionsData);
|
||||||
this.accountWithTransactions = (this.transactionsData && this.transactionsData.length > 0);
|
this.accountWithTransactions = (this.transactionsData && this.transactionsData.length > 0);
|
||||||
this.dataSource.paginator = this.paginator;
|
this.dataSource.paginator = this.paginator;
|
||||||
this.dataSource.sort = this.sort;
|
this.dataSource.sort = this.sort;
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,6 +76,10 @@ export class TransactionsTabComponent implements OnInit {
|
|||||||
|| transactionType.overdraftInterest === true || transactionType.withholdTax === true;
|
|| transactionType.overdraftInterest === true || transactionType.withholdTax === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isAccrual(transactionType: any): boolean {
|
||||||
|
return (transactionType.accrual || transactionType.code === 'savingsAccountTransactionType.accrual');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks transaction status.
|
* Checks transaction status.
|
||||||
*/
|
*/
|
||||||
@@ -87,4 +111,12 @@ export class TransactionsTabComponent implements OnInit {
|
|||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hideAccruals() {
|
||||||
|
if (!this.hideAccrualsParam.value) {
|
||||||
|
this.dataSource = new MatTableDataSource(this.tempTransaction);
|
||||||
|
} else {
|
||||||
|
this.dataSource = new MatTableDataSource(this.transactionsData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user