+6
-1
@@ -30,7 +30,12 @@ export class RecurringDepositsAccountActionsResolver implements Resolve<Object>
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const actionName = route.paramMap.get('name');
|
||||
const recurringDepositAccountId = route.paramMap.get('recurringDepositAccountId') || route.parent.parent.paramMap.get('recurringDepositAccountId');
|
||||
return undefined;
|
||||
switch (actionName) {
|
||||
case 'Add Charge':
|
||||
return this.savingsService.getSavingsChargeTemplateResource(recurringDepositAccountId);
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="recurringDepositsChargeForm" (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="recurringDepositsChargeForm.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="recurringDepositsChargeForm.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="recurringDepositsChargeForm.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="recurringDepositsChargeForm.controls.dueDate.hasError('required')">
|
||||
Due for collection on is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="recurringDepositsChargeForm.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="recurringDepositsChargeForm.controls.feeOnMonthDay.hasError('required')">
|
||||
Due Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="recurringDepositsChargeForm.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]="!recurringDepositsChargeForm.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 { AddChargeRecurringDepositsAccountComponent } from './add-charge-recurring-deposits-account.component';
|
||||
|
||||
describe('AddChargeRecurringDepositsAccountComponent', () => {
|
||||
let component: AddChargeRecurringDepositsAccountComponent;
|
||||
let fixture: ComponentFixture<AddChargeRecurringDepositsAccountComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ AddChargeRecurringDepositsAccountComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AddChargeRecurringDepositsAccountComponent);
|
||||
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 Recurring Deposits Charge component.
|
||||
* Recurring deposits endpoint is not supported so using Savings endpoint.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-add-charge-recurring-deposits-account',
|
||||
templateUrl: './add-charge-recurring-deposits-account.component.html',
|
||||
styleUrls: ['./add-charge-recurring-deposits-account.component.scss']
|
||||
})
|
||||
export class AddChargeRecurringDepositsAccountComponent implements OnInit {
|
||||
|
||||
/** Minimum Due Date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum Due Date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Add Recurring Deposits Charge form. */
|
||||
recurringDepositsChargeForm: FormGroup;
|
||||
/** savings charge options. */
|
||||
savingsChargeOptions: any;
|
||||
/** savings Id of the savings account. */
|
||||
recurringDepositAccountId: 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: { recurringDepositsAccountActionData: any }) => {
|
||||
this.savingsChargeOptions = data.recurringDepositsAccountActionData.chargeOptions;
|
||||
});
|
||||
this.recurringDepositAccountId = this.route.parent.snapshot.params['recurringDepositAccountId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the Recurring Deposits Charge form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createRecurringDepositsChargeForm();
|
||||
this.buildDependencies();
|
||||
}
|
||||
|
||||
buildDependencies() {
|
||||
this.recurringDepositsChargeForm.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.recurringDepositsChargeForm.addControl('dueDate', new FormControl('', Validators.required));
|
||||
} else {
|
||||
this.recurringDepositsChargeForm.removeControl('dueDate');
|
||||
}
|
||||
if (!this.chargeDetails.dueDateNotRequired && this.chargeDetails.chargeTimeTypeAnnualOrMonth) {
|
||||
this.recurringDepositsChargeForm.addControl('feeOnMonthDay', new FormControl('', Validators.required));
|
||||
} else {
|
||||
this.recurringDepositsChargeForm.removeControl('feeOnMonthDay');
|
||||
}
|
||||
if (chargeTimeType.value === 'Monthly Fee') {
|
||||
this.recurringDepositsChargeForm.addControl('feeInterval', new FormControl(data.feeInterval, Validators.required));
|
||||
} else {
|
||||
this.recurringDepositsChargeForm.removeControl('feeInterval');
|
||||
}
|
||||
this.recurringDepositsChargeForm.patchValue({
|
||||
'amount': data.amount,
|
||||
'chargeCalculationType': data.chargeCalculationType.id,
|
||||
'chargeTimeType': data.chargeTimeType.id
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the Recurring Deposits Charge form.
|
||||
*/
|
||||
createRecurringDepositsChargeForm() {
|
||||
this.recurringDepositsChargeForm = this.formBuilder.group({
|
||||
'chargeId': ['', Validators.required],
|
||||
'amount': ['', Validators.required],
|
||||
'chargeCalculationType': [{ value: '', disabled: true }],
|
||||
'chargeTimeType': [{ value: '', disabled: true }]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits savings charge.
|
||||
*/
|
||||
submit() {
|
||||
const savingsCharge = this.recurringDepositsChargeForm.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.recurringDepositsChargeForm.value.feeOnMonthDay;
|
||||
savingsCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat);
|
||||
}
|
||||
} else {
|
||||
const dateFormat = 'yyyy-MM-dd';
|
||||
savingsCharge.dateFormat = dateFormat;
|
||||
if (savingsCharge.dueDate) {
|
||||
const prevDate = this.recurringDepositsChargeForm.value.dueDate;
|
||||
savingsCharge.dueDate = this.datePipe.transform(prevDate, dateFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.savingsService.createSavingsCharge(this.recurringDepositAccountId, 'charges', savingsCharge).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -3,3 +3,4 @@
|
||||
<mifosx-approve-recurring-deposits-account *ngIf="actions['Approve']"></mifosx-approve-recurring-deposits-account>
|
||||
<mifosx-reject-recurring-deposits-account *ngIf="actions['Reject']"></mifosx-reject-recurring-deposits-account>
|
||||
<mifosx-withdraw-by-client-recurring-deposits-account *ngIf="actions['Withdraw By Client']"></mifosx-withdraw-by-client-recurring-deposits-account>
|
||||
<mifosx-add-charge-recurring-deposits-account *ngIf="actions['Add Charge']"></mifosx-add-charge-recurring-deposits-account>
|
||||
|
||||
+3
-1
@@ -15,12 +15,14 @@ export class RecurringDepositsAccountActionsComponent {
|
||||
'Approve': boolean
|
||||
'Reject': boolean
|
||||
'Withdraw By Client': boolean
|
||||
'Add Charge': boolean
|
||||
} = {
|
||||
'Activate': false,
|
||||
'Undo Approval': false,
|
||||
'Approve': false,
|
||||
'Reject': false,
|
||||
'Withdraw By Client': false
|
||||
'Withdraw By Client': false,
|
||||
'Add Charge': false
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||
})
|
||||
export class ChargesTabComponent implements OnInit {
|
||||
|
||||
/** Fixed Deposits Account Data */
|
||||
/** Recurring Deposits Account Data */
|
||||
recurringDepositsAccountData: any;
|
||||
/** Charges Data */
|
||||
chargesData: any[];
|
||||
@@ -40,7 +40,7 @@ export class ChargesTabComponent implements OnInit {
|
||||
@ViewChild('chargesTable') chargesTableRef: MatTable<Element>;
|
||||
|
||||
/**
|
||||
* Retrieves Fixed Deposits Account Data from `resolve`.
|
||||
* Retrieves Recurring Deposits Account Data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ export class MultiRowComponent implements OnInit, OnChanges {
|
||||
private datePipe: DatePipe,
|
||||
private savingsService: SavingsService,
|
||||
private dialog: MatDialog) {
|
||||
this.accountId = this.route.parent.parent.snapshot.paramMap.get('fixedDepositAccountId');
|
||||
this.accountId = this.route.parent.parent.snapshot.paramMap.get('recurringDepositAccountId');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ export class SingleRowComponent implements OnInit {
|
||||
private datePipe: DatePipe,
|
||||
private dialog: MatDialog,
|
||||
private savingsService: SavingsService) {
|
||||
this.accountId = this.route.parent.parent.snapshot.paramMap.get('fixedDepositAccountId');
|
||||
this.accountId = this.route.parent.parent.snapshot.paramMap.get('recurringDepositAccountId');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -81,6 +81,7 @@ export class RecurringDepositsAccountViewComponent implements OnInit {
|
||||
case 'Approve':
|
||||
case 'Reject':
|
||||
case 'Undo Approval':
|
||||
case 'Add Charge':
|
||||
case 'Withdraw By Client':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
|
||||
@@ -21,6 +21,7 @@ import { RecurringDepositsAccountDataResolver } from './common-resolvers/recurri
|
||||
import { SavingsDatatableResolver } from 'app/savings/common-resolvers/savings-datatable.resolver';
|
||||
import { SavingsDatatablesResolver } from 'app/savings/common-resolvers/savings-datatables.resolver';
|
||||
import { RecurringDepositsAccountTemplateResolver } from './common-resolvers/recurring-deposits-account-template.resolver';
|
||||
import { RecurringDepositsAccountActionsResolver } from './common-resolvers/recurring-deposit-account-actions.resolver';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
@@ -95,6 +96,9 @@ const routes: Routes = [
|
||||
path: 'actions/:name',
|
||||
data: { title: extract('Recurring Deposits Account Actions'), routeParamBreadcrumb: 'name' },
|
||||
component: RecurringDepositsAccountActionsComponent,
|
||||
resolve: {
|
||||
recurringDepositsAccountActionData: RecurringDepositsAccountActionsResolver
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -110,7 +114,8 @@ const routes: Routes = [
|
||||
RecurringDepositsAccountDataResolver,
|
||||
SavingsDatatableResolver,
|
||||
SavingsDatatablesResolver,
|
||||
RecurringDepositsAccountTemplateResolver
|
||||
RecurringDepositsAccountTemplateResolver,
|
||||
RecurringDepositsAccountActionsResolver
|
||||
]
|
||||
})
|
||||
export class RecurringDepositsRoutingModule {}
|
||||
|
||||
@@ -31,6 +31,7 @@ import { UndoApprovalRecurringDepositsAccountComponent } from './recurring-depos
|
||||
import { ApproveRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/approve-recurring-deposits-account/approve-recurring-deposits-account.component';
|
||||
import { RejectRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/reject-recurring-deposits-account/reject-recurring-deposits-account.component';
|
||||
import { WithdrawByClientRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component';
|
||||
import { AddChargeRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component';
|
||||
|
||||
/**
|
||||
* RecurringDeposits Module
|
||||
@@ -66,7 +67,8 @@ import { WithdrawByClientRecurringDepositsAccountComponent } from './recurring-d
|
||||
UndoApprovalRecurringDepositsAccountComponent,
|
||||
ApproveRecurringDepositsAccountComponent,
|
||||
RejectRecurringDepositsAccountComponent,
|
||||
WithdrawByClientRecurringDepositsAccountComponent
|
||||
WithdrawByClientRecurringDepositsAccountComponent,
|
||||
AddChargeRecurringDepositsAccountComponent
|
||||
],
|
||||
providers: [DatePipe]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user