feat: savings account transactions (view-reciept) (#949)

Fixes: #948
This commit is contained in:
Karan Takalkar
2020-06-29 17:36:11 +05:30
committed by GitHub
parent be0e7032a7
commit b1c4efccbf
13 changed files with 156 additions and 11 deletions
@@ -0,0 +1,11 @@
<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,8 @@
.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: { savingsTransactionReciept: any }) => {
this.transactionRecieptData = data.savingsTransactionReciept;
});
}
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,64 @@
<div fxLayoutAlign="end" class="container m-b-20"
*ngIf="!(transactionData.interestedPostedAsOn === false && (transactionData.transactionType.id === 17 || transactionData.transactionType.id === 3))">
<button mat-raised-button color="warn"
(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.transactionType.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.displayLabel }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Amount
</div>
<div fxFlex="50%">
{{ transactionData.amount }}
</div>
</div>
</mat-card-content>
</mat-card>
</div>
@@ -0,0 +1,10 @@
.container {
max-width: 37rem;
.content {
div {
margin: 1rem 0;
word-wrap: break-word;
}
}
}
@@ -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,67 @@
/** 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 { SavingsService } from 'app/savings/savings.service';
/** Custom Dialogs */
import { UndoTransactionDialogComponent } from '../../custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component';
/**
* View Transaction Component.
*/
@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 {SavingsService} savingsService Savings Service
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
* @param {DatePipe} datePipe DatePipe.
*/
constructor(private savingsService: SavingsService,
private route: ActivatedRoute,
private datePipe: DatePipe,
private router: Router,
public dialog: MatDialog) {
this.route.data.subscribe((data: { savingsAccountTransaction: any }) => {
this.transactionData = data.savingsAccountTransaction;
});
}
/**
* Undo the savings transaction
*/
undoTransaction() {
const accountId = this.route.parent.snapshot.params['savingAccountId'];
const undoTransactionAccountDialogRef = this.dialog.open(UndoTransactionDialogComponent);
undoTransactionAccountDialogRef.afterClosed().subscribe((response: 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.savingsService.executeSavingsAccountTransactionsCommand(accountId, 'undo', data, this.transactionData.id).subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
});
}
}