Clients search enhancement (#1605)
Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
co-authored by
Jose Alberto Hernandez
parent
475059a974
commit
d0dc2aabb2
+1
-1
@@ -128,7 +128,7 @@ export class CloseSavingsAccountComponent implements OnInit {
|
||||
locale
|
||||
};
|
||||
this.savingsService.executeSavingsAccountCommand(this.accountId, 'close', data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
this.router.navigate(['../../transactions'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<div class="container mat-elevation-z8">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<h2 mat-title *ngIf="transactionType.holdamount">Hold Amount</h2>
|
||||
<h2 mat-title *ngIf="transactionType.blockaccount">Block Savings Account</h2>
|
||||
<h2 mat-title *ngIf="transactionType.unblockaccount">Unblock Savings Account</h2>
|
||||
|
||||
<form [formGroup]="manageSavingsAccountForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content fxLayout="column">
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Reason</mat-label>
|
||||
<mat-select required formControlName="reasonForBlock">
|
||||
<mat-option *ngFor="let codeValue of reasonOptions" [value]="codeValue.id">
|
||||
{{ codeValue.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="manageSavingsAccountForm.controls.reasonForBlock.hasError('required')">
|
||||
Reason is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field fxFlex (click)="transactionDatePicker.open()" *ngIf="transactionType.holdamount">
|
||||
<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="manageSavingsAccountForm.controls.transactionDate.hasError('required')">
|
||||
Transaction Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="transactionType.holdamount">
|
||||
<mat-label>Transaction Amount</mat-label>
|
||||
<input type="number" formControlName="transactionAmount" required matInput />
|
||||
<mat-error *ngIf="manageSavingsAccountForm.controls.transactionAmount.hasError('required')">
|
||||
Transaction Amount 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]="['../../transactions']">Cancel</button>
|
||||
<button mat-raised-button color="primary" [disabled]="!manageSavingsAccountForm.valid">Confirm</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
width: 37rem;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ManageSavingsAccountComponent } from './manage-savings-account.component';
|
||||
|
||||
describe('ManageSavingsAccountComponent', () => {
|
||||
let component: ManageSavingsAccountComponent;
|
||||
let fixture: ComponentFixture<ManageSavingsAccountComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ManageSavingsAccountComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ManageSavingsAccountComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
import { SavingsService } from 'app/savings/savings.service';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
import { SystemService } from 'app/system/system.service';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-manage-savings-account',
|
||||
templateUrl: './manage-savings-account.component.html',
|
||||
styleUrls: ['./manage-savings-account.component.scss']
|
||||
})
|
||||
export class ManageSavingsAccountComponent implements OnInit {
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Manage Savings Account form. */
|
||||
manageSavingsAccountForm: FormGroup;
|
||||
/** Savings Account Id */
|
||||
savingAccountId: string;
|
||||
transactionCommand: string;
|
||||
|
||||
reasonOptions: any = [];
|
||||
|
||||
transactionType: {
|
||||
holdamount: boolean,
|
||||
blockaccount: boolean,
|
||||
unblockaccount: boolean
|
||||
} = {
|
||||
holdamount: false, blockaccount: false, unblockaccount: false };
|
||||
|
||||
/**
|
||||
* @param {FormBuilder} formBuilder Form Builder
|
||||
* @param {SavingsService} savingsService Savings Service
|
||||
* @param {Dates} dateUtils Date Utils
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
* @param {SettingsService} settingsService Setting service
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private savingsService: SavingsService,
|
||||
private dateUtils: Dates,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private systemService: SystemService,
|
||||
private settingsService: SettingsService) {
|
||||
this.transactionCommand = this.route.snapshot.params['name'].toLowerCase().replaceAll(' ', '');
|
||||
this.transactionType[this.transactionCommand] = true;
|
||||
this.savingAccountId = this.route.parent.snapshot.params['savingAccountId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the post interest savings form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.maxDate = this.settingsService.businessDate;
|
||||
this.createManageSavingsAccountForm();
|
||||
if (this.transactionType.holdamount || this.transactionType.blockaccount) {
|
||||
this.getCodeValues();
|
||||
}
|
||||
}
|
||||
|
||||
getCodeValues() {
|
||||
let codeName = 'SavingsTransactionFreezeReasons'; // Default Hold Amount
|
||||
if (this.transactionType.blockaccount) {
|
||||
codeName = 'SavingsAccountBlockReasons';
|
||||
}
|
||||
|
||||
this.systemService.getCodes().subscribe((codes: any) => {
|
||||
codes.some((code: any) => {
|
||||
if (code.name === codeName) {
|
||||
this.systemService.getCodeValues(code.id).subscribe((codeValues: any) => {
|
||||
this.reasonOptions = codeValues;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the post interest savings account form.
|
||||
*/
|
||||
createManageSavingsAccountForm() {
|
||||
if (this.transactionType.holdamount) {
|
||||
this.manageSavingsAccountForm = this.formBuilder.group({
|
||||
'reasonForBlock': ['', Validators.required],
|
||||
'transactionDate': ['', Validators.required],
|
||||
'transactionAmount': [0.0, Validators.required]
|
||||
});
|
||||
} else {
|
||||
this.manageSavingsAccountForm = this.formBuilder.group({
|
||||
'reasonForBlock': ['', Validators.required]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
submit() {
|
||||
let command = '';
|
||||
let payload = { };
|
||||
|
||||
if (this.transactionType.holdamount) {
|
||||
const manageSavingsAccountFormData = this.manageSavingsAccountForm.value;
|
||||
const locale = this.settingsService.language.code;
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
const prevTransactionDate: Date = this.manageSavingsAccountForm.value.transactionDate;
|
||||
if (manageSavingsAccountFormData.transactionDate instanceof Date) {
|
||||
manageSavingsAccountFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat);
|
||||
}
|
||||
payload = {
|
||||
...manageSavingsAccountFormData,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
command = 'holdAmount';
|
||||
|
||||
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, command, payload).subscribe((response: any) => {
|
||||
console.log(response);
|
||||
this.router.navigate(['../../transactions'], { relativeTo: this.route });
|
||||
});
|
||||
} else {
|
||||
payload = {
|
||||
... this.manageSavingsAccountForm.value
|
||||
}
|
||||
if (this.transactionType.blockaccount) {
|
||||
command = 'block';
|
||||
}
|
||||
|
||||
this.savingsService.executeSavingsAccountCommand(this.savingAccountId, command, payload).subscribe((response: any) => {
|
||||
console.log(response);
|
||||
this.router.navigate(['../../transactions'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,3 +10,4 @@
|
||||
<mifosx-savings-transactions *ngIf="actions['Withdrawal'] || actions['Deposit']"></mifosx-savings-transactions>
|
||||
<mifosx-close-savings-account *ngIf="actions['Close']"></mifosx-close-savings-account>
|
||||
<mifosx-apply-annual-fees-savings-account *ngIf="actions['Apply Annual Fees']"></mifosx-apply-annual-fees-savings-account>
|
||||
<mifosx-manage-savings-account *ngIf="actions['Hold Amount']"></mifosx-manage-savings-account>
|
||||
|
||||
@@ -27,6 +27,9 @@ export class SavingAccountActionsComponent {
|
||||
'Unassign Staff': boolean
|
||||
'Withdraw By Client': boolean
|
||||
'Apply Annual Fees': boolean
|
||||
'Hold Amount': boolean
|
||||
'Block Account': boolean
|
||||
'Unblock Account': boolean
|
||||
} = {
|
||||
'Approve': false,
|
||||
'Reject': false,
|
||||
@@ -40,7 +43,10 @@ export class SavingAccountActionsComponent {
|
||||
'Add Charge': false,
|
||||
'Unassign Staff': false,
|
||||
'Withdraw By Client': false,
|
||||
'Apply Annual Fees': false
|
||||
'Apply Annual Fees': false,
|
||||
'Hold Amount': false,
|
||||
'Block Account': false,
|
||||
'Unblock Account': false
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user