Compare commits

..
Author SHA1 Message Date
anshul 8e98077158 feat: add investment reports, bond components, dashboard, and service implementation 2026-10-23 16:49:50 +05:30
anshul 731ab5a0e0 feat(investment): bucket wise report, script rating and non-SLR limits on purchase 2026-10-23 12:38:24 +05:30
anshul 7bd880387e feat(investment): interest received and receivable report page with Excel export 2026-10-23 11:26:11 +05:30
anshul 86e3a5da27 Merge remote-tracking branch 'origin/dev-latest' into feature/investment 2026-10-22 18:32:50 +05:30
anshul d89f13471c feat(investment): due date diary, script status, deal no by deal date, matured-only redemption, keep typed rate and business-rule error title 2026-10-22 17:39:50 +05:30
anshul 6890584b16 feat(investment): FD TDS fields, GOI interest to the paisa, compact home reminders, deal no in holdings and settle guard 2026-10-20 16:16:12 +05:30
anshul d584af8e54 feat(investment): FD screens - purchase, maturity/premature/renewal, interest entry and reminders 2026-10-16 17:24:13 +05:30
anshul e1b33827ea fix(investment): maturity date mandatory on script master 2026-10-16 12:11:49 +05:30
anshul 8ed8f92b00 feat(investment): sell, redemption, write-off, GOI transfer and amortize screens 2026-10-15 18:45:21 +05:30
anshul c9feeae3cb feat(investment): interest in transaction log, accrued interest since last coupon, investment-only GL list 2026-10-14 17:40:08 +05:30
anshul 0404197c1b feat(investment): interest voucher posting UI, home pending alert and day-end reminder 2026-10-14 15:11:43 +05:30
anshul 8a6becff86 Merge origin/dev-latest into feature/investment 2026-10-14 10:49:37 +05:30
anshulandClaude Opus 5.5 c803e20628 feat(investment): settle purchases from Holdings; broken-period interest to settlement date
- Purchases are saved as Pending Settlement. Holdings show the status and
  a Settle button (from the settlement date), and the GL transaction id
  once settled.
- The transaction log shows "Not posted (pending settlement)" until a
  deal is settled, and dates the purchase on its settlement date.
- Broken-period interest is counted up to the settlement date.
- Accounting Preview title and the Holdings Settlement Date column
  reflect settlement-date posting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 10:28:19 +05:30
anshulandClaude Opus 5.5 6a04a92113 feat(investment): Daily Script Master, market rate on purchase, broken-period interest as expense
- 09 Daily Script Master now saves to and loads from the backend (sample
  rows removed), with Drop to correct a wrong rate.
- Purchase Entry takes the rate (NAV for a mutual fund) from the newest
  Daily Script Master rate on or before the deal date, shows which rate
  was used, warns when the rate entered is outside the day's low-high,
  and clears the rate when the script has none.
- Broken-period interest paid to the seller is debited to expense GL
  500606 instead of Interest Receivable (RBI UCB Investment Directions,
  para 152, confirmed by Jitendra Sir); Interest Entry labels it so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:27:15 +05:30
anshulandClaude Opus 5.5 88f34f58e3 feat(investment): deal time, interest cycle and charges on Purchase Entry
As per Jitendra Sir's review:
- Deal Time is now a mandatory field next to Deal Date.
- New Interest Cycle section: the two coupon days, last and next coupon,
  next coupon amount and days to it.
- Stamp duty, brokerage and other charges sit on the main form. They are
  expenses on their own GLs (500601/500602/500603), so they are added to
  the settlement amount but no longer to the book value, and each shows
  as its own debit line in the accounting preview.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 11:54:33 +05:30
anshul 88c4242692 Merge origin/dev-latest into feature/investment 2026-10-12 10:35:53 +05:30
anshulandClaude Opus 5.5 ca01e9b65b feat(investment): Interest Entry screen with coupon and provision schedule
Replace the dummy interest calculation tab with the real Interest Entry:
pick Type / Script / Deal No and Retrieve the holding's schedule from
the backend - every half-yearly coupon and every 31 Mar / 30 Sep closing
provision up to maturity, with days (30/360), gross interest, amount
already booked, net income and the Dr/Cr entry per line. Display only;
nothing is posted to GL yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 18:36:01 +05:30
anshulandClaude Opus 5.5 a4e0a22205 feat(investment): wire Bank/Party, Script Master and Purchase Entry to the backend
- Bank / Party Master and Script Master follow the bank's existing CBS
  screens (address, bank type, GL A/c, RBI code, limit, LEI, counterparty
  bank details; SLR type, auto script code, ISIN, interest rate, issue /
  maturity date, auto period, company details) and save to
  /investment/parties and /investment/scripts. GL dropdowns list enabled
  ASSET detail accounts from the chart of accounts.
- Purchase Entry simplified to the mandatory fields; script details,
  settlement date, last interest date, units, book value, premium/discount,
  accrued interest (30/360 up to the deal date), settlement amount and YTM
  are filled automatically; optional fields sit under "More Details";
  an Accounting Preview shows the GL entry. Save / Retrieve / Drop use
  /investment/purchases and the Holdings register lists saved purchases.
- New InvestmentService for the investment API calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 12:38:10 +05:30
27 changed files with 7906 additions and 2474 deletions
@@ -386,6 +386,38 @@
</div>
</div>
}
<!-- Investment interest vouchers that are due but not posted. A reminder only: unlike the interest
above it never stops the close (Jitendra Sir); the voucher can still be posted afterwards. -->
@if (preview?.investmentInterestPending?.length) {
<div class="bd-warn">
<mat-icon>notifications_active</mat-icon>
<div>
<strong>Reminder: investment interest vouchers are pending.</strong>
@for (t of preview.investmentInterestPending; track t.purchaseId) {
<div>
{{ t.lineType === 'COUPON' ? 'Coupon' : 'Provision' }} · {{ t.scriptDesc }} · deal {{ t.dealNo }} ·
{{ t.intDate }} · ₹{{ (t.lineType === 'COUPON' ? t.grossInterest : t.amount) | number: '1.2-2' }}
</div>
}
Post them under Investment → Govt Security / Bond → 03 Interest Entry. You can still close the day.
</div>
</div>
}
@if (preview?.investmentFdPending?.length) {
<div class="bd-warn">
<mat-icon>notifications_active</mat-icon>
<div>
<strong>Reminder: FD investment entries are pending.</strong>
@for (t of preview.investmentFdPending; track t.fdId) {
<div>
{{ t.lineType === 'MATURITY' ? 'Maturity' : t.lineType === 'PAYOUT' ? 'Interest payout' : 'Provision' }}
· {{ t.partyName }} · FD {{ t.dealNo }} · {{ t.intDate }} · ₹{{ t.amount | number: '1.2-2' }}
</div>
}
Post them under Investment → FD Investment. You can still close the day.
</div>
</div>
}
@if (preview?.savingsInterestPending?.length) {
<div class="bd-warn">
<mat-icon>warning</mat-icon>
@@ -109,7 +109,15 @@ export class ErrorHandlerInterceptor implements HttpInterceptor {
} else if (status === 400) {
alert = { type: 'Bad Request', message: errorMessage || 'Invalid parameters were passed in the request!' };
} else if (status === 403) {
alert = { type: 'Unauthorized Request', message: errorMessage || 'You are not authorized for this request!' };
// A 403 is either a missing permission or a business rule the record does not meet yet ("post the coupon
// first", "matures on …"). Only the first is an authorisation problem; the rule is told by its code.
const errorCode: string =
errorBody?.errors?.[0]?.userMessageGlobalisationCode || errorBody?.userMessageGlobalisationCode || '';
const isPermission = !errorCode || /not\.authori[sz]ed|unauthori[sz]ed|access\.denied|forbidden/i.test(errorCode);
alert = {
type: isPermission ? 'Unauthorized Request' : 'Action Not Allowed',
message: errorMessage || 'You are not authorized for this request!'
};
} else if (status === 404) {
alert = {
type: this.translate.instant('error.resource.not.found'),
+6 -6
View File
@@ -1522,13 +1522,13 @@
<!-- Investment -->
<div class="deposit-menu-group">
<div class="deposit-group-title">Investment</div>
<button mat-menu-item routerLink="/investment/dashboard" tabindex="0">
<button mat-menu-item routerLink="/investment/diary" tabindex="0">
<fa-icon icon="calendar-alt" class="menu-item-icon"></fa-icon> Due Date Diary for All Investment
</button>
<button mat-menu-item routerLink="/investment/reports" tabindex="0">
<button mat-menu-item routerLink="/investment/interest-report" tabindex="0">
<fa-icon icon="dollar-sign" class="menu-item-icon"></fa-icon> Total Int Received &amp; Receivable Report
</button>
<button mat-menu-item routerLink="/investment/reports" tabindex="0">
<button mat-menu-item routerLink="/investment/bucket-report" tabindex="0">
<fa-icon icon="piggy-bank" class="menu-item-icon"></fa-icon> Bucket Wise Investment
</button>
<button mat-menu-item routerLink="/deaf" tabindex="0">
@@ -2392,7 +2392,7 @@
<a
class="gl-link"
[class.hidden]="!matchesInvestmentSearch('Due Date Diary for All Investment')"
routerLink="/investment/dashboard"
routerLink="/investment/diary"
(click)="investmentMenuOpen = false"
>
<fa-icon icon="calendar-check" class="gl-icon"></fa-icon> Due Date Diary for All Investment
@@ -2400,7 +2400,7 @@
<a
class="gl-link"
[class.hidden]="!matchesInvestmentSearch('Bucket Wise Investment')"
routerLink="/investment/reports"
routerLink="/investment/bucket-report"
(click)="investmentMenuOpen = false"
>
<fa-icon icon="layer-group" class="gl-icon"></fa-icon> Bucket Wise Investment
@@ -2500,7 +2500,7 @@
<a
class="gl-link"
[class.hidden]="!matchesInvestmentSearch('Total Int Received & Receivable Report')"
routerLink="/investment/reports"
routerLink="/investment/interest-report"
(click)="investmentMenuOpen = false"
>
<fa-icon icon="hand-holding-usd" class="gl-icon"></fa-icon> Total Int Received &amp; Receivable Report
+59
View File
@@ -47,6 +47,65 @@
</div>
</div>
<!-- Pending investment entries (GOI / bond interest, FDs with other banks): one line each, details on demand -->
@if (pendingInvestmentInterest.length || pendingFd.length) {
<div class="investment-interest-alert">
<span class="iia-icon">🔔</span>
<div class="iia-text">
<strong>Investment entries pending</strong>
@if (pendingInvestmentInterest.length) {
<div class="iia-row">
<span class="iia-summary"
>GOI / Bonds: {{ pendingInvestmentInterest.length }} interest voucher(s){{
overdueNote(pendingInvestmentInterest)
}}</span
>
<button type="button" class="iia-toggle" (click)="showInterestDetails = !showInterestDetails">
{{ showInterestDetails ? 'Hide' : 'Details' }}
</button>
<a class="iia-action" routerLink="/investment/bonds" [queryParams]="{ tab: 'interest' }"
>Open Interest Entry →</a
>
</div>
@if (showInterestDetails) {
@for (t of pendingInvestmentInterest.slice(0, detailLimit); track t.purchaseId) {
<a class="iia-item" routerLink="/investment/bonds" [queryParams]="{ tab: 'interest' }">
{{ t.lineType === 'COUPON' ? 'Coupon' : 'Provision' }} · {{ t.scriptDesc }} · deal {{ t.dealNo }} ·
{{ t.overdue ? 'overdue since ' + t.intDate : t.postable ? 'due today' : 'due ' + t.intDate }}
</a>
}
@if (pendingInvestmentInterest.length > detailLimit) {
<span class="iia-more">+{{ pendingInvestmentInterest.length - detailLimit }} more in Interest Entry</span>
}
}
}
@if (pendingFd.length) {
<div class="iia-row">
<span class="iia-summary"
>FD with banks: {{ pendingFd.length }} entry(ies){{ overdueNote(pendingFd) }}</span
>
<button type="button" class="iia-toggle" (click)="showFdDetails = !showFdDetails">
{{ showFdDetails ? 'Hide' : 'Details' }}
</button>
<a class="iia-action" routerLink="/investment/fd">Open FD Investment →</a>
</div>
@if (showFdDetails) {
@for (t of pendingFd.slice(0, detailLimit); track t.fdId + t.lineType + t.intDate) {
<a class="iia-item" routerLink="/investment/fd" [queryParams]="{ tab: 'interest', fd: t.fdId }">
{{ t.lineType === 'MATURITY' ? 'Maturity' : t.lineType === 'PAYOUT' ? 'Interest payout' : 'Provision' }}
· {{ t.partyName }} · FD {{ t.dealNo }} ·
{{ t.overdue ? 'overdue since ' + t.intDate : t.postable ? 'due today' : 'due ' + t.intDate }}
</a>
}
@if (pendingFd.length > detailLimit) {
<span class="iia-more">+{{ pendingFd.length - detailLimit }} more in FD Investment</span>
}
}
}
</div>
</div>
}
<!-- Quick Action Cards -->
<div class="quick-actions">
<a class="qa-card" [routerLink]="['/dashboard']" #buttonDashboard>
+75
View File
@@ -424,3 +424,78 @@ $accent: #0ea5e9;
grid-template-columns: 1fr;
}
}
.investment-interest-alert {
display: flex;
align-items: flex-start;
gap: 12px;
margin: 12px 0;
padding: 12px 16px;
border: 1px solid #f5c26b;
border-left: 4px solid #e08e0b;
border-radius: 8px;
background: #fff8e6;
color: #5c3d00;
text-decoration: none;
.iia-icon {
font-size: 20px;
line-height: 1.2;
}
.iia-text {
display: flex;
flex: 1;
flex-direction: column;
gap: 4px;
min-width: 0;
}
.iia-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 4px 12px;
font-size: 14px;
}
.iia-summary {
flex: 1;
min-width: 0;
}
.iia-toggle {
padding: 2px 10px;
border: 1px solid #e0a43a;
border-radius: 12px;
background: transparent;
color: inherit;
font-size: 12px;
cursor: pointer;
}
.iia-item {
padding-left: 12px;
font-size: 13px;
color: inherit;
text-decoration: none;
}
.iia-more {
padding-left: 12px;
font-size: 12px;
font-style: italic;
}
a.iia-item:hover {
text-decoration: underline;
}
.iia-action {
align-self: center;
font-weight: 600;
white-space: nowrap;
color: inherit;
text-decoration: none;
}
}
+35
View File
@@ -26,6 +26,7 @@ import { PopoverService } from '../configuration-wizard/popover/popover.service'
import { ConfigurationWizardService } from '../configuration-wizard/configuration-wizard.service';
import { SettingsService } from 'app/settings/settings.service';
import { DscService } from 'app/users/dsc/dsc.service';
import { InvestmentFdDueDto, InvestmentInterestDueDto, InvestmentService } from 'app/investment/investment.service';
/** Custom Components */
import { NextStepDialogComponent } from '../configuration-wizard/next-step-dialog/next-step-dialog.component';
@@ -109,6 +110,7 @@ export class HomeComponent implements OnInit, AfterViewInit {
this.tenant = this.tenantIdentifier();
this.setFilteredActivities();
this.loadDscStatus();
this.loadPendingInvestmentInterest();
if (!this.authenticationService.hasDialogBeenShown()) {
this.dialog.open(WarningDialogComponent, {
disableClose: false,
@@ -118,6 +120,39 @@ export class HomeComponent implements OnInit, AfterViewInit {
}
}
/** Investment interest lines due now or within two days, shown on the home screen so nobody has to look for them. */
pendingInvestmentInterest: InvestmentInterestDueDto[] = [];
/** FDs placed with other banks: interest vouchers and maturities due now or within two days. */
pendingFd: InvestmentFdDueDto[] = [];
/** The lists stay folded to one line each; the user opens them when needed. */
showInterestDetails = false;
showFdDetails = false;
readonly detailLimit = 5;
private readonly investmentService = inject(InvestmentService);
/** " · 3 overdue, oldest 14-08-2025" for a list of due entries (dates DD-MM-YYYY); empty when none is overdue. */
overdueNote(items: Array<{ overdue?: boolean; intDate: string }>): string {
const late = items.filter((t) => t.overdue);
if (!late.length) {
return '';
}
const key = (d: string) => d.split('-').reverse().join('');
const oldest = late.map((t) => t.intDate).sort((a, b) => key(a).localeCompare(key(b)))[0];
return ` · ${late.length} overdue, oldest ${oldest}`;
}
/** Silent when the user cannot see investments or nothing is due — the strip simply does not render. */
private loadPendingInvestmentInterest(): void {
this.investmentService.getDueInterest().subscribe({
next: (due) => (this.pendingInvestmentInterest = due ?? []),
error: () => (this.pendingInvestmentInterest = [])
});
this.investmentService.getFdDue().subscribe({
next: (due) => (this.pendingFd = due ?? []),
error: () => (this.pendingFd = [])
});
}
/**
* Surface a small "DSC verified" badge in the welcome banner when the
* signed-in user has at least one ACTIVE DSC certificate. Silent on
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,198 @@
<!--
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/.
-->
<div class="pg">
<header class="pg-head">
<div>
<div class="pg-eyebrow">TREASURY · INVESTMENT · REPORTS</div>
<h1 class="pg-title">Bucket Wise Investment</h1>
<p class="pg-sub">
Govt Securities, bonds and FDs held on a date, split by the time left to maturity. Click a bucket to see the
holdings in it.
</p>
</div>
<button type="button" class="pg-btn pg-btn--ghost" [disabled]="!report || generating" (click)="exportExcel()">
{{ generating ? 'Generating…' : 'Export to Excel' }}
</button>
</header>
<div class="pg-card">
<div class="inv-form-grid">
<label class="inv-form-field"
><span>As on</span><mifosx-date-ddmmyyyy [(ngModel)]="asOnDate"></mifosx-date-ddmmyyyy
></label>
</div>
<div class="diary-actions">
<button type="button" class="pg-btn pg-btn--primary" [disabled]="loading" (click)="load()">
{{ loading ? 'Loading…' : 'Show' }}
</button>
</div>
@if (error) {
<p class="diary-error">{{ error }}</p>
}
</div>
@if (report; as r) {
<div class="diary-summary">
<div class="diary-tile">
<span class="diary-tile-l">Total Investment</span
><span class="diary-tile-v">₹{{ r.total.totalAmount | number: '1.2-2' }}</span>
</div>
<div class="diary-tile">
<span class="diary-tile-l">Govt Securities (book value)</span
><span class="diary-tile-v">₹{{ r.total.govtBookValue | number: '1.2-2' }}</span>
</div>
@if (hasBonds) {
<div class="diary-tile">
<span class="diary-tile-l">Bonds / Non-SLR (book value)</span
><span class="diary-tile-v">₹{{ r.total.bondBookValue | number: '1.2-2' }}</span>
</div>
}
<div class="diary-tile">
<span class="diary-tile-l">FD with banks</span
><span class="diary-tile-v">₹{{ r.total.fdPrincipal | number: '1.2-2' }}</span>
</div>
</div>
<div class="pg-card">
<div class="pos-section-label">As on {{ r.asOnDate }} · by time left to maturity</div>
<table class="pg-table">
<thead>
<tr>
<th>Bucket</th>
<th class="num">Govt Sec</th>
<th class="num">Govt Sec Face Value</th>
<th class="num">Govt Sec Book Value</th>
@if (hasBonds) {
<th class="num">Bonds</th>
<th class="num">Bonds Book Value</th>
}
<th class="num">FD</th>
<th class="num">FD Principal</th>
<th class="num">Total Amount</th>
<th class="num">Share</th>
</tr>
</thead>
<tbody>
@for (b of r.buckets; track b.code) {
<tr class="report-pick" [class.report-pick--on]="bucket === b.code" (click)="pickBucket(b)">
<td>
<strong>{{ b.label }}</strong>
</td>
<td class="num">{{ b.govtCount }}</td>
<td class="num">₹{{ b.govtFaceValue | number: '1.2-2' }}</td>
<td class="num">₹{{ b.govtBookValue | number: '1.2-2' }}</td>
@if (hasBonds) {
<td class="num">{{ b.bondCount }}</td>
<td class="num">₹{{ b.bondBookValue | number: '1.2-2' }}</td>
}
<td class="num">{{ b.fdCount }}</td>
<td class="num">₹{{ b.fdPrincipal | number: '1.2-2' }}</td>
<td class="num">₹{{ b.totalAmount | number: '1.2-2' }}</td>
<td class="num">{{ share(b) | number: '1.2-2' }}%</td>
</tr>
}
</tbody>
<tfoot>
<tr class="report-total">
<td>Total</td>
<td class="num">{{ r.total.govtCount }}</td>
<td class="num">₹{{ r.total.govtFaceValue | number: '1.2-2' }}</td>
<td class="num">₹{{ r.total.govtBookValue | number: '1.2-2' }}</td>
@if (hasBonds) {
<td class="num">{{ r.total.bondCount }}</td>
<td class="num">₹{{ r.total.bondBookValue | number: '1.2-2' }}</td>
}
<td class="num">{{ r.total.fdCount }}</td>
<td class="num">₹{{ r.total.fdPrincipal | number: '1.2-2' }}</td>
<td class="num">₹{{ r.total.totalAmount | number: '1.2-2' }}</td>
<td class="num">{{ r.total.totalAmount > 0 ? '100.00%' : '—' }}</td>
</tr>
</tfoot>
</table>
</div>
<div class="pg-card">
<div class="inv-form-grid">
<label class="inv-form-field">
<span>Bucket</span>
<select [(ngModel)]="bucket">
<option value="">All buckets</option>
@for (b of r.buckets; track b.code) {
<option [value]="b.code">{{ b.label }}</option>
}
</select>
</label>
<label class="inv-form-field">
<span>Investment</span>
<select [(ngModel)]="instrument">
<option value="">All</option>
<option value="GOVT_SECURITY">Govt Security</option>
@if (hasBonds) {
<option value="BOND">Bond / Non-SLR</option>
}
<option value="FD">FD with banks</option>
</select>
</label>
</div>
<table class="pg-table">
<thead>
<tr>
<th>Bucket</th>
<th>Investment</th>
<th>Deal No</th>
<th>Particulars</th>
<th>Category</th>
<th class="num">Rate</th>
<th>Maturity</th>
<th>Time Left</th>
<th class="num">Face Value / Principal</th>
<th class="num">Book Value / Principal</th>
</tr>
</thead>
<tbody>
@for (x of rows; track x.instrument + x.refId) {
<tr>
<td>{{ bucketLabel(x.bucket) }}</td>
<td>{{ instrumentLabel(x.instrument) }}</td>
<td>
<span class="pg-chip">{{ x.dealNo }}</span>
</td>
<td>{{ x.particulars }}</td>
<td>{{ x.category || '—' }}</td>
<td class="num">{{ x.rate !== null && x.rate !== undefined ? x.rate + '%' : '—' }}</td>
<td>{{ x.maturityDate }}</td>
<td>
@if (x.daysToMaturity < 0) {
<span class="inv-badge diary-badge--overdue">{{ timeLeft(x) }}</span>
} @else {
{{ timeLeft(x) }}
}
</td>
<td class="num">₹{{ x.faceValue | number: '1.2-2' }}</td>
<td class="num">₹{{ x.bookValue | number: '1.2-2' }}</td>
</tr>
} @empty {
<tr>
<td colspan="10" class="pg-empty">No investment held in this selection.</td>
</tr>
}
</tbody>
@if (rows.length) {
<tfoot>
<tr class="report-total">
<td colspan="8">Total ({{ rows.length }})</td>
<td class="num">₹{{ rowsTotal.faceValue | number: '1.2-2' }}</td>
<td class="num">₹{{ rowsTotal.bookValue | number: '1.2-2' }}</td>
</tr>
</tfoot>
}
</table>
</div>
}
</div>
@@ -0,0 +1,235 @@
/**
* 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 { DateDdmmyyyyPickerComponent } from '../date-ddmmyyyy-picker/date-ddmmyyyy-picker.component';
import { todayDDMMYYYY } from '../investment-data';
import { exportWorkbook } from '../investment-export';
import {
InvestmentBucketDto,
InvestmentBucketReportDto,
InvestmentBucketRowDto,
InvestmentService,
apiErrorMessage
} from '../investment.service';
type InstrumentFilter = '' | InvestmentBucketRowDto['instrument'];
const INSTRUMENT_LABEL: Record<InvestmentBucketRowDto['instrument'], string> = {
GOVT_SECURITY: 'Govt Security',
BOND: 'Bond / Non-SLR',
FD: 'FD'
};
/**
* Bucket Wise Investment: Govt Securities, bonds and FDs held on a date, split by the time left to maturity — up to
* 1 year, over 1 to 3, over 3 to 5 and over 5 years. Clicking a bucket lists the holdings in it.
*/
@Component({
selector: 'mifosx-investment-bucket-report',
templateUrl: './investment-bucket-report.component.html',
styleUrls: [
'../../cashier/cashier-shared.scss',
'../investment-shared.scss',
'../investment-diary/investment-diary.component.scss'
],
standalone: true,
imports: [
CommonModule,
FormsModule,
DateDdmmyyyyPickerComponent
]
})
export class InvestmentBucketReportComponent implements OnInit {
private readonly investmentService = inject(InvestmentService);
asOnDate = todayDDMMYYYY();
bucket = '';
instrument: InstrumentFilter = '';
report: InvestmentBucketReportDto | null = null;
loading = false;
generating = false;
error = '';
ngOnInit(): void {
this.load();
}
load(): void {
if (!this.asOnDate) {
this.error = 'Enter the As on date.';
return;
}
this.loading = true;
this.error = '';
this.investmentService.getBucketReport(this.asOnDate).subscribe({
next: (r: InvestmentBucketReportDto) => {
this.report = r;
this.loading = false;
},
error: (err: unknown) => {
this.report = null;
this.loading = false;
this.error = apiErrorMessage(err);
}
});
}
/** Bonds / Non-SLR columns only when any are held. */
get hasBonds(): boolean {
return (this.report?.total.bondCount ?? 0) > 0;
}
get rows(): InvestmentBucketRowDto[] {
const all: InvestmentBucketRowDto[] = this.report?.rows ?? [];
return all.filter(
(r: InvestmentBucketRowDto) =>
(!this.bucket || r.bucket === this.bucket) && (!this.instrument || r.instrument === this.instrument)
);
}
get rowsTotal(): { faceValue: number; bookValue: number } {
return this.rows.reduce(
(t: { faceValue: number; bookValue: number }, r: InvestmentBucketRowDto) => ({
faceValue: t.faceValue + r.faceValue,
bookValue: t.bookValue + r.bookValue
}),
{ faceValue: 0, bookValue: 0 }
);
}
pickBucket(b: InvestmentBucketDto): void {
this.bucket = this.bucket === b.code ? '' : b.code;
}
bucketLabel(code: string): string {
return this.report?.buckets.find((b: InvestmentBucketDto) => b.code === code)?.label ?? code;
}
instrumentLabel(i: InvestmentBucketRowDto['instrument']): string {
return INSTRUMENT_LABEL[i];
}
/** Share of the bucket in the total amount, in %. */
share(b: InvestmentBucketDto): number {
const total = this.report?.total.totalAmount ?? 0;
return total > 0 ? (b.totalAmount / total) * 100 : 0;
}
/** Time left to maturity as years and months, or how long it is overdue. */
timeLeft(r: InvestmentBucketRowDto): string {
if (r.daysToMaturity < 0) {
return `Overdue ${-r.daysToMaturity} days`;
}
const months = Math.floor(r.daysToMaturity / 30.4375);
const years = Math.floor(months / 12);
if (years === 0 && months === 0) {
return `${r.daysToMaturity} days`;
}
return years > 0 ? `${years}y ${months % 12}m` : `${months}m`;
}
async exportExcel(): Promise<void> {
const report = this.report;
if (!report) {
return;
}
this.generating = true;
try {
const bucketRow = (b: InvestmentBucketDto): (string | number | null)[] => [
b.label,
b.govtCount,
b.govtFaceValue,
b.govtBookValue,
...(this.hasBonds ? [
b.bondCount,
b.bondFaceValue,
b.bondBookValue
] : []),
b.fdCount,
b.fdPrincipal,
b.totalAmount,
Number(this.share(b).toFixed(2))
];
await exportWorkbook(
[
{
sheetName: 'Bucket Summary',
title: 'Bucket Wise Investment',
subtitle: `As on ${report.asOnDate} · by time left to maturity`,
headers: [
'Bucket',
'Govt Sec (No.)',
'Govt Sec Face Value',
'Govt Sec Book Value',
...(this.hasBonds ? [
'Bonds (No.)',
'Bonds Face Value',
'Bonds Book Value'
] : []),
'FD (No.)',
'FD Principal',
'Total Amount',
'Share %'
],
rows: [
...report.buckets.map(bucketRow),
bucketRow(report.total)
]
},
{
sheetName: 'Holdings',
title: 'Bucket Wise Investment — Holdings',
subtitle: `As on ${report.asOnDate}`,
headers: [
'Bucket',
'Investment',
'Deal No',
'Particulars',
'Category',
'Rate %',
'Maturity',
'Time Left',
'Face Value / Principal',
'Book Value / Principal'
],
widths: [
22,
16,
16,
40,
10,
8,
12,
16,
20,
20
],
rows: report.rows.map((r: InvestmentBucketRowDto) => [
this.bucketLabel(r.bucket),
this.instrumentLabel(r.instrument),
r.dealNo,
r.particulars,
r.category ?? '',
r.rate ?? null,
r.maturityDate,
this.timeLeft(r),
r.faceValue,
r.bookValue
])
}
],
`Bucket-Wise-Investment-${report.asOnDate}`
);
} finally {
this.generating = false;
}
}
}
@@ -12,34 +12,50 @@
<div class="pg-eyebrow">TREASURY · INVESTMENT</div>
<h1 class="pg-title">Investment Portfolio Dashboard</h1>
<p class="pg-sub">
Consolidated position across FD, Govt Security, Non-SLR, Bonds, Mutual Fund and Share holdings as on
What the bank holds today across Govt Securities, FDs with banks, Non-SLR, Bonds, Mutual Funds and Shares, as on
{{ asOnDate }}.
</p>
</div>
<div class="pg-toolbar">
<button type="button" class="pg-btn pg-btn--ghost" [disabled]="generating" (click)="exportExcel()">
<button type="button" class="pg-btn pg-btn--ghost" [disabled]="loading" (click)="load()">
{{ loading ? 'Loading…' : 'Refresh' }}
</button>
<button type="button" class="pg-btn pg-btn--ghost" [disabled]="generating || loading" (click)="exportExcel()">
{{ generating ? 'Exporting…' : 'Export to Excel' }}
</button>
</div>
</header>
@if (error) {
<div class="pg-card">
<p class="inv-hint inv-hint--bad">{{ error }}</p>
</div>
}
<div class="inv-kpis">
<div class="inv-kpi">
<span class="inv-kpi__label">Total Holdings</span>
<span class="inv-kpi__label">Holdings</span>
<span class="inv-kpi__value">{{ totalHoldings }}</span>
<span class="inv-kpi__sub">{{ activeCount }} active · {{ maturedCount }} matured</span>
<span class="inv-kpi__sub"
>{{ maturingSoon.length }} due within 90 days{{ overdueCount ? ' (' + overdueCount + ' overdue)' : '' }}</span
>
</div>
<div class="inv-kpi">
<span class="inv-kpi__label">Total Invested (Face Value)</span>
<span class="inv-kpi__value">₹{{ totalFaceValue | number: '1.2-2' }}</span>
<span class="inv-kpi__label">Total Invested (Book Value)</span>
<span class="inv-kpi__value">₹{{ totalBookValue | number: '1.2-2' }}</span>
<span class="inv-kpi__sub">Face value ₹{{ totalFaceValue | number: '1.2-2' }}</span>
</div>
<div class="inv-kpi">
<span class="inv-kpi__label">Accrued Interest / Income</span>
<span class="inv-kpi__label">Interest Receivable</span>
<span class="inv-kpi__value col-in">₹{{ totalAccruedInterest | number: '1.2-2' }}</span>
<span class="inv-kpi__sub"
>Earned till today, not received · ₹{{ totalProvisioned | number: '1.2-2' }} provisioned</span
>
</div>
<div class="inv-kpi">
<span class="inv-kpi__label">Projected Value at Maturity</span>
<span class="inv-kpi__label">Value at Maturity</span>
<span class="inv-kpi__value">₹{{ totalMaturityValue | number: '1.2-2' }}</span>
<span class="inv-kpi__sub">Securities at face value, FDs with interest</span>
</div>
</div>
@@ -51,7 +67,9 @@
<th>Instrument Type</th>
<th class="num">Holdings</th>
<th class="num">Face Value</th>
<th class="num col-in">Accrued Interest</th>
<th class="num">Book Value</th>
<th class="num">Share</th>
<th class="num col-in">Interest Receivable</th>
<th class="num col-net">Maturity Value</th>
<th></th>
</tr>
@@ -62,6 +80,8 @@
<td>{{ s.label }}</td>
<td class="num">{{ s.count }}</td>
<td class="num">₹{{ s.faceValue | number: '1.2-2' }}</td>
<td class="num">₹{{ s.bookValue | number: '1.2-2' }}</td>
<td class="num">{{ s.sharePct | number: '1.1-1' }}%</td>
<td class="num col-in">₹{{ s.accruedInterest | number: '1.2-2' }}</td>
<td class="num col-net">₹{{ s.maturityValue | number: '1.2-2' }}</td>
<td>
@@ -75,6 +95,8 @@
<td>Total</td>
<td class="num">{{ totalHoldings }}</td>
<td class="num">₹{{ totalFaceValue | number: '1.2-2' }}</td>
<td class="num">₹{{ totalBookValue | number: '1.2-2' }}</td>
<td class="num">{{ totalBookValue > 0 ? '100%' : '—' }}</td>
<td class="num">₹{{ totalAccruedInterest | number: '1.2-2' }}</td>
<td class="num">₹{{ totalMaturityValue | number: '1.2-2' }}</td>
<td></td>
@@ -84,93 +106,70 @@
</div>
<div class="pg-card">
<div class="pos-section-label">Portfolio Allocation — Target vs Actual</div>
<p class="pg-sub">
Govt Security, Non-SLR, Mutual Fund and Share targets trace to RBI's SLR floor (18% of NDTL) and Non-SLR ceiling
(≤10% of deposits) for Urban Co-operative Banks; Fixed Deposit and Bond are board-approved policy choices within
the room that framework leaves.
</p>
<div class="pos-section-label">RBI Limits</div>
@if (limitNote) {
<p class="inv-hint inv-hint--bad">{{ limitNote }}</p>
}
@if (limits.length) {
<table class="pg-table">
<thead>
<tr>
<th>Instrument Type</th>
<th>Target Basis</th>
<th class="num">Target %</th>
<th class="num">Actual %</th>
<th class="num">Actual Value</th>
<th class="num">Variance</th>
<th>Limit</th>
<th>Basis</th>
<th class="num">Allowed</th>
<th class="num">Used</th>
<th class="num">Used %</th>
<th>Status</th>
</tr>
</thead>
<tbody>
@for (a of allocationVsTarget; track a.type) {
@for (l of limits; track l.label) {
<tr>
<td>{{ a.label }}</td>
<td>{{ l.label }}</td>
<td>{{ l.basis }}</td>
<td class="num">₹{{ l.limit | number: '1.2-2' }}</td>
<td class="num">₹{{ l.used | number: '1.2-2' }}</td>
<td class="num">{{ l.usedPct === null ? '—' : (l.usedPct | number: '1.1-1') + '%' }}</td>
<td>
<span class="inv-badge" [class.inv-badge--matured]="a.isRbiLinked">
{{ a.isRbiLinked ? 'RBI SLR / Non-SLR Norm' : 'Board Policy' }}
</span>
</td>
<td class="num">{{ a.targetPct }}%</td>
<td class="num">{{ a.actualPct }}%</td>
<td class="num">₹{{ a.actualValue | number: '1.2-2' }}</td>
<td
class="num"
[class.col-out]="a.statusLabel !== 'Within Target'"
[class.col-in]="a.statusLabel === 'Within Target'"
>
{{ a.variancePct > 0 ? '+' : '' }}{{ a.variancePct }}%
</td>
<td>
<span
class="inv-badge"
[class.inv-badge--active]="a.statusLabel === 'Within Target'"
[class.inv-badge--sold]="a.statusLabel === 'Over-Allocated'"
[class.inv-badge--written_off]="a.statusLabel === 'Under-Allocated'"
>
{{ a.statusLabel }}
<span class="inv-badge" [class.inv-badge--active]="l.within" [class.inv-badge--written_off]="!l.within">
{{ l.within ? 'Within' : 'Above limit' }}
</span>
</td>
</tr>
}
</tbody>
<tfoot>
<tr class="cctr-total-row">
<td>Total</td>
<td class="num">100%</td>
<td class="num">100%</td>
<td class="num">₹{{ totalFaceValue | number: '1.2-2' }}</td>
<td colspan="2"></td>
</tr>
</tfoot>
</table>
}
</div>
<div class="pg-card">
<div class="pos-section-label">Due-Date Diary — Maturing Within 90 Days</div>
<div class="pos-section-label">Maturing Within 90 Days</div>
@if (maturingSoon.length === 0) {
<div class="pg-empty">No holdings maturing in the next 90 days.</div>
} @else {
<div>
@for (h of maturingSoon; track h.certNo) {
@for (m of maturingSoon; track m.dealNo) {
<div class="inv-maturity-row">
<span>
<span class="pg-chip">{{ h.certNo }}</span>
{{ h.scriptName }} — {{ h.party }} ({{ instrumentLabel(h.instrumentType) }})
<span class="pg-chip">{{ m.dealNo }}</span>
{{ m.particulars }} ({{ m.instrument }})
</span>
<span>
Matures {{ h.maturityDate }} ·
Matures {{ m.maturityDate }} · ₹{{ m.amount | number: '1.2-2' }} ·
<span
class="inv-maturity-days"
[class.inv-maturity-days--soon]="daysLeft(h) <= 30"
[class.inv-maturity-days--ok]="daysLeft(h) > 30"
[class.inv-maturity-days--soon]="m.days <= 30"
[class.inv-maturity-days--ok]="m.days > 30"
>
{{ daysLeft(h) }} days
{{ m.days < 0 ? 'Overdue ' + -m.days + ' days' : m.days + ' days' }}
</span>
</span>
</div>
}
</div>
<div class="inv-form-actions" style="padding: 8px 16px">
<a class="pg-btn pg-btn--ghost" routerLink="/investment/diary">Open Due Date Diary</a>
</div>
}
</div>
@@ -179,19 +178,17 @@
<div class="inv-nav-grid" style="padding: 16px">
<a class="inv-nav-card" routerLink="/investment/fd">
<span class="inv-nav-card__label">Fixed Deposit</span>
<span class="inv-nav-card__count">{{ summaries[0].count }}</span>
<span class="inv-nav-card__value">Purchase / Interest / Sell / Write-off</span>
<span class="inv-nav-card__count">{{ countOf('FD') }}</span>
<span class="inv-nav-card__value">Purchase / Interest / Maturity / Renewal</span>
</a>
<a class="inv-nav-card" routerLink="/investment/bonds">
<span class="inv-nav-card__label">Govt Security / Non-SLR / Bonds / MF</span>
<span class="inv-nav-card__count">{{
summaries[1].count + summaries[2].count + summaries[3].count + summaries[4].count
}}</span>
<span class="inv-nav-card__count">{{ countOf('GOVT_SECURITY', 'NON_SLR', 'BOND', 'MUTUAL_FUND') }}</span>
<span class="inv-nav-card__value">Purchase / Interest / Sell / Amortize</span>
</a>
<a class="inv-nav-card" routerLink="/investment/share">
<span class="inv-nav-card__label">Share Entry</span>
<span class="inv-nav-card__count">{{ summaries[5].count }}</span>
<span class="inv-nav-card__count">{{ countOf('SHARE') }}</span>
<span class="inv-nav-card__value">Purchase / Dividend / Sell / Write-off</span>
</a>
<a class="inv-nav-card" routerLink="/investment/interest">
@@ -6,21 +6,23 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { Component } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterLink } from '@angular/router';
import {
ALL_HOLDINGS,
ALLOCATION_TARGET_IS_RBI_LINKED,
INSTRUMENT_LABELS,
InstrumentType,
InvestmentHolding,
TARGET_ALLOCATION_PCT,
accruedInterest,
daysToMaturity,
maturityAmount
} from '../investment-data';
import { forkJoin } from 'rxjs';
import { INSTRUMENT_LABELS, InstrumentType, parseDDMMYYYY, todayDDMMYYYY } from '../investment-data';
import { exportWorkbook } from '../investment-export';
import {
InvestmentBucketReportDto,
InvestmentBucketRowDto,
InvestmentFdDto,
InvestmentFdLimitDto,
InvestmentInterestReportDto,
InvestmentNonSlrLimitDto,
InvestmentPurchaseDto,
InvestmentService,
apiErrorMessage
} from '../investment.service';
interface InstrumentSummary {
type: InstrumentType;
@@ -28,25 +30,45 @@ interface InstrumentSummary {
route: string;
count: number;
faceValue: number;
bookValue: number;
accruedInterest: number;
maturityValue: number;
sharePct: number;
}
interface AllocationRow {
type: InstrumentType;
interface LimitRow {
label: string;
targetPct: number;
actualPct: number;
actualValue: number;
variancePct: number;
statusLabel: 'Within Target' | 'Over-Allocated' | 'Under-Allocated';
/** True when the target itself traces to an RBI SLR/Non-SLR rule rather than being a
* board-only policy choice — see TARGET_ALLOCATION_PCT's doc comment in investment-data.ts. */
isRbiLinked: boolean;
basis: string;
limit: number | null;
used: number;
usedPct: number | null;
within: boolean;
}
/** Cross-instrument portfolio dashboard — every figure is derived from ALL_HOLDINGS, never
* hand-duplicated, so it can never drift from the per-instrument screens or Reports. */
/** A holding maturing soon, or past maturity and not yet redeemed / closed. */
interface MaturingRow {
dealNo: string;
particulars: string;
instrument: string;
maturityDate: string;
days: number;
amount: number;
}
const ROUTE: Record<InstrumentType, string> = {
FD: '/investment/fd',
GOVT_SECURITY: '/investment/bonds',
NON_SLR: '/investment/bonds',
BOND: '/investment/bonds',
MUTUAL_FUND: '/investment/bonds',
SHARE: '/investment/share'
};
/**
* Cross-instrument portfolio dashboard on live data: what is held today by instrument (face value, book value,
* interest earned and not yet received, value at maturity), where the portfolio stands against the RBI limits, and
* what matures in the next 90 days.
*/
@Component({
selector: 'mifosx-investment-dashboard',
templateUrl: './investment-dashboard.component.html',
@@ -60,107 +82,216 @@ interface AllocationRow {
RouterLink
]
})
export class InvestmentDashboardComponent {
asOnDate = '';
export class InvestmentDashboardComponent implements OnInit {
private readonly investmentService = inject(InvestmentService);
asOnDate = todayDDMMYYYY();
loading = false;
error = '';
generating = false;
toastMsg = '';
toastVisible = false;
private toastTimer: ReturnType<typeof setTimeout> | undefined;
private readonly types: Array<{ type: InstrumentType; route: string }> = [
{ type: 'FD', route: '/investment/fd' },
{ type: 'GOVT_SECURITY', route: '/investment/bonds' },
{ type: 'NON_SLR', route: '/investment/bonds' },
{ type: 'BOND', route: '/investment/bonds' },
{ type: 'MUTUAL_FUND', route: '/investment/bonds' },
{ type: 'SHARE', route: '/investment/share' }
summaries: InstrumentSummary[] = [];
limits: LimitRow[] = [];
limitNote = '';
maturingSoon: MaturingRow[] = [];
totalReceivable = 0;
totalProvisioned = 0;
ngOnInit(): void {
this.load();
}
load(): void {
const today = this.asOnDate;
const d = parseDDMMYYYY(today);
const fyStart = `01-04-${d.getMonth() >= 3 ? d.getFullYear() : d.getFullYear() - 1}`;
this.loading = true;
this.error = '';
forkJoin({
bucket: this.investmentService.getBucketReport(today),
interest: this.investmentService.getInterestReport(fyStart, today),
purchases: this.investmentService.getPurchases(),
fds: this.investmentService.getFds(),
fdQuote: this.investmentService.quoteFd({ amount: 0, intRate: 0, dealDate: today }),
nonSlr: this.investmentService.getNonSlrLimit(null, today, 0)
}).subscribe({
next: (r) => {
this.build(r.bucket, r.interest, r.purchases, r.fds, r.fdQuote.limit ?? null, r.nonSlr);
this.loading = false;
},
error: (err: unknown) => {
this.loading = false;
this.error = apiErrorMessage(err);
}
});
}
private build(
bucket: InvestmentBucketReportDto,
interest: InvestmentInterestReportDto,
purchases: InvestmentPurchaseDto[],
fds: InvestmentFdDto[],
fdLimit: InvestmentFdLimitDto | null,
nonSlr: InvestmentNonSlrLimitDto
): void {
const purchaseById = new Map<number, InvestmentPurchaseDto>(
purchases.map((p) => [
p.id,
p
])
);
const fdById = new Map<number, InvestmentFdDto>(
fds
.filter((f) => f.id != null)
.map((f) => [
f.id as number,
f
])
);
const receivable = new Map<string, number>(
interest.rows.map((x) => [
x.instrument + ':' + x.refId,
x.receivable
])
);
this.totalReceivable = interest.totalReceivable;
this.totalProvisioned = interest.totalProvisioned;
// Bucket rows are the Govt Securities, bonds and FDs held today; the purchase tells a Non-SLR from a Bond.
const typeOf = (r: InvestmentBucketRowDto): InstrumentType =>
r.instrument === 'FD' ? 'FD' : (purchaseById.get(r.refId)?.bondType ?? 'BOND');
const acc = new Map<InstrumentType, InstrumentSummary>();
const sum = (type: InstrumentType): InstrumentSummary => {
let s = acc.get(type);
if (!s) {
s = {
type,
label: INSTRUMENT_LABELS[type],
route: ROUTE[type],
count: 0,
faceValue: 0,
bookValue: 0,
accruedInterest: 0,
maturityValue: 0,
sharePct: 0
};
acc.set(type, s);
}
return s;
};
for (const r of bucket.rows) {
const s = sum(typeOf(r));
s.count += 1;
s.faceValue += r.faceValue;
s.bookValue += r.bookValue;
s.accruedInterest += receivable.get((r.instrument === 'FD' ? 'FD' : 'SECURITY') + ':' + r.refId) ?? 0;
// A security is redeemed at face value; an FD pays its maturity amount (just the principal on a payout FD).
s.maturityValue +=
r.instrument === 'FD' ? (fdById.get(r.refId)?.expectedMaturityAmount ?? r.faceValue) : r.faceValue;
}
// Mutual funds and shares have no maturity, so they are not in the buckets; their units are held at cost.
for (const p of purchases) {
if ((p.bondType === 'MUTUAL_FUND' || p.bondType === 'SHARE') && p.status === 'ACTIVE') {
const s = sum(p.bondType);
s.count += 1;
s.faceValue += p.faceValue;
s.bookValue += p.bookValue;
s.maturityValue += p.bookValue;
}
}
const order: InstrumentType[] = [
'GOVT_SECURITY',
'FD',
'NON_SLR',
'BOND',
'MUTUAL_FUND',
'SHARE'
];
const total = [...acc.values()].reduce((t, s) => t + s.bookValue, 0);
this.summaries = order
.map((t) => sum(t))
.map((s) => ({ ...s, sharePct: total > 0 ? (s.bookValue / total) * 100 : 0 }));
constructor() {
const d = new Date();
this.asOnDate = `${String(d.getDate()).padStart(2, '0')}-${String(d.getMonth() + 1).padStart(2, '0')}-${d.getFullYear()}`;
this.limits = [];
this.limitNote = '';
if (fdLimit?.grossLimit != null) {
const used = fdLimit.fdOutstanding + fdLimit.bankBalances;
this.limits.push(
this.limitRow(
'Deposits with other banks',
'FDs + current accounts, ≤ 20% of deposits',
fdLimit.grossLimit,
used
)
);
}
if (nonSlr.nonSlrLimit != null) {
this.limits.push(
this.limitRow(
'Non-SLR investments',
'Bonds, CP / CD, MF, ≤ 10% of deposits',
nonSlr.nonSlrLimit,
nonSlr.nonSlrOutstanding
)
);
this.limits.push(
this.limitRow(
'Unlisted non-SLR',
`≤ 10% of non-SLR held on ${nonSlr.asOnDate}`,
nonSlr.unlistedLimit,
nonSlr.unlistedOutstanding
)
);
} else {
this.limitNote = `Total deposits as on ${nonSlr.asOnDate} are not entered yet; enter them on the FD screen to see the RBI limits.`;
}
private holdingsOf(type: InstrumentType): InvestmentHolding[] {
return ALL_HOLDINGS.filter((h) => h.instrumentType === type);
this.maturingSoon = bucket.rows
.filter((r) => r.daysToMaturity <= 90)
.map((r) => ({
dealNo: r.dealNo,
particulars: r.particulars,
instrument: INSTRUMENT_LABELS[typeOf(r)],
maturityDate: r.maturityDate,
days: r.daysToMaturity,
amount: r.instrument === 'FD' ? (fdById.get(r.refId)?.expectedMaturityAmount ?? r.faceValue) : r.faceValue
}));
}
get summaries(): InstrumentSummary[] {
return this.types.map(({ type, route }) => {
const holdings = this.holdingsOf(type);
return {
type,
label: INSTRUMENT_LABELS[type],
route,
count: holdings.length,
faceValue: holdings.reduce((s, h) => s + h.faceValue, 0),
accruedInterest: holdings.reduce((s, h) => s + accruedInterest(h, this.asOnDate), 0),
maturityValue: holdings.reduce((s, h) => s + maturityAmount(h), 0)
};
});
}
/** Board-approved policy target % per instrument type vs the portfolio's actual allocation
* (by invested/face value) — a ±2 percentage-point band is treated as "Within Target" since
* a treasury desk can't rebalance to the exact decimal every day. */
get allocationVsTarget(): AllocationRow[] {
const total = this.totalFaceValue;
return this.types.map(({ type }) => {
const value = this.holdingsOf(type).reduce((s, h) => s + h.faceValue, 0);
const actualPct = total ? (value / total) * 100 : 0;
const targetPct = TARGET_ALLOCATION_PCT[type];
const variancePct = +(actualPct - targetPct).toFixed(1);
const statusLabel: AllocationRow['statusLabel'] =
Math.abs(variancePct) <= 2 ? 'Within Target' : variancePct > 0 ? 'Over-Allocated' : 'Under-Allocated';
return {
type,
label: INSTRUMENT_LABELS[type],
targetPct,
actualPct: +actualPct.toFixed(1),
actualValue: value,
variancePct,
statusLabel,
isRbiLinked: ALLOCATION_TARGET_IS_RBI_LINKED[type]
};
});
private limitRow(label: string, basis: string, limit: number, used: number): LimitRow {
return { label, basis, limit, used, usedPct: limit > 0 ? (used / limit) * 100 : null, within: used <= limit };
}
get totalHoldings(): number {
return ALL_HOLDINGS.length;
return this.summaries.reduce((t, s) => t + s.count, 0);
}
get totalFaceValue(): number {
return ALL_HOLDINGS.reduce((s, h) => s + h.faceValue, 0);
return this.summaries.reduce((t, s) => t + s.faceValue, 0);
}
get totalBookValue(): number {
return this.summaries.reduce((t, s) => t + s.bookValue, 0);
}
get totalAccruedInterest(): number {
return ALL_HOLDINGS.reduce((s, h) => s + accruedInterest(h, this.asOnDate), 0);
return this.summaries.reduce((t, s) => t + s.accruedInterest, 0);
}
get totalMaturityValue(): number {
return ALL_HOLDINGS.reduce((s, h) => s + maturityAmount(h), 0);
return this.summaries.reduce((t, s) => t + s.maturityValue, 0);
}
get activeCount(): number {
return ALL_HOLDINGS.filter((h) => h.status === 'ACTIVE').length;
get overdueCount(): number {
return this.maturingSoon.filter((m) => m.days < 0).length;
}
get maturedCount(): number {
return ALL_HOLDINGS.filter((h) => h.status === 'MATURED').length;
}
/** Holdings maturing within the next 90 days — a "due-date diary" style widget. */
get maturingSoon(): InvestmentHolding[] {
return ALL_HOLDINGS.filter((h) => h.status === 'ACTIVE' && daysToMaturity(h, this.asOnDate) <= 90).sort(
(a, b) => daysToMaturity(a, this.asOnDate) - daysToMaturity(b, this.asOnDate)
);
}
daysLeft(h: InvestmentHolding): number {
return daysToMaturity(h, this.asOnDate);
}
instrumentLabel(type: InstrumentType): string {
return INSTRUMENT_LABELS[type];
/** Holdings of one or more instrument types, for the Quick Entry cards. */
countOf(...types: InstrumentType[]): number {
return this.summaries.filter((s) => types.includes(s.type)).reduce((t, s) => t + s.count, 0);
}
async exportExcel(): Promise<void> {
@@ -176,54 +307,97 @@ export class InvestmentDashboardComponent {
'Instrument Type',
'Holdings',
'Face Value',
'Accrued Interest',
'Book Value',
'Share %',
'Interest Receivable',
'Maturity Value'
],
widths: [
26,
12,
22,
10,
18,
18,
10,
18,
18
],
rows: this.summaries.map((s) => [
rows: [
...this.summaries.map((s) => [
s.label,
s.count,
s.faceValue,
s.bookValue,
Number(s.sharePct.toFixed(2)),
s.accruedInterest,
s.maturityValue
])
]),
[
'Total',
this.totalHoldings,
this.totalFaceValue,
this.totalBookValue,
100,
this.totalAccruedInterest,
this.totalMaturityValue
]
]
},
{
sheetName: 'Portfolio Allocation',
title: 'Portfolio Allocation — Target vs Actual',
sheetName: 'RBI Limits',
title: 'RBI Limits',
subtitle: `As on ${this.asOnDate}`,
headers: [
'Instrument Type',
'Target Basis',
'Target %',
'Actual %',
'Actual Value',
'Variance %',
'Limit',
'Basis',
'Allowed',
'Used',
'Used %',
'Status'
],
widths: [
26,
20,
12,
12,
40,
18,
18,
10,
14
],
rows: this.limits.map((l) => [
l.label,
l.basis,
l.limit,
l.used,
l.usedPct === null ? null : Number(l.usedPct.toFixed(2)),
l.within ? 'Within' : 'Above limit'
])
},
{
sheetName: 'Maturing in 90 days',
title: 'Maturing Within 90 Days (and overdue)',
subtitle: `As on ${this.asOnDate}`,
headers: [
'Deal No',
'Investment',
'Particulars',
'Maturity',
'Days',
'Amount'
],
widths: [
16,
16,
40,
12,
10,
18
],
rows: this.allocationVsTarget.map((a) => [
a.label,
a.isRbiLinked ? 'RBI SLR / Non-SLR Norm' : 'Board Policy',
a.targetPct,
a.actualPct,
a.actualValue,
a.variancePct,
a.statusLabel
rows: this.maturingSoon.map((m) => [
m.dealNo,
m.instrument,
m.particulars,
m.maturityDate,
m.days,
m.amount
])
}
],
+566 -29
View File
@@ -17,7 +17,7 @@
*/
export type InstrumentType = 'FD' | 'GOVT_SECURITY' | 'NON_SLR' | 'BOND' | 'MUTUAL_FUND' | 'SHARE';
export type HoldingStatus = 'ACTIVE' | 'MATURED' | 'SOLD' | 'WRITTEN_OFF';
export type HoldingStatus = 'PENDING_SETTLEMENT' | 'ACTIVE' | 'MATURED' | 'SOLD' | 'WRITTEN_OFF';
export type InterestFreq = 'MONTHLY' | 'QUARTERLY' | 'HALF_YEARLY' | 'YEARLY' | 'CUMULATIVE';
export type TxnType =
| 'PURCHASE'
@@ -28,6 +28,7 @@ export type TxnType =
| 'REDEEM'
| 'WRITE_OFF'
| 'AMORTIZE'
| 'TRANSFER'
| 'PART_PAYMENT';
export const INSTRUMENT_LABELS: Record<InstrumentType, string> = {
@@ -123,6 +124,22 @@ export interface InvestmentHolding {
* never re-counts days up to this date, so re-running a Calculation & Post for an overlapping
* or repeated period always yields 0 instead of double-posting the same interest. */
interestPostedTillDate?: string;
/** RBI investment category chosen at purchase — HTM / AFS / HFT. */
category?: string;
/** SGL / CSGL account the security is held in (custody, not an accounting GL). */
sglAccountNo?: string;
/** Backend id / deal number / party code once the purchase is saved (absent on sample rows). */
id?: number;
dealNo?: string;
partyCode?: string;
bookValue?: number;
settlementAmount?: number;
/** Settlement date of the deal (deal date + T+n) — it can be settled on or after this day. */
settlementDate?: string;
/** Last coupon date before the purchase; coupons fall every six months from it. */
lastIntDate?: string;
/** Journal entry transaction posted when the deal was settled. */
glTransactionId?: string;
}
export interface InvestmentTxn {
@@ -248,6 +265,80 @@ export function accruedInterestBetween(h: InvestmentHolding, fromStr: string, to
return Math.round(h.faceValue * (h.interestRate / 100) * (days / 365.25));
}
/** Days between two DD-MM-YYYY dates on a 30/360 basis (every month 30 days), as the bank's existing
* CBS counts them — e.g. 10-08 → 30-09 = 50 days, 10-08 → 07-10 = 57 days. */
export function days360(fromStr: string, toStr: string): number {
const a = parseDDMMYYYY(fromStr);
const b = parseDDMMYYYY(toStr);
if (isNaN(a.getTime()) || isNaN(b.getTime()) || b <= a) {
return 0;
}
const d1 = Math.min(a.getDate(), 30);
const d2 = Math.min(b.getDate(), 30);
return (b.getFullYear() - a.getFullYear()) * 360 + (b.getMonth() - a.getMonth()) * 30 + (d2 - d1);
}
/** Most recent half-yearly coupon date on or before `onStr`, derived from the maturity date (coupons
* fall on the maturity day/month and six months either side of it). */
export function lastHalfYearlyCouponDate(maturityStr: string, onStr: string): string {
const mat = parseDDMMYYYY(maturityStr);
const on = parseDDMMYYYY(onStr);
if (isNaN(mat.getTime()) || isNaN(on.getTime())) {
return '';
}
const day = mat.getDate();
const couponOn = (year: number, month: number): Date => {
const lastDay = new Date(year, month + 1, 0).getDate();
return new Date(year, month, Math.min(day, lastDay));
};
const months = [
mat.getMonth() % 6,
(mat.getMonth() % 6) + 6
];
let best: Date | undefined;
for (const year of [
on.getFullYear() - 1,
on.getFullYear()
]) {
for (const m of months) {
const c = couponOn(year, m);
if (c <= on && (!best || c > best)) {
best = c;
}
}
}
return best ? formatDDMMYYYY(best) : '';
}
/** First half-yearly coupon date after `onStr` (coupons fall on the maturity day/month and six months
* either side), never later than maturity. */
export function nextHalfYearlyCouponDate(maturityStr: string, onStr: string): string {
const last = lastHalfYearlyCouponDate(maturityStr, onStr);
const mat = parseDDMMYYYY(maturityStr);
if (!last || isNaN(mat.getTime())) {
return '';
}
const l = parseDDMMYYYY(last);
const year = l.getFullYear() + (l.getMonth() >= 6 ? 1 : 0);
const month = (l.getMonth() + 6) % 12;
const next = new Date(year, month, Math.min(mat.getDate(), new Date(year, month + 1, 0).getDate()));
return formatDDMMYYYY(next > mat ? mat : next);
}
/** The two coupon days of a half-yearly security, e.g. "14 Feb / 14 Aug". */
export function couponDatesLabel(maturityStr: string): string {
const mat = parseDDMMYYYY(maturityStr);
if (isNaN(mat.getTime())) {
return '';
}
const label = (month: number): string => {
const day = Math.min(mat.getDate(), new Date(2001, month + 1, 0).getDate());
return `${day} ${new Date(2001, month, 1).toLocaleString('en-US', { month: 'short' })}`;
};
const first = mat.getMonth() % 6;
return `${label(first)} / ${label(first + 6)}`;
}
export function formatDDMMYYYY(d: Date): string {
return `${String(d.getDate()).padStart(2, '0')}-${String(d.getMonth() + 1).padStart(2, '0')}-${d.getFullYear()}`;
}
@@ -1404,99 +1495,405 @@ export const CASH_BANK_GL_MASTER: InvestmentGlOption[] = [
{ glCode: '110030', glName: 'HDFC BANK CURRENT ACCOUNT' }
];
/** Investment GLs a script / party can be mapped to. PROPOSED codes awaiting approval — the
* backend will take these from the chart of accounts, never hard-coded. */
export const INVESTMENT_GL_OPTIONS: InvestmentGlOption[] = [
{ glCode: '100701', glName: 'INVESTMENT IN CENTRAL GOVT SECURITIES' },
{ glCode: '100702', glName: 'INVESTMENT IN STATE GOVT SECURITIES' },
{ glCode: '100703', glName: 'INVESTMENT IN BONDS / DEBENTURES' },
{ glCode: '100704', glName: 'FIXED DEPOSITS WITH OTHER BANKS' },
{ glCode: '100705', glName: 'INVESTMENT IN MUTUAL FUNDS' },
{ glCode: '100706', glName: 'INVESTMENT IN SHARES' }
];
/** Fallback investment GL when a script has none mapped. */
export const INVESTMENT_GL_BY_TYPE: Record<InstrumentType, string> = {
GOVT_SECURITY: '100701',
NON_SLR: '100703',
BOND: '100703',
FD: '100704',
MUTUAL_FUND: '100705',
SHARE: '100706'
};
/** Broken-period interest paid to the seller at purchase — an expense, not part of cost (RBI UCB Investment
* Directions para 152). */
export const BROKEN_PERIOD_INTEREST_GL: InvestmentGlOption = {
glCode: '500606',
glName: 'BROKEN PERIOD INTEREST PAID ON INVESTMENTS'
};
/** Charges on an investment deal — expenses on their own GLs, not part of the book value (Jitendra Sir). */
export const STAMP_DUTY_GL: InvestmentGlOption = { glCode: '500601', glName: 'STAMP DUTY ON INVESTMENTS' };
export const BROKERAGE_GL: InvestmentGlOption = { glCode: '500602', glName: 'BROKERAGE ON INVESTMENTS' };
export const OTHER_CHARGES_GL: InvestmentGlOption = { glCode: '500603', glName: 'OTHER CHARGES ON INVESTMENTS' };
/** Premium paid over face value, held until amortised to maturity (Jitendra Sir). */
export const PREMIUM_ON_INVESTMENTS_GL: InvestmentGlOption = { glCode: '100707', glName: 'PREMIUM ON INVESTMENTS' };
/** Interest receivable (the senior's "Provision A/c") — debited for interest bought from the seller. */
export const INTEREST_RECEIVABLE_GL: InvestmentGlOption = {
glCode: '100603',
glName: 'INTEREST RECEIVABLE ON INVESTMENTS (PROVISION)'
};
/** Bank accounts a purchase can be paid from — these GLs already exist in the chart of accounts. */
export const SETTLEMENT_BANK_GL_OPTIONS: InvestmentGlOption[] = [
{ glCode: '100201', glName: 'IDBI BANK' },
{ glCode: '100202', glName: 'YES BANK' }
];
/** Every GL the Investment screens can show by name. */
export const INVESTMENT_GL_LOOKUP: InvestmentGlOption[] = [
...INVESTMENT_GL_OPTIONS,
INTEREST_RECEIVABLE_GL,
...SETTLEMENT_BANK_GL_OPTIONS
];
/** SLR classification on the Script Master, as in the bank's existing CBS ("GOI" = Central Govt). */
export type SlrType = 'GOI' | 'STATE_GOVT' | 'TREASURY' | 'NON_SLR';
export const SLR_TYPE_OPTIONS: Array<{ value: SlrType; label: string }> = [
{ value: 'GOI', label: 'GOI' },
{ value: 'STATE_GOVT', label: 'STATE GOVT' },
{ value: 'TREASURY', label: 'TREASURY' },
{ value: 'NON_SLR', label: 'NON SLR' }
];
export interface ScriptMaster {
/** Backend id once the script is saved (absent on the sample rows). */
id?: number;
scriptCode: string;
scriptName: string;
instrumentType: InstrumentType;
isin: string;
faceValuePerUnit: number;
// Fields below follow the bank's existing CBS Script Master; a purchase picks them up instead
// of the dealer re-typing them on every deal.
slrType?: SlrType;
/** Investment GL this script is booked to. */
glAccountId?: number;
glCode?: string;
glName?: string;
active?: boolean;
/** Interest (coupon) rate % per annum. */
couponRate?: number;
issueDate?: string;
maturityDate?: string;
// Issuer details — used for Bond / Mutual Fund scripts.
companyName?: string;
address1?: string;
address2?: string;
address3?: string;
city?: string;
pincode?: string;
phone?: string;
fax?: string;
corpCode?: string;
/** Credit rating — long-term for bonds, short-term for CP / CD (Non-SLR and Bond scripts). */
rating?: string;
ratingAgency?: string;
/** Listed on an exchange or proposed to be listed; unlisted ones have their own RBI limit. */
listed?: boolean;
}
/** Credit ratings on the Script Master, best first: long-term for bonds, short-term for CP / CD. */
export const RATING_OPTIONS: Array<{ group: string; values: string[] }> = [
{
group: 'Long-term (bonds)',
values: [
'AAA',
'AA+',
'AA',
'AA-',
'A+',
'A',
'A-',
'BBB+',
'BBB',
'BBB-',
'BB+',
'BB',
'BB-',
'B+',
'B',
'B-',
'C',
'D'
]
},
{
group: 'Short-term (CP / CD)',
values: [
'A1+',
'A1',
'A2+',
'A2',
'A3+',
'A3',
'A4+',
'A4'
]
},
{ group: 'None', values: ['UNRATED'] }
];
/** RBI: bonds rated "A" or higher, CP / CD rated "A2" or higher. */
export const ELIGIBLE_RATINGS: string[] = [
'AAA',
'AA+',
'AA',
'AA-',
'A+',
'A',
'A-',
'A1+',
'A1',
'A2+',
'A2'
];
/** Credit rating agencies registered with SEBI. */
export const RATING_AGENCY_OPTIONS: Array<{ value: string; label: string }> = [
{ value: 'CRISIL', label: 'CRISIL' },
{ value: 'ICRA', label: 'ICRA' },
{ value: 'CARE', label: 'CARE' },
{ value: 'INDIA_RATINGS', label: 'India Ratings' },
{ value: 'ACUITE', label: 'Acuite' },
{ value: 'BRICKWORK', label: 'Brickwork' },
{ value: 'INFOMERICS', label: 'Infomerics' }
];
/** Period between two DD-MM-YYYY dates as years / months / days, as shown on the Script Master. */
export function periodBetween(fromStr?: string, toStr?: string): { years: number; months: number; days: number } {
const none = { years: 0, months: 0, days: 0 };
if (!fromStr || !toStr) {
return none;
}
const from = parseDDMMYYYY(fromStr);
const to = parseDDMMYYYY(toStr);
if (isNaN(from.getTime()) || isNaN(to.getTime()) || to < from) {
return none;
}
let years = to.getFullYear() - from.getFullYear();
let months = to.getMonth() - from.getMonth();
let days = to.getDate() - from.getDate();
if (days < 0) {
months -= 1;
days += new Date(to.getFullYear(), to.getMonth(), 0).getDate();
}
if (months < 0) {
years -= 1;
months += 12;
}
return { years, months, days };
}
export const SCRIPT_MASTER: ScriptMaster[] = [
{ scriptCode: 'FD-CUM', scriptName: 'Cumulative Fixed Deposit', instrumentType: 'FD', isin: '', faceValuePerUnit: 1 },
{
scriptCode: 'FD-CUM',
scriptName: 'Cumulative Fixed Deposit',
instrumentType: 'FD',
isin: '',
faceValuePerUnit: 1,
slrType: 'NON_SLR',
glCode: '100704'
},
{
scriptCode: 'FD-MIP',
scriptName: 'Monthly Interest Payout FD',
instrumentType: 'FD',
isin: '',
faceValuePerUnit: 1
faceValuePerUnit: 1,
slrType: 'NON_SLR',
glCode: '100704'
},
{
scriptCode: 'IN0020230012',
scriptName: '7.26% GOI 2033',
instrumentType: 'GOVT_SECURITY',
isin: 'IN0020230012',
faceValuePerUnit: 100
faceValuePerUnit: 100,
slrType: 'GOI',
glCode: '100701',
couponRate: 7.26,
issueDate: '15-01-2023',
maturityDate: '15-01-2033'
},
{
scriptCode: 'IN0020220089',
scriptName: '7.10% GOI 2029',
instrumentType: 'GOVT_SECURITY',
isin: 'IN0020220089',
faceValuePerUnit: 100
faceValuePerUnit: 100,
slrType: 'GOI',
glCode: '100701',
couponRate: 7.1,
issueDate: '10-03-2022',
maturityDate: '10-03-2029'
},
{
scriptCode: 'IN0020210056',
scriptName: '6.79% GOI 2027',
instrumentType: 'GOVT_SECURITY',
isin: 'IN0020210056',
faceValuePerUnit: 100,
slrType: 'GOI',
glCode: '100701',
couponRate: 6.79,
issueDate: '05-06-2021',
maturityDate: '05-06-2027'
},
{
scriptCode: 'IN0020240034',
scriptName: '7.18% GOI 2037',
instrumentType: 'GOVT_SECURITY',
isin: 'IN0020240034',
faceValuePerUnit: 100,
slrType: 'GOI',
glCode: '100701',
couponRate: 7.18,
issueDate: '22-04-2024',
maturityDate: '22-04-2037'
},
{
scriptCode: 'MH-SDL-2031',
scriptName: '8.05% Maharashtra SDL 2031',
instrumentType: 'GOVT_SECURITY',
isin: '',
faceValuePerUnit: 100,
slrType: 'STATE_GOVT',
glCode: '100702',
couponRate: 8.05,
issueDate: '15-02-2021',
maturityDate: '15-02-2031'
},
{
scriptCode: 'GJ-SDL-2026',
scriptName: '7.85% Gujarat SDL 2026',
instrumentType: 'GOVT_SECURITY',
isin: '',
faceValuePerUnit: 100,
slrType: 'STATE_GOVT',
glCode: '100702',
couponRate: 7.85,
issueDate: '18-09-2016',
maturityDate: '18-09-2026'
},
{
scriptCode: 'TBILL-364D',
scriptName: '364 Days Treasury Bill',
instrumentType: 'GOVT_SECURITY',
isin: '',
faceValuePerUnit: 100
faceValuePerUnit: 100,
slrType: 'TREASURY',
glCode: '100701',
couponRate: 0,
issueDate: '02-07-2026',
maturityDate: '02-07-2027'
},
{
scriptCode: 'TBILL-91D',
scriptName: '91 Days Treasury Bill',
instrumentType: 'GOVT_SECURITY',
isin: '',
faceValuePerUnit: 100,
slrType: 'TREASURY',
glCode: '100701',
couponRate: 0,
issueDate: '15-05-2026',
maturityDate: '13-08-2026'
},
{
scriptCode: 'REC-7.5-2031',
scriptName: 'REC Ltd Bond 7.50% 2031',
instrumentType: 'NON_SLR',
isin: 'INE020B08JN0',
faceValuePerUnit: 100
faceValuePerUnit: 100,
slrType: 'NON_SLR',
glCode: '100703',
couponRate: 7.5,
issueDate: '11-08-2021',
maturityDate: '11-08-2031',
companyName: 'REC Limited',
city: 'New Delhi'
},
{
scriptCode: 'NABARD-7.35-2030',
scriptName: 'NABARD Bond 7.35% 2030',
instrumentType: 'NON_SLR',
isin: 'INE261F09EU1',
faceValuePerUnit: 100
faceValuePerUnit: 100,
slrType: 'NON_SLR',
glCode: '100703',
couponRate: 7.35,
issueDate: '20-09-2020',
maturityDate: '20-09-2030',
companyName: 'NABARD',
city: 'Mumbai'
},
{
scriptCode: 'LTF-8.1-2028',
scriptName: 'L&T Finance NCD 8.10% 2028',
instrumentType: 'BOND',
isin: 'INE027E07BR5',
faceValuePerUnit: 100
faceValuePerUnit: 100,
slrType: 'NON_SLR',
glCode: '100703',
couponRate: 8.1,
companyName: 'L&T Finance Ltd',
city: 'Mumbai'
},
{
scriptCode: 'BAF-7.95-2027',
scriptName: 'Bajaj Finance NCD 7.95% 2027',
instrumentType: 'BOND',
isin: 'INE296A07SP0',
faceValuePerUnit: 100
faceValuePerUnit: 100,
slrType: 'NON_SLR',
glCode: '100703',
couponRate: 7.95,
companyName: 'Bajaj Finance Ltd',
city: 'Pune'
},
{
scriptCode: 'SBI-OVN',
scriptName: 'SBI Overnight Fund',
instrumentType: 'MUTUAL_FUND',
isin: 'INF200KA1Q40',
faceValuePerUnit: 1000
faceValuePerUnit: 1000,
slrType: 'NON_SLR',
glCode: '100705',
companyName: 'SBI Mutual Fund',
city: 'Mumbai'
},
{
scriptCode: 'HDFC-LIQ',
scriptName: 'HDFC Liquid Fund',
instrumentType: 'MUTUAL_FUND',
isin: 'INF179KA1WR9',
faceValuePerUnit: 1000
faceValuePerUnit: 1000,
slrType: 'NON_SLR',
glCode: '100705',
companyName: 'HDFC Mutual Fund',
city: 'Mumbai'
},
{
scriptCode: 'SBIN',
scriptName: 'State Bank of India',
instrumentType: 'SHARE',
isin: 'INE062A01020',
faceValuePerUnit: 1
faceValuePerUnit: 1,
slrType: 'NON_SLR',
glCode: '100706'
},
{
scriptCode: 'HDFCBANK',
scriptName: 'HDFC Bank Ltd',
instrumentType: 'SHARE',
isin: 'INE040A01034',
faceValuePerUnit: 1
faceValuePerUnit: 1,
slrType: 'NON_SLR',
glCode: '100706'
}
];
@@ -1561,23 +1958,157 @@ export const BROKER_MASTER: BrokerMaster[] = [
];
export interface PartyMaster {
/** Backend id once the party is saved (absent on the sample rows). */
id?: number;
partyCode: string;
partyName: string;
partyType: 'BANK' | 'CORPORATE' | 'GOVT' | 'AMC' | 'EXCHANGE' | 'COOP_SOCIETY';
panNo: string;
panNo?: string;
// Fields below follow the bank's existing CBS Bank / Party Master.
bondType?: InstrumentType;
address1?: string;
address2?: string;
address3?: string;
city?: string;
pincode?: string;
phone?: string;
fax?: string;
bankType?: string;
/** GL this party is mapped to. */
glAccountId?: number;
glCode?: string;
glName?: string;
/** Interest income GL of the FDs placed with this bank (Bond Type FD). */
interestGlAccountId?: number;
interestGlCode?: string;
interestGlName?: string;
/** Whether this bank deducts TDS from FD interest (some do, some do not), and at what rate (%). */
tdsApplicable?: boolean;
tdsRate?: number | null;
rbiCode?: string;
/** Exposure limit for this party (₹). */
limit?: number | null;
leiNo?: string;
// Counterparty's bank details
cpBankName?: string;
cpBranchName?: string;
cpAccountNo?: string;
cpIfsc?: string;
/** Absent means ACTIVE. An INACTIVE party is not offered for new deals. */
status?: 'ACTIVE' | 'INACTIVE';
}
/** Sample Bank Type options until the bank confirms its list. */
export const BANK_TYPE_OPTIONS = [
'SCHEDULED COMMERCIAL BANK',
'STATE CO-OPERATIVE BANK',
'DISTRICT CENTRAL CO-OPERATIVE BANK',
'URBAN CO-OPERATIVE BANK',
'RBI / GOVERNMENT',
'OTHER'
];
export const PARTY_MASTER: PartyMaster[] = [
{ partyCode: 'PTY-001', partyName: 'Jila Sahakari Kendriya Bank', partyType: 'BANK', panNo: 'AABCJ1234K' },
{ partyCode: 'PTY-002', partyName: 'State Cooperative Bank Ltd', partyType: 'BANK', panNo: 'AABCS5678L' },
{ partyCode: 'PTY-003', partyName: 'RBI - SGL', partyType: 'GOVT', panNo: 'AAACR4849R' },
{ partyCode: 'PTY-004', partyName: 'REC Limited', partyType: 'CORPORATE', panNo: 'AAACR0641G' },
{ partyCode: 'PTY-005', partyName: 'NABARD', partyType: 'CORPORATE', panNo: 'AAACN0272B' },
{ partyCode: 'PTY-006', partyName: 'L&T Finance Ltd', partyType: 'CORPORATE', panNo: 'AAACL0140P' },
{ partyCode: 'PTY-007', partyName: 'SBI Mutual Fund', partyType: 'AMC', panNo: 'AAATS4325L' },
{ partyCode: 'PTY-008', partyName: 'HDFC Mutual Fund', partyType: 'AMC', panNo: 'AAATH1234M' },
{ partyCode: 'PTY-009', partyName: 'NSE/BSE', partyType: 'EXCHANGE', panNo: 'AAACN0028G' },
{ partyCode: 'PTY-010', partyName: 'District Cooperative Bank', partyType: 'COOP_SOCIETY', panNo: 'AABCD9988K' }
{
partyCode: 'PTY-001',
partyName: 'Jila Sahakari Kendriya Bank',
partyType: 'BANK',
bondType: 'FD',
glCode: '100704',
city: 'Vidisha',
bankType: 'DISTRICT CENTRAL CO-OPERATIVE BANK',
status: 'ACTIVE'
},
{
partyCode: 'PTY-002',
partyName: 'State Cooperative Bank Ltd',
partyType: 'BANK',
bondType: 'FD',
glCode: '100704',
city: 'Bhopal',
bankType: 'STATE CO-OPERATIVE BANK',
status: 'ACTIVE'
},
{
partyCode: 'PTY-003',
partyName: 'RBI - SGL',
partyType: 'GOVT',
bondType: 'GOVT_SECURITY',
glCode: '100701',
city: 'Mumbai',
bankType: 'RBI / GOVERNMENT',
status: 'ACTIVE'
},
{
partyCode: 'PTY-004',
partyName: 'REC Limited',
partyType: 'CORPORATE',
bondType: 'NON_SLR',
glCode: '100703',
city: 'New Delhi',
bankType: 'OTHER',
status: 'ACTIVE'
},
{
partyCode: 'PTY-005',
partyName: 'NABARD',
partyType: 'CORPORATE',
bondType: 'NON_SLR',
glCode: '100703',
city: 'Mumbai',
bankType: 'OTHER',
status: 'ACTIVE'
},
{
partyCode: 'PTY-006',
partyName: 'L&T Finance Ltd',
partyType: 'CORPORATE',
bondType: 'BOND',
glCode: '100703',
city: 'Mumbai',
bankType: 'OTHER',
status: 'ACTIVE'
},
{
partyCode: 'PTY-007',
partyName: 'SBI Mutual Fund',
partyType: 'AMC',
bondType: 'MUTUAL_FUND',
glCode: '100705',
city: 'Mumbai',
bankType: 'OTHER',
status: 'ACTIVE'
},
{
partyCode: 'PTY-008',
partyName: 'HDFC Mutual Fund',
partyType: 'AMC',
bondType: 'MUTUAL_FUND',
glCode: '100705',
city: 'Mumbai',
bankType: 'OTHER',
status: 'ACTIVE'
},
{
partyCode: 'PTY-009',
partyName: 'NSE/BSE',
partyType: 'EXCHANGE',
bondType: 'SHARE',
glCode: '100706',
city: 'Mumbai',
bankType: 'OTHER',
status: 'ACTIVE'
},
{
partyCode: 'PTY-010',
partyName: 'District Cooperative Bank',
partyType: 'COOP_SOCIETY',
bondType: 'SHARE',
glCode: '100706',
city: 'Vidisha',
bankType: 'DISTRICT CENTRAL CO-OPERATIVE BANK',
status: 'ACTIVE'
}
];
export interface SubTypeMaster {
@@ -1593,7 +2124,11 @@ export const SUBTYPE_MASTER: SubTypeMaster[] = [
{ subTypeCode: '4', subTypeName: 'EQUITY', instrumentType: 'SHARE' },
{ subTypeCode: '5', subTypeName: 'CO-OP SHARE', instrumentType: 'SHARE' },
{ subTypeCode: '6', subTypeName: 'DEBT - OVERNIGHT', instrumentType: 'MUTUAL_FUND' },
{ subTypeCode: '7', subTypeName: 'DEBT - LIQUID', instrumentType: 'MUTUAL_FUND' }
{ subTypeCode: '7', subTypeName: 'DEBT - LIQUID', instrumentType: 'MUTUAL_FUND' },
{ subTypeCode: '8', subTypeName: 'DEBT - MONEY MARKET', instrumentType: 'MUTUAL_FUND' },
{ subTypeCode: '9', subTypeName: 'DEBT - BANKING & PSU', instrumentType: 'MUTUAL_FUND' },
{ subTypeCode: '10', subTypeName: 'DEBT - CORPORATE BOND', instrumentType: 'MUTUAL_FUND' },
{ subTypeCode: '11', subTypeName: 'DEBT - GILT', instrumentType: 'MUTUAL_FUND' }
];
export interface ControlParameter {
@@ -1725,13 +2260,15 @@ export const LIEN_REASON_MASTER: LienReason[] = [
/** Daily Script Master (legacy menu "09") — the day's quoted rate per script, entered/imported
* every working day. Distinct from Script Market Detail ("13") which also carries YTM/valuation. */
export interface DailyScriptRate {
/** Backend id once saved. */
id?: number;
rateDate: string;
scriptCode: string;
scriptName: string;
openRate: number;
openRate: number | null;
closeRate: number;
highRate: number;
lowRate: number;
highRate: number | null;
lowRate: number | null;
}
export const DAILY_SCRIPT_RATES: DailyScriptRate[] = [
@@ -0,0 +1,126 @@
<!--
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/.
-->
<div class="pg">
<header class="pg-head">
<div>
<div class="pg-eyebrow">TREASURY · INVESTMENT · DUE DATE DIARY</div>
<h1 class="pg-title">Due Date Diary</h1>
<p class="pg-sub">
Coupons, 31 Mar / 30 Sep provisions, premium amortisation, maturities and FD interest due in a period, with what
is posted and what is still pending.
</p>
</div>
</header>
<div class="pg-card">
<div class="inv-form-grid">
<label class="inv-form-field"
><span>From</span><mifosx-date-ddmmyyyy [(ngModel)]="fromDate"></mifosx-date-ddmmyyyy
></label>
<label class="inv-form-field"
><span>To</span><mifosx-date-ddmmyyyy [(ngModel)]="toDate"></mifosx-date-ddmmyyyy
></label>
<label class="inv-form-field">
<span>Investment</span>
<select [(ngModel)]="instrument">
<option value="">All</option>
<option value="SECURITY">Govt Security / Bond</option>
<option value="FD">FD with banks</option>
</select>
</label>
<label class="inv-form-field">
<span>Status</span>
<select [(ngModel)]="status">
<option value="">All</option>
<option value="PENDING">Pending</option>
<option value="POSTED">Posted</option>
</select>
</label>
</div>
<div class="diary-actions">
<button type="button" class="pg-btn pg-btn--ghost" (click)="setRange(7)">Next 7 days</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="setRange(30)">Next 30 days</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="setRange(90)">Next 90 days</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="showOverdue()">Overdue</button>
<button type="button" class="pg-btn pg-btn--primary" [disabled]="loading" (click)="load()">
{{ loading ? 'Loading…' : 'Show' }}
</button>
</div>
@if (error) {
<p class="diary-error">{{ error }}</p>
}
</div>
@if (diary; as d) {
<div class="diary-summary">
<div class="diary-tile">
<span class="diary-tile-l">Entries</span><span class="diary-tile-v">{{ rows.length }}</span>
</div>
<div class="diary-tile">
<span class="diary-tile-l">Pending</span><span class="diary-tile-v">{{ d.pendingCount }}</span>
</div>
<div class="diary-tile" [class.diary-tile--bad]="d.overdueCount > 0">
<span class="diary-tile-l">Overdue</span><span class="diary-tile-v">{{ d.overdueCount }}</span>
</div>
<div class="diary-tile">
<span class="diary-tile-l">Money expected (not yet received)</span
><span class="diary-tile-v">₹{{ d.expectedInflow | number: '1.2-2' }}</span>
</div>
</div>
<div class="pg-card">
<div class="pos-section-label">{{ d.fromDate }} to {{ d.toDate }} · as on {{ d.asOnDate }}</div>
<table class="pg-table">
<thead>
<tr>
<th>Date</th>
<th>Due</th>
<th>Investment</th>
<th>Deal No</th>
<th>Particulars</th>
<th class="num">Amount</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
@for (r of rows; track r.instrument + r.refId + r.kind + r.date) {
<tr>
<td>{{ r.date }}</td>
<td>{{ kindLabels[r.kind] }}</td>
<td>{{ r.instrument === 'FD' ? 'FD' : 'Govt Security / Bond' }}</td>
<td>
<span class="pg-chip">{{ r.dealNo }}</span>
</td>
<td>{{ r.particulars }}</td>
<td class="num">
{{ r.amount !== null && r.amount !== undefined ? '₹' + (r.amount | number: '1.2-2') : '—' }}
</td>
<td>
<span class="inv-badge" [ngClass]="'diary-badge--' + r.status.toLowerCase()">{{ statusLabel(r) }}</span>
@if (r.voucherNo) {
<br /><small>{{ r.voucherNo }}</small>
}
</td>
<td>
@if (r.status !== 'POSTED') {
<a class="diary-open" [routerLink]="link(r).path" [queryParams]="link(r).query">Open →</a>
}
</td>
</tr>
} @empty {
<tr>
<td colspan="8" class="pg-empty">Nothing falls due in this period.</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
@@ -0,0 +1,97 @@
/**
* 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/.
*/
.diary-actions {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
margin-top: 12px;
}
.diary-error {
margin: 8px 0 0;
color: #b91c1c;
}
.diary-summary {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 12px;
}
.diary-tile {
display: flex;
flex-direction: column;
gap: 4px;
padding: 14px 16px;
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #fff;
&--bad {
border-color: #fecaca;
background: #fef2f2;
}
}
.diary-tile-l {
font-size: 12px;
color: #64748b;
text-transform: uppercase;
letter-spacing: 0.04em;
}
.diary-tile-v {
font-size: 22px;
font-weight: 700;
color: #0f172a;
}
.diary-badge--posted {
background: #f0fdf4;
color: #15803d;
border: 1px solid #bbf7d0;
}
.diary-badge--due {
background: #fff7ed;
color: #c2410c;
border: 1px solid #fed7aa;
}
.diary-badge--overdue {
background: #fef2f2;
color: #b91c1c;
border: 1px solid #fecaca;
}
.diary-badge--upcoming {
background: #eff6ff;
color: #1d4ed8;
border: 1px solid #bfdbfe;
}
.diary-open {
font-weight: 600;
white-space: nowrap;
text-decoration: none;
}
.report-total td {
font-weight: 700;
border-top: 2px solid #cbd5e1;
}
.report-pick {
cursor: pointer;
&--on td {
background: #eff6ff;
}
}
@@ -0,0 +1,122 @@
/**
* 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 { RouterModule } from '@angular/router';
import { DateDdmmyyyyPickerComponent } from '../date-ddmmyyyy-picker/date-ddmmyyyy-picker.component';
import { addPeriod, todayDDMMYYYY } from '../investment-data';
import { InvestmentDiaryDto, InvestmentDiaryRowDto, InvestmentService, apiErrorMessage } from '../investment.service';
type InstrumentFilter = '' | 'SECURITY' | 'FD';
type StatusFilter = '' | 'PENDING' | 'POSTED';
/**
* Due Date Diary for All Investment: coupons, 31 Mar / 30 Sep provisions, premium amortisation, maturities and FD
* payouts in a period, with what is posted, due or overdue, and a link to the screen that posts each one.
*/
@Component({
selector: 'mifosx-investment-diary',
templateUrl: './investment-diary.component.html',
styleUrls: [
'../../cashier/cashier-shared.scss',
'../investment-shared.scss',
'./investment-diary.component.scss'
],
standalone: true,
imports: [
CommonModule,
FormsModule,
RouterModule,
DateDdmmyyyyPickerComponent
]
})
export class InvestmentDiaryComponent implements OnInit {
private readonly investmentService = inject(InvestmentService);
// Opens on everything still to be done: what is pending from the past year and what falls due in the next 30 days.
fromDate = addPeriod(todayDDMMYYYY(), -1, 0, 0);
toDate = addPeriod(todayDDMMYYYY(), 0, 0, 30);
instrument: InstrumentFilter = '';
status: StatusFilter = 'PENDING';
diary: InvestmentDiaryDto | null = null;
loading = false;
error = '';
readonly kindLabels: Record<InvestmentDiaryRowDto['kind'], string> = {
COUPON: 'Coupon',
PROVISION: 'Interest provision',
MATURITY: 'Maturity / redemption',
AMORTISATION: 'Premium amortisation',
FD_PROVISION: 'FD interest provision',
FD_PAYOUT: 'FD interest payout',
FD_MATURITY: 'FD maturity'
};
ngOnInit(): void {
this.load();
}
/** Quick ranges from today. */
setRange(days: number): void {
this.status = '';
this.fromDate = todayDDMMYYYY();
this.toDate = addPeriod(this.fromDate, 0, 0, days);
this.load();
}
/** What is still pending from the past (up to a year back) and today. */
showOverdue(): void {
this.toDate = todayDDMMYYYY();
this.fromDate = addPeriod(this.toDate, -1, 0, 0);
this.status = 'PENDING';
this.load();
}
load(): void {
if (!this.fromDate || !this.toDate) {
this.error = 'Enter the From and To dates.';
return;
}
this.loading = true;
this.error = '';
this.investmentService.getDiary(this.fromDate, this.toDate).subscribe({
next: (d) => {
this.diary = d;
this.loading = false;
},
error: (err) => {
this.diary = null;
this.loading = false;
this.error = apiErrorMessage(err);
}
});
}
get rows(): InvestmentDiaryRowDto[] {
return (this.diary?.rows ?? []).filter(
(r) =>
(!this.instrument || r.instrument === this.instrument) &&
(!this.status || (this.status === 'POSTED' ? r.status === 'POSTED' : r.status !== 'POSTED'))
);
}
/** The screen that posts this entry. */
link(r: InvestmentDiaryRowDto): { path: string; query: Record<string, string | number> } {
if (r.instrument === 'FD') {
return { path: '/investment/fd', query: { tab: 'interest', fd: r.refId } };
}
const tab = r.kind === 'MATURITY' ? 'redemption' : r.kind === 'AMORTISATION' ? 'amortize' : 'interest';
return { path: '/investment/bonds', query: { tab } };
}
statusLabel(r: InvestmentDiaryRowDto): string {
return r.status === 'DUE' ? 'Due today' : r.status.charAt(0) + r.status.slice(1).toLowerCase();
}
}
@@ -0,0 +1,125 @@
<!--
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/.
-->
<div class="pg">
<header class="pg-head">
<div>
<div class="pg-eyebrow">TREASURY · INVESTMENT · REPORTS</div>
<h1 class="pg-title">Total Interest Received &amp; Receivable</h1>
<p class="pg-sub">
Interest received from Govt Securities, bonds and FDs in the period, and interest earned up to the To date that
has not come in yet.
</p>
</div>
<button type="button" class="pg-btn pg-btn--ghost" [disabled]="!report || generating" (click)="exportExcel()">
{{ generating ? 'Generating…' : 'Export to Excel' }}
</button>
</header>
<div class="pg-card">
<div class="inv-form-grid">
<label class="inv-form-field"
><span>From</span><mifosx-date-ddmmyyyy [(ngModel)]="fromDate"></mifosx-date-ddmmyyyy
></label>
<label class="inv-form-field"
><span>To (receivable as on)</span><mifosx-date-ddmmyyyy [(ngModel)]="toDate"></mifosx-date-ddmmyyyy
></label>
<label class="inv-form-field">
<span>Investment</span>
<select [(ngModel)]="instrument">
<option value="">All</option>
<option value="SECURITY">Govt Security / Bond</option>
<option value="FD">FD with banks</option>
</select>
</label>
</div>
<div class="diary-actions">
<button type="button" class="pg-btn pg-btn--primary" [disabled]="loading" (click)="load()">
{{ loading ? 'Loading…' : 'Show' }}
</button>
</div>
@if (error) {
<p class="diary-error">{{ error }}</p>
}
</div>
@if (report; as r) {
<div class="diary-summary">
<div class="diary-tile">
<span class="diary-tile-l">Received</span
><span class="diary-tile-v">₹{{ totals.received | number: '1.2-2' }}</span>
</div>
<div class="diary-tile">
<span class="diary-tile-l">Receivable</span
><span class="diary-tile-v">₹{{ totals.receivable | number: '1.2-2' }}</span>
</div>
<div class="diary-tile">
<span class="diary-tile-l">Of which provisioned (100603)</span
><span class="diary-tile-v">₹{{ totals.provisioned | number: '1.2-2' }}</span>
</div>
<div class="diary-tile">
<span class="diary-tile-l">Total</span><span class="diary-tile-v">₹{{ totals.total | number: '1.2-2' }}</span>
</div>
</div>
<div class="pg-card">
<div class="pos-section-label">
{{ r.fromDate }} to {{ r.toDate }} · received in the period, receivable as on {{ r.toDate }}
</div>
<table class="pg-table">
<thead>
<tr>
<th>Investment</th>
<th>Deal No</th>
<th>Particulars</th>
<th>Status</th>
<th class="num">Principal / Face Value</th>
<th class="num">Rate</th>
<th class="num col-in">Received</th>
<th class="num">Receivable</th>
<th class="num">Of which provisioned</th>
<th class="num">Total</th>
</tr>
</thead>
<tbody>
@for (x of rows; track x.instrument + x.refId) {
<tr>
<td>{{ x.instrument === 'FD' ? 'FD' : 'Govt Security / Bond' }}</td>
<td>
<span class="pg-chip">{{ x.dealNo }}</span>
</td>
<td>{{ x.particulars }}</td>
<td>{{ x.status }}</td>
<td class="num">₹{{ x.principal | number: '1.2-2' }}</td>
<td class="num">{{ x.rate !== null && x.rate !== undefined ? x.rate + '%' : '—' }}</td>
<td class="num col-in">₹{{ x.received | number: '1.2-2' }}</td>
<td class="num">₹{{ x.receivable | number: '1.2-2' }}</td>
<td class="num">₹{{ x.provisioned | number: '1.2-2' }}</td>
<td class="num">₹{{ x.total | number: '1.2-2' }}</td>
</tr>
} @empty {
<tr>
<td colspan="10" class="pg-empty">No interest received or receivable in this period.</td>
</tr>
}
</tbody>
@if (rows.length) {
<tfoot>
<tr class="report-total">
<td colspan="6">Total</td>
<td class="num col-in">₹{{ totals.received | number: '1.2-2' }}</td>
<td class="num">₹{{ totals.receivable | number: '1.2-2' }}</td>
<td class="num">₹{{ totals.provisioned | number: '1.2-2' }}</td>
<td class="num">₹{{ totals.total | number: '1.2-2' }}</td>
</tr>
</tfoot>
}
</table>
</div>
}
</div>
@@ -0,0 +1,173 @@
/**
* 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 { DateDdmmyyyyPickerComponent } from '../date-ddmmyyyy-picker/date-ddmmyyyy-picker.component';
import { parseDDMMYYYY, todayDDMMYYYY } from '../investment-data';
import { exportWorkbook } from '../investment-export';
import {
InvestmentInterestReportDto,
InvestmentInterestReportRowDto,
InvestmentService,
apiErrorMessage
} from '../investment.service';
type InstrumentFilter = '' | 'SECURITY' | 'FD';
/**
* Total Interest Received & Receivable: per Govt Security / bond deal and FD, the interest received in a period and the
* interest earned up to its last day that has not come in yet, with the part already provisioned in the books.
*/
@Component({
selector: 'mifosx-investment-interest-report',
templateUrl: './investment-interest-report.component.html',
styleUrls: [
'../../cashier/cashier-shared.scss',
'../investment-shared.scss',
'../investment-diary/investment-diary.component.scss'
],
standalone: true,
imports: [
CommonModule,
FormsModule,
DateDdmmyyyyPickerComponent
]
})
export class InvestmentInterestReportComponent implements OnInit {
private readonly investmentService = inject(InvestmentService);
/** Defaults to the current financial year, 1 April to today. */
fromDate = InvestmentInterestReportComponent.financialYearStart();
toDate = todayDDMMYYYY();
instrument: InstrumentFilter = '';
report: InvestmentInterestReportDto | null = null;
loading = false;
generating = false;
error = '';
ngOnInit(): void {
this.load();
}
private static financialYearStart(): string {
const d = parseDDMMYYYY(todayDDMMYYYY());
const year = d.getMonth() >= 3 ? d.getFullYear() : d.getFullYear() - 1;
return `01-04-${year}`;
}
load(): void {
if (!this.fromDate || !this.toDate) {
this.error = 'Enter the From and To dates.';
return;
}
this.loading = true;
this.error = '';
this.investmentService.getInterestReport(this.fromDate, this.toDate).subscribe({
next: (r) => {
this.report = r;
this.loading = false;
},
error: (err) => {
this.report = null;
this.loading = false;
this.error = apiErrorMessage(err);
}
});
}
get rows(): InvestmentInterestReportRowDto[] {
return (this.report?.rows ?? []).filter((r) => !this.instrument || r.instrument === this.instrument);
}
/** Totals of the rows shown, so they follow the Investment filter. */
get totals(): { received: number; receivable: number; provisioned: number; total: number } {
return this.rows.reduce(
(t, r) => ({
received: t.received + r.received,
receivable: t.receivable + r.receivable,
provisioned: t.provisioned + r.provisioned,
total: t.total + r.total
}),
{ received: 0, receivable: 0, provisioned: 0, total: 0 }
);
}
async exportExcel(): Promise<void> {
if (!this.report) {
return;
}
this.generating = true;
try {
const t = this.totals;
await exportWorkbook(
[
{
sheetName: 'Interest Received',
title: 'Total Interest Received & Receivable',
subtitle: `${this.report.fromDate} to ${this.report.toDate}`,
headers: [
'Investment',
'Deal No',
'Particulars',
'Status',
'Principal / Face Value',
'Rate %',
'Received',
'Receivable',
'Of which provisioned',
'Total'
],
widths: [
14,
16,
40,
12,
18,
8,
16,
16,
18,
16
],
rows: [
...this.rows.map((r) => [
r.instrument === 'FD' ? 'FD' : 'Govt Security / Bond',
r.dealNo,
r.particulars,
r.status,
r.principal,
r.rate ?? null,
r.received,
r.receivable,
r.provisioned,
r.total
]),
[
'Total',
'',
'',
'',
null,
null,
t.received,
t.receivable,
t.provisioned,
t.total
]
]
}
],
`Interest-Received-Receivable-${this.report.toDate}`
);
} finally {
this.generating = false;
}
}
}
@@ -106,38 +106,136 @@
</button>
</div>
<!-- PARTY MASTER -->
<!-- PARTY MASTER (layout follows the bank's existing CBS Bank / Party Master) -->
@if (activeTab === 'party') {
<div class="pg-card">
<div class="pos-section-label">Add Bank / Party</div>
<div class="pos-section-label">Bank / Party Master — Entry</div>
<div class="inv-form-grid">
<label class="inv-form-field"
><span>Party Name *</span><input type="text" [(ngModel)]="newParty.partyName"
/></label>
<label class="inv-form-field">
<span>Party Type *</span>
<select [(ngModel)]="newParty.partyType">
<span>* Bond Type</span>
<select [(ngModel)]="partyForm.bondType">
<option [ngValue]="undefined">-- Select --</option>
<option value="BANK">BANK</option>
<option value="CORPORATE">CORPORATE</option>
<option value="GOVT">GOVT</option>
<option value="AMC">AMC</option>
<option value="EXCHANGE">EXCHANGE</option>
<option value="COOP_SOCIETY">COOP SOCIETY</option>
@for (t of instrumentTypes; track t) {
<option [value]="t">{{ t }}</option>
}
</select>
</label>
<label class="inv-form-field"><span>PAN No</span><input type="text" [(ngModel)]="newParty.panNo" /></label>
<label class="inv-form-field"
><span>* Party Code</span><input type="text" [value]="partyForm.partyCode || nextPartyCode" readonly
/></label>
<label class="inv-form-field"
><span>* Party Name</span><input type="text" [(ngModel)]="partyForm.partyName"
/></label>
<label class="inv-form-field"
><span>Address Line 1 (Building / Flat No.)</span
><input type="text" placeholder="e.g. Shop No. 12, Shanti Complex" [(ngModel)]="partyForm.address1"
/></label>
<label class="inv-form-field"
><span>Address Line 2 (Street / Area)</span
><input type="text" placeholder="e.g. MG Road, Near Bus Stand" [(ngModel)]="partyForm.address2"
/></label>
<label class="inv-form-field"
><span>Address Line 3 (Locality / Landmark)</span
><input type="text" placeholder="e.g. Arera Colony" [(ngModel)]="partyForm.address3"
/></label>
<label class="inv-form-field"><span>City</span><input type="text" [(ngModel)]="partyForm.city" /></label>
<label class="inv-form-field"
><span>Pincode</span><input type="text" maxlength="6" [(ngModel)]="partyForm.pincode"
/></label>
<label class="inv-form-field"><span>Phone</span><input type="text" [(ngModel)]="partyForm.phone" /></label>
<label class="inv-form-field"><span>Fax</span><input type="text" [(ngModel)]="partyForm.fax" /></label>
<label class="inv-form-field">
<span>Bank Type</span>
<select [(ngModel)]="partyForm.bankType">
<option [ngValue]="undefined">-- Select --</option>
@for (b of bankTypeOptions; track b) {
<option [value]="b">{{ b }}</option>
}
</select>
</label>
<label class="inv-form-field">
<span>* GL A/c No.</span>
<select [(ngModel)]="partyForm.glAccountId">
<option [ngValue]="undefined">-- Select --</option>
@for (g of partyGlOptions; track g.id) {
<option [ngValue]="g.id">{{ g.glCode }} — {{ g.name }}</option>
}
</select>
</label>
@if (partyForm.bondType === 'FD') {
<label class="inv-form-field">
<span>* Interest GL</span>
<select [(ngModel)]="partyForm.interestGlAccountId">
<option [ngValue]="undefined">-- Select --</option>
@for (g of interestGlOptions; track g.id) {
<option [ngValue]="g.id">{{ g.glCode }} — {{ g.name }}</option>
}
</select>
</label>
<label class="inv-form-field">
<span>Bank deducts TDS on FD interest?</span>
<select [ngModel]="partyForm.tdsApplicable ?? false" (ngModelChange)="partyForm.tdsApplicable = $event">
<option [ngValue]="false">No</option>
<option [ngValue]="true">Yes</option>
</select>
</label>
@if (partyForm.tdsApplicable) {
<label class="inv-form-field"
><span>* TDS rate (%)</span
><input type="number" min="0" max="99" step="0.01" [(ngModel)]="partyForm.tdsRate" placeholder="e.g. 10"
/></label>
}
}
<label class="inv-form-field"><span>RBI Code</span><input type="text" [(ngModel)]="partyForm.rbiCode" /></label>
<label class="inv-form-field"
><span>Limit (₹)</span><input type="number" min="0" [(ngModel)]="partyForm.limit"
/></label>
<label class="inv-form-field"><span>LEI No</span><input type="text" [(ngModel)]="partyForm.leiNo" /></label>
<label class="inv-form-field">
<span>Status</span>
<select [(ngModel)]="partyForm.status">
<option [ngValue]="undefined">ACTIVE</option>
<option value="INACTIVE">INACTIVE</option>
</select>
</label>
</div>
<div class="pos-section-label">Counterparty's Bank Details</div>
<div class="inv-form-grid">
<label class="inv-form-field"
><span>Name of Bank</span><input type="text" [(ngModel)]="partyForm.cpBankName"
/></label>
<label class="inv-form-field"
><span>Name of Branch</span><input type="text" [(ngModel)]="partyForm.cpBranchName"
/></label>
<label class="inv-form-field"
><span>Account No.</span><input type="text" [(ngModel)]="partyForm.cpAccountNo"
/></label>
<label class="inv-form-field"
><span>IFSC</span><input type="text" maxlength="11" [(ngModel)]="partyForm.cpIfsc"
/></label>
</div>
<div class="inv-form-actions">
<button type="button" class="pg-btn pg-btn--primary" (click)="addParty()">Save</button>
<label class="inv-form-field"
><span>Search Party Code</span><input type="text" placeholder="e.g. PTY-001" [(ngModel)]="partySearchCode"
/></label>
<button type="button" class="pg-btn pg-btn--primary" [disabled]="saving" (click)="saveParty()">Save</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="searchParty()">Search</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="cancelParty()">Cancel</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="dropParty()">Drop</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="cancelParty()">Exit</button>
</div>
<table class="pg-table">
<thead>
<tr>
<th>Party Code</th>
<th>Bond Type</th>
<th>Party Name</th>
<th>Type</th>
<th>PAN No</th>
<th>City</th>
<th>Bank Type</th>
<th>GL A/c</th>
<th class="num">Limit</th>
<th>Counterparty Bank / IFSC</th>
<th>Status</th>
</tr>
</thead>
<tbody>
@@ -146,9 +244,14 @@
<td>
<span class="pg-chip">{{ p.partyCode }}</span>
</td>
<td>{{ p.bondType || '—' }}</td>
<td>{{ p.partyName }}</td>
<td>{{ p.partyType }}</td>
<td>{{ p.panNo }}</td>
<td>{{ p.city || '—' }}</td>
<td>{{ p.bankType || '—' }}</td>
<td>{{ p.glCode ? p.glCode + ' — ' + glName(p.glCode) : '—' }}</td>
<td class="num">{{ (p.limit ?? null) !== null ? '₹' + (p.limit | number: '1.0-0') : '—' }}</td>
<td>{{ p.cpBankName ? p.cpBankName + (p.cpIfsc ? ' / ' + p.cpIfsc : '') : '—' }}</td>
<td>{{ p.status ?? 'ACTIVE' }}</td>
</tr>
}
</tbody>
@@ -156,42 +259,176 @@
</div>
}
<!-- SCRIPT MASTER -->
<!-- SCRIPT MASTER (layout follows the bank's existing CBS Script Master) -->
@if (activeTab === 'script') {
<div class="pg-card">
<div class="pos-section-label">Add Script</div>
<div class="pos-section-label">Script Master — Entry</div>
<div class="inv-form-grid">
<label class="inv-form-field"
><span>Script Code</span><input type="text" [(ngModel)]="newScript.scriptCode"
/></label>
<label class="inv-form-field"
><span>Script Name *</span><input type="text" [(ngModel)]="newScript.scriptName"
/></label>
<label class="inv-form-field">
<span>Instrument Type *</span>
<select [(ngModel)]="newScript.instrumentType">
<span>* Bond Type</span>
<select [(ngModel)]="scriptForm.instrumentType" [disabled]="!!scriptForm.scriptCode">
<option [ngValue]="undefined">-- Select --</option>
@for (t of instrumentTypes; track t) {
<option [value]="t">{{ t }}</option>
}
</select>
</label>
<label class="inv-form-field"><span>ISIN</span><input type="text" [(ngModel)]="newScript.isin" /></label>
<label class="inv-form-field">
<span>SLR</span>
<select [(ngModel)]="scriptForm.slrType">
<option [ngValue]="undefined">-- Select --</option>
@for (o of slrTypeOptions; track o.value) {
<option [value]="o.value">{{ o.label }}</option>
}
</select>
</label>
<label class="inv-form-field"
><span>Face Value / Unit</span><input type="number" [(ngModel)]="newScript.faceValuePerUnit"
><span>* Script Code</span><input type="text" [value]="scriptForm.scriptCode || nextScriptCode" readonly
/></label>
<label class="inv-form-field"
><span>* Script Desc</span
><input type="text" placeholder="e.g. 7.50%GOI2034" [(ngModel)]="scriptForm.scriptName"
/></label>
<label class="inv-form-field">
<span>* GL A/c No.</span>
<select [(ngModel)]="scriptForm.glAccountId">
<option [ngValue]="undefined">-- Select --</option>
@for (g of scriptGlOptions; track g.id) {
<option [ngValue]="g.id">{{ g.glCode }} — {{ g.name }}</option>
}
</select>
</label>
<label class="inv-form-field"
><span>{{ scriptIsDebtSecurity ? '* ' : '' }}ISIN</span><input type="text" [(ngModel)]="scriptForm.isin"
/></label>
<label class="inv-form-field"
><span>{{ scriptIsDebtSecurity ? '* ' : '' }}Int Rate %</span
><input type="number" step="0.01" min="0" [(ngModel)]="scriptForm.couponRate"
/></label>
<label class="inv-form-field"
><span>{{ scriptIsDebtSecurity ? '* ' : '' }}Issue Date</span
><mifosx-date-ddmmyyyy [(ngModel)]="scriptForm.issueDate"></mifosx-date-ddmmyyyy
></label>
<label class="inv-form-field"
><span>{{ scriptIsDebtSecurity ? '* ' : '' }}Redum / Mat Date</span
><mifosx-date-ddmmyyyy [(ngModel)]="scriptForm.maturityDate"></mifosx-date-ddmmyyyy
></label>
<label class="inv-form-field"
><span>Period (Year)</span><input type="text" [value]="scriptPeriod.years" readonly
/></label>
<label class="inv-form-field"
><span>Period (Month)</span><input type="text" [value]="scriptPeriod.months" readonly
/></label>
<label class="inv-form-field"
><span>Period (Days)</span><input type="text" [value]="scriptPeriod.days" readonly
/></label>
</div>
@if (scriptIsRated) {
<div class="pos-section-label">Credit Rating (RBI: bonds "A" or higher, CP / CD "A2" or higher)</div>
<div class="inv-form-grid">
<label class="inv-form-field">
<span>* Rating</span>
<select [(ngModel)]="scriptForm.rating">
<option [ngValue]="undefined">-- Select --</option>
@for (g of ratingOptions; track g.group) {
<optgroup [label]="g.group">
@for (r of g.values; track r) {
<option [value]="r">{{ r }}</option>
}
</optgroup>
}
</select>
</label>
<label class="inv-form-field">
<span>Rating Agency</span>
<select [(ngModel)]="scriptForm.ratingAgency">
<option [ngValue]="undefined">-- Select --</option>
@for (a of ratingAgencyOptions; track a.value) {
<option [value]="a.value">{{ a.label }}</option>
}
</select>
</label>
<label class="inv-form-field">
<span>Listing</span>
<select
[ngModel]="scriptForm.listed === false ? 'UNLISTED' : 'LISTED'"
(ngModelChange)="scriptForm.listed = $event !== 'UNLISTED'"
>
<option value="LISTED">Listed / proposed to be listed</option>
<option value="UNLISTED">Unlisted</option>
</select>
</label>
</div>
@if (scriptForm.rating) {
<p class="inv-hint" [class.inv-hint--bad]="!scriptRatingEligible">
{{
scriptRatingEligible
? 'Rating meets the RBI minimum; this security can be bought.'
: 'Below the RBI minimum rating; a purchase of this security will be blocked.'
}}
</p>
}
}
<div class="pos-section-label">Company Details (Bond / Mutual Fund)</div>
<div class="inv-form-grid">
<label class="inv-form-field"
><span>Company Name</span><input type="text" [(ngModel)]="scriptForm.companyName"
/></label>
<label class="inv-form-field"
><span>Address Line 1 (Building / Flat No.)</span
><input type="text" placeholder="e.g. Shop No. 12, Shanti Complex" [(ngModel)]="scriptForm.address1"
/></label>
<label class="inv-form-field"
><span>Address Line 2 (Street / Area)</span
><input type="text" placeholder="e.g. MG Road, Near Bus Stand" [(ngModel)]="scriptForm.address2"
/></label>
<label class="inv-form-field"
><span>Address Line 3 (Locality / Landmark)</span
><input type="text" placeholder="e.g. Arera Colony" [(ngModel)]="scriptForm.address3"
/></label>
<label class="inv-form-field"><span>City</span><input type="text" [(ngModel)]="scriptForm.city" /></label>
<label class="inv-form-field"
><span>Pincode</span><input type="text" maxlength="6" [(ngModel)]="scriptForm.pincode"
/></label>
<label class="inv-form-field"><span>Phone</span><input type="text" [(ngModel)]="scriptForm.phone" /></label>
<label class="inv-form-field"><span>Fax</span><input type="text" [(ngModel)]="scriptForm.fax" /></label>
<label class="inv-form-field"
><span>Corp. Code</span><input type="text" [(ngModel)]="scriptForm.corpCode"
/></label>
<label class="inv-form-field">
<span>Status</span>
<select
[ngModel]="scriptForm.active === false ? 'INACTIVE' : 'ACTIVE'"
(ngModelChange)="scriptForm.active = $event !== 'INACTIVE'"
>
<option value="ACTIVE">ACTIVE</option>
<option value="INACTIVE">INACTIVE</option>
</select>
</label>
</div>
<div class="inv-form-actions">
<button type="button" class="pg-btn pg-btn--primary" (click)="addScript()">Save</button>
<label class="inv-form-field"
><span>Search Script Code</span><input type="text" placeholder="e.g. G00001" [(ngModel)]="scriptSearchCode"
/></label>
<button type="button" class="pg-btn pg-btn--primary" [disabled]="saving" (click)="saveScript()">Save</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="searchScript()">Search</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="cancelScript()">Cancel</button>
<button type="button" class="pg-btn pg-btn--ghost" (click)="cancelScript()">Exit</button>
</div>
<table class="pg-table">
<thead>
<tr>
<th>Script Code</th>
<th>Script Name</th>
<th>Instrument</th>
<th>Bond Type</th>
<th>SLR</th>
<th>Script Desc</th>
<th>GL A/c</th>
<th>ISIN</th>
<th class="num">Face Value/Unit</th>
<th class="num">Int Rate %</th>
<th>Issue Date</th>
<th>Maturity</th>
<th>Rating</th>
<th>Status</th>
</tr>
</thead>
<tbody>
@@ -200,10 +437,16 @@
<td>
<span class="pg-chip">{{ s.scriptCode }}</span>
</td>
<td>{{ s.scriptName }}</td>
<td>{{ s.instrumentType }}</td>
<td>{{ s.slrType || '—' }}</td>
<td>{{ s.scriptName }}</td>
<td>{{ s.glCode || '—' }}</td>
<td>{{ s.isin || '—' }}</td>
<td class="num">{{ s.faceValuePerUnit }}</td>
<td class="num">{{ s.couponRate ?? '—' }}</td>
<td>{{ s.issueDate || '—' }}</td>
<td>{{ s.maturityDate || '—' }}</td>
<td>{{ s.rating ? s.rating + (s.listed === false ? ' · Unlisted' : '') : '—' }}</td>
<td>{{ s.active === false ? 'INACTIVE' : 'ACTIVE' }}</td>
</tr>
}
</tbody>
@@ -386,10 +629,11 @@
<th class="num">High</th>
<th class="num">Low</th>
<th class="num">Close</th>
<th></th>
</tr>
</thead>
<tbody>
@for (r of dailyScriptRates; track r.rateDate + r.scriptCode) {
@for (r of dailyScriptRates; track r.id ?? r.rateDate + r.scriptCode) {
<tr>
<td>{{ r.rateDate }}</td>
<td>
@@ -400,6 +644,13 @@
<td class="num">{{ r.highRate | number: '1.2-2' }}</td>
<td class="num">{{ r.lowRate | number: '1.2-2' }}</td>
<td class="num">{{ r.closeRate | number: '1.2-2' }}</td>
<td>
<button type="button" class="pg-btn pg-btn--ghost" (click)="dropDailyRate(r)">Drop</button>
</td>
</tr>
} @empty {
<tr>
<td colspan="8" class="pg-empty">No rates entered yet.</td>
</tr>
}
</tbody>
@@ -6,20 +6,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { Component } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { DateDdmmyyyyPickerComponent } from '../date-ddmmyyyy-picker/date-ddmmyyyy-picker.component';
import {
SCRIPT_MASTER,
BROKER_MASTER,
PARTY_MASTER,
SUBTYPE_MASTER,
CONTROL_PARAMETERS,
MUTUAL_FUND_PRODUCTS,
SGL_BANK_MASTER,
SCRIPT_MARKET_DETAIL,
DAILY_SCRIPT_RATES,
LIEN_REASON_MASTER,
ScriptMaster,
BrokerMaster,
@@ -31,9 +28,17 @@ import {
ScriptMarketDetail,
DailyScriptRate,
LienReason,
InstrumentType
InstrumentType,
BANK_TYPE_OPTIONS,
SLR_TYPE_OPTIONS,
INVESTMENT_GL_LOOKUP,
ELIGIBLE_RATINGS,
RATING_AGENCY_OPTIONS,
RATING_OPTIONS,
periodBetween
} from '../investment-data';
import { exportWorkbook, ExportSheetSpec } from '../investment-export';
import { InvestmentGlAccount, InvestmentService, apiErrorMessage, toDailyScriptRate } from '../investment.service';
type MasterTab =
| 'party'
@@ -51,6 +56,10 @@ type MasterTab =
* Investment master-data screens (legacy "04-13" Entry submenu masters) — 9 simple dummy
* lists, each with an inline Add-row form so the demo stays interactive without a backend.
*/
/** Detail GLs under the 100700 INVESTMENTS head; 100707 holds premium only, never a party's or script's GL. */
const INVESTMENT_GL_HEAD_PREFIX = '1007';
const PREMIUM_ON_INVESTMENTS_GL_CODE = '100707';
@Component({
selector: 'mifosx-investment-masters',
templateUrl: './investment-masters.component.html',
@@ -65,18 +74,19 @@ type MasterTab =
DateDdmmyyyyPickerComponent
]
})
export class InvestmentMastersComponent {
export class InvestmentMastersComponent implements OnInit {
activeTab: MasterTab = 'party';
scripts: ScriptMaster[] = [...SCRIPT_MASTER];
scripts: ScriptMaster[] = [];
brokers: BrokerMaster[] = [...BROKER_MASTER];
parties: PartyMaster[] = [...PARTY_MASTER];
parties: PartyMaster[] = [];
subTypes: SubTypeMaster[] = [...SUBTYPE_MASTER];
controlParams: ControlParameter[] = [...CONTROL_PARAMETERS];
mfProducts: MutualFundProductMaster[] = [...MUTUAL_FUND_PRODUCTS];
sglBanks: SglBankMaster[] = [...SGL_BANK_MASTER];
marketDetails: ScriptMarketDetail[] = [...SCRIPT_MARKET_DETAIL];
dailyScriptRates: DailyScriptRate[] = [...DAILY_SCRIPT_RATES];
/** Loaded from the backend (Daily Script Master) in ngOnInit. */
dailyScriptRates: DailyScriptRate[] = [];
lienReasons: LienReason[] = [...LIEN_REASON_MASTER];
readonly instrumentTypes: InstrumentType[] = [
@@ -106,8 +116,23 @@ export class InvestmentMastersComponent {
toastVisible = false;
private toastTimer: ReturnType<typeof setTimeout> | undefined;
newParty: Partial<PartyMaster> = {};
newScript: Partial<ScriptMaster> = {};
// Bank / Party Master and Script Master follow the bank's existing CBS screens (one entry form
// with Save / Search / Cancel / Drop / Exit) and are stored in the backend through
// InvestmentService; the other master tabs are still sample data.
private readonly investmentService = inject(InvestmentService);
partyForm: Partial<PartyMaster> = {};
partySearchCode = '';
scriptForm: Partial<ScriptMaster> = {};
scriptSearchCode = '';
saving = false;
readonly bankTypeOptions = BANK_TYPE_OPTIONS;
readonly slrTypeOptions = SLR_TYPE_OPTIONS;
readonly ratingOptions = RATING_OPTIONS;
readonly ratingAgencyOptions = RATING_AGENCY_OPTIONS;
/** Investment GLs (under the 100700 INVESTMENTS head) a party or script can be mapped to — not loans, banks or test GLs. */
investmentGlOptions: InvestmentGlAccount[] = [];
/** Income GLs under 400400 INCOME FROM INVESTMENTS, for an FD bank's interest. */
interestGlOptions: InvestmentGlAccount[] = [];
newSubType: Partial<SubTypeMaster> = {};
newBroker: Partial<BrokerMaster> = {};
newControlParam: Partial<ControlParameter> = {};
@@ -116,43 +141,273 @@ export class InvestmentMastersComponent {
newSglBank: Partial<SglBankMaster> = {};
newDailyRate: Partial<DailyScriptRate> = {};
ngOnInit(): void {
this.loadDailyRates();
this.investmentService.getAssetGlAccounts().subscribe({
next: (gls) =>
(this.investmentGlOptions = gls.filter(
(g) => g.glCode.startsWith(INVESTMENT_GL_HEAD_PREFIX) && g.glCode !== PREMIUM_ON_INVESTMENTS_GL_CODE
)),
error: (err) => this.toast(`Could not load GL accounts: ${apiErrorMessage(err)}`)
});
this.investmentService.getIncomeGlAccounts().subscribe({
next: (gls) => (this.interestGlOptions = gls.filter((g) => g.glCode.startsWith('4004'))),
error: (err) => this.toast(`Could not load income GLs: ${apiErrorMessage(err)}`)
});
this.reloadMasters();
}
setTab(tab: MasterTab): void {
this.activeTab = tab;
}
addParty(): void {
if (!this.newParty.partyName || !this.newParty.partyType) {
this.toast('Enter Party Name and Type.');
return;
}
this.parties = [
{
partyCode: `PTY-${String(this.parties.length + 1).padStart(3, '0')}`,
panNo: '',
...this.newParty
} as PartyMaster,
...this.parties
];
this.newParty = {};
this.toast('Party/Bank master added.');
/** Re-reads both masters from the backend (also refreshes the lists the Purchase screen uses). */
private reloadMasters(): void {
this.investmentService.syncSharedMasters().subscribe({
next: ({ parties, scripts }) => {
this.parties = parties;
this.scripts = scripts;
},
error: (err) => this.toast(`Could not load masters: ${apiErrorMessage(err)}`)
});
}
addScript(): void {
if (!this.newScript.scriptName || !this.newScript.instrumentType) {
this.toast('Enter Script Name and Instrument Type.');
glName(glCode?: string): string {
return (
this.investmentGlOptions.find((g) => g.glCode === glCode)?.name ??
INVESTMENT_GL_LOOKUP.find((g) => g.glCode === glCode)?.glName ??
''
);
}
/** FD GLs are the bank-wise children of 100704 (codes 1007040x). */
private static isFdGl(glCode: string): boolean {
return glCode.startsWith('1007040');
}
/** An FD bank is mapped to its own FD GL; any other party to a non-FD investment GL. */
get partyGlOptions(): InvestmentGlAccount[] {
const fd = this.partyForm.bondType === 'FD';
return this.investmentGlOptions.filter((g) => InvestmentMastersComponent.isFdGl(g.glCode) === fd);
}
/** Scripts are securities, never an FD with a bank. */
get scriptGlOptions(): InvestmentGlAccount[] {
return this.investmentGlOptions.filter((g) => !InvestmentMastersComponent.isFdGl(g.glCode));
}
// -------------------- Bank / Party Master --------------------
/** Preview of the code the backend will assign; the saved code always comes from the backend. */
get nextPartyCode(): string {
const nums = this.parties.map((p) => parseInt(p.partyCode.replace(/\D/g, ''), 10)).filter((n) => !isNaN(n));
return `PTY-${String((nums.length ? Math.max(...nums) : 0) + 1).padStart(3, '0')}`;
}
saveParty(): void {
const f = this.partyForm;
if (!f.bondType || !f.partyName || !f.glAccountId) {
this.toast('Enter Bond Type, Party Name and GL A/c No.');
return;
}
this.scripts = [
{
scriptCode: this.newScript.scriptCode || `SCR-${this.scripts.length + 1}`,
isin: '',
faceValuePerUnit: 100,
...this.newScript
} as ScriptMaster,
...this.scripts
];
this.newScript = {};
this.toast('Script master added.');
if (f.bondType === 'FD' && !f.interestGlAccountId) {
this.toast('An FD bank needs its Interest GL as well.');
return;
}
const tds = f.bondType === 'FD' && !!f.tdsApplicable;
if (tds && !(Number(f.tdsRate) > 0 && Number(f.tdsRate) < 100)) {
this.toast('Enter the TDS rate (%) this bank deducts on FD interest.');
return;
}
const body = {
bondType: f.bondType,
partyName: f.partyName,
address1: f.address1 ?? '',
address2: f.address2 ?? '',
address3: f.address3 ?? '',
city: f.city ?? '',
pincode: f.pincode ?? '',
phone: f.phone ?? '',
fax: f.fax ?? '',
bankType: f.bankType ?? '',
glAccountId: Number(f.glAccountId),
interestGlAccountId: f.bondType === 'FD' && f.interestGlAccountId ? Number(f.interestGlAccountId) : null,
tdsApplicable: tds,
tdsRate: tds ? Number(f.tdsRate) : null,
rbiCode: f.rbiCode ?? '',
limit: f.limit ?? null,
leiNo: f.leiNo ?? '',
cpBankName: f.cpBankName ?? '',
cpBranchName: f.cpBranchName ?? '',
cpAccountNo: f.cpAccountNo ?? '',
cpIfsc: f.cpIfsc ?? '',
active: f.status !== 'INACTIVE',
locale: 'en'
};
const request = f.id ? this.investmentService.updateParty(f.id, body) : this.investmentService.createParty(body);
this.saving = true;
request.subscribe({
next: (res) => {
this.saving = false;
this.toast(`Party ${res.resourceIdentifier ?? f.partyCode} ${f.id ? 'updated' : 'saved'}.`);
this.partyForm = {};
this.reloadMasters();
},
error: (err) => {
this.saving = false;
this.toast(apiErrorMessage(err));
}
});
}
searchParty(): void {
const p = this.parties.find((x) => x.partyCode.toUpperCase() === this.partySearchCode.trim().toUpperCase());
if (!p) {
this.toast(`Party Code ${this.partySearchCode} not found.`);
return;
}
this.partyForm = { ...p };
this.toast(`Party ${p.partyCode} loaded.`);
}
cancelParty(): void {
this.partyForm = {};
this.partySearchCode = '';
}
dropParty(): void {
const f = this.partyForm;
if (!f.id) {
this.toast('Search a saved party first, then Drop.');
return;
}
this.investmentService.deleteParty(f.id).subscribe({
next: () => {
this.toast(`Party ${f.partyCode} dropped.`);
this.partyForm = {};
this.reloadMasters();
},
error: (err) => this.toast(apiErrorMessage(err))
});
}
// -------------------- Script Master --------------------
/** Coupon / maturity terms only apply to debt securities. */
get scriptIsDebtSecurity(): boolean {
return [
'GOVT_SECURITY',
'NON_SLR',
'BOND'
].includes(this.scriptForm.instrumentType ?? '');
}
/** Corporate bonds, CPs and CDs carry a credit rating and a listed / unlisted flag (RBI non-SLR rules). */
get scriptIsRated(): boolean {
return [
'NON_SLR',
'BOND'
].includes(this.scriptForm.instrumentType ?? '');
}
/** Whether the rating entered meets the RBI minimum: "A" for bonds, "A2" for CP / CD. */
get scriptRatingEligible(): boolean {
return !!this.scriptForm.rating && ELIGIBLE_RATINGS.includes(this.scriptForm.rating);
}
/** Preview of the code the backend will assign — a type letter + running number, e.g. G00001. */
get nextScriptCode(): string {
const prefixByType: Record<InstrumentType, string> = {
GOVT_SECURITY: 'G',
NON_SLR: 'N',
BOND: 'B',
MUTUAL_FUND: 'M',
FD: 'F',
SHARE: 'S'
};
const type = this.scriptForm.instrumentType;
if (!type) {
return '';
}
const prefix = prefixByType[type];
const pattern = new RegExp(`^${prefix}(\\d{5})$`);
const nums = this.scripts
.map((s) => pattern.exec(s.scriptCode)?.[1])
.filter((n): n is string => !!n)
.map((n) => parseInt(n, 10));
return `${prefix}${String((nums.length ? Math.max(...nums) : 0) + 1).padStart(5, '0')}`;
}
get scriptPeriod(): { years: number; months: number; days: number } {
return periodBetween(this.scriptForm.issueDate, this.scriptForm.maturityDate);
}
saveScript(): void {
const f = this.scriptForm;
if (!f.instrumentType || !f.scriptName || !f.glAccountId) {
this.toast('Enter Bond Type, Script Desc and GL A/c No.');
return;
}
if (this.scriptIsDebtSecurity && (!f.isin || f.couponRate == null || !f.issueDate || !f.maturityDate)) {
this.toast('Enter ISIN, Int Rate, Issue Date and Maturity Date for this security.');
return;
}
if (this.scriptIsRated && !f.rating) {
this.toast('Enter the credit rating of this bond / CP / CD.');
return;
}
const body = {
bondType: f.instrumentType,
slrType: f.slrType ?? '',
scriptDesc: f.scriptName,
glAccountId: Number(f.glAccountId),
isin: f.isin ?? '',
intRate: f.couponRate ?? null,
issueDate: f.issueDate ?? '',
maturityDate: f.maturityDate ?? '',
companyName: f.companyName ?? '',
address1: f.address1 ?? '',
address2: f.address2 ?? '',
address3: f.address3 ?? '',
city: f.city ?? '',
pincode: f.pincode ?? '',
phone: f.phone ?? '',
fax: f.fax ?? '',
corpCode: f.corpCode ?? '',
rating: this.scriptIsRated ? (f.rating ?? '') : '',
ratingAgency: this.scriptIsRated ? (f.ratingAgency ?? '') : '',
listed: !this.scriptIsRated || f.listed !== false,
active: f.active !== false,
dateFormat: 'dd-MM-yyyy',
locale: 'en'
};
const request = f.id ? this.investmentService.updateScript(f.id, body) : this.investmentService.createScript(body);
this.saving = true;
request.subscribe({
next: (res) => {
this.saving = false;
this.toast(`Script ${res.resourceIdentifier ?? f.scriptCode} ${f.id ? 'updated' : 'saved'}.`);
this.scriptForm = {};
this.reloadMasters();
},
error: (err) => {
this.saving = false;
this.toast(apiErrorMessage(err));
}
});
}
searchScript(): void {
const s = this.scripts.find((x) => x.scriptCode.toUpperCase() === this.scriptSearchCode.trim().toUpperCase());
if (!s) {
this.toast(`Script Code ${this.scriptSearchCode} not found.`);
return;
}
this.scriptForm = { ...s };
this.toast(`Script ${s.scriptCode} loaded.`);
}
cancelScript(): void {
this.scriptForm = {};
this.scriptSearchCode = '';
}
addSubType(): void {
@@ -248,24 +503,56 @@ export class InvestmentMastersComponent {
this.toast('SGL Bank master added.');
}
private loadDailyRates(): void {
this.investmentService.getDailyRates().subscribe({
next: (rows) => (this.dailyScriptRates = rows.map(toDailyScriptRate)),
error: (err) => this.toast(`Could not load daily script rates: ${apiErrorMessage(err)}`)
});
}
addDailyRate(): void {
if (!this.newDailyRate.scriptCode || !this.newDailyRate.rateDate || this.newDailyRate.closeRate == null) {
const r = this.newDailyRate;
if (!r.scriptCode || !r.rateDate || r.closeRate == null) {
this.toast('Enter Rate Date, Script Code and Close Rate.');
return;
}
const script = this.scripts.find((s) => s.scriptCode === this.newDailyRate.scriptCode);
this.dailyScriptRates = [
{
scriptName: script?.scriptName || '',
openRate: this.newDailyRate.closeRate,
highRate: this.newDailyRate.closeRate,
lowRate: this.newDailyRate.closeRate,
...this.newDailyRate
} as DailyScriptRate,
...this.dailyScriptRates
];
const script = this.scripts.find((s) => s.scriptCode === r.scriptCode);
if (!script?.id) {
this.toast(`Script ${r.scriptCode} is not saved in Script Master.`);
return;
}
const body = {
scriptId: script.id,
rateDate: r.rateDate,
closeRate: r.closeRate,
...(r.openRate != null ? { openRate: r.openRate } : {}),
...(r.highRate != null ? { highRate: r.highRate } : {}),
...(r.lowRate != null ? { lowRate: r.lowRate } : {}),
dateFormat: 'dd-MM-yyyy',
locale: 'en'
};
this.investmentService.createDailyRate(body).subscribe({
next: () => {
this.toast(`Rate for ${r.scriptCode} on ${r.rateDate} saved.`);
this.newDailyRate = {};
this.toast('Daily script rate added.');
this.loadDailyRates();
},
error: (err) => this.toast(apiErrorMessage(err))
});
}
/** A wrong rate is corrected by dropping it and entering it again. */
dropDailyRate(r: DailyScriptRate): void {
if (!r.id) {
return;
}
this.investmentService.deleteDailyRate(r.id).subscribe({
next: () => {
this.toast(`Rate for ${r.scriptCode} on ${r.rateDate} dropped.`);
this.loadDailyRates();
},
error: (err) => this.toast(apiErrorMessage(err))
});
}
// -------------------- Export to Excel --------------------
@@ -279,46 +566,121 @@ export class InvestmentMastersComponent {
return one(
[
'Party Code',
'Bond Type',
'Party Name',
'Type',
'PAN No'
'Address',
'City',
'Pincode',
'Phone',
'Fax',
'Bank Type',
'GL A/c No',
'RBI Code',
'Limit',
'LEI No',
'Counterparty Bank',
'Branch',
'Account No',
'IFSC',
'Status'
],
[
12,
14,
30,
16,
14
36,
14,
10,
14,
14,
24,
12,
12,
14,
22,
24,
20,
18,
14,
10
],
this.parties.map((p) => [
p.partyCode,
p.bondType ?? '',
p.partyName,
p.partyType,
p.panNo
[
p.address1,
p.address2,
p.address3
]
.filter((x) => !!x)
.join(', '),
p.city ?? '',
p.pincode ?? '',
p.phone ?? '',
p.fax ?? '',
p.bankType ?? '',
p.glCode ?? '',
p.rbiCode ?? '',
p.limit ?? null,
p.leiNo ?? '',
p.cpBankName ?? '',
p.cpBranchName ?? '',
p.cpAccountNo ?? '',
p.cpIfsc ?? '',
p.status ?? 'ACTIVE'
])
);
case 'script':
return one(
[
'Script Code',
'Script Name',
'Instrument',
'Bond Type',
'SLR',
'Script Desc',
'GL A/c No',
'ISIN',
'Face Value/Unit'
'Int Rate %',
'Issue Date',
'Maturity Date',
'Period (Y/M/D)',
'Face Value/Unit',
'Company Name',
'Corp Code'
],
[
14,
16,
12,
30,
12,
16,
16,
16
10,
14,
14,
14,
14,
24,
12
],
this.scripts.map((s) => [
this.scripts.map((s) => {
const p = periodBetween(s.issueDate, s.maturityDate);
return [
s.scriptCode,
s.scriptName,
s.instrumentType,
s.slrType ?? '',
s.scriptName,
s.glCode ?? '',
s.isin,
s.faceValuePerUnit
])
s.couponRate ?? null,
s.issueDate ?? '',
s.maturityDate ?? '',
s.issueDate && s.maturityDate ? `${p.years}/${p.months}/${p.days}` : '',
s.faceValuePerUnit,
s.companyName ?? '',
s.corpCode ?? ''
];
})
);
case 'subtype':
return one(
@@ -12,17 +12,26 @@
<div class="pg-eyebrow">TREASURY · INVESTMENT · REPORTS</div>
<h1 class="pg-title">Investment Reports</h1>
<p class="pg-sub">
Balance reports, ledgers, registers, maturity lists and the consolidated portfolio — all derived live from the
same holdings/transactions used by the Entry screens.
Balance reports, ledgers, registers, maturity lists and the consolidated portfolio from the saved deals, FDs and
their GL entries, as on {{ asOnDate }}.
</p>
</div>
<div class="pg-toolbar">
<button type="button" class="pg-btn pg-btn--ghost" [disabled]="generating" (click)="exportExcel()">
<button type="button" class="pg-btn pg-btn--ghost" [disabled]="loading" (click)="load()">
{{ loading ? 'Loading…' : 'Refresh' }}
</button>
<button type="button" class="pg-btn pg-btn--ghost" [disabled]="generating || loading" (click)="exportExcel()">
{{ generating ? 'Exporting…' : 'Export to Excel' }}
</button>
</div>
</header>
@if (error) {
<div class="pg-card">
<p class="inv-hint inv-hint--bad">{{ error }}</p>
</div>
}
<div class="cctr-tabs">
<button
type="button"
@@ -124,7 +133,7 @@
: activeReport === 'shareBalance'
? shareHoldings
: fdHoldings;
track h.certNo
track h.instrumentType + ':' + h.id
) {
<tr>
<td>
@@ -138,6 +147,12 @@
<span [class]="statusClass(h)">{{ h.status }}</span>
</td>
</tr>
} @empty {
<tr>
<td colspan="6" class="pg-empty">
{{ activeReport === 'shareBalance' ? 'Share entry is not live yet.' : 'No holdings.' }}
</td>
</tr>
}
</tbody>
</table>
@@ -280,7 +295,7 @@
: activeReport === 'amortizeLedger'
? amortizeTxns
: dealSlips;
track t.voucherNo
track $index
) {
<tr>
<td>{{ t.txnDate }}</td>
@@ -303,7 +318,10 @@
}
@if (activeReport === 'intDueRegister') {
<div class="pg-card">
<div class="pos-section-label">Interest Due Register (Non-Cumulative Holdings)</div>
<div class="pos-section-label">
Interest Due Register — interest earned up to {{ asOnDate }} and not received yet ·
<a routerLink="/investment/diary">Due Date Diary</a>
</div>
<table class="pg-table">
<thead>
<tr>
@@ -311,11 +329,11 @@
<th>Script / Party</th>
<th>Frequency</th>
<th class="num">Rate</th>
<th class="num col-in">Due Amount (as on {{ asOnDate }})</th>
<th class="num col-in">Receivable (as on {{ asOnDate }})</th>
</tr>
</thead>
<tbody>
@for (h of interestDueRegister; track h.certNo) {
@for (h of interestDueRegister; track h.instrumentType + ':' + h.id) {
<tr>
<td>
<span class="pg-chip">{{ h.certNo }}</span>
@@ -325,6 +343,10 @@
<td class="num">{{ h.interestRate }}%</td>
<td class="num col-in">₹{{ h.dueAmount | number: '1.2-2' }}</td>
</tr>
} @empty {
<tr>
<td colspan="5" class="pg-empty">No interest receivable.</td>
</tr>
}
</tbody>
</table>
@@ -344,7 +366,7 @@
</tr>
</thead>
<tbody>
@for (h of slrBondRegister; track h.certNo) {
@for (h of slrBondRegister; track h.instrumentType + ':' + h.id) {
<tr>
<td>
<span class="pg-chip">{{ h.certNo }}</span>
@@ -372,29 +394,33 @@
</tr>
</thead>
<tbody>
@for (t of receivedInterestTxns; track t.voucherNo) {
@for (t of receivedInterestTxns; track $index) {
<tr>
<td>{{ t.txnDate }}</td>
<td>{{ t.certNo }}</td>
<td>{{ t.particulars }}</td>
<td class="num col-in">₹{{ t.amount | number: '1.2-2' }}</td>
</tr>
} @empty {
<tr>
<td colspan="4" class="pg-empty">No interest received yet.</td>
</tr>
}
</tbody>
</table>
</div>
<div class="pg-card">
<div class="pos-section-label">Pending Interest (No Interest Posted Yet)</div>
<div class="pos-section-label">Pending Interest — earned up to {{ asOnDate }}, not received yet</div>
<table class="pg-table">
<thead>
<tr>
<th>Cert No</th>
<th>Script / Party</th>
<th class="num col-out">Accrued (Pending)</th>
<th class="num col-out">Receivable</th>
</tr>
</thead>
<tbody>
@for (h of pendingInterestHoldings; track h.certNo) {
@for (h of pendingInterestHoldings; track h.instrumentType + ':' + h.id) {
<tr>
<td>
<span class="pg-chip">{{ h.certNo }}</span>
@@ -487,11 +513,11 @@
<th>Cert No</th>
<th>Party</th>
<th class="num">Face Value</th>
<th>Matured On</th>
<th>Maturity Date</th>
</tr>
</thead>
<tbody>
@for (h of maturedFdList; track h.certNo) {
@for (h of maturedFdList; track h.instrumentType + ':' + h.id) {
<tr>
<td>
<span class="pg-chip">{{ h.certNo }}</span>
@@ -524,7 +550,7 @@
</tr>
</thead>
<tbody>
@for (h of maturingList; track h.certNo) {
@for (h of maturingList; track h.instrumentType + ':' + h.id) {
<tr>
<td>
<span class="pg-chip">{{ h.certNo }}</span>
@@ -543,24 +569,12 @@
@if (activeReport === 'maturityPattern') {
<div class="pg-card">
<div class="pos-section-label">Maturity Pattern Register</div>
<table class="pg-table">
<thead>
<tr>
<th>Bucket</th>
<th class="num">Holdings</th>
<th class="num">Face Value</th>
</tr>
</thead>
<tbody>
@for (b of maturityBuckets; track b.label) {
<tr>
<td>{{ b.label }}</td>
<td class="num">{{ b.count }}</td>
<td class="num">₹{{ b.faceValue | number: '1.2-2' }}</td>
</tr>
}
</tbody>
</table>
<p class="pg-sub" style="padding: 0 16px">
The maturity pattern (up to 1 year, 1–3, 3–5 and over 5 years) is the Bucket Wise Investment report.
</p>
<div class="inv-form-actions" style="padding: 8px 16px">
<a class="pg-btn pg-btn--primary" routerLink="/investment/bucket-report">Open Bucket Wise Investment</a>
</div>
</div>
}
@if (
@@ -601,7 +615,7 @@
: activeReport === 'shareSecList'
? shareSecList
: mutualFundList;
track h.certNo
track h.instrumentType + ':' + h.id
) {
<tr>
<td>
@@ -615,6 +629,12 @@
<span [class]="statusClass(h)">{{ h.status }}</span>
</td>
</tr>
} @empty {
<tr>
<td colspan="6" class="pg-empty">
{{ activeReport === 'shareSecList' ? 'Share entry is not live yet.' : 'No holdings.' }}
</td>
</tr>
}
</tbody>
</table>
@@ -622,35 +642,35 @@
}
@if (activeReport === 'shiftingReport') {
<div class="pg-card">
<div class="pos-section-label">
Shifting Report — SLR Securities with Market Deviation ≥ 1% (AFS/HTM review candidates)
</div>
<div class="pos-section-label">Shifting Report — Govt Securities transferred to another script / category</div>
<table class="pg-table">
<thead>
<tr>
<th>Cert No</th>
<th>Script</th>
<th class="num">Purchase Rate</th>
<th class="num">Market Price</th>
<th class="num">Deviation %</th>
<th>Date</th>
<th>Deal No</th>
<th>From</th>
<th>To</th>
<th class="num">Units</th>
<th class="num">Book Value</th>
<th>Voucher</th>
</tr>
</thead>
<tbody>
@for (h of shiftingCandidates; track h.certNo) {
@for (x of transfers; track x.id) {
<tr>
<td>{{ x.transferDate }}</td>
<td>
<span class="pg-chip">{{ h.certNo }}</span>
</td>
<td>{{ h.scriptName }}</td>
<td class="num">{{ h.purchaseRate }}</td>
<td class="num">{{ h.marketPrice }}</td>
<td class="num" [class.col-in]="h.deviationPct > 0" [class.col-out]="h.deviationPct < 0">
{{ h.deviationPct }}%
<span class="pg-chip">{{ x.dealNo }}</span>
</td>
<td>{{ x.fromScriptCode }} {{ x.fromScriptDesc }}</td>
<td>{{ x.toScriptCode }} {{ x.toScriptDesc }}</td>
<td class="num">{{ x.units | number: '1.0-4' }}</td>
<td class="num">₹{{ x.bookValue | number: '1.2-2' }}</td>
<td>{{ x.voucherNo || '—' }}</td>
</tr>
} @empty {
<tr>
<td colspan="5" class="pg-empty">No securities crossing the 1% deviation threshold today.</td>
<td colspan="7" class="pg-empty">No securities shifted.</td>
</tr>
}
</tbody>
@@ -687,7 +707,7 @@
<tfoot>
<tr class="cctr-total-row">
<td>Total</td>
<td class="num"></td>
<td class="num">{{ portfolioTotalCount }}</td>
<td class="num">₹{{ portfolioTotalFaceValue | number: '1.2-2' }}</td>
<td class="num">₹{{ portfolioTotalAccrued | number: '1.2-2' }}</td>
<td class="num">₹{{ portfolioTotalMaturity | number: '1.2-2' }}</td>
@@ -6,35 +6,44 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { Component } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterLink } from '@angular/router';
import { forkJoin, of } from 'rxjs';
import { catchError } from 'rxjs/operators';
import {
ALL_HOLDINGS,
ALL_TXNS,
FD_HOLDINGS,
GOVT_SECURITY_HOLDINGS,
NON_SLR_HOLDINGS,
BOND_HOLDINGS,
MUTUAL_FUND_HOLDINGS,
SHARE_HOLDINGS,
SCRIPT_MARKET_DETAIL,
InstrumentType,
InvestmentHolding,
InvestmentTxn,
INSTRUMENT_LABELS,
accruedInterest,
maturityAmount,
daysToMaturity,
parseDDMMYYYY,
todayDDMMYYYY
} from '../investment-data';
import { exportWorkbook, ExportSheetSpec } from '../investment-export';
import {
InvestmentDailyRateDto,
InvestmentFdDto,
InvestmentFdScheduleDto,
InvestmentSecurityTransferDto,
InvestmentService,
apiErrorMessage,
toFdHolding,
toFdTxns,
toHolding,
toInterestTxn,
toPurchaseTxn,
toSaleTxn,
toTransferTxn
} from '../investment.service';
type ReportGroup = 'balance' | 'ledger' | 'maturity' | 'portfolio';
/**
* ~20 legacy Investment reports, grouped into 4 tabs. Every figure here is derived from the
* same ALL_HOLDINGS/ALL_TXNS arrays used by the Entry screens and Dashboard — so a report can
* never drift out of sync with what a Purchase/Sell/Interest entry actually recorded.
* ~20 legacy Investment reports in 4 tabs, on live data: the saved purchases and FDs as holdings, and their GL
* entries (settlements, interest, sales, redemptions, amortisation, transfers, FD placements and closures) as the
* ledgers. Interest receivable comes from the Interest Received & Receivable report, market rates from the Daily
* Script Master.
*/
@Component({
selector: 'mifosx-investment-reports',
@@ -44,37 +53,176 @@ type ReportGroup = 'balance' | 'ledger' | 'maturity' | 'portfolio';
'../investment-shared.scss'
],
standalone: true,
imports: [CommonModule]
imports: [
CommonModule,
RouterLink
]
})
export class InvestmentReportsComponent {
export class InvestmentReportsComponent implements OnInit {
private readonly investmentService = inject(InvestmentService);
activeGroup: ReportGroup = 'balance';
activeReport = 'govtSecBalance';
asOnDate = todayDDMMYYYY();
loading = false;
error = '';
generating = false;
toastMsg = '';
toastVisible = false;
private toastTimer: ReturnType<typeof setTimeout> | undefined;
/** Saved purchases and FDs as holdings, and their GL entries, newest first. */
holdings: InvestmentHolding[] = [];
txns: InvestmentTxn[] = [];
/** Coupons and FD interest paid out — interest actually received. */
receivedTxns: InvestmentTxn[] = [];
/** GOI category transfers (security shifted to another script / category). */
transfers: InvestmentSecurityTransferDto[] = [];
/** FD interest lines need one call per FD, so they load when a report needs them. */
fdInterestLoaded = false;
private fds: InvestmentFdDto[] = [];
private receivable = new Map<string, number>();
private fdMaturity = new Map<number, number>();
private latestRate = new Map<string, number>();
ngOnInit(): void {
this.load();
}
load(): void {
const d = parseDDMMYYYY(this.asOnDate);
const fyStart = `01-04-${d.getMonth() >= 3 ? d.getFullYear() : d.getFullYear() - 1}`;
this.loading = true;
this.error = '';
this.fdInterestLoaded = false;
forkJoin({
purchases: this.investmentService.getPurchases(),
fds: this.investmentService.getFds(),
sales: this.investmentService.getSales(),
postings: this.investmentService.getInterestPostings(),
transfers: this.investmentService.getTransfers(),
interest: this.investmentService.getInterestReport(fyStart, this.asOnDate),
rates: this.investmentService.getDailyRates().pipe(catchError(() => of([] as InvestmentDailyRateDto[])))
}).subscribe({
next: (r) => {
this.fds = r.fds;
this.transfers = r.transfers;
this.holdings = [
...r.purchases.map(toHolding),
...r.fds.map(toFdHolding)
];
this.txns = this.byDateDesc([
...r.purchases.map(toPurchaseTxn),
...r.postings.map(toInterestTxn),
...r.sales.map(toSaleTxn),
...r.transfers.map(toTransferTxn),
...r.fds.flatMap((f) => toFdTxns(f, []))
]);
this.receivedTxns = this.byDateDesc(r.postings.filter((x) => x.lineType === 'COUPON').map(toInterestTxn));
this.receivable = new Map(
r.interest.rows.map((x) => [
x.instrument + ':' + x.refId,
x.receivable
])
);
this.fdMaturity = new Map(
r.fds
.filter((f) => f.id != null)
.map((f) => [
f.id as number,
f.expectedMaturityAmount ?? f.principal ?? 0
])
);
// Latest close on or before the as-on date, per script.
const asOn = parseDDMMYYYY(this.asOnDate).getTime();
this.latestRate = new Map();
[...r.rates]
.filter((x) => parseDDMMYYYY(x.rateDate).getTime() <= asOn)
.sort((a, b) => parseDDMMYYYY(a.rateDate).getTime() - parseDDMMYYYY(b.rateDate).getTime())
.forEach((x) => this.latestRate.set(x.scriptCode, x.closeRate));
this.loading = false;
if (this.activeReport === 'fdLedger' || this.activeReport === 'pendingReceived') {
this.loadFdInterest();
}
},
error: (err: unknown) => {
this.loading = false;
this.error = apiErrorMessage(err);
}
});
}
/** Adds each FD's posted interest lines to the ledgers (one schedule call per FD). */
private loadFdInterest(): void {
if (this.fdInterestLoaded || !this.fds.length) {
return;
}
this.fdInterestLoaded = true;
const withId = this.fds.filter((f) => f.id != null);
forkJoin(
withId.map((f) =>
this.investmentService
.getFdSchedule(f.id as number)
.pipe(catchError(() => of(null as InvestmentFdScheduleDto | null)))
)
).subscribe((schedules) => {
const lines: InvestmentTxn[] = [];
const received: InvestmentTxn[] = [];
schedules.forEach((s, i) => {
if (!s) {
return;
}
const interest = toFdTxns(withId[i], s.rows).filter((t) => t.txnType === 'INTEREST');
lines.push(...interest);
received.push(...interest.filter((t) => !t.particulars.startsWith('Provision')));
});
this.txns = this.byDateDesc([
...this.txns,
...lines
]);
this.receivedTxns = this.byDateDesc([
...this.receivedTxns,
...received
]);
});
}
private byDateDesc(txns: InvestmentTxn[]): InvestmentTxn[] {
return txns
.filter((t) => !!t.txnDate)
.sort((a, b) => parseDDMMYYYY(b.txnDate).getTime() - parseDDMMYYYY(a.txnDate).getTime());
}
setGroup(group: ReportGroup, defaultReport: string): void {
this.activeGroup = group;
this.activeReport = defaultReport;
this.setReport(defaultReport);
}
setReport(report: string): void {
this.activeReport = report;
if (report === 'fdLedger' || report === 'pendingReceived') {
this.loadFdInterest();
}
}
instrumentLabel(type: InstrumentType): string {
return INSTRUMENT_LABELS[type];
}
/** Interest earned up to the as-on date and not yet received (Interest Received & Receivable report). */
accrued(h: InvestmentHolding): number {
return accruedInterest(h, this.asOnDate);
return this.receivable.get((h.instrumentType === 'FD' ? 'FD' : 'SECURITY') + ':' + h.id) ?? 0;
}
/** What comes back at maturity: the FD maturity amount, a security's face value, a fund's cost. */
maturity(h: InvestmentHolding): number {
return maturityAmount(h);
if (h.instrumentType === 'FD') {
return this.fdMaturity.get(h.id ?? -1) ?? h.faceValue;
}
return h.instrumentType === 'MUTUAL_FUND' || h.instrumentType === 'SHARE'
? (h.bookValue ?? h.faceValue)
: h.faceValue;
}
daysLeft(h: InvestmentHolding): number {
@@ -85,23 +233,32 @@ export class InvestmentReportsComponent {
return `inv-badge inv-badge--${h.status.toLowerCase()}`;
}
/** Latest close in the Daily Script Master on or before the as-on date. */
marketPrice(scriptCode: string): number | null {
return SCRIPT_MARKET_DETAIL.find((m) => m.scriptCode === scriptCode)?.marketPrice ?? null;
return this.latestRate.get(scriptCode) ?? null;
}
private active(type?: InstrumentType): InvestmentHolding[] {
return this.holdings.filter((h) => h.status === 'ACTIVE' && (!type || h.instrumentType === type));
}
private ofType(type: InstrumentType): InvestmentHolding[] {
return this.holdings.filter((h) => h.instrumentType === type);
}
// -------------------- Balance Reports --------------------
get govtSecHoldings(): InvestmentHolding[] {
return GOVT_SECURITY_HOLDINGS;
return this.active('GOVT_SECURITY');
}
get shareHoldings(): InvestmentHolding[] {
return SHARE_HOLDINGS;
return this.active('SHARE');
}
get fdHoldings(): InvestmentHolding[] {
return FD_HOLDINGS;
return this.active('FD');
}
get bankInvestmentList(): Array<{ party: string; count: number; totalFaceValue: number }> {
const map = new Map<string, { party: string; count: number; totalFaceValue: number }>();
for (const h of ALL_HOLDINGS) {
for (const h of this.active()) {
const row = map.get(h.party) || { party: h.party, count: 0, totalFaceValue: 0 };
row.count += 1;
row.totalFaceValue += h.faceValue;
@@ -112,112 +269,68 @@ export class InvestmentReportsComponent {
// -------------------- Ledgers & Registers --------------------
get fdTxns(): InvestmentTxn[] {
return ALL_TXNS.filter((t) => t.instrumentType === 'FD');
return this.txns.filter((t) => t.instrumentType === 'FD');
}
get bondTxns(): InvestmentTxn[] {
return ALL_TXNS.filter((t) => ([
return this.txns.filter((t) => ([
'GOVT_SECURITY',
'NON_SLR',
'BOND'
'BOND',
'MUTUAL_FUND'
] as InstrumentType[]).includes(t.instrumentType));
}
get shareTxns(): InvestmentTxn[] {
return ALL_TXNS.filter((t) => t.instrumentType === 'SHARE');
return this.txns.filter((t) => t.instrumentType === 'SHARE');
}
get amortizeTxns(): InvestmentTxn[] {
return ALL_TXNS.filter((t) => t.txnType === 'AMORTIZE');
return this.txns.filter((t) => t.txnType === 'AMORTIZE');
}
get dealSlips(): InvestmentTxn[] {
return ALL_TXNS.filter((t) => t.txnType === 'PURCHASE');
return this.txns.filter((t) => t.txnType === 'PURCHASE' && t.instrumentType !== 'FD');
}
get slrBondRegister(): InvestmentHolding[] {
return GOVT_SECURITY_HOLDINGS.filter((h) => h.subType === 'SLR');
return this.active('GOVT_SECURITY');
}
/** Holdings with interest earned up to the as-on date and not received yet, with the amount. */
get interestDueRegister(): Array<InvestmentHolding & { dueAmount: number }> {
return ALL_HOLDINGS.filter((h) => h.status === 'ACTIVE' && h.interestFreq !== 'CUMULATIVE').map((h) => ({
...h,
dueAmount: this.accrued(h)
}));
return this.active()
.map((h) => ({ ...h, dueAmount: this.accrued(h) }))
.filter((h) => h.dueAmount > 0);
}
get receivedInterestTxns(): InvestmentTxn[] {
return ALL_TXNS.filter((t) => t.txnType === 'INTEREST' || t.txnType === 'DIVIDEND');
return this.receivedTxns;
}
get pendingInterestHoldings(): InvestmentHolding[] {
const receivedCerts = new Set(this.receivedInterestTxns.map((t) => t.certNo));
return ALL_HOLDINGS.filter(
(h) => h.status === 'ACTIVE' && h.interestFreq !== 'CUMULATIVE' && !receivedCerts.has(h.certNo)
);
return this.active().filter((h) => this.accrued(h) > 0);
}
// -------------------- Maturity & Lists --------------------
get maturedFdList(): InvestmentHolding[] {
return FD_HOLDINGS.filter((h) => h.status === 'MATURED');
return this.ofType('FD').filter((h) => h.status === 'MATURED');
}
get maturingList(): InvestmentHolding[] {
return [
...FD_HOLDINGS,
...GOVT_SECURITY_HOLDINGS
]
.filter((h) => h.status === 'ACTIVE')
.sort((a, b) => this.daysLeft(a) - this.daysLeft(b));
}
get maturityBuckets(): Array<{ label: string; count: number; faceValue: number }> {
const buckets = [
{ label: '0-1 Year', min: -99999, max: 365, count: 0, faceValue: 0 },
{ label: '1-3 Years', min: 366, max: 1095, count: 0, faceValue: 0 },
{ label: '3-5 Years', min: 1096, max: 1825, count: 0, faceValue: 0 },
{ label: 'Above 5 Years', min: 1826, max: 999999, count: 0, faceValue: 0 }
];
for (const h of ALL_HOLDINGS.filter((x) => x.status === 'ACTIVE')) {
const days = this.daysLeft(h);
const bucket = buckets.find((b) => days >= b.min && days <= b.max);
if (bucket) {
bucket.count += 1;
bucket.faceValue += h.faceValue;
}
}
return buckets;
...this.active('FD'),
...this.active('GOVT_SECURITY')
].sort((a, b) => this.daysLeft(a) - this.daysLeft(b));
}
get govtSecList(): InvestmentHolding[] {
return GOVT_SECURITY_HOLDINGS;
return this.ofType('GOVT_SECURITY');
}
get fdSecList(): InvestmentHolding[] {
return FD_HOLDINGS;
return this.ofType('FD');
}
get shareSecList(): InvestmentHolding[] {
return SHARE_HOLDINGS;
return this.ofType('SHARE');
}
get mutualFundList(): InvestmentHolding[] {
return MUTUAL_FUND_HOLDINGS;
}
get nonSlrList(): InvestmentHolding[] {
return NON_SLR_HOLDINGS;
}
get bondList(): InvestmentHolding[] {
return BOND_HOLDINGS;
}
/** Shifting Report — SLR securities whose market value has moved away from book value by
* more than 1%, a proxy for "category shift" candidates (AFS/HTM reclassification review). */
get shiftingCandidates(): Array<InvestmentHolding & { marketPrice: number; deviationPct: number }> {
return GOVT_SECURITY_HOLDINGS.map((h) => {
const mp = this.marketPrice(h.scriptCode);
if (mp === null) {
return null;
}
const deviationPct = +(((mp - h.purchaseRate) / h.purchaseRate) * 100).toFixed(2);
return { ...h, marketPrice: mp, deviationPct };
})
.filter(
(x): x is InvestmentHolding & { marketPrice: number; deviationPct: number } =>
x !== null && Math.abs(x.deviationPct) >= 1
)
.sort((a, b) => Math.abs(b.deviationPct) - Math.abs(a.deviationPct));
return this.ofType('MUTUAL_FUND');
}
// -------------------- Portfolio --------------------
private readonly portfolioTypes: InstrumentType[] = [
'FD',
'GOVT_SECURITY',
'FD',
'NON_SLR',
'BOND',
'MUTUAL_FUND',
@@ -231,7 +344,7 @@ export class InvestmentReportsComponent {
maturityValue: number;
}> {
return this.portfolioTypes.map((type) => {
const holdings = ALL_HOLDINGS.filter((h) => h.instrumentType === type);
const holdings = this.active(type);
return {
label: INSTRUMENT_LABELS[type],
count: holdings.length,
@@ -241,6 +354,9 @@ export class InvestmentReportsComponent {
};
});
}
get portfolioTotalCount(): number {
return this.portfolioSummary.reduce((s, r) => s + r.count, 0);
}
get portfolioTotalFaceValue(): number {
return this.portfolioSummary.reduce((s, r) => s + r.faceValue, 0);
}
@@ -480,26 +596,6 @@ export class InvestmentReportsComponent {
this.holdingsExportWidths,
this.maturingList.map((h) => this.holdingsExportRow(h))
);
case 'maturityPattern':
return one(
'Maturity Pattern',
'Maturity Pattern Register',
[
'Bucket',
'Holdings',
'Face Value'
],
[
22,
14,
18
],
this.maturityBuckets.map((b) => [
b.label,
b.count,
b.faceValue
])
);
case 'govtSecList':
return one(
'Govt Security List',
@@ -535,27 +631,33 @@ export class InvestmentReportsComponent {
case 'shiftingReport':
return one(
'Shifting Report',
'Shifting Report — SLR Market Deviation ≥ 1%',
'Shifting Report — Govt Securities transferred to another script / category',
[
'Cert No',
'Script',
'Purchase Rate',
'Market Price',
'Deviation %'
'Date',
'Deal No',
'From',
'To',
'Units',
'Book Value',
'Voucher No'
],
[
14,
30,
12,
16,
34,
34,
12,
16,
14
20
],
this.shiftingCandidates.map((x) => [
x.certNo,
x.scriptName,
x.purchaseRate,
x.marketPrice,
x.deviationPct
this.transfers.map((x) => [
x.transferDate,
x.dealNo,
`${x.fromScriptCode} ${x.fromScriptDesc}`,
`${x.toScriptCode} ${x.toScriptDesc}`,
x.units,
x.bookValue,
x.voucherNo ?? ''
])
);
case 'portfolio':
@@ -17,6 +17,9 @@ import { ShareInvestmentComponent } from './share-investment/share-investment.co
import { InvestmentMastersComponent } from './investment-masters/investment-masters.component';
import { InvestmentReportsComponent } from './investment-reports/investment-reports.component';
import { InvestmentInterestComponent } from './investment-interest/investment-interest.component';
import { InvestmentDiaryComponent } from './investment-diary/investment-diary.component';
import { InvestmentInterestReportComponent } from './investment-interest-report/investment-interest-report.component';
import { InvestmentBucketReportComponent } from './investment-bucket-report/investment-bucket-report.component';
const routes: Routes = [
Route.withShell([
@@ -54,6 +57,21 @@ const routes: Routes = [
component: InvestmentInterestComponent,
data: { title: 'Investment Interest', breadcrumb: 'Investment Interest' }
},
{
path: 'diary',
component: InvestmentDiaryComponent,
data: { title: 'Due Date Diary', breadcrumb: 'Due Date Diary' }
},
{
path: 'interest-report',
component: InvestmentInterestReportComponent,
data: { title: 'Interest Received & Receivable', breadcrumb: 'Interest Received & Receivable' }
},
{
path: 'bucket-report',
component: InvestmentBucketReportComponent,
data: { title: 'Bucket Wise Investment', breadcrumb: 'Bucket Wise Investment' }
},
{
path: 'reports',
component: InvestmentReportsComponent,
+11
View File
@@ -260,3 +260,14 @@
transform: translateX(-50%) translateY(0);
}
}
.inv-hint {
margin: 8px 0;
padding: 0 16px;
font-size: 13px;
color: #15803d;
&--bad {
color: #b91c1c;
}
}
File diff suppressed because it is too large Load Diff