feat: savings account actions (unassign-staff) (#927)

Fixes: #926
This commit is contained in:
Karan Takalkar
2020-06-26 19:54:48 +05:30
committed by GitHub
parent b4c5b4716c
commit cded123bee
8 changed files with 151 additions and 3 deletions
@@ -4,4 +4,5 @@
<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-post-interest-as-on-savings-account *ngIf="actions['Post Interest As On']"></mifosx-post-interest-as-on-savings-account>
<mifosx-savings-account-assign-staff [savingsAccountData]="savingsAccountData" *ngIf="actions['Assign Staff']"></mifosx-savings-account-assign-staff>
<mifosx-savings-account-assign-staff [savingsAccountData]="savingsAccountData" *ngIf="actions['Assign Staff']"></mifosx-savings-account-assign-staff>
<mifosx-savings-account-unassign-staff *ngIf="actions['Unassign Staff']"></mifosx-savings-account-unassign-staff>
@@ -23,13 +23,17 @@ export class SavingAccountActionsComponent {
'Activate': boolean
'Undo Approval': boolean
'Post Interest As On': boolean
'Assign Staff': boolean
'Unassign Staff': boolean
} = {
'Approve': false,
'Reject': false,
'Withdraw': false,
'Activate': false,
'Undo Approval': false,
'Post Interest As On': false
'Post Interest As On': false,
'Assign Staff': false,
'Unassign Staff': false
};
/**
@@ -0,0 +1,30 @@
<div class="container">
<mat-card>
<form [formGroup]="savingsUnassignStaffForm" (ngSubmit)="submit()">
<mat-card-content>
<mat-form-field fxFlex>
<mat-label>Unassignment Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="unassignedDatePicker" required formControlName="unassignedDate">
<mat-datepicker-toggle matSuffix [for]="unassignedDatePicker"></mat-datepicker-toggle>
<mat-datepicker #unassignedDatePicker></mat-datepicker>
<mat-error *ngIf="savingsUnassignStaffForm.controls.unassignedDate.hasError('required')">
Unassignment 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]="!savingsUnassignStaffForm.valid">Confirm</button>
</mat-card-actions>
</form>
</mat-card>
</div>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SavingsAccountUnassignStaffComponent } from './savings-account-unassign-staff.component';
describe('SavingsAccountUnassignStaffComponent', () => {
let component: SavingsAccountUnassignStaffComponent;
let fixture: ComponentFixture<SavingsAccountUnassignStaffComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SavingsAccountUnassignStaffComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SavingsAccountUnassignStaffComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,82 @@
/** Angular Imports */
import { Component, OnInit, Input } 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';
/**
* Savings Account Unassign Staff Component
*/
@Component({
selector: 'mifosx-savings-account-unassign-staff',
templateUrl: './savings-account-unassign-staff.component.html',
styleUrls: ['./savings-account-unassign-staff.component.scss']
})
export class SavingsAccountUnassignStaffComponent implements OnInit {
/** Minimum date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum date allowed. */
maxDate = new Date();
/** Savings Account Unassign Staff form. */
savingsUnassignStaffForm: 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 savings account unassign staff form.
*/
ngOnInit() {
this.createSavingsUnassignStaffForm();
}
/**
* Creates the savings account unassign staff form.
*/
createSavingsUnassignStaffForm() {
this.savingsUnassignStaffForm = this.formBuilder.group({
'unassignedDate': ['', Validators.required]
});
}
/**
* Submits the form and unassigns staff 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 prevUnassignmentDate: Date = this.savingsUnassignStaffForm.value.unassignedDate;
this.savingsUnassignStaffForm.patchValue({
unassignedDate: this.datePipe.transform(prevUnassignmentDate, dateFormat),
});
const data = {
...this.savingsUnassignStaffForm.value,
dateFormat,
locale
};
this.savingsService.executeSavingsAccountCommand(this.accountId, 'unassignSavingsOfficer', data).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
}
@@ -105,6 +105,7 @@ export class SavingsAccountViewComponent implements OnInit {
case 'Undo Approval':
case 'Post Interest As On':
case 'Assign Staff':
case 'Unassign Staff':
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
break;
case 'Modify Application':
+3 -1
View File
@@ -32,6 +32,7 @@ import { ActivateSavingsAccountComponent } from './saving-account-actions/activa
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';
import { SavingsAccountAssignStaffComponent } from './saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component';
import { SavingsAccountUnassignStaffComponent } from './saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component';
/**
* Savings Module
@@ -68,7 +69,8 @@ import { SavingsAccountAssignStaffComponent } from './saving-account-actions/sav
ActivateSavingsAccountComponent,
UndoApprovalSavingsAccountComponent,
PostInterestAsOnSavingsAccountComponent,
SavingsAccountAssignStaffComponent
SavingsAccountAssignStaffComponent,
SavingsAccountUnassignStaffComponent
],
providers: [DatePipe]
})