feat: non-individual entity UI improvements — hide individual-only sections, fix legal form display, send extended fields to API

- Hide Family Members tab/section for non-individual entities in client view, create flow, and preview
- Hide Financial & Classification section for non-individual entities in personal data and preview
- Fix legal form column in clients list — fetch legalForm from client API for correct display
- Add person/business icon before client name in list rows
- Remove unsupportedNpd filter — send authorizedSignatory, additionalInfo, dateOfRegistration to API
- Add registration number format hint (mat-hint) based on constitution type
- Add spacing between verification row and constitution type dropdowns
- Reduce table cell padding and prevent action buttons from being clipped
- Add missing MPL-2.0 license headers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Aditya
2026-04-04 15:10:51 +05:30
co-authored by Claude Opus 4.6
parent ab01111424
commit b890d24bb7
522 changed files with 51991 additions and 21885 deletions
+167 -79
View File
@@ -6,7 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/** Angular Imports */
import { Component, OnInit, ViewChild, inject } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort, MatSortHeader } from '@angular/material/sort';
@@ -23,12 +22,45 @@ import {
MatRowDef,
MatRow
} from '@angular/material/table';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { NgClass } from '@angular/common';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
/**
* Reports component.
*/
/** Category icon/color mapping */
const CATEGORY_CONFIG: Record<string, { icon: string; color: string }> = {
Client: { icon: 'fa-users', color: 'blue' },
Loan: { icon: 'fa-credit-card', color: 'green' },
Savings: { icon: 'fa-piggy-bank', color: 'teal' },
Fund: { icon: 'fa-hand-holding-usd', color: 'amber' },
Accounting: { icon: 'fa-calculator', color: 'purple' },
Aging: { icon: 'fa-clock', color: 'red' },
'Aging(Arrears)': { icon: 'fa-exclamation-triangle', color: 'red' },
SMS: { icon: 'fa-sms', color: 'green' },
'Loans Pending Approval': { icon: 'fa-hourglass-half', color: 'amber' },
'General Reports': { icon: 'fa-file-alt', color: 'purple' }
};
const DEFAULT_CONFIG = { icon: 'fa-chart-bar', color: 'blue' };
/** Sub-category rules for large categories (keyword → sub-category name) */
const SUB_CATEGORY_RULES: Record<string, { name: string; keywords: string[]; icon: string; color: string }[]> = {
Loan: [
{ name: 'Disbursal & Approval', keywords: ['disbursal', 'pending approval', 'awaiting'], icon: 'fa-check-circle', color: 'green' },
{ name: 'Active & Portfolio', keywords: ['active loan', 'portfolio', 'outstanding', 'balance', 'summary'], icon: 'fa-chart-line', color: 'blue' },
{ name: 'Arrears & Aging', keywords: ['arrear', 'aging', 'overdue', 'delinquen', 'written off', 'write-off', 'obligation'], icon: 'fa-exclamation-triangle', color: 'red' },
{ name: 'Repayment & Collection', keywords: ['repayment', 'collection', 'demand', 'due', 'paid', 'payment', 'transaction'], icon: 'fa-money-bill', color: 'teal' },
{ name: 'Other Loan Reports', keywords: [], icon: 'fa-file-alt', color: 'purple' }
]
};
interface SubCat {
name: string;
count: number;
icon: string;
color: string;
reports: any[];
}
@Component({
selector: 'mifosx-reports',
templateUrl: './reports.component.html',
@@ -47,107 +79,163 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
MatHeaderRow,
MatRowDef,
MatRow,
MatPaginator
MatPaginator,
NgClass
]
})
export class ReportsComponent implements OnInit {
private route = inject(ActivatedRoute);
private router = inject(Router);
/** Reports data. */
reportsData: any;
/** Report category filter. */
reportsData: any[] = [];
filter: string;
/** Columns to be displayed in reports table. */
displayedColumns: string[] = [
'reportName',
'reportType',
'reportCategory'
];
/** Data source for reports table. */
dataSource = new MatTableDataSource();
displayedColumns: string[] = ['reportName', 'reportType', 'reportCategory'];
dataSource = new MatTableDataSource<any>();
/** Category dashboard */
categories: { name: string; count: number; icon: string; color: string }[] = [];
selectedCategory: string | null = null;
filteredReports: any[] = [];
isSearching = false;
/** Sub-categories (for large categories) */
subCategories: SubCat[] = [];
selectedSubCategory: string | null = null;
showSubCategories = false;
/** Paginator for reports table. */
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
/** Sorter for reports table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
/**
* Retrieves the reports data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
* Prevents reuse of route parameter `filter`.
* @param {Router} router: Router.
*/
constructor() {
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.route.data.subscribe((data: { reports: any }) => {
this.reportsData = data.reports;
this.reportsData = data.reports || [];
});
this.filter = this.route.snapshot.params['filter'];
}
/*
*Sets and filters the reports table by category.
*/
ngOnInit() {
this.setReports();
this.filterReportsByCategory();
}
/**
* Switches filterPredicate if filterValue is not null.
* @param {string} filterValue filter string for mat-table.
*/
applyFilter(filterValue: string) {
if (filterValue.length) {
this.setCustomFilterPredicate();
this.dataSource.filter = filterValue.trim().toLowerCase();
} else {
this.filterReportsByCategory();
this.buildCategories();
if (this.filter) {
this.selectCategory(this.filter);
}
}
/**
* Initializes the data source, paginator and sorter for reports table.
*/
setReports() {
this.dataSource = new MatTableDataSource(this.reportsData);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
/**
* Filters the data source only for report category passed in route params.
*/
filterReportsByCategory() {
this.dataSource.filterPredicate = (data: any, filter: string) => {
return data.reportCategory === filter;
};
this.dataSource.filter = this.filter;
private isNullCategory(c: any): boolean {
return !c || (typeof c === 'string' && (c.toUpperCase() === 'NULL' || c === '(NULL)'));
}
/**
* Filters Reports for filter value string and report category.
*/
setCustomFilterPredicate() {
this.dataSource.filterPredicate = (data: any, filter: string) => {
/** Transform the data into a lowercase string of all property values. */
const dataStr = Object.keys(data)
.reduce(function (currentTerm: string, key: string) {
/** Use an obscure Unicode character to delimit the words in the concatenated string.
* This avoids matches where the values of two columns combined will match the user's query
*/
return currentTerm + /** @type {any} */ data[key] + '◬';
}, '')
.toLowerCase();
/** Transform the filter by converting it to lowercase and removing whitespace. */
const transformedFilter = filter.trim().toLowerCase();
/* Seperates filter for All reports page.*/
if (this.filter) {
return dataStr.indexOf(transformedFilter) !== -1 && data.reportCategory === this.filter;
} else {
return dataStr.indexOf(transformedFilter) !== -1;
buildCategories() {
const catMap = new Map<string, number>();
for (const report of this.reportsData) {
const cat = this.isNullCategory(report.reportCategory) ? 'General Reports' : report.reportCategory;
catMap.set(cat, (catMap.get(cat) || 0) + 1);
}
this.categories = Array.from(catMap.entries())
.sort((a, b) => b[1] - a[1])
.map(([name, count]) => {
const cfg = CATEGORY_CONFIG[name] || DEFAULT_CONFIG;
return { name, count, icon: cfg.icon, color: cfg.color };
});
}
selectCategory(category: string) {
this.selectedCategory = category;
this.selectedSubCategory = null;
if (category === 'General Reports') {
this.filteredReports = this.reportsData.filter((r: any) => this.isNullCategory(r.reportCategory));
} else {
this.filteredReports = this.reportsData.filter((r: any) => r.reportCategory === category);
}
// Check if this category has sub-category rules
const rules = SUB_CATEGORY_RULES[category];
if (rules && this.filteredReports.length > 15) {
this.buildSubCategories(rules);
this.showSubCategories = true;
} else {
this.showSubCategories = false;
this.setTableData(this.filteredReports);
}
this.isSearching = false;
}
private buildSubCategories(rules: { name: string; keywords: string[]; icon: string; color: string }[]) {
const assigned = new Set<number>();
this.subCategories = [];
for (const rule of rules) {
if (rule.keywords.length === 0) continue; // "Other" bucket — handle last
const matched = this.filteredReports.filter((r: any, idx: number) => {
if (assigned.has(idx)) return false;
const name = (r.reportName || '').toLowerCase();
return rule.keywords.some(kw => name.includes(kw));
});
matched.forEach(r => assigned.add(this.filteredReports.indexOf(r)));
if (matched.length > 0) {
this.subCategories.push({ name: rule.name, count: matched.length, icon: rule.icon, color: rule.color, reports: matched });
}
};
}
// "Other" bucket — remaining unmatched
const otherRule = rules.find(r => r.keywords.length === 0);
const remaining = this.filteredReports.filter((_, idx) => !assigned.has(idx));
if (remaining.length > 0 && otherRule) {
this.subCategories.push({ name: otherRule.name, count: remaining.length, icon: otherRule.icon, color: otherRule.color, reports: remaining });
}
}
selectSubCategory(subCat: SubCat) {
this.selectedSubCategory = subCat.name;
this.showSubCategories = false;
this.setTableData(subCat.reports);
}
backToSubCategories() {
this.selectedSubCategory = null;
this.showSubCategories = true;
}
clearCategory() {
this.selectedCategory = null;
this.selectedSubCategory = null;
this.showSubCategories = false;
this.isSearching = false;
this.setTableData(this.reportsData);
}
private setTableData(data: any[]) {
this.dataSource = new MatTableDataSource(data);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
applyFilter(filterValue: string) {
if (filterValue.trim().length > 0) {
this.isSearching = true;
this.showSubCategories = false;
if (this.selectedSubCategory) {
const subCat = this.subCategories.find(sc => sc.name === this.selectedSubCategory);
this.setTableData(subCat ? subCat.reports : this.filteredReports);
} else if (this.selectedCategory) {
this.setTableData(this.filteredReports);
} else {
this.setTableData(this.reportsData);
}
this.dataSource.filter = filterValue.trim().toLowerCase();
} else {
if (this.selectedSubCategory) {
// keep showing sub-cat table
} else if (this.selectedCategory && SUB_CATEGORY_RULES[this.selectedCategory] && this.filteredReports.length > 15) {
this.isSearching = false;
this.showSubCategories = true;
} else {
this.isSearching = false;
}
}
}
}