@@ -0,0 +1,116 @@
|
||||
|
||||
|
||||
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
||||
<span *ngIf="savingsAccountData.status.value === 'Active' && chargeData.amountOutstanding !== 0">
|
||||
<button mat-raised-button color="accent" *mifosxHasPermission="'PAY_SAVINGSACCOUNTCHARGE'" (click)="payCharge()">
|
||||
<fa-icon icon="dollar-sign"></fa-icon>
|
||||
Pay Charge
|
||||
</button>
|
||||
<button mat-raised-button color="primary" *mifosxHasPermission="'WAIVE_SAVINGSACCOUNTCHARGE'" (click)="waiveCharge()">
|
||||
<fa-icon icon="flag"></fa-icon>
|
||||
Waive Charge
|
||||
</button>
|
||||
<span *ngIf="isRecurringCharge()">
|
||||
<button mat-raised-button color="warn" *mifosxHasPermission="'INACTIVATE_SAVINGSACCOUNTCHARGE'" (click)="inactivateCharge()">
|
||||
<fa-icon icon="trash"></fa-icon>
|
||||
Inactivate Charge
|
||||
</button>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="row wrap" class="content">
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Name
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.name }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Charge Type
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.penalty ? 'Penalty' : 'Fees' }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Currency
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.currency.displayLabel }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Payment due at
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.chargeTimeType.value }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Payment due as of
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.dueDate | date }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Calculation Type
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.chargeCalculationType.value }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Due
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.amount }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Paid
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.amountPaid }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Waived
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.amountWaived }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Outstanding
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.amountOutstanding }}
|
||||
</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 { ViewChargeComponent } from './view-charge.component';
|
||||
|
||||
describe('ViewChargeComponent', () => {
|
||||
let component: ViewChargeComponent;
|
||||
let fixture: ComponentFixture<ViewChargeComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ViewChargeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ViewChargeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,136 @@
|
||||
/** 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 { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
||||
import { WaiveChargeDialogComponent } from '../custom-dialogs/waive-charge-dialog/waive-charge-dialog.component';
|
||||
import { InactivateChargeDialogComponent } from '../custom-dialogs/inactivate-charge-dialog/inactivate-charge-dialog.component';
|
||||
|
||||
/** Custom Models */
|
||||
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
|
||||
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
|
||||
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
|
||||
|
||||
/**
|
||||
* View Charge Component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-view-charge',
|
||||
templateUrl: './view-charge.component.html',
|
||||
styleUrls: ['./view-charge.component.scss']
|
||||
})
|
||||
export class ViewChargeComponent {
|
||||
|
||||
/** Charge data. */
|
||||
chargeData: any;
|
||||
/** Savings Account Data */
|
||||
savingsAccountData: any;
|
||||
|
||||
/**
|
||||
* Retrieves the Charge 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: { savingsAccountCharge: any, savingsAccountData: any }) => {
|
||||
this.chargeData = data.savingsAccountCharge;
|
||||
this.savingsAccountData = data.savingsAccountData;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Pays the charge.
|
||||
*/
|
||||
payCharge() {
|
||||
const formfields: FormfieldBase[] = [
|
||||
new InputBase({
|
||||
controlName: 'amount',
|
||||
label: 'Amount',
|
||||
value: '',
|
||||
type: 'number',
|
||||
required: true
|
||||
}),
|
||||
new DatepickerBase({
|
||||
controlName: 'dueDate',
|
||||
label: 'Payment Date',
|
||||
value: '',
|
||||
type: 'date',
|
||||
required: true
|
||||
})
|
||||
];
|
||||
const data = {
|
||||
title: 'Pay Charge',
|
||||
layout: { addButtonText: 'Confirm' },
|
||||
formfields: formfields
|
||||
};
|
||||
const payChargeDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||
payChargeDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data) {
|
||||
const locale = 'en';
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
const dataObject = {
|
||||
...response.data.value,
|
||||
dueDate: this.datePipe.transform(response.data.value.dueDate, dateFormat),
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.savingsService.executeSavingsAccountChargesCommand(this.chargeData.accountId, 'paycharge', dataObject, this.chargeData.id)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Waive's the charge
|
||||
*/
|
||||
waiveCharge() {
|
||||
const waiveChargeDialogRef = this.dialog.open(WaiveChargeDialogComponent, { data: { id: this.chargeData.id } });
|
||||
waiveChargeDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.confirm) {
|
||||
this.savingsService.executeSavingsAccountChargesCommand(this.chargeData.accountId, 'waive', {}, this.chargeData.id)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Inactivate's the charge
|
||||
*/
|
||||
inactivateCharge() {
|
||||
const inactivateChargeDialogRef = this.dialog.open(InactivateChargeDialogComponent, { data: { id: this.chargeData.id } });
|
||||
inactivateChargeDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.confirm) {
|
||||
this.savingsService.executeSavingsAccountChargesCommand(this.chargeData.accountId, 'inactivate', {}, this.chargeData.id)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if charge is recurring
|
||||
*/
|
||||
isRecurringCharge() {
|
||||
const chargeTimeType = this.chargeData.chargeTimeType.value;
|
||||
return chargeTimeType === 'Monthly Fee' || chargeTimeType === 'Annual Fee' || chargeTimeType === 'Weekly Fee';
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user