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:
Muskan Khedia
2020-08-15 19:26:05 +05:30
committed by GitHub
parent c42e128b09
commit 537d8482c7
26 changed files with 985 additions and 54 deletions
@@ -0,0 +1,33 @@
/** Angular Imports */
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
/** rxjs Imports */
import { Observable } from 'rxjs';
/** Custom Services */
import { LoansService } from '../loans.service';
/**
* Loans Account Transaction Template data resolver.
*/
@Injectable()
export class LoansAccountTransactionTemplateResolver implements Resolve<Object> {
/**
* @param {LoansService} LoansService Loans service.
*/
constructor(private loansService: LoansService) { }
/**
* Returns the Loans Account Transaction Template data.
* @param {ActivatedRouteSnapshot} route Route Snapshot
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const loanAccountId = route.parent.parent.parent.paramMap.get('loanId');
const transactionId = route.paramMap.get('id');
return this.loansService.getLoansAccountTransactionTemplate(loanAccountId, transactionId);
}
}
@@ -0,0 +1,33 @@
/** Angular Imports */
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
/** rxjs Imports */
import { Observable } from 'rxjs';
/** Custom Services */
import { LoansService } from '../loans.service';
/**
* Loans Account Transaction data resolver.
*/
@Injectable()
export class LoansAccountTransactionResolver implements Resolve<Object> {
/**
* @param {LoansService} LoansService Loans service.
*/
constructor(private loansService: LoansService) { }
/**
* Returns the Loans Account Transaction data.
* @param {ActivatedRouteSnapshot} route Route Snapshot
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const loanAccountId = route.parent.parent.parent.paramMap.get('loanId');
const transactionId = route.paramMap.get('id');
return this.loansService.getLoansAccountTransaction(loanAccountId, transactionId);
}
}
@@ -0,0 +1,36 @@
/** Angular Imports */
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
/** rxjs Imports */
import { Observable } from 'rxjs';
/** Custom Services */
import { ReportsService } from 'app/reports/reports.service';
/**
* Loans Transaction Reciept resolver.
*/
@Injectable()
export class LoansTransactionRecieptResolver implements Resolve<Object> {
/**
* @param {ReportsService} reportsService Reports service.
*/
constructor(private reportsService: ReportsService) { }
/**
* Returns the Loans Transaction Reciept
* @param {ActivatedRouteSnapshot} route Route Snapshot
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const transactionId = route.paramMap.get('id');
const data = {
'output-type': 'PDF',
R_transactionId: transactionId
};
return this.reportsService.getPentahoRunReportData({name: 'Loan Transaction Receipt'}, data, 'default', 'en', 'dd MMMM yyyy');
}
}
+54 -5
View File
@@ -24,6 +24,11 @@ import { CreateLoansAccountComponent } from './create-loans-account/create-loans
import { LoanDocumentsTabComponent } from './loans-view/loan-documents-tab/loan-documents-tab.component';
import { StandingInstructionsTabComponent } from 'app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component';
import { EditLoansAccountComponent } from './edit-loans-account/edit-loans-account.component';
import { ViewChargeComponent } from './loans-view/view-charge/view-charge.component';
import { ViewTransactionComponent } from './loans-view/transactions/view-transaction/view-transaction.component';
import { EditTransactionComponent } from './loans-view/transactions/edit-transaction/edit-transaction.component';
import { ViewRecieptComponent } from './loans-view/transactions/view-reciept/view-reciept.component';
import { ExportTransactionsComponent } from './loans-view/transactions/export-transactions/export-transactions.component';
/** Custom Resolvers */
import { LoanDetailsResolver } from './common-resolvers/loan-details.resolver';
@@ -36,7 +41,9 @@ import { LoansAccountTemplateResolver } from './common-resolvers/loans-account-t
import { LoanDocumentsResolver } from './common-resolvers/loan-documents.resolver';
import { LoansAccountAndTemplateResolver } from './common-resolvers/loans-account-and-template.resolver';
import { LoansAccountChargeResolver } from './common-resolvers/loans-account-charge.resolver';
import { ViewChargeComponent } from './loans-view/view-charge/view-charge.component';
import { LoansAccountTransactionResolver } from './common-resolvers/loans-account-transaction.resolver';
import { LoansTransactionRecieptResolver } from './common-resolvers/loans-transaction-reciept.resolver';
import { LoansAccountTransactionTemplateResolver } from './common-resolvers/loans-account-transaction-template.resolver';
/** Loans Route. */
const routes: Routes = [
@@ -93,11 +100,50 @@ const routes: Routes = [
},
{
path: 'transactions',
component: TransactionsTabComponent,
data: { title: extract('Transactions'), breadcrumb: 'Transactions', routeParamBreadcrumb: false },
data: { title: extract('Loans Account Transactions'), breadcrumb: 'Transactions', routeParamBreadcrumb: false },
resolve: {
loanDetailsAssociationData: LoanDetailsChargesResolver
}
},
children: [
{
path: '',
component: TransactionsTabComponent
},
{
path: 'export',
component: ExportTransactionsComponent
},
{
path: ':id',
data: { routeParamBreadcrumb: 'id' },
children: [
{
path: '',
component: ViewTransactionComponent,
resolve: {
loansAccountTransaction: LoansAccountTransactionResolver
}
},
{
path: 'edit',
component: EditTransactionComponent,
data: { breadcrumb: 'Edit', routeParamBreadcrumb: false },
resolve: {
loansAccountTransactionTemplate: LoansAccountTransactionTemplateResolver
}
},
{
path: 'reciept',
component: ViewRecieptComponent,
data: { breadcrumb: 'Reciept', routeParamBreadcrumb: false },
resolve: {
loansTransactionReciept: LoansTransactionRecieptResolver
}
}
]
}
]
},
{
path: 'loan-collateral',
@@ -222,7 +268,10 @@ const routes: Routes = [
LoansAccountTemplateResolver,
LoanDocumentsResolver,
LoansAccountAndTemplateResolver,
LoansAccountChargeResolver
LoansAccountChargeResolver,
LoansAccountTransactionResolver,
LoansAccountTransactionTemplateResolver,
LoansTransactionRecieptResolver
]
})
@@ -130,7 +130,6 @@ export class CreateGuarantorComponent implements OnInit, AfterViewInit {
}
clientSelected(clientDetails: any) {
console.log(clientDetails);
this.accountOptions = [];
this.loanService.guarantorAccountResource(this.loanId, clientDetails.id).subscribe((response: any) => {
this.accountOptions = response.accountLinkingOptions;
@@ -1,8 +1,8 @@
<div class="container">
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px" class="transaction-buttons">
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px" class="transaction-buttons" *ngIf="checkStatus()">
<mat-checkbox [formControl]="hideAccrualsParam" (click)="hideAccruals()" class="accruals">Hide Accruals</mat-checkbox>
<button mat-raised-button color="primary">
<button mat-raised-button color="primary" [routerLink]="['export']">
Export
</button>
<button mat-raised-button color="primary">
@@ -10,67 +10,69 @@
</button>
</div>
<table mat-table [dataSource]="showTransactions">
<table mat-table [dataSource]="showTransactionsData">
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> Date </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.id }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.id }} </td>
</ng-container>
<ng-container matColumnDef="office">
<th mat-header-cell *matHeaderCellDef> Office </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.officeName }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.officeName }} </td>
</ng-container>
<ng-container matColumnDef="transactionDate">
<th mat-header-cell *matHeaderCellDef> Transaction Date </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.date | date }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.date | date }} </td>
</ng-container>
<ng-container matColumnDef="transactionType">
<th mat-header-cell *matHeaderCellDef> Transaction Type </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.type.value }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.type.value }} </td>
</ng-container>
<ng-container matColumnDef="amount">
<th mat-header-cell *matHeaderCellDef> Amount </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.amount | number }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.amount | number }} </td>
</ng-container>
<ng-container matColumnDef="principal">
<th mat-header-cell *matHeaderCellDef> Breakdown </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.principalPortion | number }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.principalPortion | number }} </td>
</ng-container>
<ng-container matColumnDef="interest">
<th mat-header-cell *matHeaderCellDef> </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.interestPortion | number }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.interestPortion | number }} </td>
</ng-container>
<ng-container matColumnDef="fee">
<th mat-header-cell *matHeaderCellDef> </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.feeChargesPortion | number }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.feeChargesPortion | number }} </td>
</ng-container>
<ng-container matColumnDef="penalties">
<th mat-header-cell *matHeaderCellDef> </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.penaltyChargesPortion | number }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.penaltyChargesPortion | number }} </td>
</ng-container>
<ng-container matColumnDef="loanBalance">
<th mat-header-cell *matHeaderCellDef> Loan Balance </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}"> {{ ele.outstandingLoanBalance | number }} </td>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}"> {{ transaction.outstandingLoanBalance | number }} </td>
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> </th>
<td mat-cell *matCellDef="let ele" [ngClass]="{'strike': ele.manuallyReversed}">
<span *ngIf="!ele.manuallyReversedession">
<i class="fa fa-file-text fa fa-large" matTooltip="View Receipts"></i>
</span>
<span>
<i class="fa fa-arrow-circle-right fa fa-large coll" matTooltip="View Journal Entries" matTooltipPosition="left"></i>
</span>
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let transaction" [ngClass]="{'strike': transaction.manuallyReversed}">
<button class="account-action-button" *ngIf="!transaction.manuallyReversedession" mat-raised-button color="primary" (click)="routeEdit($event)"
[routerLink]="[transaction.id, 'reciept']" matTooltip="View Receipts">
<i class="fa fa-file-text"></i>
</button>
<button class="account-action-button" mat-raised-button color="primary" matTooltip="View Journal Entries" matTooltipPosition="left"
(click)="routeEdit($event)" >
<i class="fa fa-arrow-circle-right"></i>
</button>
</td>
</ng-container>
@@ -101,7 +103,7 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-header-row *matHeaderRowDef="['header', 'header-principal', 'header-interest', 'header-fees', 'header-penalties', 'header-action']"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row" (click)="showTransactions(row)"></tr>
</table>
@@ -1,22 +1,28 @@
table {
width: 100%;
margin: 3% 0%;
}
.container {
padding-bottom: 2%;
}
.transaction-buttons {
margin-right: 5%;
padding-top: 5%;
}
.transaction-buttons {
padding-bottom: 1rem;
padding-top: 1rem;
.accruals {
padding-top: 1%;
}
}
.strike {
text-decoration: line-through;
color: red;
}
.accruals {
padding-top: 1%;
table {
width: 100%;
.account-action-button{
min-width: 26px;
padding: 0 0 3px 0;
margin: 0 10%;
line-height: 25px;
}
.select-row:hover {
cursor: pointer;
}
.strike {
text-decoration: line-through;
color: red;
}
}
}
@@ -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();
}
}
@@ -0,0 +1,80 @@
<div class="container">
<mat-card>
<form [formGroup]="editTransactionForm" (ngSubmit)="submit()">
<mat-card-content fxLayout="column">
<mat-form-field>
<mat-label>Transaction Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="dueDatePicker"
formControlName="transactionDate" required>
<mat-datepicker-toggle matSuffix [for]="dueDatePicker"></mat-datepicker-toggle>
<mat-datepicker #dueDatePicker></mat-datepicker>
<mat-error *ngIf="editTransactionForm.controls.transactionDate.hasError('required')">
Transaction Date is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Transaction Amount</mat-label>
<input type="number" formControlName="transactionAmount" required matInput />
<mat-error *ngIf="editTransactionForm.controls.transactionAmount.hasError('required')">
Transaction Amount is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Payment Type</mat-label>
<mat-select formControlName="paymentTypeId">
<mat-option *ngFor="let paymentType of paymentTypeOptions" [value]="paymentType.id">
{{ paymentType.name }}
</mat-option>
</mat-select>
</mat-form-field>
<div fxLayoutGap="5px" fxLayout="row" fxLayout.xs="column">
<mat-label fxFlexAlign="center">Show Payment Details</mat-label>
<button type="button" mat-mini-fab color="primary" (click)="addPaymentDetails()">
<fa-icon [icon]="!addPaymentDetailsFlag ? 'plus-circle' : 'minus-circle'" size="lg"></fa-icon>
</button>
</div>
<mat-form-field *ngIf="editTransactionForm.controls['accountNumber']">
<mat-label>Account Number</mat-label>
<input type="number" formControlName="accountNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="editTransactionForm.controls['checkNumber']">
<mat-label>Cheque</mat-label>
<input type="number" formControlName="checkNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="editTransactionForm.controls['routingCode']">
<mat-label>Routing Code</mat-label>
<input formControlName="routingCode" matInput />
</mat-form-field>
<mat-form-field *ngIf="editTransactionForm.controls['receiptNumber']">
<mat-label>Receipt Number</mat-label>
<input formControlName="receiptNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="editTransactionForm.controls['bankNumber']">
<mat-label>Bank</mat-label>
<input formControlName="bankNumber" matInput />
</mat-form-field>
<mat-card-actions fxLayoutGap="5px" fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center">
<button type="button" mat-raised-button [routerLink]="['../']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!editTransactionForm.valid">Submit</button>
</mat-card-actions>
</mat-card-content>
</form>
</mat-card>
</div>
@@ -0,0 +1,5 @@
.container {
width: 37rem;
margin-top: 3%;
padding-bottom: 2%;
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { EditTransactionComponent } from './edit-transaction.component';
describe('EditTransactionComponent', () => {
let component: EditTransactionComponent;
let fixture: ComponentFixture<EditTransactionComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditTransactionComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EditTransactionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,123 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { LoansService } from 'app/loans/loans.service';
/**
* Edit Transaction component.
*/
@Component({
selector: 'mifosx-edit-transaction',
templateUrl: './edit-transaction.component.html',
styleUrls: ['./edit-transaction.component.scss']
})
export class EditTransactionComponent implements OnInit {
/** Minimum Due Date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum Due Date allowed. */
maxDate = new Date();
/** Loans account transaction form. */
editTransactionForm: FormGroup;
/** loans account transaction payment options. */
paymentTypeOptions: {
id: number,
name: string,
description: string,
isCashPayment: boolean,
position: number
}[];
/** Flag to enable payment details fields. */
addPaymentDetailsFlag: Boolean = false;
/** loan account's Id */
loanAccountId: string;
/** Transaction Template */
transactionTemplateData: any;
/**
* Retrieves the Loan Account transaction template data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder.
* @param {LoansService} loansService Loans Service.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe DatePipe.
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private loansService: LoansService) {
this.route.data.subscribe((data: { loansAccountTransactionTemplate: any }) => {
this.transactionTemplateData = data.loansAccountTransactionTemplate;
this.paymentTypeOptions = this.transactionTemplateData.paymentTypeOptions;
});
this.loanAccountId = this.route.parent.parent.parent.snapshot.params['loanId'];
}
/**
* Creates the Loan account transaction form when component loads.
*/
ngOnInit() {
this.createEditTransactionForm();
this.editTransactionForm.patchValue({
'transactionDate': this.transactionTemplateData.date && new Date(this.transactionTemplateData.date),
'transactionAmount': this.transactionTemplateData.amount,
'paymentTypeId': this.transactionTemplateData.paymentTypeId
});
}
/**
* Method to create the Loan Account Transaction Form.
*/
createEditTransactionForm() {
this.editTransactionForm = this.formBuilder.group({
'transactionDate': ['', Validators.required],
'transactionAmount': ['', Validators.required],
'paymentTypeId': [''],
});
}
/**
* Method to add payment detail fields to the UI.
*/
addPaymentDetails() {
this.addPaymentDetailsFlag = !this.addPaymentDetailsFlag;
if (this.addPaymentDetailsFlag) {
this.editTransactionForm.addControl('accountNumber', new FormControl(''));
this.editTransactionForm.addControl('checkNumber', new FormControl(''));
this.editTransactionForm.addControl('routingCode', new FormControl(''));
this.editTransactionForm.addControl('receiptNumber', new FormControl(''));
this.editTransactionForm.addControl('bankNumber', new FormControl(''));
} else {
this.editTransactionForm.removeControl('accountNumber');
this.editTransactionForm.removeControl('checkNumber');
this.editTransactionForm.removeControl('routingCode');
this.editTransactionForm.removeControl('receiptNumber');
this.editTransactionForm.removeControl('bankNumber');
}
}
/**
* Method to submit the transaction details.
*/
submit() {
const prevTransactionDate: Date = this.editTransactionForm.value.transactionDate;
// TODO: Update once language and date settings are setup
const dateFormat = 'dd-MM-yyyy';
this.editTransactionForm.patchValue({
transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat)
});
const transactionData = this.editTransactionForm.value;
transactionData.locale = 'en';
transactionData.dateFormat = dateFormat;
this.loansService.executeLoansAccountTransactionsCommand(this.loanAccountId, 'modify', transactionData, this.transactionTemplateData.id)
.subscribe((res: any) => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
}
@@ -0,0 +1,35 @@
<form class="m-t-20" fxLayout="column" [formGroup]="transactionsReportForm" (ngSubmit)="generate()">
<div fxLayout="row" fxLayoutGap="3%" fxLayoutAlign="center">
<mat-form-field fxFlex="30%">
<mat-label>From Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="fromDatePicker" required formControlName="fromDate">
<mat-datepicker-toggle matSuffix [for]="fromDatePicker"></mat-datepicker-toggle>
<mat-datepicker #fromDatePicker></mat-datepicker>
<mat-error>
From date is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="30%">
<mat-label>To Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="toDatePicker" required formControlName="toDate">
<mat-datepicker-toggle matSuffix [for]="toDatePicker"></mat-datepicker-toggle>
<mat-datepicker #toDatePicker></mat-datepicker>
<mat-error>
To date is <strong>required</strong>
</mat-error>
</mat-form-field>
</div>
<div class="generate-button" fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5%">
<button type="button" mat-raised-button [routerLink]="['../']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!transactionsReportForm.valid">
<fa-icon icon="cogs"></fa-icon>&nbsp;&nbsp;Generate Report &nbsp;</button>
</div>
</form>
<iframe *ngIf="!hideOutput" [src]="pentahoUrl" frameborder="0" width=100% height="750px;"></iframe>
@@ -0,0 +1,5 @@
.generate-button {
max-height: 2%;
padding: 1% 0 2% 6%;
align-self: center;
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ExportTransactionsComponent } from './export-transactions.component';
describe('ExportTransactionsComponent', () => {
let component: ExportTransactionsComponent;
let fixture: ComponentFixture<ExportTransactionsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ExportTransactionsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ExportTransactionsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,87 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
/** Custom Services */
import { ReportsService } from 'app/reports/reports.service';
/**
* Export Client Loans Transactions Component
*/
@Component({
selector: 'mifosx-export-transactions',
templateUrl: './export-transactions.component.html',
styleUrls: ['./export-transactions.component.scss']
})
export class ExportTransactionsComponent implements OnInit {
/** Minimum date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum date allowed. */
maxDate = new Date();
/** Transactions Report Form */
transactionsReportForm: any;
/** substitute for resolver */
hideOutput = true;
/** trusted resource url for pentaho output */
pentahoUrl: any;
/** Loans Account Id */
loansAccountId: any;
/**
* Fetches loans account data from grandparent's `resolve`
* @param {DomSanitizer} sanitizer DOM Sanitizer
* @param {ReportsService} reportsService Reports Service
* @param {FormBuilder} formBuilder Form Builder
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
*/
constructor(private sanitizer: DomSanitizer,
private reportsService: ReportsService,
private formBuilder: FormBuilder,
private datePipe: DatePipe,
private route: ActivatedRoute) {
this.route.parent.data.subscribe((data: { loanDetailsAssociationData: any }) => {
this.loansAccountId = data.loanDetailsAssociationData.accountNo;
});
}
ngOnInit() {
this.createTransactionsReportForm();
}
/**
* Creates the transactions report form.
*/
createTransactionsReportForm() {
this.transactionsReportForm = this.formBuilder.group({
'fromDate': ['', Validators.required],
'toDate': ['', Validators.required],
});
}
/**
* Generates client loans transactions report.
*/
generate() {
const data = {
'output-type': 'PDF',
R_startDate: this.datePipe.transform(this.transactionsReportForm.value.fromDate, 'yyyy-MM-dd'),
R_endDate: this.datePipe.transform(this.transactionsReportForm.value.toDate, 'yyyy-MM-dd'),
R_selectLoan: this.loansAccountId
};
this.reportsService.getPentahoRunReportData({ name: 'Client Loan Account Schedule'}, data, 'default', 'en', 'dd MMMM yyyy')
.subscribe( (res: any) => {
const contentType = res.headers.get('Content-Type');
const file = new Blob([res.body], {type: contentType});
const filecontent = URL.createObjectURL(file);
this.pentahoUrl = this.sanitizer.bypassSecurityTrustResourceUrl(filecontent);
this.hideOutput = false;
});
}
}
@@ -0,0 +1,10 @@
<mat-card class="container">
<div class="back-button">
<button type="button" color="primary" mat-raised-button [routerLink]="['../../']">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;&nbsp;Back</button>
</div>
<iframe [src]="pentahoUrl" frameborder="0" width=100% height="600px;"></iframe>
</mat-card>
@@ -0,0 +1,7 @@
.container {
max-width: 50rem;
.back-button {
max-height: 2%;
margin-bottom: 2%;
}
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ViewRecieptComponent } from './view-reciept.component';
describe('ViewRecieptComponent', () => {
let component: ViewRecieptComponent;
let fixture: ComponentFixture<ViewRecieptComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewRecieptComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ViewRecieptComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,40 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
/**
* View Transaction Reciept Component
*/
@Component({
selector: 'mifosx-view-reciept',
templateUrl: './view-reciept.component.html',
styleUrls: ['./view-reciept.component.scss']
})
export class ViewRecieptComponent implements OnInit {
/** trusted resource url for pentaho output */
pentahoUrl: any;
/** Transaction Reciept Data */
transactionRecieptData: any;
/**
* Fetches transaction reciept `resolve`
* @param {DomSanitizer} sanitizer DOM Sanitizer
* @param {ActivatedRoute} route Activated Route
*/
constructor(private sanitizer: DomSanitizer,
private route: ActivatedRoute) {
this.route.data.subscribe((data: { loansTransactionReciept: any }) => {
this.transactionRecieptData = data.loansTransactionReciept;
});
}
ngOnInit() {
const contentType = this.transactionRecieptData.headers.get('Content-Type');
const file = new Blob([this.transactionRecieptData.body], {type: contentType});
const filecontent = URL.createObjectURL(file);
this.pentahoUrl = this.sanitizer.bypassSecurityTrustResourceUrl(filecontent);
}
}
@@ -0,0 +1,119 @@
<div fxLayoutAlign="end" class="container m-b-20 transaction-buttons" fxLayoutGap="2%"
*ngIf="!(transactionData.type.contra)">
<span *mifosxHasPermission="'ADJUST_LOAN'">
<button mat-raised-button color="primary" [routerLink]="'edit'">
<fa-icon icon="edit"></fa-icon>&nbsp;&nbsp;Edit
</button>
</span>
<button mat-raised-button color="warn" *mifosxHasPermission="'ADJUST_LOAN'" (click)="undoTransaction()">
<fa-icon icon="undo"></fa-icon>&nbsp;&nbsp;Undo
</button>
</div>
<div class="container">
<mat-card>
<mat-card-content>
<div fxLayout="row wrap" class="content">
<div fxFlex="50%" class="mat-body-strong">
Transaction Id
</div>
<div fxFlex="50%">
{{ transactionData.id }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Type
</div>
<div fxFlex="50%">
{{ transactionData.type.value }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Transaction Date
</div>
<div fxFlex="50%">
{{ transactionData.date | date }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Currency
</div>
<div fxFlex="50%">
{{ transactionData.currency.name }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Amount
</div>
<div fxFlex="50%">
{{ transactionData.amount }}
</div>
<ng-container *ngIf="transactionData.paymentDetailData">
<div *ngIf="transactionData.paymentDetailData.paymentType" fxFlex="50%" class="mat-body-strong">
Payment Type
</div>
<div *ngIf="transactionData.paymentDetailData.paymentType" fxFlex="50%">
{{ transactionData.paymentDetailData.paymentType.name }}
</div>
<div *ngIf="transactionData.paymentDetailData.accountNumber" fxFlex="50%" class="mat-body-strong">
Account No.
</div>
<div *ngIf="transactionData.paymentDetailData.accountNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.accountNumber }}
</div>
<div *ngIf="transactionData.paymentDetailData.checkNumber" fxFlex="50%" class="mat-body-strong">
Cheque Number
</div>
<div *ngIf="transactionData.paymentDetailData.checkNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.checkNumber }}
</div>
<div *ngIf="transactionData.paymentDetailData.routingCode" fxFlex="50%" class="mat-body-strong">
Routing Code
</div>
<div *ngIf="transactionData.paymentDetailData.routingCode" fxFlex="50%">
{{ transactionData.paymentDetailData.routingCode }}
</div>
<div *ngIf="transactionData.paymentDetailData.receiptNumber" fxFlex="50%" class="mat-body-strong">
Receipt No.
</div>
<div *ngIf="transactionData.paymentDetailData.receiptNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.receiptNumber }}
</div>
<div *ngIf="transactionData.paymentDetailData.bankNumber" fxFlex="50%" class="mat-body-strong">
Bank No.
</div>
<div *ngIf="transactionData.paymentDetailData.bankNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.bankNumber }}
</div>
</ng-container>
</div>
</mat-card-content>
</mat-card>
</div>
@@ -0,0 +1,14 @@
.container {
max-width: 37rem;
padding-bottom: 2%;
.content {
div {
margin: 1rem 0;
word-wrap: break-word;
}
}
}
.transaction-buttons {
margin-top: 3%;
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ViewTransactionComponent } from './view-transaction.component';
describe('ViewTransactionComponent', () => {
let component: ViewTransactionComponent;
let fixture: ComponentFixture<ViewTransactionComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewTransactionComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ViewTransactionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,70 @@
/** Angular Imports */
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { LoansService } from 'app/loans/loans.service';
import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component';
/** Custom Dialogs */
/**
* View Transaction Component.
* TODO: Add support for account transfers.
*/
@Component({
selector: 'mifosx-view-transaction',
templateUrl: './view-transaction.component.html',
styleUrls: ['./view-transaction.component.scss']
})
export class ViewTransactionComponent {
/** Transaction data. */
transactionData: any;
/**
* Retrieves the Transaction data from `resolve`.
* @param {LoansService} loansService Loans Service
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
* @param {DatePipe} datePipe DatePipe.
*/
constructor(private loansService: LoansService,
private route: ActivatedRoute,
private datePipe: DatePipe,
private router: Router,
public dialog: MatDialog) {
this.route.data.subscribe((data: { loansAccountTransaction: any }) => {
this.transactionData = data.loansAccountTransaction;
});
}
/**
* Undo the loans transaction
*/
undoTransaction() {
const accountId = this.route.parent.parent.parent.snapshot.params['loanId'];
const undoTransactionAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: { heading: 'Undo Transaction', dialogContext: `Are you sure you want undo the transaction ${this.transactionData.id}` }
});
undoTransactionAccountDialogRef.afterClosed().subscribe((response: { confirm: any }) => {
if (response.confirm) {
const locale = 'en';
const dateFormat = 'dd MMMM yyyy';
const data = {
transactionDate: this.datePipe.transform(this.transactionData.date && new Date(this.transactionData.date), dateFormat),
transactionAmount: 0,
dateFormat,
locale
};
this.loansService.executeLoansAccountTransactionsCommand(accountId, 'undo', data, this.transactionData.id).subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
});
}
}
+9 -1
View File
@@ -56,6 +56,10 @@ import { StandingInstructionsTabComponent } from './loans-view/standing-instruct
import { EditLoansAccountComponent } from './edit-loans-account/edit-loans-account.component';
import { LoanScreenReportsComponent } from './loans-view/loan-account-actions/loan-screen-reports/loan-screen-reports.component';
import { ApproveLoanComponent } from './loans-view/loan-account-actions/approve-loan/approve-loan.component';
import { ViewRecieptComponent } from './loans-view/transactions/view-reciept/view-reciept.component';
import { ExportTransactionsComponent } from './loans-view/transactions/export-transactions/export-transactions.component';
import { ViewTransactionComponent } from './loans-view/transactions/view-transaction/view-transaction.component';
import { EditTransactionComponent } from './loans-view/transactions/edit-transaction/edit-transaction.component';
/** Dialog Components */
import { LoansAccountViewGuarantorDetailsDialogComponent } from './custom-dialog/loans-account-view-guarantor-details-dialog/loans-account-view-guarantor-details-dialog.component';
@@ -121,7 +125,11 @@ import { LoanAccountLoadDocumentsDialogComponent } from './custom-dialog/loan-ac
EditLoansAccountComponent,
LoanScreenReportsComponent,
ApproveLoanComponent,
ViewChargeComponent
ViewChargeComponent,
ViewTransactionComponent,
EditTransactionComponent,
ViewRecieptComponent,
ExportTransactionsComponent
],
entryComponents: [
LoansAccountAddCollateralDialogComponent,
+34
View File
@@ -404,4 +404,38 @@ export class LoansService {
return this.http.delete(`/loans/${accountId}/charges/${chargeId}`);
}
/**
* @param {string} accountId Loans Account Id
* @param {string} transactionId Transaction Id
* @returns {Observable<any>}
*/
getLoansAccountTransaction(accountId: string, transactionId: string): Observable<any> {
return this.http.get(`/loans/${accountId}/transactions/${transactionId}`);
}
/**
* @param {string} accountId Loans Account Id
* @param {string} transactionId Transaction Id
* @returns {Observable<any>}
*/
getLoansAccountTransactionTemplate(accountId: string, transactionId: string): Observable<any> {
const httpParams = new HttpParams().set('template', 'true');
return this.http.get(`/loans/${accountId}/transactions/${transactionId}`, { params: httpParams });
}
/**
* @param {string} accountId Loans Account Id
* @param {string} command Command
* @param {any} data Data
* @param {string} transactionId Transaction Id
* @returns {Observable<any>}
*/
executeLoansAccountTransactionsCommand(accountId: string, command: string, data: any, transactionId?: any): Observable<any> {
const httpParams = new HttpParams().set('command', command);
if (transactionId) {
return this.http.post(`/loans/${accountId}/transactions/${transactionId}`, data, { params: httpParams });
}
return this.http.post(`/loans/${accountId}/transactions`, data, { params: httpParams });
}
}