+30
@@ -0,0 +1,30 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="postInterestSavingsAccountForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Transaction Date</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="transactionDatePicker" required formControlName="transactionDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="transactionDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #transactionDatePicker></mat-datepicker>
|
||||
<mat-error *ngIf="postInterestSavingsAccountForm.controls.transactionDate.hasError('required')">
|
||||
Transaction Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
|
||||
<button type="button" mat-raised-button [routerLink]="['../../']">Cancel</button>
|
||||
<button mat-raised-button color="primary" [disabled]="!postInterestSavingsAccountForm.valid">Confirm</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PostInterestAsOnSavingsAccountComponent } from './post-interest-as-on-savings-account.component';
|
||||
|
||||
describe('PostInterestAsOnSavingsAccountComponent', () => {
|
||||
let component: PostInterestAsOnSavingsAccountComponent;
|
||||
let fixture: ComponentFixture<PostInterestAsOnSavingsAccountComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PostInterestAsOnSavingsAccountComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PostInterestAsOnSavingsAccountComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from 'app/savings/savings.service';
|
||||
|
||||
/**
|
||||
* Post Interest Savings Account Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-post-interest-as-on-savings-account',
|
||||
templateUrl: './post-interest-as-on-savings-account.component.html',
|
||||
styleUrls: ['./post-interest-as-on-savings-account.component.scss']
|
||||
})
|
||||
export class PostInterestAsOnSavingsAccountComponent implements OnInit {
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Post Interest Savings Account form. */
|
||||
postInterestSavingsAccountForm: FormGroup;
|
||||
/** Savings Account Id */
|
||||
accountId: any;
|
||||
|
||||
/**
|
||||
* @param {FormBuilder} formBuilder Form Builder
|
||||
* @param {SavingsService} savingsService Savings Service
|
||||
* @param {DatePipe} datePipe Date Pipe
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private savingsService: SavingsService,
|
||||
private datePipe: DatePipe,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.accountId = this.route.parent.snapshot.params['savingAccountId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the post interest savings form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createPostInterestSavingsAccountForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the post interest savings account form.
|
||||
*/
|
||||
createPostInterestSavingsAccountForm() {
|
||||
this.postInterestSavingsAccountForm = this.formBuilder.group({
|
||||
'transactionDate': ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the form and post interests of the saving account,
|
||||
* if successful redirects to the saving account.
|
||||
*/
|
||||
submit() {
|
||||
// TODO: Update once language and date settings are setup
|
||||
const locale = 'en';
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
const prevTransactionDate: Date = this.postInterestSavingsAccountForm.value.transactionDate;
|
||||
this.postInterestSavingsAccountForm.patchValue({
|
||||
transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat),
|
||||
});
|
||||
const data = {
|
||||
...this.postInterestSavingsAccountForm.value,
|
||||
IsPostInterestAsOn: true,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.savingsService.executeSavingsAccountTransactionsCommand(this.accountId, 'postInterestAsOn', data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,4 +2,5 @@
|
||||
<mifosx-reject-savings-account *ngIf="actions['Reject']"></mifosx-reject-savings-account>
|
||||
<mifosx-withdraw-savings-account *ngIf="actions['Withdraw']"></mifosx-withdraw-savings-account>
|
||||
<mifosx-activate-savings-account *ngIf="actions['Activate']"></mifosx-activate-savings-account>
|
||||
<mifosx-undo-approval-savings-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-savings-account>
|
||||
<mifosx-undo-approval-savings-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-savings-account>
|
||||
<mifosx-post-interest-as-on-savings-account *ngIf="actions['Post Interest As On']"></mifosx-post-interest-as-on-savings-account>
|
||||
@@ -21,12 +21,14 @@ export class SavingAccountActionsComponent {
|
||||
'Withdraw': boolean
|
||||
'Activate': boolean
|
||||
'Undo Approval': boolean
|
||||
'Post Interest As On': boolean
|
||||
} = {
|
||||
'Approve': false,
|
||||
'Reject': false,
|
||||
'Withdraw': false,
|
||||
'Activate': false,
|
||||
'Undo Approval': false
|
||||
'Undo Approval': false,
|
||||
'Post Interest As On': false
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -103,6 +103,7 @@ export class SavingsAccountViewComponent implements OnInit {
|
||||
case 'Withdraw':
|
||||
case 'Activate':
|
||||
case 'Undo Approval':
|
||||
case 'Post Interest As On':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Modify Application':
|
||||
|
||||
@@ -30,6 +30,7 @@ import { RejectSavingsAccountComponent } from './saving-account-actions/reject-s
|
||||
import { WithdrawSavingsAccountComponent } from './saving-account-actions/withdraw-savings-account/withdraw-savings-account.component';
|
||||
import { ActivateSavingsAccountComponent } from './saving-account-actions/activate-savings-account/activate-savings-account.component';
|
||||
import { UndoApprovalSavingsAccountComponent } from './saving-account-actions/undo-approval-savings-account/undo-approval-savings-account.component';
|
||||
import { PostInterestAsOnSavingsAccountComponent } from './saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component';
|
||||
|
||||
/**
|
||||
* Savings Module
|
||||
@@ -64,7 +65,8 @@ import { UndoApprovalSavingsAccountComponent } from './saving-account-actions/un
|
||||
RejectSavingsAccountComponent,
|
||||
WithdrawSavingsAccountComponent,
|
||||
ActivateSavingsAccountComponent,
|
||||
UndoApprovalSavingsAccountComponent
|
||||
UndoApprovalSavingsAccountComponent,
|
||||
PostInterestAsOnSavingsAccountComponent
|
||||
],
|
||||
providers: [DatePipe]
|
||||
})
|
||||
|
||||
@@ -194,4 +194,15 @@ export class SavingsService {
|
||||
return this.http.post(`/savingsaccounts/${accountId}`, data, { params: httpParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} accountId Savings Account Id
|
||||
* @param {string} command Command
|
||||
* @param {any} data Data
|
||||
* @returns {Observable<any>} Savings data.
|
||||
*/
|
||||
executeSavingsAccountTransactionsCommand(accountId: string, command: string, data: any): Observable<any> {
|
||||
const httpParams = new HttpParams().set('command', command);
|
||||
return this.http.post(`/savingsaccounts/${accountId}/transactions`, data, { params: httpParams });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user