+38
@@ -0,0 +1,38 @@
|
||||
/** Angular Imports */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from 'app/savings/savings.service';
|
||||
|
||||
/**
|
||||
* Fixed Deposits Account Actions data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class FixedDepositsAccountActionsResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {SavingsService} SavingsService Savings service.
|
||||
*/
|
||||
constructor(private savingsService: SavingsService) { }
|
||||
|
||||
/**
|
||||
* Returns the Fixed deposits account actions data.
|
||||
* @param {ActivatedRouteSnapshot} route Route Snapshot
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const actionName = route.paramMap.get('name');
|
||||
const fixedDepositAccountId = route.paramMap.get('fixedDepositAccountId') || route.parent.parent.paramMap.get('fixedDepositAccountId');
|
||||
switch (actionName) {
|
||||
case 'Add Charge':
|
||||
return this.savingsService.getSavingsChargeTemplateResource(fixedDepositAccountId);
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -35,10 +35,10 @@ export class ActivateFixedDepositsAccountComponent implements OnInit {
|
||||
* @param {Router} router Router
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private savingsService: SavingsService,
|
||||
private datePipe: DatePipe,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
private savingsService: SavingsService,
|
||||
private datePipe: DatePipe,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.accountId = this.route.parent.snapshot.params['fixedDepositAccountId'];
|
||||
}
|
||||
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="fixedDepositsChargeForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="column">
|
||||
<mat-form-field>
|
||||
<mat-label>Charge</mat-label>
|
||||
<mat-select required formControlName="chargeId">
|
||||
<mat-option *ngFor="let savingsCharge of savingsChargeOptions" [value]="savingsCharge.id">
|
||||
{{ savingsCharge.name + ' (' + savingsCharge.currency.name + ')' }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="fixedDepositsChargeForm.controls.chargeId.hasError('required')">
|
||||
Charge is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div *ngIf="chargeDetails" fxLayout="column">
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Amount</mat-label>
|
||||
<input type=number required matInput formControlName="amount" />
|
||||
<mat-error *ngIf="fixedDepositsChargeForm.controls.amount.hasError('required')">
|
||||
Amount is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Charge Calculation</mat-label>
|
||||
<mat-select formControlName="chargeCalculationType">
|
||||
<mat-option *ngFor="let chargeCalculation of chargeDetails.chargeCalculationTypeOptions"
|
||||
[value]="chargeCalculation.id">
|
||||
{{ chargeCalculation.value }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Charge time type</mat-label>
|
||||
<mat-select formControlName="chargeTimeType">
|
||||
<mat-option *ngFor="let chargeTime of chargeDetails.chargeTimeTypeOptions" [value]="chargeTime.id">
|
||||
{{ chargeTime.value }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="fixedDepositsChargeForm.contains('dueDate')">
|
||||
<mat-label>Due for collection on</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="dueDatePicker" required
|
||||
formControlName="dueDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="dueDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #dueDatePicker></mat-datepicker>
|
||||
<mat-error *ngIf="fixedDepositsChargeForm.controls.dueDate.hasError('required')">
|
||||
Due for collection on is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="fixedDepositsChargeForm.contains('feeOnMonthDay')">
|
||||
<mat-label>Due On</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="feeOnMonthDayPicker" required
|
||||
formControlName="feeOnMonthDay">
|
||||
<mat-datepicker-toggle matSuffix [for]="feeOnMonthDayPicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #feeOnMonthDayPicker></mat-datepicker>
|
||||
<mat-error *ngIf="fixedDepositsChargeForm.controls.feeOnMonthDay.hasError('required')">
|
||||
Due Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="fixedDepositsChargeForm.contains('feeInterval')">
|
||||
<mat-label>Repeats Every</mat-label>
|
||||
<input matInput formControlName="feeInterval" />
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<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]="!fixedDepositsChargeForm.valid">Submit</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
width: 37rem;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AddChargeFixedDepositsAccountComponent } from './add-charge-fixed-deposits-account.component';
|
||||
|
||||
describe('AddChargeFixedDepositsAccountComponent', () => {
|
||||
let component: AddChargeFixedDepositsAccountComponent;
|
||||
let fixture: ComponentFixture<AddChargeFixedDepositsAccountComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ AddChargeFixedDepositsAccountComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AddChargeFixedDepositsAccountComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
/** 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 { SavingsService } from 'app/savings/savings.service';
|
||||
|
||||
/**
|
||||
* Add Fixed Deposits Charge component.
|
||||
* Fixed deposits endpoint is not supported so using Savings endpoint.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-add-charge-fixed-deposits-account',
|
||||
templateUrl: './add-charge-fixed-deposits-account.component.html',
|
||||
styleUrls: ['./add-charge-fixed-deposits-account.component.scss']
|
||||
})
|
||||
export class AddChargeFixedDepositsAccountComponent implements OnInit {
|
||||
|
||||
/** Minimum Due Date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum Due Date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Add Fixed Deposits Charge form. */
|
||||
fixedDepositsChargeForm: FormGroup;
|
||||
/** savings charge options. */
|
||||
savingsChargeOptions: any;
|
||||
/** savings Id of the savings account. */
|
||||
fixedDepositAccountId: string;
|
||||
/** charge details */
|
||||
chargeDetails: any;
|
||||
|
||||
/**
|
||||
* Retrieves charge template data from `resolve`
|
||||
* @param {FormBuilder} formBuilder Form Builder
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
* @param {DatePipe} datePipe Date Pipe
|
||||
* @param {SavingsService} savingsService Savings Service
|
||||
*/
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private datePipe: DatePipe,
|
||||
private savingsService: SavingsService
|
||||
) {
|
||||
this.route.data.subscribe((data: { fixedDepositsAccountActionData: any }) => {
|
||||
this.savingsChargeOptions = data.fixedDepositsAccountActionData.chargeOptions;
|
||||
});
|
||||
this.fixedDepositAccountId = this.route.parent.snapshot.params['fixedDepositAccountId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the Fixed Deposits Charge form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createFixedDepositsChargeForm();
|
||||
this.buildDependencies();
|
||||
}
|
||||
|
||||
buildDependencies() {
|
||||
this.fixedDepositsChargeForm.controls.chargeId.valueChanges.subscribe(chargeId => {
|
||||
this.savingsService.getChargeTemplate(chargeId).subscribe((data: any) => {
|
||||
this.chargeDetails = data;
|
||||
const chargeTimeType = data.chargeTimeType.id;
|
||||
if (data.chargeTimeType.value === 'Withdrawal Fee' || data.chargeTimeType.value === 'Saving No Activity Fee') {
|
||||
this.chargeDetails.dueDateNotRequired = true;
|
||||
}
|
||||
if (data.chargeTimeType.value === 'Annual Fee' || data.chargeTimeType.value === 'Monthly Fee') {
|
||||
this.chargeDetails.chargeTimeTypeAnnualOrMonth = true;
|
||||
}
|
||||
if (!this.chargeDetails.dueDateNotRequired && !this.chargeDetails.chargeTimeTypeAnnualOrMonth) {
|
||||
this.fixedDepositsChargeForm.addControl('dueDate', new FormControl('', Validators.required));
|
||||
} else {
|
||||
this.fixedDepositsChargeForm.removeControl('dueDate');
|
||||
}
|
||||
if (!this.chargeDetails.dueDateNotRequired && this.chargeDetails.chargeTimeTypeAnnualOrMonth) {
|
||||
this.fixedDepositsChargeForm.addControl('feeOnMonthDay', new FormControl('', Validators.required));
|
||||
} else {
|
||||
this.fixedDepositsChargeForm.removeControl('feeOnMonthDay');
|
||||
}
|
||||
if (chargeTimeType.value === 'Monthly Fee') {
|
||||
this.fixedDepositsChargeForm.addControl('feeInterval', new FormControl(data.feeInterval, Validators.required));
|
||||
} else {
|
||||
this.fixedDepositsChargeForm.removeControl('feeInterval');
|
||||
}
|
||||
this.fixedDepositsChargeForm.patchValue({
|
||||
'amount': data.amount,
|
||||
'chargeCalculationType': data.chargeCalculationType.id,
|
||||
'chargeTimeType': data.chargeTimeType.id
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the Fixed Deposits Charge form.
|
||||
*/
|
||||
createFixedDepositsChargeForm() {
|
||||
this.fixedDepositsChargeForm = this.formBuilder.group({
|
||||
'chargeId': ['', Validators.required],
|
||||
'amount': ['', Validators.required],
|
||||
'chargeCalculationType': [{ value: '', disabled: true }],
|
||||
'chargeTimeType': [{ value: '', disabled: true }]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits savings charge.
|
||||
*/
|
||||
submit() {
|
||||
const savingsCharge = this.fixedDepositsChargeForm.value;
|
||||
savingsCharge.locale = 'en';
|
||||
if (!savingsCharge.feeInterval) {
|
||||
savingsCharge.feeInterval = this.chargeDetails.feeInterval;
|
||||
}
|
||||
if (this.chargeDetails.dueDateNotRequired !== true) {
|
||||
if (this.chargeDetails.chargeTimeTypeAnnualOrMonth === true) {
|
||||
const monthDayFormat = 'MMMM-dd'; // TODO: Update once language and date settings are setup
|
||||
savingsCharge.monthDayFormat = monthDayFormat;
|
||||
if (savingsCharge.feeOnMonthDay) {
|
||||
const prevDate = this.fixedDepositsChargeForm.value.feeOnMonthDay;
|
||||
savingsCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat);
|
||||
}
|
||||
} else {
|
||||
const dateFormat = 'yyyy-MM-dd';
|
||||
savingsCharge.dateFormat = dateFormat;
|
||||
if (savingsCharge.dueDate) {
|
||||
const prevDate = this.fixedDepositsChargeForm.value.dueDate;
|
||||
savingsCharge.dueDate = this.datePipe.transform(prevDate, dateFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.savingsService.createSavingsCharge(this.fixedDepositAccountId, 'charges', savingsCharge).subscribe( () => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -3,5 +3,5 @@
|
||||
<mifosx-activate-fixed-deposits-account *ngIf="actions['Activate']"></mifosx-activate-fixed-deposits-account>
|
||||
<mifosx-undo-approval-fixed-deposits-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-fixed-deposits-account>
|
||||
<mifosx-withdraw-by-client-fixed-deposits-account *ngIf="actions['Withdraw By Client']"></mifosx-withdraw-by-client-fixed-deposits-account>
|
||||
<!-- <mifosx-add-charge-fixed-deposits-account *ngIf="actions['Add Charge']"></mifosx-add-charge-fixed-deposits-account>
|
||||
<mifosx-close-fixed-deposits-account *ngIf="actions['Close']"></mifosx-close-fixed-deposits-account> -->
|
||||
<mifosx-add-charge-fixed-deposits-account *ngIf="actions['Add Charge']"></mifosx-add-charge-fixed-deposits-account>
|
||||
<!-- <mifosx-close-fixed-deposits-account *ngIf="actions['Close']"></mifosx-close-fixed-deposits-account> -->
|
||||
|
||||
+2
@@ -20,6 +20,7 @@ export class FixedDepositsAccountActionsComponent {
|
||||
'Close': boolean
|
||||
'Undo Approval': boolean
|
||||
'Add Charge': boolean
|
||||
'Premature Close': boolean
|
||||
'Withdraw By Client': boolean
|
||||
} = {
|
||||
'Approve': false,
|
||||
@@ -28,6 +29,7 @@ export class FixedDepositsAccountActionsComponent {
|
||||
'Close': false,
|
||||
'Undo Approval': false,
|
||||
'Add Charge': false,
|
||||
'Premature Close': false,
|
||||
'Withdraw By Client': false
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import { FixedDepositsAccountViewResolver } from '../fixed-deposits/common-resol
|
||||
import { SavingsDatatableResolver } from 'app/savings/common-resolvers/savings-datatable.resolver';
|
||||
import { SavingsDatatablesResolver } from 'app/savings/common-resolvers/savings-datatables.resolver';
|
||||
import { FixedDepositsAccountTransactionResolver } from '../fixed-deposits/common-resolvers/fixed-deposit-account-transaction.resolver';
|
||||
import { FixedDepositsAccountActionsResolver } from '../fixed-deposits/common-resolvers/fixed-deposit-account-actions.resolver';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
@@ -29,15 +30,13 @@ const routes: Routes = [
|
||||
{
|
||||
path: ':fixedDepositAccountId',
|
||||
data: { title: extract('Fixed Deposit Account View'), routeParamBreadcrumb: 'fixedDepositAccountId' },
|
||||
resolve: {
|
||||
savingsDatatables: SavingsDatatablesResolver
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: FixedDepositAccountViewComponent,
|
||||
resolve: {
|
||||
fixedDepositsAccountData: FixedDepositsAccountViewResolver
|
||||
fixedDepositsAccountData: FixedDepositsAccountViewResolver,
|
||||
savingsDatatables: SavingsDatatablesResolver
|
||||
},
|
||||
children: [
|
||||
{
|
||||
@@ -101,7 +100,10 @@ const routes: Routes = [
|
||||
{
|
||||
path: 'actions/:name',
|
||||
data: { title: extract('Fixed Deposits Account Actions'), routeParamBreadcrumb: 'name' },
|
||||
component: FixedDepositsAccountActionsComponent
|
||||
component: FixedDepositsAccountActionsComponent,
|
||||
resolve: {
|
||||
fixedDepositsAccountActionData: FixedDepositsAccountActionsResolver
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -116,7 +118,8 @@ const routes: Routes = [
|
||||
FixedDepositsAccountViewResolver,
|
||||
SavingsDatatableResolver,
|
||||
SavingsDatatablesResolver,
|
||||
FixedDepositsAccountTransactionResolver
|
||||
FixedDepositsAccountTransactionResolver,
|
||||
FixedDepositsAccountActionsResolver
|
||||
]
|
||||
})
|
||||
export class FixedDepositsRoutingModule { }
|
||||
|
||||
@@ -29,6 +29,7 @@ import { WithdrawByClientFixedDepositsAccountComponent } from './fixed-deposits-
|
||||
import { ViewTransactionComponent } from './fixed-deposit-account-view/view-transaction/view-transaction.component';
|
||||
import { WaiveChargeDialogComponent } from './fixed-deposit-account-view/custom-dialogs/waive-charge-dialog/waive-charge-dialog.component';
|
||||
import { InactivateChargeDialogComponent } from './fixed-deposit-account-view/custom-dialogs/inactivate-charge-dialog/inactivate-charge-dialog.component';
|
||||
import { AddChargeFixedDepositsAccountComponent } from './fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@@ -51,7 +52,8 @@ import { InactivateChargeDialogComponent } from './fixed-deposit-account-view/cu
|
||||
WithdrawByClientFixedDepositsAccountComponent,
|
||||
ViewTransactionComponent,
|
||||
WaiveChargeDialogComponent,
|
||||
InactivateChargeDialogComponent
|
||||
InactivateChargeDialogComponent,
|
||||
AddChargeFixedDepositsAccountComponent
|
||||
],
|
||||
imports: [
|
||||
SharedModule,
|
||||
|
||||
@@ -33,7 +33,7 @@ export class FixedDepositsService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} accountId Savings Account Id
|
||||
* @param {string} accountId Account Id
|
||||
* @param {string} command Command
|
||||
* @param {any} data Data
|
||||
* @returns {Observable<any>}
|
||||
|
||||
Reference in New Issue
Block a user