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
+109 -22
View File
@@ -6,41 +6,128 @@
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<div class="container">
<div class="layout-row gap-20px">
<mat-form-field class="flex-fill">
<mat-label>{{ 'labels.inputs.Filter' | translate }}</mat-label>
<input matInput (keyup)="applyFilter($event.target.value)" />
</mat-form-field>
<div class="rpt-container">
<!-- Header -->
<div class="rpt-header">
<div class="rpt-header__left">
<div class="rpt-logomark"><span></span><span></span><span></span><span></span></div>
<h2 class="rpt-header__title">{{ 'labels.menus.Reports' | translate }}</h2>
<span class="rpt-header__badge">{{ reportsData?.length || 0 }} reports</span>
</div>
</div>
<div class="mat-elevation-z8">
<table mat-table [dataSource]="dataSource" matSort>
<!-- ===== LEVEL 0: All Categories ===== -->
@if (!selectedCategory) {
<div class="rpt-search-row">
<mat-form-field appearance="outline" class="rpt-search">
<i class="fas fa-search rpt-search__icon" matPrefix></i>
<input matInput placeholder="Search all reports..." (keyup)="applyFilter($event.target.value)" />
</mat-form-field>
</div>
@if (isSearching) {
<ng-container *ngTemplateOutlet="reportTable"></ng-container>
}
@if (!isSearching) {
<div class="rpt-tiles">
@for (cat of categories; track cat.name) {
<div class="rpt-tile" (click)="selectCategory(cat.name)">
<div class="rpt-tile__icon" [ngClass]="cat.color"><i [class]="'fas ' + cat.icon"></i></div>
<div class="rpt-tile__info">
<span class="rpt-tile__name">{{ cat.name }}</span>
<span class="rpt-tile__count">{{ cat.count }} reports</span>
</div>
<i class="fas fa-chevron-right rpt-tile__arrow"></i>
</div>
}
</div>
}
}
<!-- ===== LEVEL 1: Category Selected ===== -->
@if (selectedCategory) {
<div class="rpt-detail">
<!-- Breadcrumb -->
<div class="rpt-detail__header">
<button mat-stroked-button class="rpt-back-btn" (click)="selectedSubCategory ? backToSubCategories() : clearCategory()">
<i class="fas fa-arrow-left"></i>
{{ selectedSubCategory ? selectedCategory : 'All Categories' }}
</button>
<h3 class="rpt-detail__title">{{ selectedSubCategory || selectedCategory }}</h3>
<span class="rpt-header__badge">
{{ selectedSubCategory ? dataSource.data.length : filteredReports.length }} reports
</span>
</div>
<!-- Sub-Category Tiles (for large categories like Loan) -->
@if (showSubCategories) {
<div class="rpt-search-row">
<mat-form-field appearance="outline" class="rpt-search">
<i class="fas fa-search rpt-search__icon" matPrefix></i>
<input matInput placeholder="Search in {{ selectedCategory }}..." (keyup)="applyFilter($event.target.value)" />
</mat-form-field>
</div>
@if (isSearching) {
<ng-container *ngTemplateOutlet="reportTable"></ng-container>
}
@if (!isSearching) {
<div class="rpt-tiles rpt-tiles--sub">
@for (sub of subCategories; track sub.name) {
<div class="rpt-tile" (click)="selectSubCategory(sub)">
<div class="rpt-tile__icon" [ngClass]="sub.color"><i [class]="'fas ' + sub.icon"></i></div>
<div class="rpt-tile__info">
<span class="rpt-tile__name">{{ sub.name }}</span>
<span class="rpt-tile__count">{{ sub.count }} reports</span>
</div>
<i class="fas fa-chevron-right rpt-tile__arrow"></i>
</div>
}
</div>
}
}
<!-- Direct Table (small categories or sub-category selected) -->
@if (!showSubCategories) {
<div class="rpt-search-row">
<mat-form-field appearance="outline" class="rpt-search">
<i class="fas fa-search rpt-search__icon" matPrefix></i>
<input matInput placeholder="Search reports..." (keyup)="applyFilter($event.target.value)" />
</mat-form-field>
</div>
<ng-container *ngTemplateOutlet="reportTable"></ng-container>
}
</div>
}
</div>
<!-- ===== Reusable Report Table Template ===== -->
<ng-template #reportTable>
<div class="rpt-table-wrap">
<table mat-table [dataSource]="dataSource" matSort class="rpt-table">
<ng-container matColumnDef="reportName">
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.name' | translate }}</th>
<td mat-cell *matCellDef="let report">{{ report.reportName }}</td>
<td mat-cell *matCellDef="let report" class="rpt-cell-link">{{ report.reportName }}</td>
</ng-container>
<ng-container matColumnDef="reportType">
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Type' | translate }}</th>
<td mat-cell *matCellDef="let report">{{ 'labels.text.' + report.reportType | translate }}</td>
<td mat-cell *matCellDef="let report">
<span class="rpt-type-badge">{{ 'labels.text.' + report.reportType | translate }}</span>
</td>
</ng-container>
<ng-container matColumnDef="reportCategory">
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Category' | translate }}</th>
<td mat-cell *matCellDef="let report">{{ 'labels.text.' + report.reportCategory | translate }}</td>
<td mat-cell *matCellDef="let report">
<span class="rpt-cat-badge">{{ 'labels.text.' + report.reportCategory | translate }}</span>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr
mat-row
*matRowDef="let row; columns: displayedColumns"
class="select-row"
<tr mat-row *matRowDef="let row; columns: displayedColumns" class="rpt-row"
[routerLink]="['/reports', 'run', row.reportName]"
[queryParams]="{ type: row.reportType, id: row.id }"
></tr>
[queryParams]="{ type: row.reportType, id: row.id }"></tr>
</table>
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
</div>
</div>
</ng-template>
+293 -4
View File
@@ -6,10 +6,299 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
table {
width: 100%;
$brand: #1353a0;
$accent: #0ea5e9;
$border: #e2e8f0;
$text: #0f172a;
$text-muted: #64748b;
$mono: 'Roboto Mono', 'DM Mono', monospace;
.select-row:hover {
cursor: pointer;
.rpt-container {
max-width: 1100px;
margin: 0 auto;
padding: 20px 16px;
}
// Header
.rpt-header {
display: flex;
align-items: center;
margin-bottom: 20px;
&__left {
display: flex;
align-items: center;
gap: 10px;
}
&__title {
font-size: 18px;
font-weight: 600;
color: $text;
margin: 0;
}
&__badge {
font-size: 11px;
font-family: $mono;
color: $text-muted;
background: #f1f5f9;
padding: 2px 10px;
border-radius: 10px;
font-weight: 500;
}
}
.rpt-logomark {
width: 20px;
height: 20px;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2px;
flex-shrink: 0;
span {
border-radius: 2px;
&:nth-child(1) { background: $brand; }
&:nth-child(2) { background: $accent; }
&:nth-child(3) { background: #10b981; }
&:nth-child(4) { background: #cbd5e1; }
}
}
// Search
.rpt-search-row {
margin-bottom: 16px;
}
.rpt-search {
width: 100%;
max-width: 420px;
&__icon {
color: $text-muted;
margin-right: 8px;
font-size: 13px;
}
::ng-deep {
.mat-mdc-form-field-flex { height: 38px; }
.mat-mdc-form-field-infix {
padding: 6px 0;
min-height: 38px;
}
.mat-mdc-form-field-subscript-wrapper { height: 0; min-height: 0; }
.mdc-notched-outline {
.mdc-notched-outline__leading { border-radius: 8px 0 0 8px; }
.mdc-notched-outline__trailing { border-radius: 0 8px 8px 0; }
}
input { font-size: 13px; }
}
}
// Category Tiles
.rpt-tiles {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
@media (max-width: 900px) { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 500px) { grid-template-columns: 1fr; }
}
.rpt-tile {
display: flex;
align-items: center;
gap: 14px;
padding: 16px 18px;
background: #fff;
border: 1px solid rgba(0, 0, 0, 0.06);
border-radius: 8px;
cursor: pointer;
transition: box-shadow 0.15s, transform 0.15s;
&:hover {
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
transform: translateY(-1px);
}
&__icon {
width: 40px;
height: 40px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
flex-shrink: 0;
&.blue { background: #e0f2fe; color: #0284c7; }
&.green { background: #d1fae5; color: #059669; }
&.purple { background: #ede9fe; color: #7c3aed; }
&.amber { background: #fef3c7; color: #d97706; }
&.teal { background: #ccfbf1; color: #0d9488; }
&.red { background: #fee2e2; color: #dc2626; }
}
&__info {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
&__name {
font-size: 14px;
font-weight: 600;
color: $text;
}
&__count {
font-size: 11px;
color: $text-muted;
font-family: $mono;
}
&__arrow {
font-size: 12px;
color: #cbd5e1;
flex-shrink: 0;
transition: color 0.12s;
}
&:hover &__arrow { color: $brand; }
}
.rpt-tiles--sub {
grid-template-columns: repeat(2, 1fr);
@media (max-width: 600px) { grid-template-columns: 1fr; }
}
// Detail view
.rpt-detail__header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}
.rpt-detail__title {
font-size: 16px;
font-weight: 600;
color: $text;
margin: 0;
}
.rpt-back-btn {
border-radius: 8px !important;
font-size: 12px !important;
font-weight: 600 !important;
height: 32px !important;
border-color: $border !important;
color: $text-muted !important;
i { margin-right: 6px; }
&:hover { color: $brand !important; border-color: $brand !important; }
}
// Table
.rpt-table-wrap {
border: 1px solid $border;
border-radius: 10px;
overflow: hidden;
mat-paginator {
border-top: 1px solid $border;
background: transparent;
}
}
.rpt-table {
width: 100%;
::ng-deep {
.mat-mdc-header-row {
background: #f8fafc;
min-height: 36px;
height: 36px;
}
.mat-mdc-header-cell {
font-size: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.06em;
color: $text-muted;
border-bottom: 1px solid $border;
padding: 0 16px;
}
.mat-mdc-row {
min-height: 38px;
height: 38px;
border-bottom: 1px solid #f1f5f9;
&:nth-child(even) { background: #fafbfc; }
&:last-child { border-bottom: none; }
}
.mat-mdc-cell {
font-size: 13px;
color: $text;
padding: 0 16px;
}
}
}
.rpt-row {
cursor: pointer;
&:hover {
background: #eef4ff !important;
}
}
.rpt-cell-link {
color: $brand;
font-weight: 500;
}
.rpt-type-badge {
font-size: 10px;
font-weight: 600;
padding: 2px 8px;
border-radius: 4px;
background: #ede9fe;
color: #7c3aed;
text-transform: capitalize;
}
.rpt-cat-badge {
font-size: 10px;
font-weight: 600;
padding: 2px 8px;
border-radius: 4px;
background: #e0f2fe;
color: #0284c7;
text-transform: capitalize;
}
// Dark theme
:host-context(.dark-theme) {
.rpt-tile {
background: #1e1e2e;
border-color: rgba(255, 255, 255, 0.06);
}
.rpt-tile__name { color: #e0e0e0; }
.rpt-tile__arrow { color: #444; }
.rpt-header__title { color: #e0e0e0; }
.rpt-detail__title { color: #e0e0e0; }
}
+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;
}
}
}
}