Clients search enhancement (#1605)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2022-12-26 14:25:49 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent 475059a974
commit d0dc2aabb2
29 changed files with 514 additions and 234 deletions
@@ -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 });
});
}
@@ -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>
@@ -0,0 +1,3 @@
.container {
width: 37rem;
}
@@ -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();
});
});
@@ -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
};
/**
@@ -0,0 +1,8 @@
<h1 mat-dialog-title>Release Amount</h1>
<div mat-dialog-content>
<p>Are you sure you want to release this amount ?</p>
</div>
<mat-dialog-actions align="end">
<button mat-raised-button mat-dialog-close>Cancel</button>
<button mat-raised-button color="warn" [mat-dialog-close]="{ confirm: true }">Confirm</button>
</mat-dialog-actions>
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReleaseAmountDialogComponent } from './release-amount-dialog.component';
describe('ReleaseAmountDialogComponent', () => {
let component: ReleaseAmountDialogComponent;
let fixture: ComponentFixture<ReleaseAmountDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ReleaseAmountDialogComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ReleaseAmountDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
@Component({
selector: 'mifosx-release-amount-dialog',
templateUrl: './release-amount-dialog.component.html',
styleUrls: ['./release-amount-dialog.component.scss']
})
export class ReleaseAmountDialogComponent {
/**
* @param {MatDialogRef} dialogRef Component reference to dialog.
*/
constructor(public dialogRef: MatDialogRef<ReleaseAmountDialogComponent>) { }
}
@@ -135,6 +135,9 @@ export class SavingsAccountViewComponent implements OnInit {
case 'Post Interest As On':
case 'Assign Staff':
case 'Add Charge':
case 'Hold Amount':
case 'Block Account':
case 'Unblock Account':
case 'Unassign Staff':
case 'Withdraw By Client':
case 'Apply Annual Fees':
@@ -39,6 +39,11 @@ export class SavingsButtonsConfiguration {
icon: 'arrow-down',
taskPermissionName: 'WITHDRAW_SAVINGSACCOUNT'
},
{
name: 'Hold Amount',
icon: 'lock',
taskPermissionName: 'HOLDAMOUNT_SAVINGSACCOUNT'
},
{
name: 'Calculate Interest',
icon: 'table',
@@ -1,17 +1,20 @@
<div fxLayoutAlign="end" class="container m-b-20" fxLayoutGap="2%"
*ngIf="!(transactionData.interestedPostedAsOn === false && (transactionData.transactionType.id === 17 || transactionData.transactionType.id === 3))">
<span *mifosxHasPermission="'ADJUSTTRANSACTION_SAVINGSACCOUNT'">
<button mat-raised-button color="primary"
*ngIf="transactionData.transactionType.value == 'Transfer' || transactionData.reversed == 'true'
|| transactionData.transactionType.id==3 || transactionData.transactionType.id==17"
[routerLink]="'edit'">
<fa-icon icon="edit"></fa-icon>&nbsp;&nbsp;Edit
<button mat-raised-button color="primary" *ngIf="transactionData.transactionType.value == 'Transfer' || transactionData.reversed == 'true'
|| transactionData.transactionType.id==3 || transactionData.transactionType.id==17" [routerLink]="'edit'">
<fa-icon icon="edit" class="m-r-10"></fa-icon>Edit
</button>
</span>
<button mat-raised-button color="warn"
*mifosxHasPermission="'UNDOTRANSACTION_SAVINGSACCOUNT'"
(click)="undoTransaction()">
<fa-icon icon="undo"></fa-icon>&nbsp;&nbsp;Undo
<span *ngIf="!transactionData.reversed && transactionData.transactionType.amountHold">
<button mat-raised-button color="primary" *mifosxHasPermission="'RELEASEAMOUNT_SAVINGSACCOUNT'"
(click)="releaseAmount()">
<fa-icon icon="lock-open" class="m-r-10"></fa-icon>Release Amount
</button>
</span>
<button mat-raised-button color="warn" *mifosxHasPermission="'UNDOTRANSACTION_SAVINGSACCOUNT'"
(click)="undoTransaction()" [disabled]="transactionData.reversed">
<fa-icon icon="undo" class="m-r-10"></fa-icon>Undo
</button>
</div>
@@ -30,7 +33,7 @@
<div fxFlex="50%">
{{ transactionData.id }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Type
</div>
@@ -44,7 +47,7 @@
</div>
<div fxFlex="50%">
{{ transactionData.date | dateFormat }}
{{ transactionData.date | dateFormat }}
</div>
<div fxFlex="50%" class="mat-body-strong">
@@ -76,47 +79,47 @@
<div *ngIf="transactionData.paymentDetailData.paymentType" fxFlex="50%" class="mat-body-strong">
Payment Type
</div>
<div *ngIf="transactionData.paymentDetailData.paymentType" fxFlex="50%">
{{ transactionData.paymentDetailData.paymentType.name }}
</div>
<div *ngIf="transactionData.paymentDetailData.accountNumber" fxFlex="50%" class="mat-body-strong">
Account No.
</div>
<div *ngIf="transactionData.paymentDetailData.accountNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.accountNumber }}
</div>
<div *ngIf="transactionData.paymentDetailData.checkNumber" fxFlex="50%" class="mat-body-strong">
Cheque Number
</div>
<div *ngIf="transactionData.paymentDetailData.checkNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.checkNumber }}
</div>
<div *ngIf="transactionData.paymentDetailData.routingCode" fxFlex="50%" class="mat-body-strong">
Routing Code
</div>
<div *ngIf="transactionData.paymentDetailData.routingCode" fxFlex="50%">
{{ transactionData.paymentDetailData.routingCode }}
</div>
<div *ngIf="transactionData.paymentDetailData.receiptNumber" fxFlex="50%" class="mat-body-strong">
Receipt No.
</div>
<div *ngIf="transactionData.paymentDetailData.receiptNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.receiptNumber }}
</div>
<div *ngIf="transactionData.paymentDetailData.bankNumber" fxFlex="50%" class="mat-body-strong">
Bank No.
</div>
<div *ngIf="transactionData.paymentDetailData.bankNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.bankNumber }}
</div>
@@ -125,6 +128,9 @@
</div>
<div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="2%" fxLayout.lt-md="column">
<button type="button" mat-raised-button color="primary" [routerLink]="['../']">{{ 'Back' | translate }}</button>
</div>
</mat-card-content>
</mat-card>
@@ -10,6 +10,7 @@ import { SettingsService } from 'app/settings/settings.service';
/** Custom Dialogs */
import { UndoTransactionDialogComponent } from '../../custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component';
import { Dates } from 'app/core/utils/dates';
import { ReleaseAmountDialogComponent } from '../../custom-dialogs/release-amount-dialog/release-amount-dialog.component';
/**
* View Transaction Component.
@@ -25,6 +26,8 @@ export class ViewTransactionComponent {
/** Transaction data. */
transactionData: any;
accountId: string;
/**
* Retrieves the Transaction data from `resolve`.
* @param {SavingsService} savingsService Savings Service
@@ -41,7 +44,9 @@ export class ViewTransactionComponent {
public dialog: MatDialog,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { savingsAccountTransaction: any }) => {
this.accountId = this.route.parent.snapshot.params['savingAccountId'];
this.transactionData = data.savingsAccountTransaction;
console.log(this.transactionData);
});
}
@@ -49,7 +54,6 @@ export class ViewTransactionComponent {
* Undo the savings transaction
*/
undoTransaction() {
const accountId = this.route.parent.snapshot.params['savingAccountId'];
const undoTransactionAccountDialogRef = this.dialog.open(UndoTransactionDialogComponent);
undoTransactionAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.confirm) {
@@ -61,7 +65,19 @@ export class ViewTransactionComponent {
dateFormat,
locale
};
this.savingsService.executeSavingsAccountTransactionsCommand(accountId, 'undo', data, this.transactionData.id).subscribe(() => {
this.savingsService.executeSavingsAccountTransactionsCommand(this.accountId, 'undo', data, this.transactionData.id).subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
});
}
releaseAmount() {
const releaseAmountDialogRef = this.dialog.open(ReleaseAmountDialogComponent);
releaseAmountDialogRef.afterClosed().subscribe((response: any) => {
if (response.confirm) {
const data = { };
this.savingsService.executeSavingsAccountTransactionsCommand(this.accountId, 'releaseAmount', data, this.transactionData.id).subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
+5 -1
View File
@@ -47,6 +47,8 @@ import { EditTransactionComponent } from './savings-account-view/transactions/ed
import { ApplyAnnualFeesSavingsAccountComponent } from './saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component';
import { GsimAccountComponent } from './gsim-account/gsim-account.component';
import { CreateGsimAccountComponent } from './gsim-account/create-gsim-account/create-gsim-account.component';
import { ManageSavingsAccountComponent } from './saving-account-actions/manage-savings-account/manage-savings-account.component';
import { ReleaseAmountDialogComponent } from './savings-account-view/custom-dialogs/release-amount-dialog/release-amount-dialog.component';
/**
@@ -100,7 +102,9 @@ import { CreateGsimAccountComponent } from './gsim-account/create-gsim-account/c
EditTransactionComponent,
ApplyAnnualFeesSavingsAccountComponent,
GsimAccountComponent,
CreateGsimAccountComponent
CreateGsimAccountComponent,
ManageSavingsAccountComponent,
ReleaseAmountDialogComponent
],
providers: [ ]
})