feat: implement product approval workflow updates

This commit is contained in:
2026-09-09 11:32:37 +05:30
parent abc966d507
commit 227949f8b2
31 changed files with 1472 additions and 277 deletions
@@ -33,12 +33,14 @@ import { SettingsService } from 'app/settings/settings.service';
/** Dialog Components */
import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component';
import { ViewCheckerInboxComponent } from '../../view-checker-inbox/view-checker-inbox.component';
import { Dates } from 'app/core/utils/dates';
import { TranslateService } from '@ngx-translate/core';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { MatCheckbox } from '@angular/material/checkbox';
import { DateFormatPipe } from '../../../pipes/date-format.pipe';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
import { isProductEntity, isTempTableAccountEdit } from '../../product-entities';
@Component({
selector: 'mifosx-checker-inbox',
@@ -104,27 +106,19 @@ export class CheckerInboxComponent implements OnInit {
];
/**
* Entities whose pending edits are gated by our own custom staging tables (m_savings_product_temp
* for products, the savings account edit-request table for Nominee/Digital-Feature edits) rather
* than the native command-source pipeline. They're excluded from Checker Inbox entirely -
* approving/rejecting them here would call the native /makercheckers/{id}?command=approve endpoint,
* which replays the original command handler directly and never touches our staging table, leaving
* its lock/hold stuck forever. Action them from Approvals -> Pending Product Edits / Pending Account
* Edits instead, where that's handled correctly.
* The Checker Inbox holds non-product pending requests only. Two groups are routed elsewhere:
*
* - Product requests of every action (CREATE, UPDATE, DELETE) belong to Approvals -> Product
* Approval, which merges them with the product edits staged in m_saving_product_temp so a
* checker sees one queue per product rather than two.
* - Savings/current account edits are staged the same way as product edits and belong to
* Approvals -> Pending Account Edits. Approving them here would call
* /makercheckers/{id}?command=approve, which replays the original command handler and never
* touches the staging table, leaving its lock held forever.
*/
private readonly productEditEntities = [
'SAVINGSPRODUCT',
'CURRENTPRODUCT',
'SHAREPRODUCT',
'FIXEDDEPOSITPRODUCT',
'RECURRINGDEPOSITPRODUCT',
'SAVINGSACCOUNT',
'CURRENTACCOUNT'
];
private excludeProductEdits(items: any[]): any[] {
private excludeRoutedElsewhere(items: any[]): any[] {
return (items || []).filter(
(item: any) => !(this.productEditEntities.includes(item?.entityName) && item?.actionName === 'UPDATE')
(item: any) => !isProductEntity(item?.entityName) && !isTempTableAccountEdit(item?.entityName, item?.actionName)
);
}
@@ -141,7 +135,7 @@ export class CheckerInboxComponent implements OnInit {
constructor() {
this.route.data.subscribe((data: { makerCheckerResource: any; makerCheckerTemplate: any }) => {
const raw = data.makerCheckerResource;
this.searchData = this.excludeProductEdits(Array.isArray(raw) ? raw : (raw?.pageItems ?? []));
this.searchData = this.excludeRoutedElsewhere(Array.isArray(raw) ? raw : (raw?.pageItems ?? []));
this.checkerData = this.searchData.length > 0;
this.makerCheckerTemplate = data.makerCheckerTemplate ?? {};
this.dataSource = new MatTableDataSource(this.searchData);
@@ -181,7 +175,7 @@ export class CheckerInboxComponent implements OnInit {
makerDateTimeto: this.dateUtils.formatDate(this.makerCheckerSearchForm.value.makerDateTimeto, dateFormat)
};
this.tasksService.getMakerCheckerData(makerCheckerSearchParams).subscribe((response: any) => {
this.searchData = this.excludeProductEdits(response);
this.searchData = this.excludeRoutedElsewhere(response);
if (this.searchData.length === 0) {
this.noSearchedData = true;
} else {
@@ -242,20 +236,6 @@ export class CheckerInboxComponent implements OnInit {
});
}
deleteChecker() {
const deleteCheckerDialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
heading: this.translateService.instant('labels.heading.Delete Checker'),
dialogContext: this.translateService.instant('labels.dialogContext.Are you sure you want to delete checker')
}
});
deleteCheckerDialogRef.afterClosed().subscribe((response: { confirm: any }) => {
if (response.confirm) {
this.bulkDeleteChecker();
}
});
}
bulkCheckerApproveorReject(action: any) {
const selectedAccounts = this.selection.selected.length;
const listSelectedAccounts = this.selection.selected;
@@ -270,22 +250,94 @@ export class CheckerInboxComponent implements OnInit {
});
}
bulkDeleteChecker() {
const selectedAccounts = this.selection.selected.length;
const listSelectedAccounts = this.selection.selected;
let approvedAccounts = 0;
listSelectedAccounts.forEach((element: any) => {
this.tasksService.deleteMakerChecker(element.id).subscribe((response: any) => {
approvedAccounts++;
if (selectedAccounts === approvedAccounts) {
applyFilter(filterValue: string = '') {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
/**
* Maps a maker-checker entityName to the Angular route path for that entity's existing view page.
* Returns null for entity types that have no dedicated view page in this application.
*/
private entityRoute(entityName: string, resourceId: string | number): string | null {
const id = resourceId;
switch ((entityName ?? '').toUpperCase()) {
case 'LOANPRODUCT':
return `/products/loan-products/${id}`;
case 'SAVINGSPRODUCT':
return `/products/saving-products/${id}`;
case 'CURRENTPRODUCT':
return `/products/current-products/${id}`;
case 'SHAREPRODUCT':
return `/products/share-products/${id}`;
case 'FIXEDDEPOSITPRODUCT':
return `/products/fixed-deposit-products/${id}`;
case 'RECURRINGDEPOSITPRODUCT':
return `/products/recurring-deposit-products/${id}`;
case 'CHARGE':
return `/products/charges/${id}`;
case 'GLACCOUNT':
return `/accounting/chart-of-accounts/gl-accounts/view/${id}`;
case 'CLIENT':
return `/clients/${id}/general`;
case 'LOAN':
return `/loans/${id}`;
case 'SAVINGSACCOUNT':
return `/savings-accounts/${id}`;
case 'CURRENTACCOUNT':
return `/current-accounts/${id}`;
default:
return null;
}
}
/**
* Handles a row click in the Checker Inbox.
*
* Priority:
* 1. If the row has a known entityName and a resourceId → navigate to the entity's existing
* view page (read-only; no maker-checker action buttons are present on those pages).
* 2. If no resourceId is available (e.g. a DELETE action where the entity no longer exists)
* → show a brief informational snackbar.
* 3. If the entityName is unrecognised → fall back to the existing ViewCheckerInboxComponent
* dialog so the checker can still view the command details and action the entry.
*/
viewEntry(row: any): void {
const entityName: string = row.entityName ?? '';
const resourceId = row.resourceId;
const route = this.entityRoute(entityName, resourceId);
// DIAGNOSTIC — open browser DevTools console to confirm the row payload.
// Remove after confirming root cause.
console.log('[CheckerInbox] viewEntry row =', {
id: row.id,
entityName,
actionName: row.actionName,
resourceId,
resolvedRoute: route
});
if (route && resourceId != null) {
// Navigate to the existing entity view page (no maker-checker buttons there).
this.router.navigate([route]);
return;
}
// resourceId is absent (CREATE rows: entity does not exist yet until approved),
// or entityName is unmapped — fall back to the detail dialog so the checker
// can still view the command payload and action the entry.
this.dialog
.open(ViewCheckerInboxComponent, {
data: { checkerId: row.id },
autoFocus: false
})
.afterClosed()
.subscribe((result: any) => {
// Only reload when something was actually actioned — a plain close must not throw away the
// checker's current search, which reload() does by re-navigating the route.
if (result?.refreshed) {
this.reload();
}
});
});
}
applyFilter(filterValue: string = '') {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
/**