- Add the full Share Reports surface (final balance, account statement, issued/status/nominal/share-wise/guarantor/member-interest reports, enquiry, payment certificate, share detail, dividend statement, folio statement, distinctive numbers, area-wise, mailing labels/letters, share transfer) as standalone routed components, wired into the Share menu - Wire the unattributed Share Collection receipt list into Apply Collection and Apply Additional Shares, with an Attach action independent of account/client - Sync the GL Account and Voucher No fields to whichever receipt is ticked or found, and surface the receipt's real Dr/Cr GL entries in its detail popup - Block Apply Additional Shares until the account's original application is settled Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
152 lines
3.9 KiB
TypeScript
152 lines
3.9 KiB
TypeScript
/**
|
|
* 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/.
|
|
*/
|
|
|
|
import { Component, OnInit, inject } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
import { FormsModule } from '@angular/forms';
|
|
import { ActivatedRoute } from '@angular/router';
|
|
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
|
import { of } from 'rxjs';
|
|
import { catchError } from 'rxjs/operators';
|
|
|
|
import { SharesService } from '../../shares.service';
|
|
import { SHARE_DIVIDEND_STATUS, shareReportCsv, shareReportPrint } from '../share-report.util';
|
|
|
|
/**
|
|
* Dividend Statement — every dividend declared to one member, with what has been paid and what is
|
|
* still owed.
|
|
*
|
|
* <p>
|
|
* Handed to a member as their record, so declared and paid stay separate columns: "declared" and
|
|
* "paid" are different answers to "have I had my dividend", and a statement showing one amount
|
|
* cannot tell them apart.
|
|
*/
|
|
@Component({
|
|
selector: 'mifosx-share-dividend-statement',
|
|
templateUrl: './share-dividend-statement.component.html',
|
|
styleUrls: [
|
|
'../../../letter-mgmt/certificates/certificates.shared.scss',
|
|
'../share-report.shared.scss'
|
|
],
|
|
imports: [
|
|
CommonModule,
|
|
FormsModule,
|
|
FaIconComponent
|
|
]
|
|
})
|
|
export class ShareDividendStatementComponent implements OnInit {
|
|
private sharesService = inject(SharesService);
|
|
private route = inject(ActivatedRoute);
|
|
|
|
search = '';
|
|
searching = false;
|
|
searched = false;
|
|
loadError = '';
|
|
|
|
matches: any[] = [];
|
|
member: any = null;
|
|
rows: any[] = [];
|
|
totals: any = null;
|
|
|
|
ngOnInit(): void {
|
|
const clientId = this.route.snapshot.queryParamMap.get('clientId');
|
|
if (clientId) {
|
|
this.loadByClient(Number(clientId));
|
|
}
|
|
}
|
|
|
|
runSearch(): void {
|
|
const term = this.search.trim();
|
|
if (!term) {
|
|
return;
|
|
}
|
|
this.fetch({ search: term });
|
|
}
|
|
|
|
loadByClient(clientId: number): void {
|
|
this.fetch({ clientId });
|
|
}
|
|
|
|
private fetch(params: { search?: string; clientId?: number }): void {
|
|
this.searching = true;
|
|
this.loadError = '';
|
|
this.reset();
|
|
this.sharesService
|
|
.getShareDividendStatement(params)
|
|
.pipe(
|
|
catchError((err) => {
|
|
this.loadError = this.readError(err, 'The dividend statement could not be loaded.');
|
|
return of(null);
|
|
})
|
|
)
|
|
.subscribe((res: any) => {
|
|
this.matches = res?.matches || [];
|
|
this.member = res?.member || null;
|
|
this.rows = res?.rows || [];
|
|
this.totals = res?.totals || null;
|
|
this.searching = false;
|
|
this.searched = true;
|
|
});
|
|
}
|
|
|
|
private reset(): void {
|
|
this.matches = [];
|
|
this.member = null;
|
|
this.rows = [];
|
|
this.totals = null;
|
|
}
|
|
|
|
statusLabel(status: number): string {
|
|
return SHARE_DIVIDEND_STATUS[status]?.label || String(status ?? '');
|
|
}
|
|
|
|
statusClass(status: number): string {
|
|
return SHARE_DIVIDEND_STATUS[status]?.cls || 'srep-pill--grey';
|
|
}
|
|
|
|
exportCsv(): void {
|
|
if (!this.member) {
|
|
return;
|
|
}
|
|
shareReportCsv(
|
|
`dividend-statement-${this.member.cifNumber || this.member.clientId}`,
|
|
[
|
|
'Period From',
|
|
'Period To',
|
|
'Share A/c No',
|
|
'Product',
|
|
'Rate %',
|
|
'Amount',
|
|
'Status'
|
|
],
|
|
this.rows.map((r) => [
|
|
r.periodStart,
|
|
r.periodEnd,
|
|
r.accountNo,
|
|
r.productName,
|
|
r.ratePercentage,
|
|
r.amount,
|
|
this.statusLabel(r.statusEnum)
|
|
])
|
|
);
|
|
}
|
|
|
|
print(): void {
|
|
shareReportPrint();
|
|
}
|
|
|
|
private readError(err: any, fallback: string): string {
|
|
return (
|
|
err?.error?.errors?.[0]?.defaultUserMessage ||
|
|
err?.error?.defaultUserMessage ||
|
|
err?.error?.developerMessage ||
|
|
fallback
|
|
);
|
|
}
|
|
}
|