feat: add Current Account module, DIP verification, charges integration, and translations
- Current Account module with full CRUD, transactions, charges, hold/release, block/unblock - Current Products management under Products module - DIP mobile number verification with real API call to /lookup/check - Sanctions verification dialog - Charges support for Current Account (chargeAppliesTo=5) in create/edit - Fixed permissions from SAVINGSACCOUNT to CURRENTACCOUNT across all current account components - Added all missing translation keys for Current Account in en-US.json Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
73aa69ee02
commit
0a32d7135e
@@ -0,0 +1,387 @@
|
||||
/**
|
||||
* Copyright since 2025 Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { ActivatedRoute, Router, RouterLinkActive, RouterLink, RouterOutlet } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
/** Custom Dialogs */
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
import { CalculateInterestDialogComponent } from './custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component';
|
||||
import { PostInterestDialogComponent } from './custom-dialogs/post-interest-dialog/post-interest-dialog.component';
|
||||
import { ToggleWithholdTaxDialogComponent } from './custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component';
|
||||
|
||||
/** Custom Buttons Configuration */
|
||||
import { CurrentAccountButtonsConfiguration } from './current-accounts-buttons.config';
|
||||
import { CurrentAccountsService } from '../current-accounts.service';
|
||||
import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component';
|
||||
import { Currency } from 'app/shared/models/general.model';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
/** Environment Configuration */
|
||||
import { environment } from '../../../environments/environment';
|
||||
import {
|
||||
MatCard,
|
||||
MatCardHeader,
|
||||
MatCardTitleGroup,
|
||||
MatCardMdImage,
|
||||
MatCardTitle,
|
||||
MatCardContent
|
||||
} from '@angular/material/card';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { NgClass, CurrencyPipe } from '@angular/common';
|
||||
import { LongTextComponent } from '../../shared/long-text/long-text.component';
|
||||
import { AccountNumberComponent } from '../../shared/account-number/account-number.component';
|
||||
import { MatIconButton } from '@angular/material/button';
|
||||
import { MatMenuTrigger, MatMenu, MatMenuItem } from '@angular/material/menu';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { MatTabNav, MatTabLink, MatTabNavPanel } from '@angular/material/tabs';
|
||||
import { StatusLookupPipe } from '../../pipes/status-lookup.pipe';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
|
||||
/**
|
||||
* Current Account View Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-current-account-account-view',
|
||||
templateUrl: './current-account-view.component.html',
|
||||
styleUrls: ['./current-account-view.component.scss'],
|
||||
imports: [
|
||||
...STANDALONE_SHARED_IMPORTS,
|
||||
MatCardHeader,
|
||||
MatCardTitleGroup,
|
||||
MatCardMdImage,
|
||||
MatTooltip,
|
||||
MatCardTitle,
|
||||
NgClass,
|
||||
LongTextComponent,
|
||||
AccountNumberComponent,
|
||||
MatIconButton,
|
||||
MatMenuTrigger,
|
||||
MatIcon,
|
||||
FaIconComponent,
|
||||
MatMenu,
|
||||
MatMenuItem,
|
||||
MatTabNav,
|
||||
MatTabLink,
|
||||
RouterLinkActive,
|
||||
MatTabNavPanel,
|
||||
RouterOutlet,
|
||||
CurrencyPipe,
|
||||
StatusLookupPipe
|
||||
]
|
||||
})
|
||||
export class CurrentAccountViewComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private currentAccountsService = inject(CurrentAccountsService);
|
||||
private translateService = inject(TranslateService);
|
||||
dialog = inject(MatDialog);
|
||||
|
||||
/** Current Account Data */
|
||||
currentAccountData: any;
|
||||
/** Current Account Data Tables */
|
||||
currentAccountDatatables: any;
|
||||
/** Button Configurations */
|
||||
buttonConfig: CurrentAccountButtonsConfiguration;
|
||||
/** Entity Type */
|
||||
entityType: string;
|
||||
|
||||
isActive = false;
|
||||
currency: Currency;
|
||||
|
||||
/**
|
||||
* Fetches current account data from `resolve`
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
* @param {CurrentAccountsService} currentAccountsService Current Accounts Service
|
||||
*/
|
||||
constructor() {
|
||||
this.route.data.subscribe((data: { currentAccountData: any; currentAccountDatatables: any }) => {
|
||||
this.currentAccountData = data.currentAccountData;
|
||||
this.currency = this.currentAccountData.currency;
|
||||
this.currentAccountDatatables = data.currentAccountDatatables;
|
||||
});
|
||||
if (this.router.url.includes('clients')) {
|
||||
this.entityType = 'Client';
|
||||
} else if (this.router.url.includes('groups')) {
|
||||
this.entityType = 'Group';
|
||||
} else if (this.router.url.includes('centers')) {
|
||||
this.entityType = 'Center';
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.setConditionalButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds options to button config. conditionaly.
|
||||
*/
|
||||
setConditionalButtons() {
|
||||
const status = this.currentAccountData.status.value;
|
||||
this.isActive = status === 'Active';
|
||||
const subStatus = this.currentAccountData.subStatus;
|
||||
this.buttonConfig = new CurrentAccountButtonsConfiguration(status, subStatus);
|
||||
if (this.currentAccountData.clientId) {
|
||||
this.buttonConfig.addOption({
|
||||
name: 'Transfer Funds',
|
||||
taskPermissionName: 'CREATE_ACCOUNTTRANSFER'
|
||||
});
|
||||
}
|
||||
if (this.currentAccountData.externalId && environment.mifosInterbankTransfersEnabled) {
|
||||
this.buttonConfig.addOption({
|
||||
name: 'Interbank Transfer',
|
||||
taskPermissionName: 'CREATE_ACCOUNTTRANSFER'
|
||||
});
|
||||
}
|
||||
if (!this.currentAccountData.fieldOfficerId) {
|
||||
this.buttonConfig.addOption({
|
||||
name: 'Assign Staff',
|
||||
taskPermissionName: 'UPDATESAVINGSOFFICER_CURRENTACCOUNT'
|
||||
});
|
||||
} else {
|
||||
this.buttonConfig.addOption({
|
||||
name: 'Unassign Staff',
|
||||
taskPermissionName: 'REMOVESAVINGSOFFICER_CURRENTACCOUNT'
|
||||
});
|
||||
}
|
||||
if (this.currentAccountData.charges) {
|
||||
const charges: any[] = this.currentAccountData.charges;
|
||||
charges.forEach((charge: any) => {
|
||||
if (charge.name === 'Annual fee - INR') {
|
||||
this.buttonConfig.addOption({
|
||||
name: 'Apply Annual Fees',
|
||||
taskPermissionName: 'APPLYANNUALFEE_CURRENTACCOUNT'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.currentAccountData.taxGroup) {
|
||||
if (this.currentAccountData.withHoldTax) {
|
||||
this.buttonConfig.addOption({
|
||||
name: 'Disable Withhold Tax',
|
||||
taskPermissionName: 'UPDATEWITHHOLDTAX_CURRENTACCOUNT'
|
||||
});
|
||||
} else {
|
||||
this.buttonConfig.addOption({
|
||||
name: 'Enable Withhold Tax',
|
||||
taskPermissionName: 'UPDATEWITHHOLDTAX_CURRENTACCOUNT'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refetches data foe the component
|
||||
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
|
||||
*/
|
||||
private reload() {
|
||||
const url: string = this.router.url;
|
||||
const refreshUrl: string = this.router.url.slice(
|
||||
0,
|
||||
this.router.url.indexOf('current-accounts') + 'current-accounts'.length
|
||||
);
|
||||
this.router.navigateByUrl(refreshUrl, { skipLocationChange: true }).then(() => this.router.navigate([url]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs action button/option action.
|
||||
* @param {string} name action name.
|
||||
*/
|
||||
doAction(name: string) {
|
||||
switch (name) {
|
||||
case 'Approve':
|
||||
case 'Reject':
|
||||
case 'Deposit':
|
||||
case 'Activate':
|
||||
case 'Close':
|
||||
case 'Undo Approval':
|
||||
case 'Post Interest As On':
|
||||
case 'Assign Staff':
|
||||
case 'Add Charge':
|
||||
case 'Hold Amount':
|
||||
case 'Block Account':
|
||||
case 'Block Deposit':
|
||||
case 'Block Withdrawal':
|
||||
case 'Unassign Staff':
|
||||
case 'Withdrawn by Client':
|
||||
case 'Apply Annual Fees':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Withdrawal':
|
||||
this.router.navigate([`actions/Withdrawal`], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Modify Application':
|
||||
this.router.navigate(['edit'], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Delete':
|
||||
this.deleteCurrentAccount();
|
||||
break;
|
||||
case 'Calculate Interest':
|
||||
this.calculateInterest();
|
||||
break;
|
||||
case 'Post Interest':
|
||||
this.postInterest();
|
||||
break;
|
||||
case 'Enable Withhold Tax':
|
||||
this.enableWithHoldTax();
|
||||
break;
|
||||
case 'Disable Withhold Tax':
|
||||
this.disableWithHoldTax();
|
||||
break;
|
||||
case 'Transfer Funds':
|
||||
const queryParams: any = {
|
||||
interbank: false,
|
||||
currentAccountId: this.currentAccountData.id,
|
||||
accountType: 'fromcurrentaccount'
|
||||
};
|
||||
this.router.navigate(['transfer-funds/make-account-transfer'], {
|
||||
relativeTo: this.route,
|
||||
queryParams: queryParams,
|
||||
state: { balance: this.currentAccountData.summary.availableBalance }
|
||||
});
|
||||
break;
|
||||
case 'Interbank Transfer': {
|
||||
const queryParams: any = {
|
||||
interbank: true,
|
||||
currentAccountId: this.currentAccountData.id,
|
||||
accountType: 'interbank'
|
||||
};
|
||||
this.router.navigate(['transfer-funds/make-account-transfer'], {
|
||||
relativeTo: this.route,
|
||||
queryParams: queryParams,
|
||||
state: { balance: this.currentAccountData.summary.availableBalance }
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'Unblock Account':
|
||||
case 'Unblock Deposit':
|
||||
case 'Unblock Withdrawal':
|
||||
this.unblockCurrentAccount(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes Current Account.
|
||||
*/
|
||||
private deleteCurrentAccount() {
|
||||
const deleteCurrentAccountDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `current account with id: ${this.currentAccountData.id}` }
|
||||
});
|
||||
deleteCurrentAccountDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.currentAccountsService.deleteCurrentAccount(this.currentAccountData.id).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates current account's interest
|
||||
*/
|
||||
private calculateInterest() {
|
||||
const calculateInterestAccountDialogRef = this.dialog.open(CalculateInterestDialogComponent);
|
||||
calculateInterestAccountDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.confirm) {
|
||||
this.currentAccountsService
|
||||
.executeCurrentAccountCommand(this.currentAccountData.id, 'calculateInterest', {})
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts current account's interest
|
||||
*/
|
||||
private postInterest() {
|
||||
const postInterestAccountDialogRef = this.dialog.open(PostInterestDialogComponent);
|
||||
postInterestAccountDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.confirm) {
|
||||
this.currentAccountsService
|
||||
.executeCurrentAccountCommand(this.currentAccountData.id, 'postInterest', {})
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables withhold tax for current account.
|
||||
*/
|
||||
private enableWithHoldTax() {
|
||||
const deleteCurrentAccountDialogRef = this.dialog.open(ToggleWithholdTaxDialogComponent, {
|
||||
data: { isEnable: true }
|
||||
});
|
||||
deleteCurrentAccountDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.confirm) {
|
||||
this.currentAccountsService
|
||||
.executeCurrentAccountUpdateCommand(this.currentAccountData.id, 'updateWithHoldTax', { withHoldTax: true })
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables withhold tac for current account
|
||||
*/
|
||||
private disableWithHoldTax() {
|
||||
const disableWithHoldTaxDialogRef = this.dialog.open(ToggleWithholdTaxDialogComponent, {
|
||||
data: { isEnable: false }
|
||||
});
|
||||
disableWithHoldTaxDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.confirm) {
|
||||
this.currentAccountsService
|
||||
.executeCurrentAccountUpdateCommand(this.currentAccountData.id, 'updateWithHoldTax', { withHoldTax: false })
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblock Current Account.
|
||||
*/
|
||||
private unblockCurrentAccount(action: string) {
|
||||
const unblockCurrentAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
data: {
|
||||
heading: this.translateService.instant('labels.heading.Current Account'),
|
||||
dialogContext:
|
||||
this.translateService.instant('labels.dialogContext.Are you sure you want') +
|
||||
action +
|
||||
this.translateService.instant('this Current Account')
|
||||
}
|
||||
});
|
||||
let command = 'unblock';
|
||||
if (action === 'Unblock Deposit') {
|
||||
command = 'unblockCredit';
|
||||
}
|
||||
if (action === 'Unblock Withdrawal') {
|
||||
command = 'unblockDebit';
|
||||
}
|
||||
unblockCurrentAccountDialogRef.afterClosed().subscribe((response: { confirm: any }) => {
|
||||
if (response.confirm) {
|
||||
this.currentAccountsService
|
||||
.executeCurrentAccountCommand(this.currentAccountData.id, command, {})
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user