Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b70fb4534 | ||
|
|
55f5c1cf32 | ||
|
|
6507e68203 | ||
|
|
ab8ed7e67e | ||
|
|
7ee230e58a | ||
|
|
7f3c97a205 |
@@ -73,6 +73,7 @@ import { InvestmentModule } from './investment/investment.module';
|
||||
import { NpaModule } from './npa/npa.module';
|
||||
import { ReconciliationModule } from './reconciliation/reconciliation.module';
|
||||
import { LoanOriginationModule } from './loan-origination/loan-origination.module';
|
||||
import { CreditBureauModule } from './credit-bureau/credit-bureau.module';
|
||||
import { DigitalModule } from './digital/digital.module';
|
||||
import { LetterMgmtModule } from './letter-mgmt/letter-mgmt.module';
|
||||
import { AccountsModule } from './accounts/accounts.module';
|
||||
@@ -189,6 +190,7 @@ export function HttpLoaderFactory(http: HttpClient) {
|
||||
NpaModule,
|
||||
ReconciliationModule,
|
||||
LoanOriginationModule,
|
||||
CreditBureauModule,
|
||||
DigitalModule,
|
||||
LetterMgmtModule,
|
||||
AccountsModule,
|
||||
|
||||
@@ -386,23 +386,6 @@
|
||||
</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?.savingsInterestPending?.length) {
|
||||
<div class="bd-warn">
|
||||
<mat-icon>warning</mat-icon>
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
<!--
|
||||
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="cv-tab-content cta-tab">
|
||||
<!-- ── TITLE BAR ── -->
|
||||
<div class="cta-action-bar">
|
||||
<div class="cta-action-bar__left">
|
||||
<mat-icon class="cta-action-bar__icon">swap_horiz</mat-icon>
|
||||
<div>
|
||||
<div class="cta-action-bar__title">Cash Transfers</div>
|
||||
<div class="cta-action-bar__sub">
|
||||
Approve or reject an allocation of cash from the vault to a cashier. The cash leaves the vault only when it is
|
||||
approved.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cta-counts">
|
||||
<span class="cta-count"
|
||||
><strong>{{ all.length }}</strong> waiting</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── FILTER BAR ── -->
|
||||
<div class="cta-filter-bar">
|
||||
<div class="cta-search-box">
|
||||
<mat-icon>search</mat-icon>
|
||||
<input type="text" placeholder="Search by cashier, vault, user or note" [(ngModel)]="searchTerm" />
|
||||
@if (searchTerm) {
|
||||
<button type="button" class="cta-search-box__clear" (click)="searchTerm = ''">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
<button type="button" class="cta-btn cta-btn--refresh" (click)="load()" [disabled]="loading">
|
||||
<mat-icon>refresh</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ── TABLE ── -->
|
||||
@if (loading && !loaded) {
|
||||
<div class="cta-empty"><p class="cta-empty__title">Loading…</p></div>
|
||||
} @else if (rows.length === 0) {
|
||||
<div class="cta-empty">
|
||||
<mat-icon class="cta-empty__icon">inbox</mat-icon>
|
||||
<p class="cta-empty__title">No cash transfer waiting</p>
|
||||
<p class="cta-empty__text">There is no cash allocation waiting for approval.</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="cta-table-wrap">
|
||||
<table class="cta-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>From</th>
|
||||
<th>To (Cashier)</th>
|
||||
<th class="num">Amount</th>
|
||||
<th>Note</th>
|
||||
<th>Raised By</th>
|
||||
<th>Raised At</th>
|
||||
<th class="cta-th-action">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (r of rows; track r.id) {
|
||||
<tr class="cta-row">
|
||||
<td class="cta-dt">{{ r.transfer_date || '—' }}</td>
|
||||
<td>{{ r.from_party || '—' }}</td>
|
||||
<td class="cta-strong">{{ r.to_party || '—' }}</td>
|
||||
<td class="num cta-amount">₹{{ r.total_amount | number: '1.2-2' }}</td>
|
||||
<td class="cta-reason" [title]="r.note || ''">{{ r.note || '—' }}</td>
|
||||
<td>{{ r.maker_name || '—' }}</td>
|
||||
<td class="cta-dt">{{ formatDateTime(r.maker_at) }}</td>
|
||||
<td class="cta-action-cell">
|
||||
<button type="button" class="cta-btn cta-btn--approve" (click)="review(r)">
|
||||
<mat-icon>rate_review</mat-icon> Review
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- ─── Popup: review a request, every note and coin it asks for ───────────── -->
|
||||
<ng-template #reviewDialog>
|
||||
@if (reviewing) {
|
||||
<div class="cta-dlg">
|
||||
<header class="cta-dlg__head">
|
||||
<mat-icon class="cta-dlg__ico cta-dlg__ico--ok">swap_horiz</mat-icon>
|
||||
<div class="cta-dlg__titles">
|
||||
<div class="cta-dlg__title">Review cash transfer</div>
|
||||
<div class="cta-dlg__sub">
|
||||
Raised by {{ reviewing.maker_name || '—' }} · {{ formatDateTime(reviewing.maker_at) }}
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="cta-dlg__x" aria-label="Close" (click)="closeReview()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="cta-dlg__body">
|
||||
<div class="cta-total">
|
||||
<span>Amount to release</span>
|
||||
<strong>₹{{ reviewing.total_amount | number: '1.2-2' }}</strong>
|
||||
</div>
|
||||
|
||||
<div class="cta-grid">
|
||||
<div class="cta-cell">
|
||||
<div class="cta-label">Transfer date</div>
|
||||
<div class="cta-value">{{ reviewing.transfer_date || '—' }}</div>
|
||||
</div>
|
||||
<div class="cta-cell">
|
||||
<div class="cta-label">From</div>
|
||||
<div class="cta-value">{{ reviewing.from_party || '—' }}</div>
|
||||
</div>
|
||||
<div class="cta-cell">
|
||||
<div class="cta-label">To (cashier)</div>
|
||||
<div class="cta-value">{{ reviewing.to_party || '—' }}</div>
|
||||
</div>
|
||||
<div class="cta-cell">
|
||||
<div class="cta-label">Notes and coins</div>
|
||||
<div class="cta-value">
|
||||
{{ piecesOf(reviewing) }} pieces · {{ linesOf(reviewing).length }} denominations
|
||||
</div>
|
||||
</div>
|
||||
@if (reviewing.note) {
|
||||
<div class="cta-cell cta-cell--wide">
|
||||
<div class="cta-label">Note</div>
|
||||
<div class="cta-value">{{ reviewing.note }}</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="cta-label">Denomination breakdown</div>
|
||||
<table class="cta-mini">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Denomination</th>
|
||||
<th class="num">Count</th>
|
||||
<th class="num">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (l of linesOf(reviewing); track l.value) {
|
||||
<tr>
|
||||
<td>₹{{ l.value }}</td>
|
||||
<td class="num">{{ l.count }}</td>
|
||||
<td class="num">₹{{ l.amount | number: '1.2-2' }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td>Total</td>
|
||||
<td class="num">{{ piecesOf(reviewing) }}</td>
|
||||
<td class="num">₹{{ reviewing.total_amount | number: '1.2-2' }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<footer class="cta-dlg__foot">
|
||||
<button type="button" class="cta-btn cta-btn--ghost" (click)="closeReview()">Close</button>
|
||||
<button
|
||||
type="button"
|
||||
class="cta-btn cta-btn--reject"
|
||||
[disabled]="busyId === reviewing.id"
|
||||
(click)="rejectFromReview(reviewing)"
|
||||
>
|
||||
<mat-icon>close</mat-icon> Reject
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="cta-btn cta-btn--approve"
|
||||
[disabled]="busyId === reviewing.id"
|
||||
(click)="approve(reviewing)"
|
||||
>
|
||||
<mat-icon>check</mat-icon> Approve
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<!-- ─── Popup: reject with a reason ───────────────────────────────────────── -->
|
||||
<ng-template #rejectDialog>
|
||||
@if (rejecting) {
|
||||
<div class="cta-dlg">
|
||||
<header class="cta-dlg__head">
|
||||
<mat-icon class="cta-dlg__ico">block</mat-icon>
|
||||
<div class="cta-dlg__titles">
|
||||
<div class="cta-dlg__title">Reject cash transfer</div>
|
||||
<div class="cta-dlg__sub">₹{{ rejecting.total_amount | number: '1.2-2' }} to {{ rejecting.to_party }}</div>
|
||||
</div>
|
||||
<button type="button" class="cta-dlg__x" aria-label="Close" (click)="cancelReject()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</header>
|
||||
<div class="cta-dlg__body">
|
||||
<label class="cta-label" for="cta-reason">Reason (required)</label>
|
||||
<textarea
|
||||
id="cta-reason"
|
||||
rows="3"
|
||||
placeholder="Why is this being rejected?"
|
||||
[(ngModel)]="rejectReason"
|
||||
></textarea>
|
||||
</div>
|
||||
<footer class="cta-dlg__foot">
|
||||
<button type="button" class="cta-btn cta-btn--ghost" (click)="cancelReject()">Cancel</button>
|
||||
<button
|
||||
type="button"
|
||||
class="cta-btn cta-btn--reject-solid"
|
||||
[disabled]="!rejectReason.trim() || busyId === rejecting.id"
|
||||
(click)="confirmReject()"
|
||||
>
|
||||
Confirm reject
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
}
|
||||
</ng-template>
|
||||
@@ -0,0 +1,573 @@
|
||||
/**
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
// Laid out like the other approval tabs (Withdrawal Requests): title bar, filter bar, one table.
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.cta-tab {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.cta-action-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 10px 16px;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
|
||||
&__left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
font-size: 22px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
color: #0f4f3c;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #0d1b2a;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
max-width: 640px;
|
||||
margin-top: 1px;
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
.cta-counts {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.cta-count {
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
background: #f1f5f9;
|
||||
font-size: 11px;
|
||||
color: #475569;
|
||||
|
||||
strong {
|
||||
color: #0f4f3c;
|
||||
}
|
||||
}
|
||||
|
||||
.cta-filter-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
padding: 6px 16px;
|
||||
background: #f8fafc;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.cta-fb-sep {
|
||||
flex-shrink: 0;
|
||||
width: 1px;
|
||||
height: 22px;
|
||||
margin: 0 4px;
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
.cta-search-box {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
height: 30px;
|
||||
min-width: 240px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
|
||||
mat-icon {
|
||||
flex-shrink: 0;
|
||||
font-size: 17px;
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: #cbd5e1;
|
||||
}
|
||||
|
||||
&:focus-within {
|
||||
border-color: #0f4f3c;
|
||||
box-shadow: 0 0 0 3px rgb(15 79 60 / 8%);
|
||||
}
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
color: #0d1b2a;
|
||||
|
||||
&::placeholder {
|
||||
color: #94a3b8;
|
||||
}
|
||||
}
|
||||
|
||||
&__clear {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: none;
|
||||
color: #94a3b8;
|
||||
cursor: pointer;
|
||||
|
||||
mat-icon {
|
||||
font-size: 15px;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #dc2626;
|
||||
background: #fef2f2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cta-filter-select {
|
||||
height: 30px;
|
||||
min-width: 140px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 7px;
|
||||
background: #fff;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
color: #0d1b2a;
|
||||
cursor: pointer;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: #0f4f3c;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Buttons ─────────────────────────────────────────────────────────────────
|
||||
.cta-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 26px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 7px;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&--refresh {
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
margin-left: auto;
|
||||
border-color: #e2e8f0;
|
||||
background: #fff;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
&--approve {
|
||||
background: #0f4f3c;
|
||||
color: #fff;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #0a3d2e;
|
||||
}
|
||||
}
|
||||
|
||||
&--reject {
|
||||
border-color: #fecaca;
|
||||
background: #fff;
|
||||
color: #dc2626;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #fef2f2;
|
||||
}
|
||||
}
|
||||
|
||||
&--reject-solid {
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&--ghost {
|
||||
border-color: #e2e8f0;
|
||||
background: #fff;
|
||||
color: #475569;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Table ───────────────────────────────────────────────────────────────────
|
||||
.cta-table-wrap {
|
||||
overflow-x: auto;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.cta-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 11px;
|
||||
|
||||
th {
|
||||
padding: 7px 10px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
font-size: 9.5px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.06em;
|
||||
text-align: left;
|
||||
text-transform: uppercase;
|
||||
color: #94a3b8;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 5px 10px;
|
||||
border-bottom: 1px solid #eef2f7;
|
||||
vertical-align: middle;
|
||||
color: #0d1b2a;
|
||||
}
|
||||
|
||||
.num {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cta-th-action {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
.cta-row:hover td {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.cta-mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.cta-voucher {
|
||||
font-weight: 700;
|
||||
color: #0f4f3c;
|
||||
}
|
||||
|
||||
.cta-strong {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.cta-sub {
|
||||
margin-top: 1px;
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.cta-none {
|
||||
color: #cbd5e1;
|
||||
}
|
||||
|
||||
.cta-amount {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.cta-reason {
|
||||
max-width: 220px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.cta-dt {
|
||||
white-space: nowrap;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.cta-kind {
|
||||
display: inline-block;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
|
||||
&--unpass {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
&--correction {
|
||||
background: #dbeafe;
|
||||
color: #1e40af;
|
||||
}
|
||||
}
|
||||
|
||||
.cta-action-cell {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
// ── Empty ───────────────────────────────────────────────────────────────────
|
||||
.cta-empty {
|
||||
padding: 28px 16px;
|
||||
text-align: center;
|
||||
color: #94a3b8;
|
||||
|
||||
&__icon {
|
||||
display: block;
|
||||
margin: 0 auto 6px;
|
||||
font-size: 30px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
&__text {
|
||||
margin: 3px 0 0;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Reject popup ────────────────────────────────────────────────────────────
|
||||
.cta-dlg {
|
||||
font-size: 12px;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
&__ico {
|
||||
flex: 0 0 32px;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
border-radius: 9px;
|
||||
background: #fef2f2;
|
||||
color: #dc2626;
|
||||
font-size: 18px;
|
||||
line-height: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__titles {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
&__x {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 28px;
|
||||
width: 28px;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
font-size: 18px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 12px 14px;
|
||||
max-height: 64vh;
|
||||
overflow-y: auto;
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
padding: 7px 10px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
resize: vertical;
|
||||
|
||||
&:focus {
|
||||
outline: 0;
|
||||
border-color: #0f4f3c;
|
||||
box-shadow: 0 0 0 3px rgb(15 79 60 / 8%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__foot {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 10px 14px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
}
|
||||
|
||||
.cta-label {
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.cta-dlg__ico--ok {
|
||||
background: #f0fdf4;
|
||||
color: #1f7a4d;
|
||||
}
|
||||
|
||||
.cta-total {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 10px;
|
||||
background: #ecfdf5;
|
||||
border: 1px solid #a7f3d0;
|
||||
color: #065f46;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
|
||||
strong {
|
||||
font-size: 18px;
|
||||
font-weight: 800;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
}
|
||||
|
||||
.cta-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 6px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.cta-cell {
|
||||
padding: 6px 10px;
|
||||
border-radius: 8px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #eef2f7;
|
||||
|
||||
&--wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
.cta-value {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.cta-mini {
|
||||
width: 100%;
|
||||
margin-top: 4px;
|
||||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
|
||||
th {
|
||||
padding: 6px 10px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.05em;
|
||||
text-align: left;
|
||||
text-transform: uppercase;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 5px 10px;
|
||||
border-bottom: 1px solid #eef2f7;
|
||||
}
|
||||
|
||||
.num {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
tfoot td {
|
||||
border-top: 2px solid #e2e8f0;
|
||||
border-bottom: 0;
|
||||
font-weight: 800;
|
||||
background: #f8fafc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* 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, TemplateRef, ViewChild, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { of } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { CashierService } from '../cashier.service';
|
||||
|
||||
/** A cash transfer request waiting for a checker, as the server keeps it (snake_case columns). */
|
||||
interface CashTransferRequest {
|
||||
id: number;
|
||||
transfer_date: string | null;
|
||||
from_party: string | null;
|
||||
to_party: string | null;
|
||||
note: string | null;
|
||||
total_amount: number;
|
||||
maker_name: string | null;
|
||||
maker_at: string | null;
|
||||
denominations: { denominationValue: number; count: number }[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checker side of Cash Transfer: approves or rejects an allocation of cash from the vault to a cashier. The cash
|
||||
* leaves the vault only when it is approved, by someone other than the person who raised it.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-cash-transfer-approvals',
|
||||
templateUrl: './cash-transfer-approvals.component.html',
|
||||
styleUrls: ['./cash-transfer-approvals.component.scss'],
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
MatDialogModule,
|
||||
MatIconModule,
|
||||
MatSnackBarModule
|
||||
]
|
||||
})
|
||||
export class CashTransferApprovalsComponent implements OnInit {
|
||||
private service = inject(CashierService);
|
||||
private snackBar = inject(MatSnackBar);
|
||||
private dialog = inject(MatDialog);
|
||||
|
||||
@ViewChild('rejectDialog') rejectDialog!: TemplateRef<unknown>;
|
||||
@ViewChild('reviewDialog') reviewDialog!: TemplateRef<unknown>;
|
||||
private dialogRef: MatDialogRef<unknown> | null = null;
|
||||
private reviewRef: MatDialogRef<unknown> | null = null;
|
||||
|
||||
/** The request open in the review popup, with every note and coin it asks for. */
|
||||
reviewing: CashTransferRequest | null = null;
|
||||
|
||||
all: CashTransferRequest[] = [];
|
||||
loading = false;
|
||||
loaded = false;
|
||||
busyId: number | null = null;
|
||||
searchTerm = '';
|
||||
|
||||
rejecting: CashTransferRequest | null = null;
|
||||
rejectReason = '';
|
||||
|
||||
ngOnInit(): void {
|
||||
this.load();
|
||||
}
|
||||
|
||||
load(): void {
|
||||
this.loading = true;
|
||||
this.service
|
||||
.getCashTransferRequests('PENDING')
|
||||
.pipe(catchError(() => of([] as CashTransferRequest[])))
|
||||
.subscribe((rows) => {
|
||||
this.all = rows as CashTransferRequest[];
|
||||
this.loading = false;
|
||||
this.loaded = true;
|
||||
});
|
||||
}
|
||||
|
||||
get rows(): CashTransferRequest[] {
|
||||
const term = this.searchTerm.trim().toLowerCase();
|
||||
if (!term) return this.all;
|
||||
return this.all.filter((r) => [
|
||||
r.from_party,
|
||||
r.to_party,
|
||||
r.maker_name,
|
||||
r.note
|
||||
].some((v) => (v ?? '').toLowerCase().includes(term)));
|
||||
}
|
||||
|
||||
/** One line per denomination asked for, largest first, with what each line adds up to. */
|
||||
linesOf(r: CashTransferRequest): { value: number; count: number; amount: number }[] {
|
||||
return [...(r.denominations ?? [])]
|
||||
.filter((d) => d.count > 0)
|
||||
.sort((a, b) => b.denominationValue - a.denominationValue)
|
||||
.map((d) => ({ value: d.denominationValue, count: d.count, amount: d.denominationValue * d.count }));
|
||||
}
|
||||
|
||||
/** How many notes and coins the request asks for in all. */
|
||||
piecesOf(r: CashTransferRequest): number {
|
||||
return this.linesOf(r).reduce((sum, l) => sum + l.count, 0);
|
||||
}
|
||||
|
||||
review(r: CashTransferRequest): void {
|
||||
this.reviewing = r;
|
||||
this.reviewRef?.close();
|
||||
this.reviewRef = this.dialog.open(this.reviewDialog, { width: '560px', maxWidth: '95vw', autoFocus: false });
|
||||
this.reviewRef.afterClosed().subscribe(() => (this.reviewing = null));
|
||||
}
|
||||
|
||||
closeReview(): void {
|
||||
this.reviewRef?.close();
|
||||
}
|
||||
|
||||
/** Rejecting from the review popup: the review closes, the reason popup opens for the same request. */
|
||||
rejectFromReview(r: CashTransferRequest): void {
|
||||
this.reviewRef?.close();
|
||||
this.startReject(r);
|
||||
}
|
||||
|
||||
formatDateTime(value: string | null): string {
|
||||
if (!value) return '—';
|
||||
const d = new Date(value);
|
||||
return isNaN(d.getTime())
|
||||
? value
|
||||
: d.toLocaleString('en-IN', { day: '2-digit', month: 'short', hour: '2-digit', minute: '2-digit' });
|
||||
}
|
||||
|
||||
approve(r: CashTransferRequest): void {
|
||||
if (this.busyId) return;
|
||||
this.busyId = r.id;
|
||||
this.service.approveCashTransferRequest(r.id).subscribe({
|
||||
next: (res: any) => {
|
||||
this.busyId = null;
|
||||
this.reviewRef?.close();
|
||||
this.snackBar.open(
|
||||
res?.glWarning ? `Approved (GL warning: ${res.glWarning})` : 'Approved — cash allocated to the cashier',
|
||||
'Close',
|
||||
{ duration: 6000 }
|
||||
);
|
||||
this.load();
|
||||
},
|
||||
error: (err) => {
|
||||
this.busyId = null;
|
||||
this.fail(err, 'Could not approve');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
startReject(r: CashTransferRequest): void {
|
||||
this.rejecting = r;
|
||||
this.rejectReason = '';
|
||||
this.dialogRef = this.dialog.open(this.rejectDialog, { width: '440px', maxWidth: '95vw', autoFocus: false });
|
||||
this.dialogRef.afterClosed().subscribe(() => (this.rejecting = null));
|
||||
}
|
||||
|
||||
cancelReject(): void {
|
||||
this.dialogRef?.close();
|
||||
}
|
||||
|
||||
confirmReject(): void {
|
||||
if (!this.rejecting || !this.rejectReason.trim() || this.busyId) return;
|
||||
const id = this.rejecting.id;
|
||||
this.busyId = id;
|
||||
this.service.rejectCashTransferRequest(id, this.rejectReason.trim()).subscribe({
|
||||
next: () => {
|
||||
this.busyId = null;
|
||||
this.dialogRef?.close();
|
||||
this.snackBar.open('Rejected', 'Close', { duration: 4000 });
|
||||
this.load();
|
||||
},
|
||||
error: (err) => {
|
||||
this.busyId = null;
|
||||
this.fail(err, 'Could not reject');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private fail(err: any, fallback: string): void {
|
||||
const msg = err?.error?.errors?.[0]?.defaultUserMessage ?? err?.error?.defaultUserMessage ?? fallback;
|
||||
this.snackBar.open(msg, 'Close', { duration: 8000 });
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,15 @@
|
||||
<h1 class="pg-title">Cash Transfer</h1>
|
||||
<p class="pg-sub">Move cash denomination-wise from one party to another (e.g. Vault → Cashier for opening).</p>
|
||||
</div>
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="clear()"><mat-icon>undo</mat-icon> Clear</button>
|
||||
<div class="ct-head-actions">
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="openRequests()">
|
||||
<mat-icon>pending_actions</mat-icon> My Requests
|
||||
@if (pendingCount) {
|
||||
<span class="ct-badge">{{ pendingCount }}</span>
|
||||
}
|
||||
</button>
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="clear()"><mat-icon>undo</mat-icon> Clear</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="pg-toolbar pg-toolbar--mat">
|
||||
@@ -155,7 +163,56 @@
|
||||
<div class="pg-total-bar">
|
||||
Total to transfer: <strong>₹{{ total | number: '1.2-2' }}</strong>
|
||||
<button type="button" class="pg-btn pg-btn--primary" [disabled]="!valid || saving" (click)="submit()">
|
||||
<mat-icon>swap_horiz</mat-icon> Record Transfer
|
||||
<mat-icon>send</mat-icon> Send for approval
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Popup: this person's own cash transfer requests, and where each stands. The cash moves only once a manager approves. -->
|
||||
<ng-template #requestsDialog>
|
||||
<div class="ct-dlg">
|
||||
<header class="ct-dlg__head">
|
||||
<mat-icon class="ct-dlg__ico">pending_actions</mat-icon>
|
||||
<div class="ct-dlg__titles">
|
||||
<div class="ct-dlg__title">My transfer requests</div>
|
||||
<div class="ct-dlg__sub">Cash leaves the vault only after a manager approves</div>
|
||||
</div>
|
||||
<button type="button" class="ct-dlg__x" aria-label="Close" (click)="closeRequests()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</header>
|
||||
<div class="ct-dlg__body">
|
||||
@if (myRequests.length) {
|
||||
<table class="pg-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>To</th>
|
||||
<th class="num">Amount</th>
|
||||
<th>Status</th>
|
||||
<th>Approved by</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (r of myRequests; track r.id) {
|
||||
<tr>
|
||||
<td>{{ r.transfer_date || '—' }}</td>
|
||||
<td>{{ r.to_party || '—' }}</td>
|
||||
<td class="num">₹{{ r.total_amount | number: '1.2-2' }}</td>
|
||||
<td>
|
||||
<span class="ct-status" [class]="'ct-status ct-status--' + r.status">{{ r.status }}</span>
|
||||
@if (r.rejection_reason) {
|
||||
<div class="ct-requests__note">{{ r.rejection_reason }}</div>
|
||||
}
|
||||
</td>
|
||||
<td>{{ r.checker_name || '—' }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
} @else {
|
||||
<div class="pg-empty">You have not raised any cash transfer request yet.</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
@@ -49,3 +49,131 @@
|
||||
font-size: 12px;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.ct-requests {
|
||||
padding: 0;
|
||||
|
||||
&__title {
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #0d1b2a;
|
||||
}
|
||||
|
||||
&__note {
|
||||
margin-top: 2px;
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
.ct-status {
|
||||
display: inline-block;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
background: #e2e8f0;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
|
||||
&--PENDING {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
&--APPROVED {
|
||||
background: #d1fae5;
|
||||
color: #065f46;
|
||||
}
|
||||
|
||||
&--REJECTED {
|
||||
background: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
}
|
||||
|
||||
.ct-head-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.ct-badge {
|
||||
min-width: 18px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
background: #f59e0b;
|
||||
color: #fff;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ct-dlg {
|
||||
font-size: 12px;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
&__ico {
|
||||
flex: 0 0 32px;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
border-radius: 9px;
|
||||
background: #f0fdf4;
|
||||
color: #1f7a4d;
|
||||
font-size: 18px;
|
||||
line-height: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__titles {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
&__x {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 28px;
|
||||
width: 28px;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
font-size: 18px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
&__body {
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { Component, OnInit, TemplateRef, ViewChild, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
@@ -39,6 +40,7 @@ interface Denom {
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
MatIconModule,
|
||||
MatDialogModule,
|
||||
MatSnackBarModule,
|
||||
MatFormFieldModule,
|
||||
MatSelectModule,
|
||||
@@ -48,6 +50,10 @@ interface Denom {
|
||||
export class CashTransferComponent implements OnInit {
|
||||
private service = inject(CashierService);
|
||||
private snackBar = inject(MatSnackBar);
|
||||
private dialog = inject(MatDialog);
|
||||
|
||||
@ViewChild('requestsDialog') requestsDialog!: TemplateRef<unknown>;
|
||||
private requestsRef: MatDialogRef<unknown> | null = null;
|
||||
|
||||
notes: Denom[] = [];
|
||||
coins: Denom[] = [];
|
||||
@@ -82,7 +88,34 @@ export class CashTransferComponent implements OnInit {
|
||||
vaultHasBreakdown = true;
|
||||
loadingVault = false;
|
||||
|
||||
/** The caller's own transfer requests, newest first, so a request can be followed to its approval. */
|
||||
myRequests: any[] = [];
|
||||
|
||||
loadMyRequests(): void {
|
||||
this.service
|
||||
.getCashTransferRequests(undefined, true)
|
||||
.pipe(catchError(() => of([] as any[])))
|
||||
.subscribe((rows) => (this.myRequests = rows.slice(0, 20)));
|
||||
}
|
||||
|
||||
/** How many of this person's requests are still waiting for a manager. */
|
||||
get pendingCount(): number {
|
||||
return this.myRequests.filter((r) => r.status === 'PENDING').length;
|
||||
}
|
||||
|
||||
/** Opens the list of this person's requests, freshly read, so a request can be followed to its approval. */
|
||||
openRequests(): void {
|
||||
this.loadMyRequests();
|
||||
this.requestsRef?.close();
|
||||
this.requestsRef = this.dialog.open(this.requestsDialog, { width: '720px', maxWidth: '95vw', autoFocus: false });
|
||||
}
|
||||
|
||||
closeRequests(): void {
|
||||
this.requestsRef?.close();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadMyRequests();
|
||||
const d = businessToday();
|
||||
this.transferDate = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||
this.service.getActiveDenominations().subscribe({
|
||||
@@ -245,16 +278,11 @@ export class CashTransferComponent implements OnInit {
|
||||
.filter((d) => this.countFor(d) > 0)
|
||||
.map((d) => ({ denominationId: d.id, denominationValue: d.value, count: this.countFor(d) }))
|
||||
};
|
||||
this.service.createCashTransfer(payload).subscribe({
|
||||
next: (res: any) => {
|
||||
if (res?.glWarning) {
|
||||
this.snackBar.open(`Transfer saved (GL warning: ${res.glWarning})`, 'Close', {
|
||||
duration: 8000,
|
||||
panelClass: ['snack-warn']
|
||||
});
|
||||
} else {
|
||||
this.snackBar.open('Cash transfer recorded', 'Close', { duration: 3000 });
|
||||
}
|
||||
this.service.createCashTransferRequest(payload).subscribe({
|
||||
next: () => {
|
||||
// Nothing has moved yet: a manager approves the allocation first, and only then does the cash leave the vault.
|
||||
this.snackBar.open('Cash transfer sent for manager approval', 'Close', { duration: 5000 });
|
||||
this.loadMyRequests();
|
||||
this.clear();
|
||||
this.note = '';
|
||||
this.fromParty = '';
|
||||
|
||||
@@ -83,6 +83,13 @@ const routes: Routes = [
|
||||
),
|
||||
data: { title: 'My Share Requests', breadcrumb: 'My Share Requests' }
|
||||
},
|
||||
{
|
||||
// The same page as the cashier's, reached from the clerk dashboard: a clerk unpasses vouchers here.
|
||||
path: 'voucher-correction',
|
||||
loadComponent: () =>
|
||||
import('./voucher-correction/voucher-correction.component').then((m) => m.VoucherCorrectionComponent),
|
||||
data: { title: 'Voucher Correction', breadcrumb: 'Voucher Correction' }
|
||||
},
|
||||
{
|
||||
path: 'closure-requests',
|
||||
loadComponent: () =>
|
||||
@@ -291,6 +298,12 @@ const routes: Routes = [
|
||||
component: ReconciliationComponent,
|
||||
data: { title: 'Reconciliation', breadcrumb: 'Reconciliation' }
|
||||
},
|
||||
{
|
||||
path: 'voucher-correction',
|
||||
loadComponent: () =>
|
||||
import('./voucher-correction/voucher-correction.component').then((m) => m.VoucherCorrectionComponent),
|
||||
data: { title: 'Voucher Correction', breadcrumb: 'Voucher Correction' }
|
||||
},
|
||||
{
|
||||
path: 'cash-history',
|
||||
component: CashHistoryComponent,
|
||||
|
||||
@@ -47,8 +47,21 @@ export class CashierService {
|
||||
}
|
||||
|
||||
// ── Cash Transfer ──
|
||||
createCashTransfer(data: any): Observable<any> {
|
||||
return this.http.post('/cashtransfer', data);
|
||||
/** Cash leaves the vault only when a different person approves, so the screen raises a request, not a transfer. */
|
||||
createCashTransferRequest(data: any): Observable<any> {
|
||||
return this.http.post('/cashtransfer/requests', data);
|
||||
}
|
||||
/** Requests by status (comma separated); mine narrows them to the ones the caller raised. */
|
||||
getCashTransferRequests(status?: string, mine = false): Observable<any[]> {
|
||||
let params = new HttpParams().set('mine', String(mine));
|
||||
if (status) params = params.set('status', status);
|
||||
return this.http.get<any[]>('/cashtransfer/requests', { params });
|
||||
}
|
||||
approveCashTransferRequest(id: number): Observable<any> {
|
||||
return this.http.post(`/cashtransfer/requests/${id}/approve`, {});
|
||||
}
|
||||
rejectCashTransferRequest(id: number, reason: string): Observable<any> {
|
||||
return this.http.post(`/cashtransfer/requests/${id}/reject`, { reason });
|
||||
}
|
||||
getCashTransfers(offset = 0, limit = 20): Observable<any> {
|
||||
const params = new HttpParams().set('offset', offset).set('limit', limit);
|
||||
|
||||
@@ -202,6 +202,7 @@
|
||||
<th class="num">Amount</th>
|
||||
<th>Payment</th>
|
||||
<th>Status</th>
|
||||
<th>Correction</th>
|
||||
<th>By</th>
|
||||
<th>Approved By</th>
|
||||
<th>Time</th>
|
||||
@@ -231,6 +232,18 @@
|
||||
<td>
|
||||
<span [class]="statusClass(r.status)">{{ r.status }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<!-- Where the voucher stands after a correction: unpassed, revoked, closed or corrected. -->
|
||||
<mifosx-voucher-status
|
||||
[status]="r.voucherStatus"
|
||||
[revokedBy]="r.revokedByVoucherNo"
|
||||
[replaces]="r.replacesVoucherNo"
|
||||
[note]="r.correctionNote"
|
||||
></mifosx-voucher-status>
|
||||
@if (!r.voucherStatus || r.voucherStatus === 'ACTIVE') {
|
||||
<span class="db-muted">—</span>
|
||||
}
|
||||
</td>
|
||||
<td>{{ r.handledBy ?? '—' }}</td>
|
||||
<td>
|
||||
{{ r.approvedBy ?? '—' }}
|
||||
@@ -256,7 +269,7 @@
|
||||
—
|
||||
}
|
||||
</td>
|
||||
<td colspan="5"></td>
|
||||
<td colspan="6"></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Router } from '@angular/router';
|
||||
import { catchError, of } from 'rxjs';
|
||||
import { CashierService } from '../cashier.service';
|
||||
import { businessToday } from 'app/core/utils/business-today';
|
||||
import { VoucherStatusComponent, VoucherStatus } from '../voucher-status/voucher-status.component';
|
||||
|
||||
/**
|
||||
* Which part of the day's work a row came from. Set by the server, one per source register.
|
||||
@@ -26,6 +27,11 @@ type DayBookSection = 'CASHIER' | 'CLERK' | 'SYSTEM';
|
||||
|
||||
interface DayBookRow {
|
||||
voucherNo: string | null;
|
||||
/** Where the voucher stands after a correction: active, revoked, under correction, or corrected. */
|
||||
voucherStatus?: VoucherStatus;
|
||||
revokedByVoucherNo?: string | null;
|
||||
replacesVoucherNo?: string | null;
|
||||
correctionNote?: string | null;
|
||||
section: DayBookSection;
|
||||
side: 'CR' | 'DR';
|
||||
kind: string;
|
||||
@@ -58,7 +64,8 @@ interface DayBookRow {
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
MatIconModule
|
||||
MatIconModule,
|
||||
VoucherStatusComponent
|
||||
]
|
||||
})
|
||||
export class DayBookComponent implements OnInit {
|
||||
|
||||
@@ -146,6 +146,7 @@
|
||||
<th class="num">Amount</th>
|
||||
<th>My part</th>
|
||||
<th>Status</th>
|
||||
<th>Correction</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -203,6 +204,18 @@
|
||||
{{ statusLabel(r.verificationStatus) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<!-- Where the voucher stands after a correction: unpassed, revoked, closed or corrected. -->
|
||||
<mifosx-voucher-status
|
||||
[status]="r.voucherStatus"
|
||||
[revokedBy]="r.revokedByVoucherNo"
|
||||
[replaces]="r.replacesVoucherNo"
|
||||
[note]="r.correctionNote"
|
||||
></mifosx-voucher-status>
|
||||
@if (!r.voucherStatus || r.voucherStatus === 'ACTIVE') {
|
||||
<span class="mw-acct">—</span>
|
||||
}
|
||||
</td>
|
||||
<td class="mw-time">{{ r.createdAt | date: 'HH:mm' }}</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { catchError, finalize, of } from 'rxjs';
|
||||
import { CashierService } from '../cashier.service';
|
||||
import { VoucherDetailDialogComponent } from './voucher-detail-dialog.component';
|
||||
import { businessToday } from 'app/core/utils/business-today';
|
||||
import { VoucherStatusComponent, VoucherStatus } from '../voucher-status/voucher-status.component';
|
||||
|
||||
/** What the signed-in user's part in a voucher was. */
|
||||
export type MyRole = 'RAISED' | 'VERIFIED' | 'RAISED_AND_VERIFIED';
|
||||
@@ -24,6 +25,11 @@ export type VoucherSide = 'CR' | 'DR' | 'JV';
|
||||
|
||||
interface MyWorkRow {
|
||||
voucherNo: string;
|
||||
/** Where the voucher stands after a correction: active, revoked, under correction, or corrected. */
|
||||
voucherStatus?: VoucherStatus;
|
||||
revokedByVoucherNo?: string | null;
|
||||
replacesVoucherNo?: string | null;
|
||||
correctionNote?: string | null;
|
||||
side: VoucherSide | null;
|
||||
voucherType: string | null;
|
||||
amount: number | null;
|
||||
@@ -76,7 +82,8 @@ interface MyWorkReport {
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
MatIconModule,
|
||||
MatDialogModule
|
||||
MatDialogModule,
|
||||
VoucherStatusComponent
|
||||
]
|
||||
})
|
||||
export class MyWorkComponent implements OnInit {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { VoucherStatusComponent, VoucherStatus } from '../voucher-status/voucher-status.component';
|
||||
|
||||
export interface VoucherDetailDialogData {
|
||||
/** Already-loaded detail from CashierService.voucherDetail() — the caller fetches, this dialog
|
||||
@@ -18,6 +19,10 @@ export interface VoucherDetailDialogData {
|
||||
* duplicated inside every dialog that could ever show a voucher. */
|
||||
detail: {
|
||||
voucherNo: string;
|
||||
voucherStatus?: VoucherStatus;
|
||||
revokedByVoucherNo?: string | null;
|
||||
replacesVoucherNo?: string | null;
|
||||
correctionNote?: string | null;
|
||||
voucherType: string | null;
|
||||
amount: number | null;
|
||||
branchName: string | null;
|
||||
@@ -58,7 +63,8 @@ export interface VoucherDetailDialogData {
|
||||
CommonModule,
|
||||
MatDialogModule,
|
||||
MatButtonModule,
|
||||
MatIconModule
|
||||
MatIconModule,
|
||||
VoucherStatusComponent
|
||||
],
|
||||
template: `
|
||||
<div class="vd-shell">
|
||||
@@ -66,7 +72,15 @@ export interface VoucherDetailDialogData {
|
||||
<div class="vd-header__title">
|
||||
<mat-icon class="vd-icon">receipt_long</mat-icon>
|
||||
<div>
|
||||
<h2>{{ detail.voucherNo }}</h2>
|
||||
<h2>
|
||||
{{ detail.voucherNo }}
|
||||
<mifosx-voucher-status
|
||||
[status]="detail.voucherStatus"
|
||||
[revokedBy]="detail.revokedByVoucherNo"
|
||||
[replaces]="detail.replacesVoucherNo"
|
||||
[note]="detail.correctionNote"
|
||||
></mifosx-voucher-status>
|
||||
</h2>
|
||||
<p>{{ detail.voucherType || 'Voucher' }} · {{ detail.branchName || 'Head Office' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -117,6 +117,8 @@
|
||||
<select
|
||||
class="ws-f__ctl"
|
||||
[(ngModel)]="row.typ"
|
||||
[disabled]="isTypLocked(row)"
|
||||
[title]="isTypLocked(row) ? 'Token withdrawal - TYPE is fixed to Payment' : ''"
|
||||
(click)="$event.stopPropagation()"
|
||||
(change)="onTypChange(row)"
|
||||
>
|
||||
@@ -127,11 +129,16 @@
|
||||
</div>
|
||||
<div class="ws-f ws-f--branch">
|
||||
<label class="ws-f__lbl" title="Branch">BRANCH</label>
|
||||
<select class="ws-f__ctl" [(ngModel)]="row.br" (click)="$event.stopPropagation()">
|
||||
<option [ngValue]="1">001 · Main</option>
|
||||
<option [ngValue]="2">002 · M.G. Road</option>
|
||||
<option [ngValue]="14">014 · Station Rd</option>
|
||||
<option [ngValue]="27">027 · Industrial</option>
|
||||
<select
|
||||
class="ws-f__ctl"
|
||||
[(ngModel)]="row.br"
|
||||
[disabled]="branches.length <= 1"
|
||||
[title]="branches.length <= 1 ? 'Your branch' : 'Branch'"
|
||||
(click)="$event.stopPropagation()"
|
||||
>
|
||||
@for (b of branches; track b.id) {
|
||||
<option [ngValue]="b.id">{{ b.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
@if (row.typ === 'DD') {
|
||||
@@ -177,13 +184,7 @@
|
||||
class="ws-f__ctl"
|
||||
[(ngModel)]="row.acTyp"
|
||||
(click)="$event.stopPropagation()"
|
||||
(change)="
|
||||
row.acTyp === 'GL' &&
|
||||
row.typ !== 'Disbursement' &&
|
||||
row.typ !== 'Fund Transfer' &&
|
||||
row.typ !== 'Enter Bank Transfer' &&
|
||||
(row.dbCr = 'Cr')
|
||||
"
|
||||
(change)="isCreditOnly(row) && (row.dbCr = 'Cr')"
|
||||
>
|
||||
@for (a of acTypOptionsFor(row); track a) {
|
||||
<option [value]="a">{{ a }}</option>
|
||||
@@ -266,12 +267,7 @@
|
||||
type="button"
|
||||
class="ws-seg__btn ws-seg__btn--dr"
|
||||
[class.ws-seg__btn--active-dr]="row.dbCr === 'Dr'"
|
||||
[disabled]="
|
||||
row.acTyp === 'GL' &&
|
||||
row.typ !== 'Disbursement' &&
|
||||
row.typ !== 'Fund Transfer' &&
|
||||
row.typ !== 'Enter Bank Transfer'
|
||||
"
|
||||
[disabled]="isCreditOnly(row)"
|
||||
(click)="row.dbCr = 'Dr'"
|
||||
>
|
||||
DR
|
||||
@@ -280,6 +276,7 @@
|
||||
type="button"
|
||||
class="ws-seg__btn ws-seg__btn--cr"
|
||||
[class.ws-seg__btn--active-cr]="row.dbCr === 'Cr'"
|
||||
[disabled]="row.typ === 'Withdrawal Slip'"
|
||||
(click)="row.dbCr = 'Cr'"
|
||||
>
|
||||
CR
|
||||
@@ -711,70 +708,81 @@
|
||||
<circle cx="12" cy="8" r="4" />
|
||||
<path d="M4 20c0-4 3.6-7 8-7s8 3 8 7" />
|
||||
</svg>
|
||||
Personal Information
|
||||
{{ isGlAccount ? 'GL Account Information' : 'Personal Information' }}
|
||||
</div>
|
||||
<div class="te-panel__body">
|
||||
<div class="te-field">
|
||||
<span class="te-label">Branch</span><span class="te-value">{{ officeName }}</span>
|
||||
@if (isGlAccount) {
|
||||
<div class="te-panel__body">
|
||||
@for (f of glInfo; track f.label) {
|
||||
<div class="te-field">
|
||||
<span class="te-label">{{ f.label }}</span
|
||||
><span class="te-value te-value-wrap" [class.te-mono]="f.mono">{{ f.value }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">A/c No.</span
|
||||
><span class="te-value te-mono">{{ accountDetails.accountNo }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Name</span><span class="te-value te-value-name">{{ clientName }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">S/D/W/H/O</span><span class="te-value">{{ guardianName }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Address</span><span class="te-value te-value-wrap">{{ clientAddress }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Email</span><span class="te-value">{{ clientEmail }}</span>
|
||||
</div>
|
||||
<div class="te-field-row">
|
||||
} @else {
|
||||
<div class="te-panel__body">
|
||||
<div class="te-field">
|
||||
<span class="te-label">Last Txn</span><span class="te-value">{{ lastTransactionDate }}</span>
|
||||
<span class="te-label">Branch</span><span class="te-value">{{ officeName }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Type</span
|
||||
><span class="te-value">{{ accountDetails.depositType?.value ?? selectedRow?.acTyp ?? '—' }}</span>
|
||||
<span class="te-label">A/c No.</span
|
||||
><span class="te-value te-mono">{{ accountDetails.accountNo }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Name</span><span class="te-value te-value-name">{{ clientName }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">S/D/W/H/O</span><span class="te-value">{{ guardianName }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Address</span><span class="te-value te-value-wrap">{{ clientAddress }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Email</span><span class="te-value">{{ clientEmail }}</span>
|
||||
</div>
|
||||
<div class="te-field-row">
|
||||
<div class="te-field">
|
||||
<span class="te-label">Last Txn</span><span class="te-value">{{ lastTransactionDate }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Type</span
|
||||
><span class="te-value">{{ accountDetails.depositType?.value ?? selectedRow?.acTyp ?? '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="te-field-row">
|
||||
<div class="te-field">
|
||||
<span class="te-label">Opening Dt</span><span class="te-value">{{ openingDate }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Status</span
|
||||
><span class="te-value">{{ accountDetails.status?.value ?? '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">CIF No.</span><span class="te-value te-mono">{{ cifNumber }}</span>
|
||||
</div>
|
||||
@if (isNonIndividual) {
|
||||
<div class="te-field">
|
||||
<span class="te-label">Constitution</span>
|
||||
<span class="te-value">{{
|
||||
nonPersonDetails?.constitution?.name ?? nonPersonDetails?.constitutionType?.name ?? '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Incorp. No.</span>
|
||||
<span class="te-value te-mono">{{
|
||||
nonPersonDetails?.incorpNo ?? nonPersonDetails?.incorporationNo ?? '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Main Business</span>
|
||||
<span class="te-value">{{
|
||||
nonPersonDetails?.mainBusinessLine?.name ?? nonPersonDetails?.mainBusinessLineType?.name ?? '—'
|
||||
}}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="te-field-row">
|
||||
<div class="te-field">
|
||||
<span class="te-label">Opening Dt</span><span class="te-value">{{ openingDate }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Status</span
|
||||
><span class="te-value">{{ accountDetails.status?.value ?? '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">CIF No.</span><span class="te-value te-mono">{{ cifNumber }}</span>
|
||||
</div>
|
||||
@if (isNonIndividual) {
|
||||
<div class="te-field">
|
||||
<span class="te-label">Constitution</span>
|
||||
<span class="te-value">{{
|
||||
nonPersonDetails?.constitution?.name ?? nonPersonDetails?.constitutionType?.name ?? '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Incorp. No.</span>
|
||||
<span class="te-value te-mono">{{
|
||||
nonPersonDetails?.incorpNo ?? nonPersonDetails?.incorporationNo ?? '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Main Business</span>
|
||||
<span class="te-value">{{
|
||||
nonPersonDetails?.mainBusinessLine?.name ?? nonPersonDetails?.mainBusinessLineType?.name ?? '—'
|
||||
}}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Joint Holders + Nominees -->
|
||||
@@ -929,76 +937,78 @@
|
||||
|
||||
<!-- Other Info + KYC + Account Balances -->
|
||||
<div class="te-panel">
|
||||
<div class="te-panel__header">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<rect x="3" y="4" width="18" height="18" rx="2" />
|
||||
<line x1="16" y1="2" x2="16" y2="6" />
|
||||
<line x1="8" y1="2" x2="8" y2="6" />
|
||||
<line x1="3" y1="10" x2="21" y2="10" />
|
||||
</svg>
|
||||
Other Information
|
||||
</div>
|
||||
<div class="te-panel__body">
|
||||
<div class="te-field">
|
||||
<span class="te-label">Phone No.</span><span class="te-value">{{ clientPhone }}</span>
|
||||
@if (!isGlAccount) {
|
||||
<div class="te-panel__header">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<rect x="3" y="4" width="18" height="18" rx="2" />
|
||||
<line x1="16" y1="2" x2="16" y2="6" />
|
||||
<line x1="8" y1="2" x2="8" y2="6" />
|
||||
<line x1="3" y1="10" x2="21" y2="10" />
|
||||
</svg>
|
||||
Other Information
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Client ID</span
|
||||
><span class="te-value te-mono">{{ accountDetails.clientId }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">PAN</span><span class="te-value te-mono">{{ panNumber }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">KYC Status</span>
|
||||
<span class="te-value" [style.color]="kycDetails?.kycStatus === 300 ? '#059669' : '#f59e0b'">{{
|
||||
kycStatus
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">CKYC No.</span><span class="te-value te-mono">{{ ckycNumber }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Aadhaar</span><span class="te-value te-mono">{{ aadhaarNumber }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Product</span>
|
||||
<span class="te-value">{{
|
||||
accountDetails.savingsProductName ||
|
||||
accountDetails.depositProductName ||
|
||||
accountDetails.productName ||
|
||||
'—'
|
||||
}}</span>
|
||||
</div>
|
||||
@if (selectedRow?.acTyp === 'SHR') {
|
||||
<div class="te-panel__body">
|
||||
<div class="te-field">
|
||||
<span class="te-label">No. of Shares Held</span
|
||||
><span class="te-value te-mono">{{ accountDetails.summary?.totalApprovedShares ?? 0 }}</span>
|
||||
<span class="te-label">Phone No.</span><span class="te-value">{{ clientPhone }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Market Price / Share</span
|
||||
><span class="te-value te-mono"
|
||||
>{{ currencySymbol }}{{ accountDetails.currentMarketPrice | number: '1.2-2' }}</span
|
||||
>
|
||||
<span class="te-label">Client ID</span
|
||||
><span class="te-value te-mono">{{ accountDetails.clientId }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Resolution No.</span
|
||||
><span class="te-value te-mono">{{ accountDetails.resolutionNumber || '—' }}</span>
|
||||
<span class="te-label">PAN</span><span class="te-value te-mono">{{ panNumber }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Linked Savings A/C No.</span
|
||||
><span class="te-value te-mono">{{ accountDetails.savingsAccountNumber || '—' }}</span>
|
||||
<span class="te-label">KYC Status</span>
|
||||
<span class="te-value" [style.color]="kycDetails?.kycStatus === 300 ? '#059669' : '#f59e0b'">{{
|
||||
kycStatus
|
||||
}}</span>
|
||||
</div>
|
||||
@if (accountDetails.linkedLoanAccountNo) {
|
||||
<div class="te-field">
|
||||
<span class="te-label">CKYC No.</span><span class="te-value te-mono">{{ ckycNumber }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Aadhaar</span><span class="te-value te-mono">{{ aadhaarNumber }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Product</span>
|
||||
<span class="te-value">{{
|
||||
accountDetails.savingsProductName ||
|
||||
accountDetails.depositProductName ||
|
||||
accountDetails.productName ||
|
||||
'—'
|
||||
}}</span>
|
||||
</div>
|
||||
@if (selectedRow?.acTyp === 'SHR') {
|
||||
<div class="te-field">
|
||||
<span class="te-label">Linked Loan A/C No.</span
|
||||
><span class="te-value te-mono">{{ accountDetails.linkedLoanAccountNo }}</span>
|
||||
<span class="te-label">No. of Shares Held</span
|
||||
><span class="te-value te-mono">{{ accountDetails.summary?.totalApprovedShares ?? 0 }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Market Price / Share</span
|
||||
><span class="te-value te-mono"
|
||||
>{{ currencySymbol }}{{ accountDetails.currentMarketPrice | number: '1.2-2' }}</span
|
||||
>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Resolution No.</span
|
||||
><span class="te-value te-mono">{{ accountDetails.resolutionNumber || '—' }}</span>
|
||||
</div>
|
||||
<div class="te-field">
|
||||
<span class="te-label">Linked Savings A/C No.</span
|
||||
><span class="te-value te-mono">{{ accountDetails.savingsAccountNumber || '—' }}</span>
|
||||
</div>
|
||||
@if (accountDetails.linkedLoanAccountNo) {
|
||||
<div class="te-field">
|
||||
<span class="te-label">Linked Loan A/C No.</span
|
||||
><span class="te-value te-mono">{{ accountDetails.linkedLoanAccountNo }}</span>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="te-panel__header te-panel__header--mt">
|
||||
<div class="te-panel__header" [class.te-panel__header--mt]="!isGlAccount">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<line x1="12" y1="1" x2="12" y2="23" />
|
||||
<path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" />
|
||||
@@ -1567,6 +1577,8 @@
|
||||
<select
|
||||
class="ws-f__ctl"
|
||||
[(ngModel)]="row.typ"
|
||||
[disabled]="isTypLocked(row)"
|
||||
[title]="isTypLocked(row) ? 'Token withdrawal - TYPE is fixed to Payment' : ''"
|
||||
(click)="$event.stopPropagation()"
|
||||
(change)="onTypChange(row)"
|
||||
>
|
||||
@@ -1577,11 +1589,16 @@
|
||||
</div>
|
||||
<div class="ws-f ws-f--branch">
|
||||
<label class="ws-f__lbl">BRANCH</label>
|
||||
<select class="ws-f__ctl" [(ngModel)]="row.br" (click)="$event.stopPropagation()">
|
||||
<option [ngValue]="1">001 · Main</option>
|
||||
<option [ngValue]="2">002 · M.G. Road</option>
|
||||
<option [ngValue]="14">014 · Station Rd</option>
|
||||
<option [ngValue]="27">027 · Industrial</option>
|
||||
<select
|
||||
class="ws-f__ctl"
|
||||
[(ngModel)]="row.br"
|
||||
[disabled]="branches.length <= 1"
|
||||
[title]="branches.length <= 1 ? 'Your branch' : 'Branch'"
|
||||
(click)="$event.stopPropagation()"
|
||||
>
|
||||
@for (b of branches; track b.id) {
|
||||
<option [ngValue]="b.id">{{ b.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
@if (row.typ === 'DD') {
|
||||
@@ -1627,13 +1644,7 @@
|
||||
class="ws-f__ctl"
|
||||
[(ngModel)]="row.acTyp"
|
||||
(click)="$event.stopPropagation()"
|
||||
(change)="
|
||||
row.acTyp === 'GL' &&
|
||||
row.typ !== 'Disbursement' &&
|
||||
row.typ !== 'Fund Transfer' &&
|
||||
row.typ !== 'Enter Bank Transfer' &&
|
||||
(row.dbCr = 'Cr')
|
||||
"
|
||||
(change)="isCreditOnly(row) && (row.dbCr = 'Cr')"
|
||||
>
|
||||
@for (a of acTypOptionsFor(row); track a) {
|
||||
<option [value]="a">{{ a }}</option>
|
||||
@@ -1704,12 +1715,7 @@
|
||||
type="button"
|
||||
class="ws-seg__btn ws-seg__btn--dr"
|
||||
[class.ws-seg__btn--active-dr]="row.dbCr === 'Dr'"
|
||||
[disabled]="
|
||||
row.acTyp === 'GL' &&
|
||||
row.typ !== 'Disbursement' &&
|
||||
row.typ !== 'Fund Transfer' &&
|
||||
row.typ !== 'Enter Bank Transfer'
|
||||
"
|
||||
[disabled]="isCreditOnly(row)"
|
||||
(click)="$event.stopPropagation(); row.dbCr = 'Dr'"
|
||||
>
|
||||
DR
|
||||
@@ -1718,6 +1724,7 @@
|
||||
type="button"
|
||||
class="ws-seg__btn ws-seg__btn--cr"
|
||||
[class.ws-seg__btn--active-cr]="row.dbCr === 'Cr'"
|
||||
[disabled]="row.typ === 'Withdrawal Slip'"
|
||||
(click)="$event.stopPropagation(); row.dbCr = 'Cr'"
|
||||
>
|
||||
CR
|
||||
@@ -2043,7 +2050,13 @@
|
||||
<button class="ws-btn ws-btn--ghost" type="button" (click)="onSearch()">Search</button>
|
||||
<button class="ws-btn ws-btn--mode" type="button">Change Tr.Mode</button>
|
||||
@if (isClerk) {
|
||||
<button class="ws-btn ws-btn--add" type="button" (click)="addRow()" title="Add another transaction row">
|
||||
<button
|
||||
class="ws-btn ws-btn--add"
|
||||
type="button"
|
||||
[disabled]="selectedRow?.typ === 'Withdrawal Slip'"
|
||||
(click)="addRow()"
|
||||
title="Add another transaction row"
|
||||
>
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
||||
<line x1="12" y1="5" x2="12" y2="19" />
|
||||
<line x1="5" y1="12" x2="19" y2="12" />
|
||||
|
||||
@@ -1658,6 +1658,8 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
|
||||
// Full account + client data
|
||||
accountDetails: any = null;
|
||||
/** Parent (header) GL of the selected GL account, shown in the GL Account Information panel. */
|
||||
glParent: { glCode?: string; name?: string } | null = null;
|
||||
clientDetails: any = null;
|
||||
kycDetails: any = null;
|
||||
nominees: any[] = [];
|
||||
@@ -1685,10 +1687,12 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
private searchToken = 0;
|
||||
private lastLoadedAcNo = '';
|
||||
private acNoInput$ = new Subject<{ row: TxnRow; index: number; value: string }>();
|
||||
/** How many characters of the A/C NO. start the automatic account search. */
|
||||
private static readonly AC_NO_AUTO_SEARCH_MIN_LENGTH = 6;
|
||||
cashVaultGlId: number | null = null;
|
||||
/** The Cash Vault GL account's own code and name — the denomination breakdown for a manual GL
|
||||
* entry has to be filed against THIS account, not whichever account the teller typed in, since
|
||||
* that account is never the one physical notes actually moved through (see submitGlJournalEntry).
|
||||
* that account is never the one physical notes actually moved through.
|
||||
* Both resolved dynamically off whatever this tenant's own financial-activity mapping names as
|
||||
* its cash/vault account (see loadCashVaultGl) — never a literal account name or code. */
|
||||
cashVaultGlCode: string | null = null;
|
||||
@@ -1873,6 +1877,7 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
ngOnInit(): void {
|
||||
const d = businessToday();
|
||||
this.today = `${String(d.getDate()).padStart(2, '0')}/${String(d.getMonth() + 1).padStart(2, '0')}/${d.getFullYear()}`;
|
||||
this.loadBranches();
|
||||
this.addRow();
|
||||
this.loadDenominations();
|
||||
this.loadOpeningPosition();
|
||||
@@ -1903,7 +1908,8 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
distinctUntilChanged((a, b) => a.value === b.value && a.row === b.row)
|
||||
)
|
||||
.subscribe(({ row, index, value }) => {
|
||||
if (value.trim().length >= 4) {
|
||||
// Searches on its own once six characters are typed, for clerk and cashier alike.
|
||||
if (value.trim().length >= TransactionEntryComponent.AC_NO_AUTO_SEARCH_MIN_LENGTH) {
|
||||
this.selectedRow = row;
|
||||
this.loadAccountDetails(value.trim(), row.acTyp);
|
||||
}
|
||||
@@ -2304,7 +2310,7 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
// anyway, just without the extra click to get there.
|
||||
const row: TxnRow = {
|
||||
typ: this.isClerk ? 'Withdrawal Slip' : 'Receipt',
|
||||
br: 1,
|
||||
br: this.defaultBranchId,
|
||||
trTp: '',
|
||||
acTyp: 'SD',
|
||||
acNo: '',
|
||||
@@ -2323,8 +2329,54 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
this.rows.push(row);
|
||||
}
|
||||
|
||||
/**
|
||||
* A GL row is credit-only (money received into the account) except on the transfer types, which pick
|
||||
* either side, and on a Withdrawal Slip, which is always a debit: the GL is debited and the cash
|
||||
* vault credited when cash is paid out against it (a clerk's request, approved, then paid by the cashier).
|
||||
*/
|
||||
isGlCreditOnly(row: TxnRow): boolean {
|
||||
return (
|
||||
row.acTyp === 'GL' &&
|
||||
row.typ !== 'Disbursement' &&
|
||||
row.typ !== 'Fund Transfer' &&
|
||||
row.typ !== 'Enter Bank Transfer' &&
|
||||
row.typ !== 'Withdrawal Slip'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Fixed Deposit row is credit-only on both the clerk and the cashier screens: an FD is funded once, with
|
||||
* exactly its principal, and money leaves it only through its maturity or premature closure. The one
|
||||
* exception is the clerk's own "Close this account" flow, which raises a closure request.
|
||||
*/
|
||||
isFdCreditOnly(row: TxnRow): boolean {
|
||||
return row.acTyp === 'FD' && !this.pendingClosure;
|
||||
}
|
||||
|
||||
/** DR is not offered for this row (see isGlCreditOnly and isFdCreditOnly). */
|
||||
isCreditOnly(row: TxnRow): boolean {
|
||||
return this.isGlCreditOnly(row) || this.isFdCreditOnly(row);
|
||||
}
|
||||
|
||||
/** Called when the TYPE dropdown changes — sets sensible defaults for TXN TP and DR/CR */
|
||||
/**
|
||||
* A cashier row that was filled from an approved token (withdrawal / account-closure) is cash
|
||||
* leaving the branch to the member, so its TYPE is fixed to Payment and cannot be changed.
|
||||
* Never true for the clerk screen or for rows keyed in by hand.
|
||||
*/
|
||||
isTypLocked(row: TxnRow): boolean {
|
||||
return (
|
||||
!this.isClerk &&
|
||||
!!row.tokNo?.trim() &&
|
||||
!!(this.activeWithdrawalRequest || this.activeDividendClaimRequest || this.activeClosureRequest)
|
||||
);
|
||||
}
|
||||
|
||||
onTypChange(row: TxnRow): void {
|
||||
if (this.isTypLocked(row)) {
|
||||
row.typ = 'Payment';
|
||||
return;
|
||||
}
|
||||
switch (row.typ) {
|
||||
case 'Withdrawal Slip':
|
||||
row.dbCr = 'Dr';
|
||||
@@ -2440,7 +2492,7 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
* such ambiguity — the account itself says what it's for.
|
||||
*/
|
||||
showsEntryType(row: TxnRow): boolean {
|
||||
return row.acTyp === 'GL' && row.dbCr === 'Cr';
|
||||
return row.acTyp === 'GL';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2618,14 +2670,47 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
return !!this.selectedRow && Math.abs(this.denominationTotal - this.ddTargetTotal) < 0.005;
|
||||
}
|
||||
|
||||
/**
|
||||
* The branches an entry can be posted against: the real offices of this installation. Read from the offices
|
||||
* themselves rather than from a fixed list, so a branch that is added or renamed shows up here without a code change.
|
||||
*/
|
||||
branches: { id: number; label: string }[] = [];
|
||||
|
||||
private loadBranches(): void {
|
||||
const own = this.authService.getCredentials();
|
||||
const ownBranch = own?.officeId
|
||||
? [{ id: own.officeId, label: this.branchLabel(own.officeId, own.officeName) }]
|
||||
: [];
|
||||
// The office list is only asked for by a login allowed to read it. A cashier or clerk is not, and asking anyway
|
||||
// makes the server refuse and the screen raise an "Unauthorized Request" popup; such a login works in its own
|
||||
// office, which is the one branch it is offered.
|
||||
const permissions = own?.permissions ?? [];
|
||||
const mayReadOffices = permissions.includes('ALL_FUNCTIONS') || permissions.includes('READ_OFFICE');
|
||||
if (!mayReadOffices) {
|
||||
this.branches = ownBranch;
|
||||
return;
|
||||
}
|
||||
this.http
|
||||
.get('/offices')
|
||||
.pipe(catchError(() => of([])))
|
||||
.subscribe((list: any) => {
|
||||
const offices: any[] = Array.isArray(list) ? list : [];
|
||||
this.branches =
|
||||
offices.length > 0 ? offices.map((o) => ({ id: o.id, label: this.branchLabel(o.id, o.name) })) : ownBranch;
|
||||
});
|
||||
}
|
||||
|
||||
private branchLabel(id: number, name: string | null | undefined): string {
|
||||
return `${String(id).padStart(3, '0')} · ${name ?? 'Branch ' + id}`;
|
||||
}
|
||||
|
||||
/** The office the signed-in user works in, which a new entry is posted against unless they pick another. */
|
||||
get defaultBranchId(): number {
|
||||
return this.authService.getCredentials()?.officeId ?? 1;
|
||||
}
|
||||
|
||||
branchNameFor(branchId: number): string {
|
||||
const map: Record<number, string> = {
|
||||
1: '001 · Main',
|
||||
2: '002 · M.G. Road',
|
||||
14: '014 · Station Rd',
|
||||
27: '027 · Industrial'
|
||||
};
|
||||
return map[branchId] || `Branch ${branchId}`;
|
||||
return this.branches.find((b) => b.id === branchId)?.label ?? `Branch ${branchId}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3918,7 +4003,8 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
SAVINGS: 'SD',
|
||||
CURRENT: 'CA',
|
||||
FIXED_DEPOSIT: 'FD',
|
||||
RECURRING_DEPOSIT: 'RD'
|
||||
RECURRING_DEPOSIT: 'RD',
|
||||
GL: 'GL'
|
||||
};
|
||||
|
||||
openCustomerSearch(): void {
|
||||
@@ -4243,6 +4329,17 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
this.accountDetails = acc;
|
||||
this.jointHolders = acc.jointHolders ?? [];
|
||||
// GL only: look up the parent (header) GL's name. Never runs for any other account type.
|
||||
this.glParent = null;
|
||||
if (acTyp?.toUpperCase() === 'GL' && acc.parentId) {
|
||||
this.http
|
||||
.get<any>(`/glaccounts/${acc.parentId}`)
|
||||
.pipe(catchError(() => of(null)))
|
||||
.subscribe((p: any) => {
|
||||
if (token !== this.searchToken) return;
|
||||
this.glParent = p ? { glCode: p.glCode, name: p.name } : null;
|
||||
});
|
||||
}
|
||||
// Cash Hold / Clearing Hold breakdown only exists for plain savings accounts (m_savings_account)
|
||||
// — FD/RD/Current/Share/GL have no such row, so there's nothing to ask for.
|
||||
if (acTyp?.toUpperCase() === 'SD' && acc.id) {
|
||||
@@ -4813,6 +4910,40 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
return this.accountDetails?.officeName ?? this.clientDetails?.officeName ?? '—';
|
||||
}
|
||||
|
||||
/** True when the loaded account is a General Ledger account (/glaccounts), which has no client behind it. */
|
||||
get isGlAccount(): boolean {
|
||||
return !!this.accountDetails?.glCode && this.selectedRow?.acTyp === 'GL';
|
||||
}
|
||||
|
||||
/** The GL account's own details, shown in place of the client panels. */
|
||||
get glInfo(): { label: string; value: string; mono?: boolean }[] {
|
||||
const gl = this.accountDetails;
|
||||
if (!gl) return [];
|
||||
const type = gl.type?.value ?? '—';
|
||||
const nature = [
|
||||
'ASSET',
|
||||
'EXPENSE'
|
||||
].includes(String(type).toUpperCase()) ? 'Debit' : 'Credit';
|
||||
return [
|
||||
{ label: 'GL Code', value: gl.glCode ?? '—', mono: true },
|
||||
{ label: 'GL Name', value: gl.name ?? '—' },
|
||||
{ label: 'Account Type', value: type },
|
||||
{ label: 'Usage', value: gl.usage?.value ?? '—' },
|
||||
{ label: 'Normal Balance', value: nature },
|
||||
{
|
||||
label: 'Parent GL',
|
||||
value: this.glParent?.name
|
||||
? `${this.glParent.glCode ? this.glParent.glCode.trim() + ' - ' : ''}${this.glParent.name.trim()}`
|
||||
: gl.parentId != null
|
||||
? `ID ${gl.parentId}`
|
||||
: '—'
|
||||
},
|
||||
{ label: 'Manual Entries', value: gl.manualEntriesAllowed ? 'Allowed' : 'Not allowed' },
|
||||
{ label: 'Status', value: gl.disabled ? 'Disabled' : 'Enabled' },
|
||||
{ label: 'Description', value: gl.description || '—' }
|
||||
];
|
||||
}
|
||||
|
||||
get openingDate(): string {
|
||||
const raw =
|
||||
this.accountDetails?.timeline?.submittedOnDate ??
|
||||
@@ -5155,6 +5286,20 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
onSave(): void {
|
||||
// Money never leaves a Fixed Deposit from this screen, clerk or cashier: no withdrawal slip, payment,
|
||||
// collection or transfer debits an FD. It is paid out only through its maturity or premature closure
|
||||
// (the clerk's "Close this account" flow). The DR button is already disabled for FD rows (isFdCreditOnly);
|
||||
// this also catches a row set to DR by its TYPE, such as a Withdrawal Slip.
|
||||
const fdDebitRows = this.rows.filter((r) => this.isFdCreditOnly(r) && r.dbCr === 'Dr');
|
||||
if (fdDebitRows.length > 0) {
|
||||
this.showAlert('error', 'Fixed Deposit Cannot Be Debited', [
|
||||
`FD account(s) ${fdDebitRows.map((r) => r.acNo).join(', ')} cannot be debited or withdrawn from.`,
|
||||
'Money leaves a Fixed Deposit only through its maturity or premature closure.',
|
||||
'An FD can only be credited — once, with exactly its principal.'
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Demand drafts commit here like everything else on the worksheet. Checked first because a DD
|
||||
// row shares its shape with the ordinary entries below — without this it would fall through and
|
||||
// post as a plain transaction, with the draft never raised and the charges silently dropped.
|
||||
@@ -5232,7 +5377,9 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bank transfer: only savings (SD) or current (CA/CB) accounts allowed
|
||||
// Bank transfer: savings (SD) or current (CA/CB) accounts on either side, plus a Fixed Deposit (FD) on
|
||||
// the CR side only -- funding it from the customer's own account. The server checks the funding rules
|
||||
// (first and only funding, exactly the principal, the source account's owner and available balance).
|
||||
const allowedTypes = new Set([
|
||||
'SD',
|
||||
'CA',
|
||||
@@ -5240,13 +5387,13 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
]);
|
||||
const invalidAccounts = [
|
||||
...drRows,
|
||||
...crRows
|
||||
...crRows.filter((r) => r.acTyp !== 'FD')
|
||||
].filter((r) => !allowedTypes.has(r.acTyp));
|
||||
if (invalidAccounts.length > 0) {
|
||||
this.showAlert('error', 'Invalid Account Type', [
|
||||
`Account type(s) not allowed in Bank Transfer: ${invalidAccounts.map((r) => r.acTyp + ' (' + r.acNo + ')').join(', ')}`,
|
||||
'Only Savings (SD) and Current (CA) accounts are permitted.',
|
||||
'GL, FD and SHR accounts are not allowed — use Disbursement/Collection instead.',
|
||||
'Debit side: only Savings (SD) and Current (CA) accounts. Credit side: SD, CA or a Fixed Deposit (FD).',
|
||||
'GL and SHR accounts are not allowed — use Disbursement/Collection instead.',
|
||||
'RD installments are paid through a cashier Receipt or Auto Debit.'
|
||||
]);
|
||||
return;
|
||||
@@ -5847,10 +5994,14 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
return;
|
||||
}
|
||||
|
||||
// GL withdrawal → direct journal entry (no maker-checker)
|
||||
// GL deposit → falls through to maker-checker block below
|
||||
if (row.acTyp === 'GL' && !isDeposit) {
|
||||
this.submitGlJournalEntry(row, amount, isDeposit);
|
||||
// A GL withdrawal slip is raised by the clerk and paid by the cashier against its token, exactly like a
|
||||
// savings withdrawal (the clerk branch and the token branch below). Nothing posts from this screen directly:
|
||||
// manual journal entries are switched off on the server.
|
||||
if (row.acTyp === 'GL' && !isDeposit && !this.clerkMode && !this.activeWithdrawalRequest) {
|
||||
this.showAlert('error', 'GL Withdrawal', [
|
||||
'A GL withdrawal is raised by a clerk and paid by the cashier against its token.',
|
||||
'Enter the token number of the approved request to pay it.'
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6223,17 +6374,34 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
const txnDateIso = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
|
||||
const selectedPt = this.paymentTypes.find((p: any) => p.id === row.paymentTypeId);
|
||||
|
||||
const isGl = row.acTyp === 'GL';
|
||||
// The Entry Type picked for a GL slip has no column of its own on the request, so it rides on the narration.
|
||||
const entryTypeName = isGl ? this.entryTypeOptions.find((e) => e.id === row.entryTypeCvId)?.name : undefined;
|
||||
const description = [
|
||||
row.description,
|
||||
entryTypeName ? `[Entry Type: ${entryTypeName}]` : ''
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
|
||||
return {
|
||||
accountNo: this.accountDetails.accountNo,
|
||||
accountNo: isGl ? (this.accountDetails.glCode ?? this.accountDetails.name) : this.accountDetails.accountNo,
|
||||
accountType: this.creditEntryAccountType(row.acTyp),
|
||||
savingsAccountId: this.accountDetails.id,
|
||||
clientId: this.accountDetails.clientId ?? this.clientDetails?.id ?? null,
|
||||
clientName: this.clientDetails?.displayName ?? this.accountDetails?.clientName ?? null,
|
||||
savingsAccountId: isGl ? null : this.accountDetails.id,
|
||||
// GL-specific fields: the GL being paid out of and the cash GL it is paid from (null for other types)
|
||||
glAccountId: isGl ? this.accountDetails.id : null,
|
||||
contraGlId: isGl ? this.cashVaultGlId : null,
|
||||
officeId: isGl ? row.br || 1 : null,
|
||||
currencyCode: isGl ? (this.accountDetails?.currency?.code ?? 'INR') : null,
|
||||
clientId: isGl ? null : (this.accountDetails.clientId ?? this.clientDetails?.id ?? null),
|
||||
clientName: isGl
|
||||
? (this.accountDetails?.name ?? null)
|
||||
: (this.clientDetails?.displayName ?? this.accountDetails?.clientName ?? null),
|
||||
amount,
|
||||
txnDate: txnDateIso,
|
||||
paymentTypeId: row.paymentTypeId || null,
|
||||
paymentTypeName: selectedPt?.name ?? 'Cash',
|
||||
description: row.description || null,
|
||||
description: description || null,
|
||||
chequeNo: row.chequeNo || null,
|
||||
bankName: row.bankName || null,
|
||||
tokNo: row.tokNo?.trim() || null,
|
||||
@@ -6425,106 +6593,6 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
this.addRow();
|
||||
}
|
||||
|
||||
private submitGlJournalEntry(row: TxnRow, amount: number, isDeposit: boolean): void {
|
||||
if (!this.cashVaultGlId) {
|
||||
this.showAlert('error', 'Cash Vault GL Not Configured', [
|
||||
'Financial Activity Account (CASH_AT_TELLER) is not configured.',
|
||||
'Please configure it in System → Financial Activity Accounts.'
|
||||
]);
|
||||
this.saving = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const today = businessToday();
|
||||
const txnDate = `${String(today.getDate()).padStart(2, '0')}/${String(today.getMonth() + 1).padStart(2, '0')}/${today.getFullYear()}`;
|
||||
const txnDateIso = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
|
||||
|
||||
const selectedGlId = this.accountDetails.id;
|
||||
const contraGlId = this.cashVaultGlId;
|
||||
|
||||
// isDeposit (CR button) = cashier receives cash → credit selected GL, debit contra (cash vault)
|
||||
// isWithdrawal (DR button) = cashier pays out cash → debit selected GL, credit contra (cash vault)
|
||||
const credits = isDeposit ? [{ glAccountId: selectedGlId, amount }] : [{ glAccountId: contraGlId, amount }];
|
||||
const debits = isDeposit ? [{ glAccountId: contraGlId, amount }] : [{ glAccountId: selectedGlId, amount }];
|
||||
|
||||
const payload: any = {
|
||||
officeId: row.br || 1,
|
||||
transactionDate: txnDate,
|
||||
dateFormat: 'dd/MM/yyyy',
|
||||
locale: 'en',
|
||||
currencyCode: this.accountDetails?.currency?.code ?? 'INR',
|
||||
comments: row.description || null,
|
||||
credits,
|
||||
debits,
|
||||
paymentTypeId: row.paymentTypeId
|
||||
};
|
||||
|
||||
// Check if cash payment so we can record denomination after journal entry
|
||||
const selectedPt = this.paymentTypes.find((p: any) => p.id === row.paymentTypeId);
|
||||
const isCashPayment = !!selectedPt?.isCashPayment;
|
||||
|
||||
this.saving = true;
|
||||
this.http
|
||||
.post('/journalentries', payload)
|
||||
.pipe(
|
||||
catchError((err: any) => {
|
||||
const msg =
|
||||
err?.error?.errors?.[0]?.defaultUserMessage ??
|
||||
err?.error?.developerMessage ??
|
||||
'Journal entry failed. Please try again.';
|
||||
this.showAlert('error', 'Transaction Failed', [msg]);
|
||||
this.saving = false;
|
||||
return of(null);
|
||||
})
|
||||
)
|
||||
.subscribe((res: any) => {
|
||||
this.saving = false;
|
||||
if (res) {
|
||||
// Record denomination so cashier position stays accurate
|
||||
// Same condition as savings: cash + denom entered + denom matches posted amount
|
||||
if (isCashPayment && this.denominationTotal > 0 && this.denominationTotal === amount) {
|
||||
const denomBreakdown = [
|
||||
...this.notes,
|
||||
...this.coins
|
||||
]
|
||||
.filter((d) => this.countFor(d) > 0)
|
||||
.map((d) => ({
|
||||
denominationId: d.id,
|
||||
denominationValue: d.value,
|
||||
kind: d.kind,
|
||||
count: this.countFor(d),
|
||||
subtotal: this.subtotalFor(d)
|
||||
}));
|
||||
// Filed against the Cash Vault GL, not the account the teller selected on screen: that
|
||||
// selected account (e.g. Sundry Creditors) is the other leg of the journal entry, and
|
||||
// never the one whose physical notes actually changed hands. Tagging the breakdown to it
|
||||
// instead of the vault is why this cash never reached the cashier/vault position.
|
||||
this.http
|
||||
.post('/cashier/gl-denomination', {
|
||||
txnId: res.transactionId ?? res.resourceId,
|
||||
accountNo: this.cashVaultGlCode ?? row.acNo,
|
||||
accountName: this.cashVaultGlName ?? 'Cash at Vault',
|
||||
txnType: isDeposit ? 'DEPOSIT' : 'WITHDRAWAL',
|
||||
txnDate: txnDateIso,
|
||||
paymentTypeName: selectedPt?.name ?? 'Cash',
|
||||
denominationBreakdown: denomBreakdown
|
||||
})
|
||||
.pipe(catchError(() => of(null)))
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
const ref = res.transactionId ?? res.resourceId ?? 'N/A';
|
||||
this.showAlert('success', 'GL Transaction Posted', [
|
||||
`Journal entry of ₹${amount.toLocaleString('en-IN', { minimumFractionDigits: 2 })} posted successfully.`,
|
||||
`Transaction ID: ${ref}`
|
||||
]);
|
||||
this.clearDenominations();
|
||||
this.loadOpeningPosition();
|
||||
this.loadAccountDetails(row.acNo.trim(), row.acTyp);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSearch(): void {
|
||||
if (this.selectedRow?.acNo.trim()) {
|
||||
this.loadAccountDetails(this.selectedRow.acNo.trim(), this.selectedRow.acTyp);
|
||||
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
<!--
|
||||
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="cv-tab-content vca-tab">
|
||||
<!-- ── TITLE BAR ── -->
|
||||
<div class="vca-action-bar">
|
||||
<div class="vca-action-bar__left">
|
||||
<mat-icon class="vca-action-bar__icon">undo</mat-icon>
|
||||
<div>
|
||||
<div class="vca-action-bar__title">Voucher Corrections</div>
|
||||
<div class="vca-action-bar__sub">
|
||||
Approve or reject a voucher unpass, and the correction entry that follows it. Only the correction approval
|
||||
moves money.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vca-counts">
|
||||
<span class="vca-count"
|
||||
><strong>{{ unpassCount }}</strong> unpass</span
|
||||
>
|
||||
<span class="vca-count"
|
||||
><strong>{{ correctionCount }}</strong> correction</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── FILTER BAR ── -->
|
||||
<div class="vca-filter-bar">
|
||||
<div class="vca-search-box">
|
||||
<mat-icon>search</mat-icon>
|
||||
<input type="text" placeholder="Search by voucher, account, customer or user" [(ngModel)]="searchTerm" />
|
||||
@if (searchTerm) {
|
||||
<button type="button" class="vca-search-box__clear" (click)="searchTerm = ''">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
<span class="vca-fb-sep"></span>
|
||||
|
||||
<select class="vca-filter-select" [(ngModel)]="kindFilter">
|
||||
@for (opt of kindOptions; track opt.value) {
|
||||
<option [value]="opt.value">{{ opt.label }}</option>
|
||||
}
|
||||
</select>
|
||||
|
||||
<button type="button" class="vca-btn vca-btn--refresh" (click)="load()" [disabled]="loading">
|
||||
<mat-icon>refresh</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ── TABLE ── -->
|
||||
@if (loading && !loaded) {
|
||||
<div class="vca-empty"><p class="vca-empty__title">Loading…</p></div>
|
||||
} @else if (rows.length === 0) {
|
||||
<div class="vca-empty">
|
||||
<mat-icon class="vca-empty__icon">inbox</mat-icon>
|
||||
<p class="vca-empty__title">No voucher correction waiting</p>
|
||||
<p class="vca-empty__text">There is no unpass request or correction entry waiting for review.</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="vca-table-wrap">
|
||||
<table class="vca-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Voucher No</th>
|
||||
<th>Request</th>
|
||||
<th>Posted To (Wrong)</th>
|
||||
<th>Correct Account</th>
|
||||
<th class="num">Amount</th>
|
||||
<th>Reason</th>
|
||||
<th>Raised By</th>
|
||||
<th>Raised At</th>
|
||||
<th class="vca-th-action">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (r of rows; track r.request.id) {
|
||||
<tr class="vca-row">
|
||||
<td class="vca-mono vca-voucher">{{ r.request.original_voucher_no }}</td>
|
||||
<td>
|
||||
<span class="vca-kind" [class]="'vca-kind vca-kind--' + r.kind">{{ kindLabel(r.kind) }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="vca-mono">{{ r.request.wrong_account_no }}</div>
|
||||
<div class="vca-sub">{{ r.request.wrong_client_name || '—' }}</div>
|
||||
</td>
|
||||
<td>
|
||||
@if (r.kind === 'correction') {
|
||||
<div class="vca-mono vca-strong">{{ r.request.correct_account_no }}</div>
|
||||
<div class="vca-sub">{{ r.request.correct_client_name || '—' }}</div>
|
||||
} @else {
|
||||
<span class="vca-none">—</span>
|
||||
}
|
||||
</td>
|
||||
<td class="num vca-amount">₹{{ r.request.amount | number: '1.2-2' }}</td>
|
||||
<td class="vca-reason" [title]="r.request.reason || ''">{{ r.request.reason || '—' }}</td>
|
||||
<td>{{ r.raisedBy || '—' }}</td>
|
||||
<td class="vca-dt">{{ formatDateTime(r.raisedAt) }}</td>
|
||||
<td class="vca-action-cell">
|
||||
<button
|
||||
type="button"
|
||||
class="vca-btn vca-btn--reject"
|
||||
[disabled]="busyId === r.request.id"
|
||||
(click)="startReject(r)"
|
||||
>
|
||||
<mat-icon>close</mat-icon> Reject
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="vca-btn vca-btn--approve"
|
||||
[disabled]="busyId === r.request.id"
|
||||
(click)="approve(r)"
|
||||
>
|
||||
<mat-icon>check</mat-icon>
|
||||
{{ r.kind === 'unpass' ? 'Approve unpass' : 'Approve correction' }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- ─── Popup: reject with a reason ───────────────────────────────────────── -->
|
||||
<ng-template #rejectDialog>
|
||||
@if (rejecting) {
|
||||
<div class="vca-dlg">
|
||||
<header class="vca-dlg__head">
|
||||
<mat-icon class="vca-dlg__ico">block</mat-icon>
|
||||
<div class="vca-dlg__titles">
|
||||
<div class="vca-dlg__title">
|
||||
Reject {{ rejecting.kind === 'unpass' ? 'unpass request' : 'correction entry' }}
|
||||
</div>
|
||||
<div class="vca-dlg__sub vca-mono">{{ rejecting.request.original_voucher_no }}</div>
|
||||
</div>
|
||||
<button type="button" class="vca-dlg__x" aria-label="Close" (click)="cancelReject()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</header>
|
||||
<div class="vca-dlg__body">
|
||||
<label class="vca-label" for="vca-reason">Reason (required)</label>
|
||||
<textarea
|
||||
id="vca-reason"
|
||||
rows="3"
|
||||
placeholder="Why is this being rejected?"
|
||||
[(ngModel)]="rejectReason"
|
||||
></textarea>
|
||||
</div>
|
||||
<footer class="vca-dlg__foot">
|
||||
<button type="button" class="vca-btn vca-btn--ghost" (click)="cancelReject()">Cancel</button>
|
||||
<button
|
||||
type="button"
|
||||
class="vca-btn vca-btn--reject-solid"
|
||||
[disabled]="!rejectReason.trim() || busyId === rejecting.request.id"
|
||||
(click)="confirmReject()"
|
||||
>
|
||||
Confirm reject
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
}
|
||||
</ng-template>
|
||||
+485
@@ -0,0 +1,485 @@
|
||||
/**
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
// Laid out like the other approval tabs (Withdrawal Requests): title bar, filter bar, one table.
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.vca-tab {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.vca-action-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 10px 16px;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
|
||||
&__left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
font-size: 22px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
color: #0f4f3c;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #0d1b2a;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
max-width: 640px;
|
||||
margin-top: 1px;
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
.vca-counts {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.vca-count {
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
background: #f1f5f9;
|
||||
font-size: 11px;
|
||||
color: #475569;
|
||||
|
||||
strong {
|
||||
color: #0f4f3c;
|
||||
}
|
||||
}
|
||||
|
||||
.vca-filter-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
padding: 6px 16px;
|
||||
background: #f8fafc;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.vca-fb-sep {
|
||||
flex-shrink: 0;
|
||||
width: 1px;
|
||||
height: 22px;
|
||||
margin: 0 4px;
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
.vca-search-box {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
height: 30px;
|
||||
min-width: 240px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
|
||||
mat-icon {
|
||||
flex-shrink: 0;
|
||||
font-size: 17px;
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: #cbd5e1;
|
||||
}
|
||||
|
||||
&:focus-within {
|
||||
border-color: #0f4f3c;
|
||||
box-shadow: 0 0 0 3px rgb(15 79 60 / 8%);
|
||||
}
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
color: #0d1b2a;
|
||||
|
||||
&::placeholder {
|
||||
color: #94a3b8;
|
||||
}
|
||||
}
|
||||
|
||||
&__clear {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: none;
|
||||
color: #94a3b8;
|
||||
cursor: pointer;
|
||||
|
||||
mat-icon {
|
||||
font-size: 15px;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #dc2626;
|
||||
background: #fef2f2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.vca-filter-select {
|
||||
height: 30px;
|
||||
min-width: 140px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 7px;
|
||||
background: #fff;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
color: #0d1b2a;
|
||||
cursor: pointer;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: #0f4f3c;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Buttons ─────────────────────────────────────────────────────────────────
|
||||
.vca-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 26px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 7px;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&--refresh {
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
margin-left: auto;
|
||||
border-color: #e2e8f0;
|
||||
background: #fff;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
&--approve {
|
||||
background: #0f4f3c;
|
||||
color: #fff;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #0a3d2e;
|
||||
}
|
||||
}
|
||||
|
||||
&--reject {
|
||||
border-color: #fecaca;
|
||||
background: #fff;
|
||||
color: #dc2626;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #fef2f2;
|
||||
}
|
||||
}
|
||||
|
||||
&--reject-solid {
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&--ghost {
|
||||
border-color: #e2e8f0;
|
||||
background: #fff;
|
||||
color: #475569;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Table ───────────────────────────────────────────────────────────────────
|
||||
.vca-table-wrap {
|
||||
overflow-x: auto;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.vca-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 11px;
|
||||
|
||||
th {
|
||||
padding: 7px 10px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
font-size: 9.5px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.06em;
|
||||
text-align: left;
|
||||
text-transform: uppercase;
|
||||
color: #94a3b8;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 5px 10px;
|
||||
border-bottom: 1px solid #eef2f7;
|
||||
vertical-align: middle;
|
||||
color: #0d1b2a;
|
||||
}
|
||||
|
||||
.num {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.vca-th-action {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
.vca-row:hover td {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.vca-mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.vca-voucher {
|
||||
font-weight: 700;
|
||||
color: #0f4f3c;
|
||||
}
|
||||
|
||||
.vca-strong {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.vca-sub {
|
||||
margin-top: 1px;
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.vca-none {
|
||||
color: #cbd5e1;
|
||||
}
|
||||
|
||||
.vca-amount {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.vca-reason {
|
||||
max-width: 220px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.vca-dt {
|
||||
white-space: nowrap;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.vca-kind {
|
||||
display: inline-block;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
|
||||
&--unpass {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
&--correction {
|
||||
background: #dbeafe;
|
||||
color: #1e40af;
|
||||
}
|
||||
}
|
||||
|
||||
.vca-action-cell {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
// ── Empty ───────────────────────────────────────────────────────────────────
|
||||
.vca-empty {
|
||||
padding: 28px 16px;
|
||||
text-align: center;
|
||||
color: #94a3b8;
|
||||
|
||||
&__icon {
|
||||
display: block;
|
||||
margin: 0 auto 6px;
|
||||
font-size: 30px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
&__text {
|
||||
margin: 3px 0 0;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Reject popup ────────────────────────────────────────────────────────────
|
||||
.vca-dlg {
|
||||
font-size: 12px;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
&__ico {
|
||||
flex: 0 0 32px;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
border-radius: 9px;
|
||||
background: #fef2f2;
|
||||
color: #dc2626;
|
||||
font-size: 18px;
|
||||
line-height: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__titles {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
&__x {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 28px;
|
||||
width: 28px;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
font-size: 18px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 12px 14px;
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
padding: 7px 10px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
resize: vertical;
|
||||
|
||||
&:focus {
|
||||
outline: 0;
|
||||
border-color: #0f4f3c;
|
||||
box-shadow: 0 0 0 3px rgb(15 79 60 / 8%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__foot {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 10px 14px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
}
|
||||
|
||||
.vca-label {
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
color: #94a3b8;
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
/**
|
||||
* 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, TemplateRef, ViewChild, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { of } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { VoucherCorrection, VoucherCorrectionService } from '../voucher-correction.service';
|
||||
|
||||
type Kind = 'unpass' | 'correction';
|
||||
type KindFilter = 'ALL' | Kind;
|
||||
|
||||
/** One row of the approvals table: a request, and which of the two steps it is waiting at. */
|
||||
interface ApprovalRow {
|
||||
kind: Kind;
|
||||
request: VoucherCorrection;
|
||||
raisedBy: string | null;
|
||||
raisedAt: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manager side of the voucher correction, laid out like the other approval tabs: approves or rejects the unpass of a
|
||||
* voucher, and later the correction entry the cashier made. Only the second approval moves money.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-voucher-correction-approvals',
|
||||
templateUrl: './voucher-correction-approvals.component.html',
|
||||
styleUrls: ['./voucher-correction-approvals.component.scss'],
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
MatDialogModule,
|
||||
MatIconModule,
|
||||
MatSnackBarModule
|
||||
]
|
||||
})
|
||||
export class VoucherCorrectionApprovalsComponent implements OnInit {
|
||||
private service = inject(VoucherCorrectionService);
|
||||
private snackBar = inject(MatSnackBar);
|
||||
private dialog = inject(MatDialog);
|
||||
|
||||
@ViewChild('rejectDialog') rejectDialog!: TemplateRef<unknown>;
|
||||
private dialogRef: MatDialogRef<unknown> | null = null;
|
||||
|
||||
all: ApprovalRow[] = [];
|
||||
loading = false;
|
||||
loaded = false;
|
||||
busyId: number | null = null;
|
||||
|
||||
kindFilter: KindFilter = 'ALL';
|
||||
searchTerm = '';
|
||||
|
||||
/** The row being rejected, and the reason typed for it. */
|
||||
rejecting: ApprovalRow | null = null;
|
||||
rejectReason = '';
|
||||
|
||||
readonly kindOptions: { value: KindFilter; label: string }[] = [
|
||||
{ value: 'ALL', label: 'All requests' },
|
||||
{ value: 'unpass', label: 'Unpass requests' },
|
||||
{ value: 'correction', label: 'Correction entries' }
|
||||
];
|
||||
|
||||
ngOnInit(): void {
|
||||
this.load();
|
||||
}
|
||||
|
||||
load(): void {
|
||||
this.loading = true;
|
||||
this.service
|
||||
.list('UNPASS_PENDING,CORRECTION_PENDING')
|
||||
.pipe(catchError(() => of([] as VoucherCorrection[])))
|
||||
.subscribe((rows) => {
|
||||
this.all = rows.map((r) =>
|
||||
r.status === 'UNPASS_PENDING'
|
||||
? { kind: 'unpass', request: r, raisedBy: r.unpass_by_name, raisedAt: r.unpass_at }
|
||||
: { kind: 'correction', request: r, raisedBy: r.correction_by_name, raisedAt: r.correction_at }
|
||||
);
|
||||
this.loading = false;
|
||||
this.loaded = true;
|
||||
});
|
||||
}
|
||||
|
||||
/** The table: the kind picked, narrowed by whatever is typed in the search box. */
|
||||
get rows(): ApprovalRow[] {
|
||||
const term = this.searchTerm.trim().toLowerCase();
|
||||
return this.all.filter((r) => {
|
||||
if (this.kindFilter !== 'ALL' && r.kind !== this.kindFilter) return false;
|
||||
if (!term) return true;
|
||||
const q = r.request;
|
||||
return [
|
||||
q.original_voucher_no,
|
||||
q.wrong_account_no,
|
||||
q.wrong_client_name,
|
||||
q.correct_account_no,
|
||||
q.correct_client_name,
|
||||
r.raisedBy
|
||||
].some((v) => (v ?? '').toLowerCase().includes(term));
|
||||
});
|
||||
}
|
||||
|
||||
get unpassCount(): number {
|
||||
return this.all.filter((r) => r.kind === 'unpass').length;
|
||||
}
|
||||
|
||||
get correctionCount(): number {
|
||||
return this.all.filter((r) => r.kind === 'correction').length;
|
||||
}
|
||||
|
||||
kindLabel(kind: Kind): string {
|
||||
return kind === 'unpass' ? 'Unpass' : 'Correction';
|
||||
}
|
||||
|
||||
formatDateTime(value: string | null): string {
|
||||
if (!value) return '—';
|
||||
const d = new Date(value);
|
||||
return isNaN(d.getTime())
|
||||
? value
|
||||
: d.toLocaleString('en-IN', { day: '2-digit', month: 'short', hour: '2-digit', minute: '2-digit' });
|
||||
}
|
||||
|
||||
approve(row: ApprovalRow): void {
|
||||
if (this.busyId) return;
|
||||
const id = row.request.id;
|
||||
this.busyId = id;
|
||||
const call = row.kind === 'unpass' ? this.service.approveUnpass(id) : this.service.approveCorrection(id);
|
||||
call.subscribe({
|
||||
next: (res: any) => {
|
||||
this.busyId = null;
|
||||
this.snackBar.open(
|
||||
row.kind === 'unpass'
|
||||
? `Voucher ${row.request.original_voucher_no} unpassed — the cashier can now enter the correct account`
|
||||
: `Corrected. New voucher ${res?.newVoucherNo ?? ''}`,
|
||||
'Close',
|
||||
{ duration: 6000 }
|
||||
);
|
||||
this.load();
|
||||
},
|
||||
error: (err) => {
|
||||
this.busyId = null;
|
||||
this.fail(err, 'Could not approve');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
startReject(row: ApprovalRow): void {
|
||||
this.rejecting = row;
|
||||
this.rejectReason = '';
|
||||
this.dialogRef = this.dialog.open(this.rejectDialog, { width: '440px', maxWidth: '95vw', autoFocus: false });
|
||||
this.dialogRef.afterClosed().subscribe(() => (this.rejecting = null));
|
||||
}
|
||||
|
||||
cancelReject(): void {
|
||||
this.dialogRef?.close();
|
||||
}
|
||||
|
||||
confirmReject(): void {
|
||||
if (!this.rejecting || !this.rejectReason.trim() || this.busyId) return;
|
||||
const row = this.rejecting;
|
||||
const id = row.request.id;
|
||||
this.busyId = id;
|
||||
const reason = this.rejectReason.trim();
|
||||
const call =
|
||||
row.kind === 'unpass' ? this.service.rejectUnpass(id, reason) : this.service.rejectCorrection(id, reason);
|
||||
call.subscribe({
|
||||
next: () => {
|
||||
this.busyId = null;
|
||||
this.dialogRef?.close();
|
||||
this.snackBar.open('Rejected', 'Close', { duration: 4000 });
|
||||
this.load();
|
||||
},
|
||||
error: (err) => {
|
||||
this.busyId = null;
|
||||
this.fail(err, 'Could not reject');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private fail(err: any, fallback: string): void {
|
||||
const msg = err?.error?.errors?.[0]?.defaultUserMessage ?? err?.error?.defaultUserMessage ?? fallback;
|
||||
this.snackBar.open(msg, 'Close', { duration: 8000 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* 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 { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/** One row of a voucher correction, as the server keeps it (snake_case columns). */
|
||||
export interface VoucherCorrection {
|
||||
id: number;
|
||||
original_voucher_no: string;
|
||||
original_txn_id: number;
|
||||
wrong_savings_account_id: number;
|
||||
wrong_account_no: string;
|
||||
wrong_client_name: string | null;
|
||||
amount: number;
|
||||
txn_date: string | null;
|
||||
status: 'UNPASS_PENDING' | 'UNPASSED' | 'UNPASS_REJECTED' | 'CORRECTION_PENDING' | 'COMPLETED' | 'CLOSED';
|
||||
reason: string | null;
|
||||
rejection_reason: string | null;
|
||||
unpass_by_name: string | null;
|
||||
unpass_at: string | null;
|
||||
unpass_approved_by_name: string | null;
|
||||
correct_account_no: string | null;
|
||||
correct_client_name: string | null;
|
||||
correction_by_name: string | null;
|
||||
correction_at: string | null;
|
||||
correction_approved_by_name: string | null;
|
||||
new_voucher_no: string | null;
|
||||
}
|
||||
|
||||
/** A cash deposit voucher of today that can still be unpassed. */
|
||||
export interface EligibleVoucher {
|
||||
voucherNo: string;
|
||||
amount: number;
|
||||
createdAt: string;
|
||||
cashier: string;
|
||||
txnId: number;
|
||||
savingsAccountId: number;
|
||||
accountNo: string;
|
||||
clientName: string | null;
|
||||
paymentType: string;
|
||||
}
|
||||
|
||||
/** What the server knows about a savings account typed in as the correct one. */
|
||||
export interface AccountLookup {
|
||||
id: number;
|
||||
accountNo: string;
|
||||
clientId: number | null;
|
||||
clientName: string | null;
|
||||
balance: number;
|
||||
currencyCode: string;
|
||||
canReceive: boolean;
|
||||
}
|
||||
|
||||
/** HTTP service for the voucher correction workflow: unpass, approve, re-enter, approve. */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class VoucherCorrectionService {
|
||||
private http = inject(HttpClient);
|
||||
private readonly base = '/vouchers/corrections';
|
||||
|
||||
eligible(search?: string): Observable<EligibleVoucher[]> {
|
||||
let params = new HttpParams();
|
||||
if (search) params = params.set('search', search);
|
||||
return this.http.get<EligibleVoucher[]>(`${this.base}/eligible`, { params });
|
||||
}
|
||||
|
||||
unpass(voucherNo: string, reason: string): Observable<any> {
|
||||
return this.http.post(`${this.base}/unpass`, { voucherNo, reason });
|
||||
}
|
||||
|
||||
list(status?: string, mine = false): Observable<VoucherCorrection[]> {
|
||||
let params = new HttpParams().set('mine', String(mine));
|
||||
if (status) params = params.set('status', status);
|
||||
return this.http.get<VoucherCorrection[]>(this.base, { params });
|
||||
}
|
||||
|
||||
get(id: number): Observable<VoucherCorrection> {
|
||||
return this.http.get<VoucherCorrection>(`${this.base}/${id}`);
|
||||
}
|
||||
|
||||
accountLookup(accountNo: string): Observable<AccountLookup> {
|
||||
return this.http.get<AccountLookup>(`${this.base}/account-lookup`, { params: { accountNo } });
|
||||
}
|
||||
|
||||
submitCorrection(id: number, correctAccountNo: string): Observable<any> {
|
||||
return this.http.post(`${this.base}/${id}/correction`, { correctAccountNo });
|
||||
}
|
||||
|
||||
/** The cashier gives up the correction, e.g. when the wrong account no longer holds the money. */
|
||||
close(id: number, reason: string): Observable<any> {
|
||||
return this.http.post(`${this.base}/${id}/close`, { reason });
|
||||
}
|
||||
|
||||
approveUnpass(id: number): Observable<any> {
|
||||
return this.http.post(`${this.base}/${id}/unpass/approve`, {});
|
||||
}
|
||||
|
||||
rejectUnpass(id: number, reason: string): Observable<any> {
|
||||
return this.http.post(`${this.base}/${id}/unpass/reject`, { reason });
|
||||
}
|
||||
|
||||
approveCorrection(id: number): Observable<any> {
|
||||
return this.http.post(`${this.base}/${id}/correction/approve`, {});
|
||||
}
|
||||
|
||||
rejectCorrection(id: number, reason: string): Observable<any> {
|
||||
return this.http.post(`${this.base}/${id}/correction/reject`, { reason });
|
||||
}
|
||||
|
||||
/** Ids of the transactions of this account that a completed correction removed. */
|
||||
voidedTransactions(savingsAccountId: number): Observable<number[]> {
|
||||
return this.http.get<number[]>(`${this.base}/voided-transactions`, { params: { savingsAccountId } });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,446 @@
|
||||
<!--
|
||||
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">CASHIER · VOUCHER CORRECTION</div>
|
||||
<h1 class="pg-title">Voucher Correction</h1>
|
||||
<p class="pg-sub">
|
||||
Move a cash deposit that was posted to the wrong account. Nothing changes on any account until the final
|
||||
approval.
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- The four steps, so it is always clear where a voucher is. -->
|
||||
<ol class="vc-steps">
|
||||
<li class="vc-step" [class.vc-step--on]="tab === 'today'">
|
||||
<span class="vc-step__no">1</span>
|
||||
<span class="vc-step__txt"><strong>Unpass</strong> the voucher</span>
|
||||
</li>
|
||||
<li class="vc-step">
|
||||
<span class="vc-step__no">2</span>
|
||||
<span class="vc-step__txt"><strong>Manager</strong> approves</span>
|
||||
</li>
|
||||
<li class="vc-step" [class.vc-step--on]="tab === 'unpassed'">
|
||||
<span class="vc-step__no">3</span>
|
||||
<span class="vc-step__txt">Enter the <strong>correct account</strong></span>
|
||||
</li>
|
||||
<li class="vc-step">
|
||||
<span class="vc-step__no">4</span>
|
||||
<span class="vc-step__txt"><strong>Manager</strong> approves, deposit moves</span>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<nav class="vc-tabs">
|
||||
@if (mayUnpass) {
|
||||
<button type="button" class="vc-tab" [class.vc-tab--on]="tab === 'today'" (click)="setTab('today')">
|
||||
<mat-icon>receipt_long</mat-icon> Today's Vouchers
|
||||
</button>
|
||||
}
|
||||
@if (mayCorrect) {
|
||||
<button type="button" class="vc-tab" [class.vc-tab--on]="tab === 'unpassed'" (click)="setTab('unpassed')">
|
||||
<mat-icon>edit_note</mat-icon> Unpassed — Correct Entry
|
||||
@if (unpassed.length) {
|
||||
<span class="vc-count">{{ unpassed.length }}</span>
|
||||
}
|
||||
</button>
|
||||
}
|
||||
<button type="button" class="vc-tab" [class.vc-tab--on]="tab === 'mine'" (click)="setTab('mine')">
|
||||
<mat-icon>history</mat-icon> My Requests
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<!-- ─── Today's vouchers ─────────────────────────────────────────────── -->
|
||||
@if (tab === 'today') {
|
||||
<div class="vc-toolbar">
|
||||
<div class="vc-search">
|
||||
<mat-icon>search</mat-icon>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search by voucher, account or customer name"
|
||||
[(ngModel)]="search"
|
||||
(keyup.enter)="loadVouchers()"
|
||||
/>
|
||||
</div>
|
||||
<button type="button" class="pg-btn pg-btn--primary" (click)="loadVouchers()">
|
||||
<mat-icon>search</mat-icon> Search
|
||||
</button>
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="search = ''; loadVouchers()">
|
||||
<mat-icon>refresh</mat-icon> Refresh
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="pg-card">
|
||||
<table class="pg-table vc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Voucher</th>
|
||||
<th>Account</th>
|
||||
<th>Customer</th>
|
||||
<th>Mode</th>
|
||||
<th>Cashier</th>
|
||||
<th class="num">Amount</th>
|
||||
<th class="vc-col-action"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (v of vouchers; track v.voucherNo) {
|
||||
<tr [class.vc-row--on]="selectedVoucher?.voucherNo === v.voucherNo" (click)="pick(v)">
|
||||
<td>
|
||||
<span class="pg-chip">{{ v.voucherNo }}</span>
|
||||
</td>
|
||||
<td class="vc-mono">{{ v.accountNo }}</td>
|
||||
<td>{{ v.clientName || '—' }}</td>
|
||||
<td>{{ v.paymentType }}</td>
|
||||
<td>{{ v.cashier }}</td>
|
||||
<td class="num">₹{{ v.amount | number: '1.2-2' }}</td>
|
||||
<td class="vc-col-action">
|
||||
<button
|
||||
type="button"
|
||||
class="pg-btn pg-btn--ghost vc-btn-sm"
|
||||
(click)="pick(v); $event.stopPropagation()"
|
||||
>
|
||||
<mat-icon>undo</mat-icon> Unpass
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!vouchers.length) {
|
||||
<tr>
|
||||
<td colspan="7" class="vc-empty">
|
||||
<mat-icon>{{ loadingVouchers ? 'hourglass_empty' : 'inbox' }}</mat-icon>
|
||||
<div>{{ loadingVouchers ? 'Loading…' : 'No cash deposit voucher of today can be unpassed.' }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- ─── Unpassed: enter the correct account ──────────────────────────── -->
|
||||
@if (tab === 'unpassed') {
|
||||
<div class="pg-card">
|
||||
<table class="pg-table vc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Voucher</th>
|
||||
<th>Posted to</th>
|
||||
<th>Customer</th>
|
||||
<th>Reason</th>
|
||||
<th class="num">Amount</th>
|
||||
<th class="vc-col-action"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (u of unpassed; track u.id) {
|
||||
<tr [class.vc-row--on]="active?.id === u.id" (click)="open(u)">
|
||||
<td>
|
||||
<span class="pg-chip">{{ u.original_voucher_no }}</span>
|
||||
</td>
|
||||
<td class="vc-mono">{{ u.wrong_account_no }}</td>
|
||||
<td>{{ u.wrong_client_name || '—' }}</td>
|
||||
<td class="vc-clip">{{ u.reason }}</td>
|
||||
<td class="num">₹{{ u.amount | number: '1.2-2' }}</td>
|
||||
<td class="vc-col-action">
|
||||
<button
|
||||
type="button"
|
||||
class="pg-btn pg-btn--primary vc-btn-sm"
|
||||
(click)="open(u); $event.stopPropagation()"
|
||||
>
|
||||
<mat-icon>edit</mat-icon> Correct
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!unpassed.length) {
|
||||
<tr>
|
||||
<td colspan="6" class="vc-empty">
|
||||
<mat-icon>{{ loadingUnpassed ? 'hourglass_empty' : 'task_alt' }}</mat-icon>
|
||||
<div>
|
||||
{{ loadingUnpassed ? 'Loading…' : 'No unpassed voucher is waiting for its correct account.' }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- ─── My requests ──────────────────────────────────────────────────── -->
|
||||
@if (tab === 'mine') {
|
||||
<div class="pg-card">
|
||||
<table class="pg-table vc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Voucher</th>
|
||||
<th>Posted to</th>
|
||||
<th>Corrected to</th>
|
||||
<th class="num">Amount</th>
|
||||
<th>Status</th>
|
||||
<th>New voucher</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (m of mine; track m.id) {
|
||||
<tr>
|
||||
<td>
|
||||
<span class="pg-chip">{{ m.original_voucher_no }}</span>
|
||||
</td>
|
||||
<td class="vc-mono">{{ m.wrong_account_no }}</td>
|
||||
<td class="vc-mono">{{ m.correct_account_no || '—' }}</td>
|
||||
<td class="num">₹{{ m.amount | number: '1.2-2' }}</td>
|
||||
<td>
|
||||
<span class="vc-status vc-status--{{ m.status }}">{{ statusLabel[m.status] }}</span>
|
||||
@if (m.rejection_reason) {
|
||||
<div class="vc-note">{{ m.rejection_reason }}</div>
|
||||
}
|
||||
</td>
|
||||
<td>{{ m.new_voucher_no || '—' }}</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!mine.length) {
|
||||
<tr>
|
||||
<td colspan="6" class="vc-empty">
|
||||
<mat-icon>{{ loadingMine ? 'hourglass_empty' : 'history' }}</mat-icon>
|
||||
<div>{{ loadingMine ? 'Loading…' : 'You have no voucher corrections yet.' }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- ─── Popup: unpass a voucher ──────────────────────────────────────────── -->
|
||||
<ng-template #unpassDialog>
|
||||
@if (selectedVoucher) {
|
||||
<div class="vc-dlg">
|
||||
<header class="vc-dlg__head">
|
||||
<mat-icon class="vc-dlg__ico">undo</mat-icon>
|
||||
<div class="vc-dlg__titles">
|
||||
<div class="vc-dlg__title">Unpass voucher</div>
|
||||
<div class="vc-dlg__sub vc-mono">{{ selectedVoucher.voucherNo }}</div>
|
||||
</div>
|
||||
<button type="button" class="vc-dlg__x" aria-label="Close" (click)="closeUnpass()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="vc-dlg__body">
|
||||
<div class="vc-dlg__amount">
|
||||
<span>Deposit amount</span>
|
||||
<strong>₹{{ selectedVoucher.amount | number: '1.2-2' }}</strong>
|
||||
</div>
|
||||
|
||||
<div class="vc-grid">
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Voucher</div>
|
||||
<div class="vc-value vc-mono">{{ selectedVoucher.voucherNo }}</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Created</div>
|
||||
<div class="vc-value">{{ selectedVoucher.createdAt | date: 'dd MMM yyyy, hh:mm a' }}</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Cashier</div>
|
||||
<div class="vc-value">{{ selectedVoucher.cashier }}</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Mode</div>
|
||||
<div class="vc-value">{{ selectedVoucher.paymentType }}</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Account</div>
|
||||
<div class="vc-value vc-mono">{{ selectedVoucher.accountNo }}</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Customer</div>
|
||||
<div class="vc-value">{{ selectedVoucher.clientName || '—' }}</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Account balance now</div>
|
||||
<div class="vc-value">
|
||||
@if (voucherAccount) {
|
||||
₹{{ voucherAccount.balance | number: '1.2-2' }}
|
||||
} @else {
|
||||
—
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Account status</div>
|
||||
<div class="vc-value">
|
||||
@if (voucherAccount) {
|
||||
{{ voucherAccount.canReceive ? 'Active' : 'Not active' }} · {{ voucherAccount.currencyCode }}
|
||||
} @else {
|
||||
—
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="vc-label" for="vc-reason">Reason for unpassing</label>
|
||||
<textarea
|
||||
id="vc-reason"
|
||||
class="vc-reason"
|
||||
rows="2"
|
||||
placeholder="Why is this voucher wrong? e.g. deposited in the wrong account (required)"
|
||||
[(ngModel)]="unpassReason"
|
||||
></textarea>
|
||||
|
||||
<div class="vc-info">
|
||||
<mat-icon>info</mat-icon>
|
||||
A manager approves the unpass first. Nothing changes on any account until the corrected entry is approved: the
|
||||
deposit stays on {{ selectedVoucher.accountNo }} till then.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="vc-dlg__foot">
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="closeUnpass()">Cancel</button>
|
||||
<button type="button" class="pg-btn pg-btn--primary" [disabled]="!canUnpass" (click)="unpass()">
|
||||
<mat-icon>send</mat-icon> Send for approval
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<!-- ─── Popup: enter the correct account ─────────────────────────────────── -->
|
||||
<ng-template #correctionDialog>
|
||||
@if (active) {
|
||||
<div class="vc-dlg">
|
||||
<header class="vc-dlg__head">
|
||||
<mat-icon class="vc-dlg__ico">edit_note</mat-icon>
|
||||
<div class="vc-dlg__titles">
|
||||
<div class="vc-dlg__title">Correction entry</div>
|
||||
<div class="vc-dlg__sub vc-mono">{{ active.original_voucher_no }}</div>
|
||||
</div>
|
||||
<button type="button" class="vc-dlg__x" aria-label="Close" (click)="closeActive()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="vc-dlg__body">
|
||||
<div class="vc-dlg__amount">
|
||||
<span>Amount to move</span>
|
||||
<strong>₹{{ active.amount | number: '1.2-2' }}</strong>
|
||||
</div>
|
||||
|
||||
<!-- Everything but the account number is fixed. -->
|
||||
<div class="vc-grid">
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Transaction date</div>
|
||||
<div class="vc-value">{{ active.txn_date || '—' }}</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Mode</div>
|
||||
<div class="vc-value">Cash</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Unpassed by</div>
|
||||
<div class="vc-value">{{ active.unpass_by_name || '—' }}</div>
|
||||
</div>
|
||||
<div class="vc-cell">
|
||||
<div class="vc-label">Approved by</div>
|
||||
<div class="vc-value">{{ active.unpass_approved_by_name || '—' }}</div>
|
||||
</div>
|
||||
<div class="vc-cell vc-cell--wide">
|
||||
<div class="vc-label">Reason</div>
|
||||
<div class="vc-value">{{ active.reason }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vc-compare">
|
||||
<!-- The account the deposit went to -->
|
||||
<div class="vc-acct vc-acct--wrong">
|
||||
<div class="vc-acct__tag">Posted to (wrong)</div>
|
||||
<div class="vc-acct__no vc-mono">{{ active.wrong_account_no }}</div>
|
||||
<div class="vc-acct__name">{{ active.wrong_client_name || '—' }}</div>
|
||||
<div class="vc-acct__bal">
|
||||
Balance:
|
||||
@if (wrongAccount) {
|
||||
<strong>₹{{ wrongAccount.balance | number: '1.2-2' }}</strong>
|
||||
@if (wrongHasBalance) {
|
||||
<span class="vc-ok"><mat-icon>check_circle</mat-icon> covers the deposit</span>
|
||||
} @else {
|
||||
<span class="vc-bad"
|
||||
><mat-icon>cancel</mat-icon> does not cover ₹{{ active.amount | number: '1.2-2' }}</span
|
||||
>
|
||||
}
|
||||
} @else {
|
||||
—
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<mat-icon class="vc-arrow">arrow_forward</mat-icon>
|
||||
|
||||
<!-- The account it should have gone to -->
|
||||
<div class="vc-acct" [class.vc-acct--ok]="correctOk" [class.vc-acct--wrong]="!!lookupError">
|
||||
<div class="vc-acct__tag">Correct account</div>
|
||||
<input
|
||||
id="vc-correct"
|
||||
class="vc-acct__input vc-mono"
|
||||
type="text"
|
||||
placeholder="Type the account number"
|
||||
[ngModel]="correctAccountNo"
|
||||
(ngModelChange)="onAccountInput($event)"
|
||||
(blur)="lookup()"
|
||||
/>
|
||||
@if (lookingUp) {
|
||||
<div class="vc-acct__bal">Looking up…</div>
|
||||
}
|
||||
@if (correctAccount) {
|
||||
<div class="vc-acct__name">{{ correctAccount.clientName || '—' }}</div>
|
||||
<div class="vc-acct__bal">
|
||||
Balance: <strong>₹{{ correctAccount.balance | number: '1.2-2' }}</strong>
|
||||
@if (correctOk) {
|
||||
<span class="vc-ok"><mat-icon>check_circle</mat-icon> active, can receive</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@if (lookupError) {
|
||||
<div class="vc-bad vc-acct__err"><mat-icon>error</mat-icon> {{ lookupError }}</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (wrongAccount && !wrongHasBalance) {
|
||||
<div class="vc-warn">
|
||||
<mat-icon>warning</mat-icon>
|
||||
<div>
|
||||
<strong>The customer has already used this money,</strong> so it cannot be taken back from
|
||||
{{ active.wrong_account_no }}. Deposit ₹{{ active.amount | number: '1.2-2' }} into the correct account
|
||||
from your own pocket as a fresh deposit (Transaction Entry), then press <strong>Close request</strong>.
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<footer class="vc-dlg__foot">
|
||||
<button
|
||||
type="button"
|
||||
class="pg-btn pg-btn--ghost vc-dlg__close-req"
|
||||
[disabled]="sending"
|
||||
(click)="closeRequest()"
|
||||
>
|
||||
<mat-icon>block</mat-icon> Close request
|
||||
</button>
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="closeActive()">Cancel</button>
|
||||
<button type="button" class="pg-btn pg-btn--primary" [disabled]="!canSave" (click)="save()">
|
||||
<mat-icon>check</mat-icon> Save & send for approval
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
}
|
||||
</ng-template>
|
||||
@@ -0,0 +1,599 @@
|
||||
/**
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
// Compact sizing: the page has to fit a 100% browser window without scrolling for the common case.
|
||||
.pg {
|
||||
padding: 14px 20px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.pg-title {
|
||||
font-size: 20px;
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
.pg-sub {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.pg-btn {
|
||||
height: 30px;
|
||||
padding: 0 12px;
|
||||
font-size: 12px;
|
||||
|
||||
mat-icon {
|
||||
font-size: 16px;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.pg-table {
|
||||
font-size: 12px;
|
||||
|
||||
th {
|
||||
padding: 8px 12px;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 7px 12px;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Steps ───────────────────────────────────────────────────────────────────
|
||||
.vc-steps {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.vc-step {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
|
||||
&__no {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 0 0 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: #e2e8f0;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
&--on {
|
||||
border-color: #1f7a4d;
|
||||
background: #f0fdf4;
|
||||
color: #0f4f3c;
|
||||
|
||||
.vc-step__no {
|
||||
background: #1f7a4d;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Tabs ────────────────────────────────────────────────────────────────────
|
||||
.vc-tabs {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.vc-tab {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 7px 12px;
|
||||
margin-bottom: -1px;
|
||||
border: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
background: transparent;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
|
||||
mat-icon {
|
||||
font-size: 16px;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #0f4f3c;
|
||||
}
|
||||
|
||||
&--on {
|
||||
color: #0f4f3c;
|
||||
border-bottom-color: #1f7a4d;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-count {
|
||||
padding: 0 7px;
|
||||
border-radius: 999px;
|
||||
background: #f59e0b;
|
||||
color: #fff;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
// ── Search ──────────────────────────────────────────────────────────────────
|
||||
.vc-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.vc-search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex: 1 1 280px;
|
||||
max-width: 420px;
|
||||
height: 30px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 999px;
|
||||
background: #fff;
|
||||
|
||||
&:focus-within {
|
||||
border-color: #1f7a4d;
|
||||
box-shadow: 0 0 0 3px rgb(31 122 77 / 12%);
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
font-size: 16px;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
background: transparent;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Table ───────────────────────────────────────────────────────────────────
|
||||
.vc-table {
|
||||
tbody tr {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
tr.vc-row--on td {
|
||||
background: #f0fdf4;
|
||||
|
||||
&:first-child {
|
||||
box-shadow: inset 3px 0 0 #1f7a4d;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-col-action {
|
||||
width: 1%;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.vc-clip {
|
||||
max-width: 240px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pg-chip {
|
||||
font-size: 11px;
|
||||
padding: 2px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-btn-sm {
|
||||
height: 26px;
|
||||
padding: 0 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.vc-mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.vc-empty {
|
||||
padding: 24px 12px;
|
||||
text-align: center;
|
||||
color: #94a3b8;
|
||||
font-size: 12px;
|
||||
|
||||
mat-icon {
|
||||
display: block;
|
||||
margin: 0 auto 4px;
|
||||
font-size: 28px;
|
||||
height: 28px;
|
||||
width: 28px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Popups ──────────────────────────────────────────────────────────────────
|
||||
.vc-dlg {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 86vh;
|
||||
font-size: 12px;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
&__ico {
|
||||
flex: 0 0 32px;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
border-radius: 9px;
|
||||
background: #f0fdf4;
|
||||
color: #1f7a4d;
|
||||
font-size: 18px;
|
||||
line-height: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__titles {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
&__x {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 28px;
|
||||
width: 28px;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
|
||||
mat-icon {
|
||||
font-size: 18px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #e2e8f0;
|
||||
}
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 12px 14px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
&__amount {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 10px;
|
||||
background: #ecfdf5;
|
||||
border: 1px solid #a7f3d0;
|
||||
color: #065f46;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
|
||||
strong {
|
||||
font-size: 18px;
|
||||
font-weight: 800;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
}
|
||||
|
||||
&__foot {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 10px 14px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-warn {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
background: #fffbeb;
|
||||
border: 1px solid #fde68a;
|
||||
color: #92400e;
|
||||
font-size: 11px;
|
||||
|
||||
mat-icon {
|
||||
flex: 0 0 18px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-dlg__close-req {
|
||||
margin-right: auto;
|
||||
color: #b45309;
|
||||
}
|
||||
|
||||
.vc-label {
|
||||
display: block;
|
||||
margin-bottom: 3px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.vc-reason {
|
||||
width: 100%;
|
||||
padding: 7px 10px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
resize: vertical;
|
||||
|
||||
&:focus {
|
||||
outline: 0;
|
||||
border-color: #1f7a4d;
|
||||
box-shadow: 0 0 0 3px rgb(31 122 77 / 12%);
|
||||
}
|
||||
}
|
||||
|
||||
.vc-info {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
margin-top: 8px;
|
||||
padding: 7px 10px;
|
||||
border-radius: 8px;
|
||||
background: #eff6ff;
|
||||
color: #1e40af;
|
||||
font-size: 11px;
|
||||
|
||||
mat-icon {
|
||||
flex: 0 0 16px;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
|
||||
gap: 6px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.vc-cell {
|
||||
padding: 6px 10px;
|
||||
border-radius: 8px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #eef2f7;
|
||||
}
|
||||
|
||||
.vc-cell--wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.vc-value {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
// ── Wrong → Correct ─────────────────────────────────────────────────────────
|
||||
.vc-compare {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: stretch;
|
||||
gap: 8px;
|
||||
|
||||
@media (width <= 640px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-arrow {
|
||||
align-self: center;
|
||||
color: #94a3b8;
|
||||
|
||||
@media (width <= 640px) {
|
||||
transform: rotate(90deg);
|
||||
justify-self: center;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-acct {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
|
||||
&--wrong {
|
||||
border-color: #fecaca;
|
||||
background: #fef2f2;
|
||||
}
|
||||
|
||||
&--ok {
|
||||
border-color: #a7f3d0;
|
||||
background: #ecfdf5;
|
||||
}
|
||||
|
||||
&__tag {
|
||||
margin-bottom: 4px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
&__no {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
&__input {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
|
||||
&:focus {
|
||||
outline: 0;
|
||||
border-color: #1f7a4d;
|
||||
box-shadow: 0 0 0 3px rgb(31 122 77 / 12%);
|
||||
}
|
||||
}
|
||||
|
||||
&__name {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
&__bal {
|
||||
margin-top: 3px;
|
||||
font-size: 11px;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
&__err {
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-ok,
|
||||
.vc-bad {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
margin-left: 6px;
|
||||
font-weight: 700;
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.vc-ok {
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
.vc-bad {
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
.vc-note {
|
||||
margin-top: 3px;
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
// ── Status ──────────────────────────────────────────────────────────────────
|
||||
.vc-status {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: #e2e8f0;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
|
||||
&--UNPASS_PENDING,
|
||||
&--CORRECTION_PENDING {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
&--UNPASSED {
|
||||
background: #dbeafe;
|
||||
color: #1e40af;
|
||||
}
|
||||
|
||||
&--COMPLETED {
|
||||
background: #d1fae5;
|
||||
color: #065f46;
|
||||
}
|
||||
|
||||
&--CLOSED {
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
&--UNPASS_REJECTED {
|
||||
background: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
/**
|
||||
* 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, TemplateRef, ViewChild, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { of } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { AuthenticationService } from '../../core/authentication/authentication.service';
|
||||
import {
|
||||
AccountLookup,
|
||||
EligibleVoucher,
|
||||
VoucherCorrection,
|
||||
VoucherCorrectionService
|
||||
} from '../voucher-correction.service';
|
||||
|
||||
type Tab = 'today' | 'unpassed' | 'mine';
|
||||
|
||||
/**
|
||||
* Cashier side of correcting a cash deposit that went to the wrong account.
|
||||
*
|
||||
* Today vouchers: pick the voucher and unpass it (needs a manager approval; nothing moves).
|
||||
* Unpassed: open the approved voucher, whose details are fixed, change only the account number and save
|
||||
* (needs a manager approval again; only then do the accounts change).
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-voucher-correction',
|
||||
templateUrl: './voucher-correction.component.html',
|
||||
styleUrls: [
|
||||
'../cashier-shared.scss',
|
||||
'./voucher-correction.component.scss'
|
||||
],
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
MatIconModule,
|
||||
MatDialogModule,
|
||||
MatSnackBarModule
|
||||
]
|
||||
})
|
||||
export class VoucherCorrectionComponent implements OnInit {
|
||||
private service = inject(VoucherCorrectionService);
|
||||
private snackBar = inject(MatSnackBar);
|
||||
private dialog = inject(MatDialog);
|
||||
private auth = inject(AuthenticationService);
|
||||
|
||||
/** Unpassing is for the back office (an administrator or a clerk); re-entering the account is the cashier only. */
|
||||
readonly mayUnpass = this.auth.isClerkUser() || !!this.auth.getCredentials()?.permissions?.includes('ALL_FUNCTIONS');
|
||||
readonly mayCorrect = this.auth.isCashierUser();
|
||||
|
||||
@ViewChild('unpassDialog') unpassDialog!: TemplateRef<unknown>;
|
||||
@ViewChild('correctionDialog') correctionDialog!: TemplateRef<unknown>;
|
||||
private dialogRef: MatDialogRef<unknown> | null = null;
|
||||
|
||||
tab: Tab = this.mayUnpass ? 'today' : this.mayCorrect ? 'unpassed' : 'mine';
|
||||
|
||||
// Today vouchers
|
||||
search = '';
|
||||
vouchers: EligibleVoucher[] = [];
|
||||
loadingVouchers = false;
|
||||
selectedVoucher: EligibleVoucher | null = null;
|
||||
/** The account the voucher was posted to, for the balance and status shown in the popup. */
|
||||
voucherAccount: AccountLookup | null = null;
|
||||
unpassReason = '';
|
||||
sending = false;
|
||||
|
||||
// Unpassed vouchers waiting for the correct account
|
||||
unpassed: VoucherCorrection[] = [];
|
||||
loadingUnpassed = false;
|
||||
active: VoucherCorrection | null = null;
|
||||
wrongAccount: AccountLookup | null = null;
|
||||
correctAccountNo = '';
|
||||
correctAccount: AccountLookup | null = null;
|
||||
lookupError = '';
|
||||
lookingUp = false;
|
||||
|
||||
// The cashier own requests
|
||||
mine: VoucherCorrection[] = [];
|
||||
loadingMine = false;
|
||||
|
||||
readonly statusLabel: Record<string, string> = {
|
||||
UNPASS_PENDING: 'Unpass awaiting approval',
|
||||
UNPASSED: 'Unpassed — enter correct account',
|
||||
UNPASS_REJECTED: 'Unpass rejected',
|
||||
CORRECTION_PENDING: 'Correction awaiting approval',
|
||||
COMPLETED: 'Corrected',
|
||||
CLOSED: 'Closed — cashier deposits separately'
|
||||
};
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.mayUnpass) this.loadVouchers();
|
||||
if (this.mayCorrect) this.loadUnpassed();
|
||||
if (this.tab === 'mine') this.loadMine();
|
||||
}
|
||||
|
||||
setTab(tab: Tab): void {
|
||||
this.tab = tab;
|
||||
if (tab === 'today') this.loadVouchers();
|
||||
if (tab === 'unpassed') this.loadUnpassed();
|
||||
if (tab === 'mine') this.loadMine();
|
||||
}
|
||||
|
||||
// ── Today vouchers ─────────────────────────────────────────────────────────
|
||||
|
||||
loadVouchers(): void {
|
||||
this.loadingVouchers = true;
|
||||
this.service
|
||||
.eligible(this.search.trim())
|
||||
.pipe(catchError(() => of([] as EligibleVoucher[])))
|
||||
.subscribe((rows) => {
|
||||
this.vouchers = rows;
|
||||
this.loadingVouchers = false;
|
||||
if (this.selectedVoucher && !rows.some((r) => r.voucherNo === this.selectedVoucher?.voucherNo)) {
|
||||
this.selectedVoucher = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pick(v: EligibleVoucher): void {
|
||||
this.selectedVoucher = v;
|
||||
this.unpassReason = '';
|
||||
this.voucherAccount = null;
|
||||
this.service
|
||||
.accountLookup(v.accountNo)
|
||||
.pipe(catchError(() => of(null)))
|
||||
.subscribe((a) => (this.voucherAccount = a));
|
||||
this.showDialog(this.unpassDialog, () => (this.selectedVoucher = null));
|
||||
}
|
||||
|
||||
closeUnpass(): void {
|
||||
this.dialogRef?.close();
|
||||
}
|
||||
|
||||
get canUnpass(): boolean {
|
||||
return !!this.selectedVoucher && this.unpassReason.trim().length > 0 && !this.sending;
|
||||
}
|
||||
|
||||
unpass(): void {
|
||||
if (!this.selectedVoucher || !this.canUnpass) return;
|
||||
this.sending = true;
|
||||
this.service.unpass(this.selectedVoucher.voucherNo, this.unpassReason.trim()).subscribe({
|
||||
next: () => {
|
||||
this.sending = false;
|
||||
this.snackBar.open(`Voucher ${this.selectedVoucher?.voucherNo} sent for unpass approval`, 'Close', {
|
||||
duration: 4000
|
||||
});
|
||||
this.dialogRef?.close();
|
||||
this.unpassReason = '';
|
||||
this.loadVouchers();
|
||||
},
|
||||
error: (err) => {
|
||||
this.sending = false;
|
||||
this.fail(err, 'Could not unpass the voucher');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ── Unpassed vouchers: enter the correct account ───────────────────────────
|
||||
|
||||
loadUnpassed(): void {
|
||||
this.loadingUnpassed = true;
|
||||
this.service
|
||||
.list('UNPASSED')
|
||||
.pipe(catchError(() => of([] as VoucherCorrection[])))
|
||||
.subscribe((rows) => {
|
||||
this.unpassed = rows;
|
||||
this.loadingUnpassed = false;
|
||||
});
|
||||
}
|
||||
|
||||
open(row: VoucherCorrection): void {
|
||||
this.active = row;
|
||||
this.correctAccountNo = '';
|
||||
this.correctAccount = null;
|
||||
this.lookupError = '';
|
||||
this.wrongAccount = null;
|
||||
// The account the deposit went to: its balance is what the "can this be taken back" check reads.
|
||||
this.service
|
||||
.accountLookup(row.wrong_account_no)
|
||||
.pipe(catchError(() => of(null)))
|
||||
.subscribe((a) => (this.wrongAccount = a));
|
||||
this.showDialog(this.correctionDialog, () => (this.active = null));
|
||||
}
|
||||
|
||||
closeActive(): void {
|
||||
this.dialogRef?.close();
|
||||
}
|
||||
|
||||
onAccountInput(value: string): void {
|
||||
this.correctAccountNo = value;
|
||||
this.correctAccount = null;
|
||||
this.lookupError = '';
|
||||
// Same rule as the Transaction Entry screen: searches on its own once six characters are typed.
|
||||
if (value.trim().length >= 6) this.lookup();
|
||||
}
|
||||
|
||||
lookup(): void {
|
||||
const accountNo = this.correctAccountNo.trim();
|
||||
if (!accountNo || this.lookingUp) return;
|
||||
this.lookingUp = true;
|
||||
this.service.accountLookup(accountNo).subscribe({
|
||||
next: (a) => {
|
||||
this.lookingUp = false;
|
||||
// A late answer for a number no longer typed is dropped.
|
||||
if (accountNo !== this.correctAccountNo.trim()) return;
|
||||
this.correctAccount = a;
|
||||
if (this.active && a.id === this.active.wrong_savings_account_id) {
|
||||
this.lookupError = 'This is the account the deposit was already posted to.';
|
||||
} else if (!a.canReceive) {
|
||||
this.lookupError = 'This account is not active, so it cannot receive the deposit.';
|
||||
}
|
||||
},
|
||||
error: (err) => {
|
||||
this.lookingUp = false;
|
||||
this.lookupError = err?.error?.errors?.[0]?.defaultUserMessage ?? 'Account not found.';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** The wrong account still holds the deposit, so it can be taken back without overdrawing it. */
|
||||
get wrongHasBalance(): boolean {
|
||||
return !!this.wrongAccount && !!this.active && this.wrongAccount.balance >= this.active.amount;
|
||||
}
|
||||
|
||||
get correctOk(): boolean {
|
||||
return !!this.correctAccount && this.correctAccount.canReceive && !this.lookupError;
|
||||
}
|
||||
|
||||
get canSave(): boolean {
|
||||
return !!this.active && this.correctOk && this.wrongHasBalance && !this.sending;
|
||||
}
|
||||
|
||||
save(): void {
|
||||
if (!this.active || !this.canSave) return;
|
||||
this.sending = true;
|
||||
this.service.submitCorrection(this.active.id, this.correctAccountNo.trim()).subscribe({
|
||||
next: () => {
|
||||
this.sending = false;
|
||||
this.snackBar.open('Correction sent for approval', 'Close', { duration: 4000 });
|
||||
this.dialogRef?.close();
|
||||
this.loadUnpassed();
|
||||
},
|
||||
error: (err) => {
|
||||
this.sending = false;
|
||||
this.fail(err, 'Could not save the correction');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives up this correction. The usual reason is that the wrong account no longer holds the money, so the cashier
|
||||
* puts the amount into the right account from their own pocket as a fresh deposit instead.
|
||||
*/
|
||||
closeRequest(): void {
|
||||
if (!this.active || this.sending) return;
|
||||
const reason = this.wrongHasBalance
|
||||
? 'Closed by the cashier'
|
||||
: 'Wrong account no longer holds the amount; cashier deposits it into the correct account separately';
|
||||
this.sending = true;
|
||||
this.service.close(this.active.id, reason).subscribe({
|
||||
next: () => {
|
||||
this.sending = false;
|
||||
this.snackBar.open('Request closed', 'Close', { duration: 4000 });
|
||||
this.dialogRef?.close();
|
||||
this.loadUnpassed();
|
||||
},
|
||||
error: (err) => {
|
||||
this.sending = false;
|
||||
this.fail(err, 'Could not close the request');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ── My requests ────────────────────────────────────────────────────────────
|
||||
|
||||
loadMine(): void {
|
||||
this.loadingMine = true;
|
||||
this.service
|
||||
.list(undefined, true)
|
||||
.pipe(catchError(() => of([] as VoucherCorrection[])))
|
||||
.subscribe((rows) => {
|
||||
this.mine = rows;
|
||||
this.loadingMine = false;
|
||||
});
|
||||
}
|
||||
|
||||
/** Opens one of the two popups; onClose runs however it is dismissed (button, backdrop or Esc). */
|
||||
private showDialog(template: TemplateRef<unknown>, onClose: () => void): void {
|
||||
this.dialogRef?.close();
|
||||
this.dialogRef = this.dialog.open(template, { width: '600px', maxWidth: '95vw', autoFocus: false });
|
||||
this.dialogRef.afterClosed().subscribe(onClose);
|
||||
}
|
||||
|
||||
private fail(err: any, fallback: string): void {
|
||||
const msg = err?.error?.errors?.[0]?.defaultUserMessage ?? err?.error?.defaultUserMessage ?? fallback;
|
||||
this.snackBar.open(msg, 'Close', { duration: 6000 });
|
||||
}
|
||||
}
|
||||
@@ -169,6 +169,7 @@
|
||||
<th>Debit</th>
|
||||
<th>Credit</th>
|
||||
<th class="num">Amount</th>
|
||||
<th>Correction</th>
|
||||
<th>User</th>
|
||||
<!-- Two dates, not one, on the system register.
|
||||
A voucher's timestamp is the minute it was written; the posting behind it carries
|
||||
@@ -217,6 +218,18 @@
|
||||
</td>
|
||||
}
|
||||
<td class="num">{{ row.amount | number: '1.2-2' }}</td>
|
||||
<!-- Where the voucher stands after a correction: unpassed, revoked, closed or corrected. -->
|
||||
<td>
|
||||
<mifosx-voucher-status
|
||||
[status]="row.voucherStatus"
|
||||
[revokedBy]="row.revokedByVoucherNo"
|
||||
[replaces]="row.replacesVoucherNo"
|
||||
[note]="row.correctionNote"
|
||||
></mifosx-voucher-status>
|
||||
@if (!row.voucherStatus || row.voucherStatus === 'ACTIVE') {
|
||||
<span class="vr-active">—</span>
|
||||
}
|
||||
</td>
|
||||
<td>{{ row.username || '—' }}</td>
|
||||
@if (systemOnly) {
|
||||
<td class="vr-ledgerdate" [class.vr-ledgerdate--prior]="row.postedAfterClose">
|
||||
|
||||
@@ -92,3 +92,8 @@
|
||||
text-transform: uppercase;
|
||||
color: #7c3aed;
|
||||
}
|
||||
|
||||
.vr-active {
|
||||
font-size: 11px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
import { catchError, of } from 'rxjs';
|
||||
import { CashierService } from '../cashier.service';
|
||||
import { businessToday } from 'app/core/utils/business-today';
|
||||
import { VoucherStatusComponent, VoucherStatus } from '../voucher-status/voucher-status.component';
|
||||
|
||||
/**
|
||||
* Which side of the register a screen shows.
|
||||
@@ -26,6 +27,11 @@ export type VoucherSide = 'CR' | 'DR' | 'ALL';
|
||||
/** One voucher as the register shows it: the number, the two sides, and who raised it. */
|
||||
interface VoucherRow {
|
||||
voucherNo: string;
|
||||
/** Where the voucher stands after a correction: active, revoked, under correction, or corrected. */
|
||||
voucherStatus?: VoucherStatus;
|
||||
revokedByVoucherNo?: string | null;
|
||||
replacesVoucherNo?: string | null;
|
||||
correctionNote?: string | null;
|
||||
voucherType: string | null;
|
||||
amount: number | null;
|
||||
createdAt: string | null;
|
||||
@@ -82,7 +88,8 @@ interface VoucherReport {
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
MatIconModule
|
||||
MatIconModule,
|
||||
VoucherStatusComponent
|
||||
]
|
||||
})
|
||||
export class VoucherReportComponent implements OnInit {
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* 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, Input } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
/** Where a voucher stands after a voucher correction. */
|
||||
export type VoucherStatus =
|
||||
| 'ACTIVE'
|
||||
| 'REVOKED'
|
||||
| 'UNPASS_PENDING'
|
||||
| 'UNPASSED'
|
||||
| 'CORRECTION_PENDING'
|
||||
| 'CORRECTED'
|
||||
| 'CLOSED'
|
||||
| null
|
||||
| undefined;
|
||||
|
||||
/**
|
||||
* A small badge saying whether a voucher was revoked, is under correction, or replaced another one.
|
||||
* Nothing is shown for an ordinary (active) voucher, so the registers read as before.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-voucher-status',
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
template: `
|
||||
@if (label) {
|
||||
<span class="vs" [class]="'vs vs--' + status" [title]="hint">{{ label }}</span>
|
||||
@if (note) {
|
||||
<div class="vs-note">{{ note }}</div>
|
||||
}
|
||||
}
|
||||
`,
|
||||
styles: [
|
||||
`
|
||||
.vs {
|
||||
display: inline-block;
|
||||
margin-left: 6px;
|
||||
padding: 1px 8px;
|
||||
border-radius: 999px;
|
||||
background: #e2e8f0;
|
||||
color: #334155;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.vs-note {
|
||||
margin-top: 2px;
|
||||
max-width: 280px;
|
||||
font-size: 11px;
|
||||
line-height: 1.3;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.vs--REVOKED {
|
||||
background: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.vs--UNPASS_PENDING,
|
||||
.vs--CORRECTION_PENDING {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
.vs--UNPASSED {
|
||||
background: #dbeafe;
|
||||
color: #1e40af;
|
||||
}
|
||||
|
||||
.vs--CLOSED {
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.vs--CORRECTED {
|
||||
background: #d1fae5;
|
||||
color: #065f46;
|
||||
}
|
||||
`
|
||||
]
|
||||
})
|
||||
export class VoucherStatusComponent {
|
||||
@Input() status: VoucherStatus;
|
||||
/** The voucher that replaced this one, when it is revoked. */
|
||||
@Input() revokedBy: string | null | undefined;
|
||||
/** The voucher this one replaced, when it is the corrected one. */
|
||||
@Input() replaces: string | null | undefined;
|
||||
/** Why: the reason the voucher was unpassed, or why the correction was closed. */
|
||||
@Input() note: string | null | undefined;
|
||||
|
||||
get label(): string {
|
||||
switch (this.status) {
|
||||
case 'REVOKED':
|
||||
return this.revokedBy ? `Revoked → ${this.revokedBy}` : 'Revoked';
|
||||
case 'UNPASS_PENDING':
|
||||
return 'Unpass pending';
|
||||
case 'UNPASSED':
|
||||
return 'Unpassed';
|
||||
case 'CORRECTION_PENDING':
|
||||
return 'Correction pending';
|
||||
case 'CLOSED':
|
||||
return 'Closed — cashier deposits separately';
|
||||
case 'CORRECTED':
|
||||
return this.replaces ? `Corrected (replaces ${this.replaces})` : 'Corrected';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
get hint(): string {
|
||||
switch (this.status) {
|
||||
case 'REVOKED':
|
||||
return 'This voucher was revoked: its deposit was moved to another account and a new voucher replaced it.';
|
||||
case 'UNPASS_PENDING':
|
||||
return 'A manager has not yet approved unpassing this voucher.';
|
||||
case 'UNPASSED':
|
||||
return 'Unpassed: waiting for the cashier to enter the correct account.';
|
||||
case 'CORRECTION_PENDING':
|
||||
return 'The correct account is entered; waiting for a manager to approve.';
|
||||
case 'CLOSED':
|
||||
return 'The correction was closed by the cashier; the voucher stays as it was.';
|
||||
case 'CORRECTED':
|
||||
return 'This voucher was raised by a correction and replaces the earlier one.';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,6 +131,14 @@
|
||||
</svg>
|
||||
My Closure Requests
|
||||
</a>
|
||||
<a
|
||||
class="cashier-nav__item cashier-nav__item--sec"
|
||||
[class.cashier-nav__item--active]="currentUrl.includes('/clerk/voucher-correction')"
|
||||
[routerLink]="['/clerk/voucher-correction']"
|
||||
>
|
||||
<fa-icon icon="undo"></fa-icon>
|
||||
Voucher Correction
|
||||
</a>
|
||||
@if (clerkAccountLoaded) {
|
||||
<div class="cashier-nav__item-wrap">
|
||||
<a
|
||||
@@ -287,6 +295,13 @@
|
||||
<a class="cashier-nav__item" [routerLink]="['/cashier/my-work']" routerLinkActive="cashier-nav__item--active">
|
||||
<fa-icon icon="user-check"></fa-icon> My Vouchers
|
||||
</a>
|
||||
<a
|
||||
class="cashier-nav__item"
|
||||
[routerLink]="['/cashier/voucher-correction']"
|
||||
routerLinkActive="cashier-nav__item--active"
|
||||
>
|
||||
<fa-icon icon="undo"></fa-icon> Voucher Correction
|
||||
</a>
|
||||
<a
|
||||
class="cashier-nav__item"
|
||||
[routerLink]="['/cashier/received-report']"
|
||||
@@ -392,6 +407,10 @@
|
||||
<fa-icon icon="clipboard-check" class="ni-ico"></fa-icon>Loan Origination
|
||||
<fa-icon icon="caret-down" class="ni-caret"></fa-icon>
|
||||
</a>
|
||||
<a class="ni" tabindex="0" [matMenuTriggerFor]="creditBureauMenu" *mifosxHasPermission="'MENU_CREDIT_BUREAU'">
|
||||
<fa-icon icon="id-card" class="ni-ico"></fa-icon>Credit Bureau
|
||||
<fa-icon icon="caret-down" class="ni-caret"></fa-icon>
|
||||
</a>
|
||||
<a class="ni" tabindex="0" [matMenuTriggerFor]="advancesMenu" *mifosxHasPermission="'MENU_ADVANCES'">
|
||||
<fa-icon icon="hand-holding-usd" class="ni-ico"></fa-icon>Advances
|
||||
<fa-icon icon="caret-down" class="ni-caret"></fa-icon>
|
||||
@@ -493,6 +512,11 @@
|
||||
><span class="ni-short">Loans</span>
|
||||
<fa-icon icon="caret-down" class="ni-caret"></fa-icon>
|
||||
</a>
|
||||
<a class="ni" tabindex="0" [matMenuTriggerFor]="creditBureauMenu" *mifosxHasPermission="'MENU_CREDIT_BUREAU'">
|
||||
<fa-icon icon="id-card" class="ni-ico"></fa-icon><span class="ni-full">Credit Bureau</span
|
||||
><span class="ni-short">CIC</span>
|
||||
<fa-icon icon="caret-down" class="ni-caret"></fa-icon>
|
||||
</a>
|
||||
<a
|
||||
class="ni"
|
||||
tabindex="0"
|
||||
@@ -1164,6 +1188,9 @@
|
||||
<button mat-menu-item tabindex="0" [routerLink]="['/system/denomination-master']">
|
||||
<fa-icon icon="coins" class="menu-item-icon"></fa-icon> Cash Denomination
|
||||
</button>
|
||||
<button mat-menu-item tabindex="0" [routerLink]="['/cashier/voucher-correction']">
|
||||
<fa-icon icon="undo" class="menu-item-icon"></fa-icon> Voucher Correction
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Transfers & Settlement -->
|
||||
@@ -1644,6 +1671,42 @@
|
||||
</div>
|
||||
</mat-menu>
|
||||
|
||||
<mat-menu #creditBureauMenu="matMenu" class="npa-mega-panel" [overlapTrigger]="false">
|
||||
<div class="deposit-menu-grid npa-grid" (click)="$event.stopPropagation()">
|
||||
<!-- Enquiry -->
|
||||
<div class="deposit-menu-group">
|
||||
<div class="deposit-group-title">Bureau Enquiry</div>
|
||||
<button mat-menu-item tabindex="0" routerLink="/credit-bureau/dashboard">
|
||||
<fa-icon icon="tachometer-alt" class="menu-item-icon"></fa-icon> Dashboard
|
||||
</button>
|
||||
<button
|
||||
mat-menu-item
|
||||
tabindex="0"
|
||||
routerLink="/credit-bureau/new-enquiry"
|
||||
*mifosxHasPermission="'CREATE_CICENQUIRY'"
|
||||
>
|
||||
<fa-icon icon="search" class="menu-item-icon"></fa-icon> New Enquiry (CIBIL / CIC)
|
||||
</button>
|
||||
<button mat-menu-item tabindex="0" routerLink="/credit-bureau/enquiries">
|
||||
<fa-icon icon="history" class="menu-item-icon"></fa-icon> Enquiry History & Reports
|
||||
</button>
|
||||
<button mat-menu-item tabindex="0" routerLink="/credit-bureau/consents">
|
||||
<fa-icon icon="file-signature" class="menu-item-icon"></fa-icon> Consent Register
|
||||
</button>
|
||||
</div>
|
||||
<!-- Setup -->
|
||||
<div class="deposit-menu-group">
|
||||
<div class="deposit-group-title">CIC Setup</div>
|
||||
<button mat-menu-item tabindex="0" routerLink="/credit-bureau/bureaus">
|
||||
<fa-icon icon="shield-alt" class="menu-item-icon"></fa-icon> CIC Whitelist & Configuration
|
||||
</button>
|
||||
<button mat-menu-item tabindex="0" routerLink="/credit-bureau/api-mapping">
|
||||
<fa-icon icon="project-diagram" class="menu-item-icon"></fa-icon> API Mapping
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-menu>
|
||||
|
||||
<mat-menu #ckycMenu="matMenu" class="ckyc-mega-panel" [overlapTrigger]="false">
|
||||
<div class="deposit-menu-grid ckyc-grid" (click)="$event.stopPropagation()">
|
||||
<!-- KYC Operations -->
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
<!--
|
||||
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="cic-page">
|
||||
<div class="cic-head">
|
||||
<div>
|
||||
<h1>CIC API Mapping</h1>
|
||||
<p>
|
||||
Map CBS data to each bureau's request, and the bureau's response back to the score and report — no code change
|
||||
needed.
|
||||
</p>
|
||||
</div>
|
||||
<div class="cic-actions">
|
||||
<a class="cic-btn" routerLink="/credit-bureau/bureaus">CIC Configuration</a>
|
||||
<button
|
||||
class="cic-btn primary"
|
||||
(click)="save()"
|
||||
[disabled]="saving || !endpoint"
|
||||
*mifosxHasPermission="'UPDATE_CICBUREAU'"
|
||||
>
|
||||
{{ saving ? 'Saving…' : dirty ? 'Save changes' : 'Save' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cic-card">
|
||||
<div class="cic-grid cols-3" style="align-items: end">
|
||||
<div class="cic-field">
|
||||
<label>Bureau</label>
|
||||
<select [(ngModel)]="bureauId" (ngModelChange)="load()">
|
||||
@for (b of bureaus; track b.id) {
|
||||
<option [ngValue]="b.id">{{ b.code }} — {{ b.name }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Enquiry type</label>
|
||||
<select [(ngModel)]="endpointType" (ngModelChange)="load()">
|
||||
@for (t of catalog?.endpointTypes ?? []; track t) {
|
||||
<option [value]="t">{{ t === 'CONSUMER_ENQUIRY' ? 'Consumer enquiry' : 'Commercial enquiry' }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
@if (bureau) {
|
||||
<span
|
||||
class="cic-badge"
|
||||
[class.warn]="bureau.environment === 'SIMULATOR'"
|
||||
[class.good]="bureau.environment === 'PRODUCTION'"
|
||||
>{{ bureau.environment }}</span
|
||||
>
|
||||
<span class="cic-badge" [class.good]="bureau.whitelisted">{{
|
||||
bureau.whitelisted ? 'Whitelisted' : 'Not whitelisted'
|
||||
}}</span>
|
||||
@if (endpoint && !endpoint.exists) {
|
||||
<span class="cic-badge warn">Not configured yet</span>
|
||||
}
|
||||
@if (dirty) {
|
||||
<span class="cic-badge warn">Unsaved changes</span>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (error) {
|
||||
<div class="cic-alert error">{{ error }}</div>
|
||||
}
|
||||
@if (info) {
|
||||
<div class="cic-alert success">{{ info }}</div>
|
||||
}
|
||||
@if (bureau?.environment === 'SIMULATOR') {
|
||||
<div class="cic-alert info">
|
||||
In SIMULATOR mode the built-in test bureau answers in the shape of the seeded generic mapping. When moving to the
|
||||
bureau's UAT / PRODUCTION, change the paths below to match the bureau's own API specification.
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (loading) {
|
||||
<div class="cic-card cic-empty">Loading…</div>
|
||||
}
|
||||
|
||||
@if (endpoint && !loading) {
|
||||
<div class="cic-tabs">
|
||||
<button [class.active]="tab === 'request'" (click)="tab = 'request'">
|
||||
Request mapping ({{ requestRows.length }})
|
||||
</button>
|
||||
<button [class.active]="tab === 'response'" (click)="tab = 'response'">
|
||||
Response mapping ({{ responseRows.length }})
|
||||
</button>
|
||||
<button [class.active]="tab === 'endpoint'" (click)="tab = 'endpoint'">Endpoint, headers & body</button>
|
||||
<button [class.active]="tab === 'preview'" (click)="tab = 'preview'">Preview (dry run)</button>
|
||||
</div>
|
||||
|
||||
<!-- REQUEST -->
|
||||
@if (tab === 'request') {
|
||||
<div class="cic-card">
|
||||
<h2>
|
||||
CBS field → bureau request
|
||||
<span class="cic-card-sub">Paths like <code>consumer.ids[0].number</code> build nested JSON and arrays</span>
|
||||
</h2>
|
||||
<div class="cic-table-wrap">
|
||||
<table class="cic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 34px">#</th>
|
||||
<th style="min-width: 200px">CBS field</th>
|
||||
<th style="min-width: 220px">Bureau JSON path</th>
|
||||
<th style="min-width: 160px">Transform</th>
|
||||
<th style="min-width: 120px">Fixed / default value</th>
|
||||
<th>Mandatory</th>
|
||||
<th style="width: 110px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (r of requestRows; track $index; let i = $index) {
|
||||
<tr>
|
||||
<td class="muted">{{ i + 1 }}</td>
|
||||
<td>
|
||||
<select [(ngModel)]="r.sourceField" (ngModelChange)="markDirty()">
|
||||
<option [ngValue]="null">— fixed value —</option>
|
||||
@for (f of cbsFieldList; track f.key) {
|
||||
<option [ngValue]="f.key">{{ f.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
class="cic-mono"
|
||||
[(ngModel)]="r.targetField"
|
||||
(ngModelChange)="markDirty()"
|
||||
placeholder="consumer.name.firstName"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<select [(ngModel)]="r.transform" (ngModelChange)="markDirty()">
|
||||
@for (t of transformList; track t.key) {
|
||||
<option [value]="t.key">{{ t.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
[(ngModel)]="r.defaultValue"
|
||||
(ngModelChange)="markDirty()"
|
||||
[placeholder]="r.sourceField ? 'if empty' : 'value'"
|
||||
/>
|
||||
</td>
|
||||
<td style="text-align: center">
|
||||
<input
|
||||
type="checkbox"
|
||||
[(ngModel)]="r.mandatory"
|
||||
(ngModelChange)="markDirty()"
|
||||
style="width: auto"
|
||||
/>
|
||||
</td>
|
||||
<td style="white-space: nowrap">
|
||||
<button class="cic-btn sm" (click)="move('request', i, -1)" [disabled]="i === 0" title="Move up">
|
||||
↑
|
||||
</button>
|
||||
<button
|
||||
class="cic-btn sm"
|
||||
(click)="move('request', i, 1)"
|
||||
[disabled]="i === requestRows.length - 1"
|
||||
title="Move down"
|
||||
>
|
||||
↓
|
||||
</button>
|
||||
<button class="cic-btn sm danger" (click)="removeRow('request', i)" title="Remove">✕</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="cic-actions" style="margin-top: 12px">
|
||||
<button class="cic-btn" (click)="addRow('request')">+ Add request field</button>
|
||||
<span class="muted" style="font-size: 12px"
|
||||
>A mandatory field missing on the customer stops the enquiry before the bureau is called.</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- RESPONSE -->
|
||||
@if (tab === 'response') {
|
||||
<div class="cic-card">
|
||||
<h2>
|
||||
Bureau response → CBS result
|
||||
<span class="cic-card-sub"
|
||||
>"score" drives the score shown everywhere; "hit" = false marks a no-hit; "errorCode" marks a failure</span
|
||||
>
|
||||
</h2>
|
||||
<div class="cic-table-wrap">
|
||||
<table class="cic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 34px">#</th>
|
||||
<th style="min-width: 240px">Bureau response JSON path</th>
|
||||
<th style="min-width: 220px">CBS result field</th>
|
||||
<th style="min-width: 150px">Transform</th>
|
||||
<th style="min-width: 110px">Default</th>
|
||||
<th style="width: 110px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (r of responseRows; track $index; let i = $index) {
|
||||
<tr>
|
||||
<td class="muted">{{ i + 1 }}</td>
|
||||
<td>
|
||||
<input
|
||||
class="cic-mono"
|
||||
[(ngModel)]="r.sourceField"
|
||||
(ngModelChange)="markDirty()"
|
||||
placeholder="report.score.value"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
class="cic-mono"
|
||||
[(ngModel)]="r.targetField"
|
||||
(ngModelChange)="markDirty()"
|
||||
list="cic-result-fields"
|
||||
placeholder="score"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<select [(ngModel)]="r.transform" (ngModelChange)="markDirty()">
|
||||
@for (t of transformList; track t.key) {
|
||||
<option [value]="t.key">{{ t.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
<td><input [(ngModel)]="r.defaultValue" (ngModelChange)="markDirty()" /></td>
|
||||
<td style="white-space: nowrap">
|
||||
<button class="cic-btn sm" (click)="move('response', i, -1)" [disabled]="i === 0">↑</button>
|
||||
<button
|
||||
class="cic-btn sm"
|
||||
(click)="move('response', i, 1)"
|
||||
[disabled]="i === responseRows.length - 1"
|
||||
>
|
||||
↓
|
||||
</button>
|
||||
<button class="cic-btn sm danger" (click)="removeRow('response', i)">✕</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<datalist id="cic-result-fields">
|
||||
@for (f of resultFieldList; track f.key) {
|
||||
<option [value]="f.key">{{ f.label }}</option>
|
||||
}
|
||||
</datalist>
|
||||
<div class="cic-actions" style="margin-top: 12px">
|
||||
<button class="cic-btn" (click)="addRow('response')">+ Add response field</button>
|
||||
<span class="muted" style="font-size: 12px"
|
||||
>Standard result fields: {{ resultFieldList.length }}; any other simple name is kept as an extra
|
||||
field.</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- ENDPOINT -->
|
||||
@if (tab === 'endpoint') {
|
||||
<div class="cic-card">
|
||||
<h2>Endpoint</h2>
|
||||
<div class="cic-grid cols-4">
|
||||
<div class="cic-field">
|
||||
<label>HTTP method</label>
|
||||
<select [(ngModel)]="endpoint.httpMethod" (ngModelChange)="markDirty()">
|
||||
@for (m of catalog?.httpMethods ?? []; track m) {
|
||||
<option [value]="m">{{ m }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-field" style="grid-column: span 2">
|
||||
<label>Path (appended to the bureau's base URL)</label>
|
||||
<input
|
||||
class="cic-mono"
|
||||
[(ngModel)]="endpoint.path"
|
||||
(ngModelChange)="markDirty()"
|
||||
placeholder="/consumer/enquiry"
|
||||
/>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Content type</label>
|
||||
<input class="cic-mono" [(ngModel)]="endpoint.contentType" (ngModelChange)="markDirty()" />
|
||||
</div>
|
||||
</div>
|
||||
<label style="display: flex; gap: 8px; align-items: center; font-size: 13px; margin-top: 12px">
|
||||
<input type="checkbox" [(ngModel)]="endpoint.isActive" (ngModelChange)="markDirty()" /> Endpoint active
|
||||
</label>
|
||||
<div class="cic-grid cols-2" style="margin-top: 14px">
|
||||
<div class="cic-field">
|
||||
<label>Static headers (JSON object)</label>
|
||||
<textarea
|
||||
class="cic-mono"
|
||||
rows="10"
|
||||
[(ngModel)]="endpoint.headersJson"
|
||||
(ngModelChange)="markDirty()"
|
||||
></textarea>
|
||||
<span class="hint"
|
||||
>Placeholders like <code>{{ '{{' }}bureau.memberCode{{ '}}' }}</code> or
|
||||
<code>{{ '{{' }}enquiry.reference{{ '}}' }}</code> are filled in. Authentication headers are added
|
||||
automatically.</span
|
||||
>
|
||||
@if (jsonErrors.headers) {
|
||||
<span class="tone-bad" style="font-size: 12px">{{ jsonErrors.headers }}</span>
|
||||
}
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Base request body (JSON object)</label>
|
||||
<textarea
|
||||
class="cic-mono"
|
||||
rows="10"
|
||||
[(ngModel)]="endpoint.baseBody"
|
||||
(ngModelChange)="markDirty()"
|
||||
></textarea>
|
||||
<span class="hint">Constant parts of the request; request mappings are written into it.</span>
|
||||
@if (jsonErrors.body) {
|
||||
<span class="tone-bad" style="font-size: 12px">{{ jsonErrors.body }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- PREVIEW -->
|
||||
@if (tab === 'preview') {
|
||||
<div class="cic-card">
|
||||
<h2>
|
||||
Preview
|
||||
<span class="cic-card-sub"
|
||||
>builds the request from the saved mapping for a real customer — nothing is sent</span
|
||||
>
|
||||
</h2>
|
||||
<div class="cic-grid cols-4" style="align-items: end">
|
||||
<div class="cic-field" style="grid-column: span 2">
|
||||
<label>Customer</label>
|
||||
<div style="display: flex; gap: 8px">
|
||||
<input
|
||||
[value]="previewClient ? previewClient.name + ' (#' + previewClient.id + ')' : ''"
|
||||
placeholder="Search a customer"
|
||||
readonly
|
||||
/>
|
||||
<button class="cic-btn sm" (click)="pickPreviewClient()">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Amount (₹)</label>
|
||||
<input type="number" [(ngModel)]="previewAmount" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Purpose</label>
|
||||
<select [(ngModel)]="previewPurpose">
|
||||
@for (p of purposes; track p.code) {
|
||||
<option [value]="p.code">{{ p.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="cic-btn primary"
|
||||
style="margin-top: 12px"
|
||||
(click)="runPreview()"
|
||||
[disabled]="previewing || !previewClient"
|
||||
>
|
||||
{{ previewing ? 'Building…' : 'Build preview' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (previewResult) {
|
||||
@if (previewResult.missingMandatory?.length) {
|
||||
<div class="cic-alert error">
|
||||
This customer would be refused — missing mandatory fields:
|
||||
<ul>
|
||||
@for (m of previewResult.missingMandatory; track m) {
|
||||
<li>{{ m }}</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="cic-alert success">All mandatory fields are present for this customer.</div>
|
||||
}
|
||||
<div class="cic-split">
|
||||
<div class="cic-card">
|
||||
<h2>Request body <span class="cic-card-sub">sensitive values masked</span></h2>
|
||||
<pre class="cic-code">{{ prettyBody(previewResult.body) }}</pre>
|
||||
</div>
|
||||
<div class="cic-card">
|
||||
<h2>Call</h2>
|
||||
<dl class="cic-kv" style="grid-template-columns: 120px minmax(0, 1fr)">
|
||||
<dt>Method</dt>
|
||||
<dd>{{ previewResult.method }}</dd>
|
||||
<dt>URL</dt>
|
||||
<dd class="cic-mono">{{ previewResult.url }}</dd>
|
||||
<dt>Auth</dt>
|
||||
<dd>{{ previewResult.authentication }}</dd>
|
||||
@for (h of headerEntries(previewResult.headers); track h.k) {
|
||||
<dt class="cic-mono">{{ h.k }}</dt>
|
||||
<dd class="cic-mono">{{ h.v }}</dd>
|
||||
}
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,308 @@
|
||||
/**
|
||||
* 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 { CommonModule } from '@angular/common';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, RouterModule } from '@angular/router';
|
||||
|
||||
import { HasPermissionDirective } from 'app/directives/has-permission/has-permission.directive';
|
||||
import {
|
||||
CustomerSearchDialogComponent,
|
||||
CustomerSearchResult
|
||||
} from 'app/shared/customer-search-dialog/customer-search-dialog.component';
|
||||
import { CicBureau, CicCatalog, CicEndpoint, CicMapping, CicService, cicError } from '../cic.service';
|
||||
|
||||
/**
|
||||
* The per-bureau API mapping, maintained from the UI: endpoint (method, path, headers, base body), REQUEST rows that
|
||||
* put a CBS field into the bureau's request at a JSON path, and RESPONSE rows that read the bureau's answer into the
|
||||
* CBS result (score, accounts, overdue ...). A dry-run preview shows the exact request for a real customer.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-cic-api-mapping',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
RouterModule,
|
||||
MatDialogModule,
|
||||
HasPermissionDirective
|
||||
],
|
||||
templateUrl: './cic-api-mapping.component.html',
|
||||
styleUrls: ['../cic-shared.scss']
|
||||
})
|
||||
export class CicApiMappingComponent implements OnInit {
|
||||
private cic = inject(CicService);
|
||||
private dialog = inject(MatDialog);
|
||||
private route = inject(ActivatedRoute);
|
||||
|
||||
catalog: CicCatalog | null = null;
|
||||
bureaus: CicBureau[] = [];
|
||||
bureauId: number | null = null;
|
||||
endpointType = 'CONSUMER_ENQUIRY';
|
||||
|
||||
endpoint: CicEndpoint | null = null;
|
||||
requestRows: CicMapping[] = [];
|
||||
responseRows: CicMapping[] = [];
|
||||
tab: 'request' | 'response' | 'endpoint' | 'preview' = 'request';
|
||||
|
||||
loading = false;
|
||||
saving = false;
|
||||
dirty = false;
|
||||
error: string | null = null;
|
||||
info: string | null = null;
|
||||
jsonErrors: { headers?: string; body?: string } = {};
|
||||
|
||||
// preview
|
||||
previewClient: { id: number; name: string } | null = null;
|
||||
previewAmount = 100000;
|
||||
previewPurpose = 'NEW_LOAN';
|
||||
previewResult: any = null;
|
||||
previewing = false;
|
||||
|
||||
cbsFieldList: { key: string; label: string }[] = [];
|
||||
resultFieldList: { key: string; label: string }[] = [];
|
||||
transformList: { key: string; label: string }[] = [];
|
||||
purposes: { code: string; label: string }[] = [];
|
||||
|
||||
ngOnInit(): void {
|
||||
this.cic.catalog().subscribe({
|
||||
next: (c) => {
|
||||
this.catalog = c;
|
||||
this.cbsFieldList = Object.entries(c.cbsFields).map(
|
||||
([
|
||||
key,
|
||||
label
|
||||
]) => ({ key, label })
|
||||
);
|
||||
this.resultFieldList = Object.entries(c.resultFields).map(
|
||||
([
|
||||
key,
|
||||
label
|
||||
]) => ({ key, label })
|
||||
);
|
||||
this.transformList = Object.entries(c.transforms).map(
|
||||
([
|
||||
key,
|
||||
label
|
||||
]) => ({ key, label })
|
||||
);
|
||||
this.purposes = Object.entries(c.purposes).map(
|
||||
([
|
||||
code,
|
||||
label
|
||||
]) => ({ code, label })
|
||||
);
|
||||
},
|
||||
error: (e) => (this.error = cicError(e))
|
||||
});
|
||||
this.cic.bureaus().subscribe({
|
||||
next: (b) => {
|
||||
this.bureaus = b;
|
||||
const wanted = Number(this.route.snapshot.queryParamMap.get('bureauId'));
|
||||
this.bureauId = b.find((x) => x.id === wanted)?.id ?? b[0]?.id ?? null;
|
||||
this.load();
|
||||
},
|
||||
error: (e) => (this.error = cicError(e, 'Could not load the bureaus.'))
|
||||
});
|
||||
}
|
||||
|
||||
get bureau(): CicBureau | undefined {
|
||||
return this.bureaus.find((b) => b.id === this.bureauId);
|
||||
}
|
||||
|
||||
load(): void {
|
||||
if (!this.bureauId) return;
|
||||
if (this.dirty && !confirm('Discard unsaved mapping changes?')) return;
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
this.info = null;
|
||||
this.previewResult = null;
|
||||
this.cic.endpoint(this.bureauId, this.endpointType).subscribe({
|
||||
next: (e) => {
|
||||
this.endpoint = { ...e, headersJson: this.prettyJson(e.headersJson), baseBody: this.prettyJson(e.baseBody) };
|
||||
this.requestRows = e.requestMappings.map((m) => ({ ...m }));
|
||||
this.responseRows = e.responseMappings.map((m) => ({ ...m }));
|
||||
this.loading = false;
|
||||
this.dirty = false;
|
||||
this.jsonErrors = {};
|
||||
},
|
||||
error: (err) => {
|
||||
this.loading = false;
|
||||
this.error = cicError(err, 'Could not load the mapping.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
markDirty(): void {
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
addRow(direction: 'request' | 'response'): void {
|
||||
const row: CicMapping = {
|
||||
sourceField: null,
|
||||
targetField: '',
|
||||
transform: 'NONE',
|
||||
defaultValue: null,
|
||||
mandatory: false
|
||||
};
|
||||
(direction === 'request' ? this.requestRows : this.responseRows).push(row);
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
removeRow(direction: 'request' | 'response', index: number): void {
|
||||
(direction === 'request' ? this.requestRows : this.responseRows).splice(index, 1);
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
move(direction: 'request' | 'response', index: number, delta: number): void {
|
||||
const rows = direction === 'request' ? this.requestRows : this.responseRows;
|
||||
const to = index + delta;
|
||||
if (to < 0 || to >= rows.length) return;
|
||||
[
|
||||
rows[index],
|
||||
rows[to]
|
||||
] = [
|
||||
rows[to],
|
||||
rows[index]
|
||||
];
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
/** Local checks before the server's own validation. */
|
||||
private validJson(): boolean {
|
||||
this.jsonErrors = {};
|
||||
for (const [
|
||||
key,
|
||||
text
|
||||
] of [
|
||||
[
|
||||
'headers',
|
||||
this.endpoint?.headersJson
|
||||
],
|
||||
[
|
||||
'body',
|
||||
this.endpoint?.baseBody
|
||||
]
|
||||
] as const) {
|
||||
try {
|
||||
const parsed = JSON.parse(text || '{}');
|
||||
if (typeof parsed !== 'object' || Array.isArray(parsed) || parsed === null)
|
||||
throw new Error('must be a JSON object');
|
||||
} catch (e: any) {
|
||||
this.jsonErrors[key] = `Not a valid JSON object: ${e?.message ?? e}`;
|
||||
}
|
||||
}
|
||||
return !this.jsonErrors.headers && !this.jsonErrors.body;
|
||||
}
|
||||
|
||||
save(): void {
|
||||
if (!this.bureauId || !this.endpoint) return;
|
||||
if (!this.validJson()) {
|
||||
this.tab = 'endpoint';
|
||||
this.error = 'Fix the JSON on the Endpoint tab before saving.';
|
||||
return;
|
||||
}
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
this.info = null;
|
||||
const clean = (rows: CicMapping[]) =>
|
||||
rows.map((r, i) => ({
|
||||
sourceField: r.sourceField || null,
|
||||
targetField: (r.targetField || '').trim(),
|
||||
transform: r.transform || 'NONE',
|
||||
defaultValue: r.defaultValue === '' ? null : r.defaultValue,
|
||||
mandatory: !!r.mandatory,
|
||||
sortOrder: (i + 1) * 10
|
||||
}));
|
||||
this.cic
|
||||
.saveEndpoint(this.bureauId, this.endpointType, {
|
||||
httpMethod: this.endpoint.httpMethod,
|
||||
path: this.endpoint.path,
|
||||
contentType: this.endpoint.contentType,
|
||||
headersJson: JSON.stringify(JSON.parse(this.endpoint.headersJson || '{}')),
|
||||
baseBody: JSON.stringify(JSON.parse(this.endpoint.baseBody || '{}')),
|
||||
isActive: this.endpoint.isActive,
|
||||
requestMappings: clean(this.requestRows),
|
||||
responseMappings: clean(this.responseRows)
|
||||
})
|
||||
.subscribe({
|
||||
next: (e) => {
|
||||
this.saving = false;
|
||||
this.dirty = false;
|
||||
this.endpoint = { ...e, headersJson: this.prettyJson(e.headersJson), baseBody: this.prettyJson(e.baseBody) };
|
||||
this.requestRows = e.requestMappings.map((m) => ({ ...m }));
|
||||
this.responseRows = e.responseMappings.map((m) => ({ ...m }));
|
||||
this.info = `${this.bureau?.code} ${this.endpointType} mapping saved (${this.requestRows.length} request, ${this.responseRows.length} response fields).`;
|
||||
},
|
||||
error: (err) => {
|
||||
this.saving = false;
|
||||
this.error = cicError(err, 'Could not save the mapping.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pickPreviewClient(): void {
|
||||
this.dialog
|
||||
.open(CustomerSearchDialogComponent, { width: '960px', maxWidth: '95vw', data: { requireAccount: false } })
|
||||
.afterClosed()
|
||||
.subscribe((r: CustomerSearchResult | undefined) => {
|
||||
if (r?.clientId) this.previewClient = { id: r.clientId, name: r.displayName };
|
||||
});
|
||||
}
|
||||
|
||||
runPreview(): void {
|
||||
if (!this.bureauId || !this.previewClient) return;
|
||||
if (this.dirty) {
|
||||
this.error = 'Save the mapping first — the preview uses the saved mapping.';
|
||||
return;
|
||||
}
|
||||
this.previewing = true;
|
||||
this.error = null;
|
||||
this.cic
|
||||
.preview(this.bureauId, {
|
||||
clientId: this.previewClient.id,
|
||||
enquiryType: this.endpointType,
|
||||
purpose: this.previewPurpose,
|
||||
loanAmount: this.previewAmount
|
||||
})
|
||||
.subscribe({
|
||||
next: (r) => {
|
||||
this.previewing = false;
|
||||
this.previewResult = r;
|
||||
},
|
||||
error: (e) => {
|
||||
this.previewing = false;
|
||||
this.error = cicError(e, 'Preview failed.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
prettyJson(text?: string | null): string {
|
||||
if (!text) return '{}';
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(text), null, 2);
|
||||
} catch {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
prettyBody(text?: string | null): string {
|
||||
return this.prettyJson(text);
|
||||
}
|
||||
|
||||
headerEntries(h: Record<string, string> | null | undefined): { k: string; v: string }[] {
|
||||
return Object.entries(h ?? {}).map(
|
||||
([
|
||||
k,
|
||||
v
|
||||
]) => ({ k, v })
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
<!--
|
||||
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="cic-page">
|
||||
<div class="cic-head">
|
||||
<div>
|
||||
<h1>CIC Whitelist & Configuration</h1>
|
||||
<p>
|
||||
Choose which Credit Information Companies this bank may enquire, and how each is reached. Only whitelisted
|
||||
bureaus appear on the enquiry screen.
|
||||
</p>
|
||||
</div>
|
||||
<div class="cic-actions">
|
||||
<a class="cic-btn" routerLink="/credit-bureau/api-mapping">API Mapping</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (error) {
|
||||
<div class="cic-alert error">{{ error }}</div>
|
||||
}
|
||||
@if (info) {
|
||||
<div class="cic-alert success">{{ info }}</div>
|
||||
}
|
||||
|
||||
@if (loading && !bureaus.length) {
|
||||
<div class="cic-card cic-empty">Loading…</div>
|
||||
}
|
||||
|
||||
<div class="cic-grid cols-2">
|
||||
@for (b of bureaus; track b.id) {
|
||||
<div class="cic-card" style="margin-bottom: 0">
|
||||
<div style="display: flex; justify-content: space-between; gap: 12px; align-items: flex-start">
|
||||
<div style="min-width: 0">
|
||||
<div style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap">
|
||||
<b style="font-size: 16px">{{ b.code }}</b>
|
||||
<span class="cic-badge" [class]="'cic-badge ' + envTone(b.environment)">{{ b.environment }}</span>
|
||||
@if (b.isDefault) {
|
||||
<span class="cic-badge brand">Default</span>
|
||||
}
|
||||
</div>
|
||||
<div class="muted" style="font-size: 12px; margin-top: 3px">{{ b.name }}</div>
|
||||
</div>
|
||||
<label style="display: flex; gap: 8px; align-items: center; font-size: 12px; font-weight: 600">
|
||||
{{ b.whitelisted ? 'Whitelisted' : 'Not whitelisted' }}
|
||||
<span class="cic-switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
[checked]="b.whitelisted"
|
||||
[disabled]="toggling === b.id"
|
||||
(change)="toggle(b, $event)"
|
||||
*mifosxHasPermission="'UPDATE_CICBUREAU'"
|
||||
/>
|
||||
<span></span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<dl class="cic-kv" style="margin-top: 14px; grid-template-columns: 140px minmax(0, 1fr)">
|
||||
<dt>Base URL</dt>
|
||||
<dd class="cic-mono">{{ b.environment === 'SIMULATOR' ? '(simulator)' : b.baseUrl || '— not set —' }}</dd>
|
||||
<dt>Member code</dt>
|
||||
<dd>{{ b.memberCode || '—' }}</dd>
|
||||
<dt>Authentication</dt>
|
||||
<dd>
|
||||
{{ authLabels[b.authType] || b.authType }}
|
||||
@if (b.authType !== 'NONE') {
|
||||
<span class="cic-badge" [class.good]="b.hasSecret" [class.bad]="!b.hasSecret">{{
|
||||
b.hasSecret ? 'credential stored' : 'no credential'
|
||||
}}</span>
|
||||
}
|
||||
</dd>
|
||||
<dt>Endpoints</dt>
|
||||
<dd>{{ b.activeEndpoints }} active</dd>
|
||||
<dt>Report reuse</dt>
|
||||
<dd>{{ b.reportValidityDays ? 'within ' + b.reportValidityDays + ' days' : 'always pull fresh' }}</dd>
|
||||
<dt>Charge / enquiry</dt>
|
||||
<dd>₹{{ b.enquiryCharge | number: '1.0-2' }}</dd>
|
||||
<dt>Last test</dt>
|
||||
<dd>
|
||||
@if (b.lastTestStatus) {
|
||||
<span
|
||||
class="cic-badge"
|
||||
[class.good]="b.lastTestStatus === 'OK'"
|
||||
[class.bad]="b.lastTestStatus !== 'OK'"
|
||||
>{{ b.lastTestStatus }}</span
|
||||
>
|
||||
<span class="muted" style="font-size: 12px"> {{ b.lastTestedOn | slice: 0 : 16 }}</span>
|
||||
<div class="muted" style="font-size: 12px">{{ b.lastTestMessage }}</div>
|
||||
} @else {
|
||||
<span class="muted">never</span>
|
||||
}
|
||||
</dd>
|
||||
<dt>Enquiries (30d)</dt>
|
||||
<dd>{{ b.enquiriesLast30Days }}</dd>
|
||||
</dl>
|
||||
|
||||
<div class="cic-actions" style="margin-top: 14px">
|
||||
<button class="cic-btn" (click)="edit(b)" *mifosxHasPermission="'UPDATE_CICBUREAU'">Configure</button>
|
||||
<button
|
||||
class="cic-btn"
|
||||
(click)="test(b)"
|
||||
[disabled]="testing === b.id"
|
||||
*mifosxHasPermission="'UPDATE_CICBUREAU'"
|
||||
>
|
||||
{{ testing === b.id ? 'Testing…' : 'Test Connection' }}
|
||||
</button>
|
||||
<a class="cic-btn" routerLink="/credit-bureau/api-mapping" [queryParams]="{ bureauId: b.id }">API Mapping</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="cic-alert info" style="margin-top: 16px">
|
||||
<b>Going live with a bureau:</b> 1) get the bank's member code, API URL and credentials from the bureau; 2)
|
||||
Configure them here (environment UAT first); 3) adapt the request / response fields under API Mapping to the
|
||||
bureau's specification and use Preview; 4) Test Connection and run a test enquiry; 5) switch to PRODUCTION and
|
||||
whitelist it.
|
||||
</div>
|
||||
|
||||
@if (editing) {
|
||||
<div class="cic-modal-backdrop" (click)="editing = null">
|
||||
<div class="cic-modal" style="width: min(820px, 100%)" (click)="$event.stopPropagation()">
|
||||
<h3>Configure {{ editing.code }}</h3>
|
||||
<div class="cic-grid cols-2">
|
||||
<div class="cic-field">
|
||||
<label>Display name</label>
|
||||
<input [(ngModel)]="form.name" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Environment</label>
|
||||
<select [(ngModel)]="form.environment">
|
||||
<option value="SIMULATOR">SIMULATOR — built-in test bureau, no network call</option>
|
||||
<option value="UAT">UAT — bureau's test environment</option>
|
||||
<option value="PRODUCTION">PRODUCTION — live bureau</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-field" style="grid-column: 1 / -1">
|
||||
<label>Base URL</label>
|
||||
<input class="cic-mono" [(ngModel)]="form.baseUrl" placeholder="https://api.bureau.example/v1" />
|
||||
<span class="hint"
|
||||
>Endpoint paths from API Mapping are appended to this. PRODUCTION requires https://.</span
|
||||
>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Bank's member code / id</label>
|
||||
<input [(ngModel)]="form.memberCode" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Authentication</label>
|
||||
<select [(ngModel)]="form.authType">
|
||||
@for (a of catalog?.authTypes ?? []; track a) {
|
||||
<option [value]="a">{{ authLabels[a] || a }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
@if (form.authType === 'BASIC') {
|
||||
<div class="cic-field">
|
||||
<label>User id</label>
|
||||
<input [(ngModel)]="form.username" autocomplete="off" />
|
||||
</div>
|
||||
}
|
||||
@if (form.authType === 'API_KEY') {
|
||||
<div class="cic-field">
|
||||
<label>API key header name</label>
|
||||
<input class="cic-mono" [(ngModel)]="form.apiKeyHeader" />
|
||||
</div>
|
||||
}
|
||||
@if (form.authType === 'OAUTH2_CLIENT_CREDENTIALS') {
|
||||
<div class="cic-field">
|
||||
<label>Token URL</label>
|
||||
<input
|
||||
class="cic-mono"
|
||||
[(ngModel)]="form.tokenUrl"
|
||||
placeholder="https://auth.bureau.example/oauth/token"
|
||||
/>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Client id</label>
|
||||
<input [(ngModel)]="form.clientId" autocomplete="off" />
|
||||
</div>
|
||||
}
|
||||
@if (needsSecret(form.authType)) {
|
||||
<div class="cic-field">
|
||||
<label>{{ secretLabel(form.authType) }}</label>
|
||||
<input
|
||||
type="password"
|
||||
[(ngModel)]="form.secret"
|
||||
autocomplete="new-password"
|
||||
[placeholder]="editing.hasSecret ? '•••••• stored — leave blank to keep' : 'Enter to store (encrypted)'"
|
||||
/>
|
||||
@if (editing.hasSecret) {
|
||||
<label style="display: flex; gap: 6px; align-items: center; font-weight: 500; font-size: 12px">
|
||||
<input type="checkbox" [(ngModel)]="form.clearSecret" style="width: auto" /> Remove the stored
|
||||
credential
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<div class="cic-field">
|
||||
<label>Timeout (ms)</label>
|
||||
<input type="number" min="1000" max="300000" [(ngModel)]="form.timeoutMs" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Reuse a report for (days)</label>
|
||||
<input type="number" min="0" max="365" [(ngModel)]="form.reportValidityDays" />
|
||||
<span class="hint">0 = always pull a fresh report. Reuse avoids a second hard enquiry and its charge.</span>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Charge per enquiry (₹)</label>
|
||||
<input type="number" min="0" [(ngModel)]="form.enquiryCharge" />
|
||||
</div>
|
||||
<div class="cic-field" style="grid-column: 1 / -1">
|
||||
<label>Description</label>
|
||||
<input [(ngModel)]="form.description" />
|
||||
</div>
|
||||
<label style="display: flex; gap: 8px; align-items: center; font-size: 13px">
|
||||
<input type="checkbox" [(ngModel)]="form.isDefault" /> Default bureau on the enquiry screen
|
||||
</label>
|
||||
</div>
|
||||
<div class="foot">
|
||||
<button class="cic-btn" (click)="editing = null">Cancel</button>
|
||||
<button class="cic-btn primary" (click)="save()" [disabled]="saving">
|
||||
{{ saving ? 'Saving…' : 'Save' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* 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 { CommonModule } from '@angular/common';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { HasPermissionDirective } from 'app/directives/has-permission/has-permission.directive';
|
||||
import { CicBureau, CicCatalog, CicService, cicError } from '../cic.service';
|
||||
|
||||
/**
|
||||
* Which CICs the bank may enquire (whitelist), and how each is reached: environment, URL, member code,
|
||||
* authentication and credentials (stored encrypted, never shown back), timeouts, report reuse window and charge.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-cic-bureau-config',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
RouterModule,
|
||||
HasPermissionDirective
|
||||
],
|
||||
templateUrl: './cic-bureau-config.component.html',
|
||||
styleUrls: ['../cic-shared.scss']
|
||||
})
|
||||
export class CicBureauConfigComponent implements OnInit {
|
||||
private cic = inject(CicService);
|
||||
|
||||
catalog: CicCatalog | null = null;
|
||||
bureaus: CicBureau[] = [];
|
||||
loading = false;
|
||||
error: string | null = null;
|
||||
info: string | null = null;
|
||||
|
||||
editing: CicBureau | null = null;
|
||||
form: any = {};
|
||||
saving = false;
|
||||
testing: number | null = null;
|
||||
toggling: number | null = null;
|
||||
|
||||
readonly authLabels: Record<string, string> = {
|
||||
NONE: 'None (IP whitelisting / mutual TLS)',
|
||||
BASIC: 'Basic (user id + password)',
|
||||
API_KEY: 'API key in a header',
|
||||
BEARER_TOKEN: 'Static bearer token',
|
||||
OAUTH2_CLIENT_CREDENTIALS: 'OAuth2 client credentials'
|
||||
};
|
||||
|
||||
ngOnInit(): void {
|
||||
this.cic.catalog().subscribe({ next: (c) => (this.catalog = c), error: (e) => (this.error = cicError(e)) });
|
||||
this.load();
|
||||
}
|
||||
|
||||
load(): void {
|
||||
this.loading = true;
|
||||
this.cic.bureaus().subscribe({
|
||||
next: (b) => {
|
||||
this.bureaus = b;
|
||||
this.loading = false;
|
||||
},
|
||||
error: (e) => {
|
||||
this.error = cicError(e, 'Could not load the bureaus.');
|
||||
this.loading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toggle(b: CicBureau, event: Event): void {
|
||||
const target = event.target as HTMLInputElement;
|
||||
const want = target.checked;
|
||||
target.checked = b.whitelisted; // reflect the server's answer, not the click
|
||||
this.error = null;
|
||||
this.info = null;
|
||||
this.toggling = b.id;
|
||||
this.cic.setWhitelisted(b.id, want).subscribe({
|
||||
next: (u) => {
|
||||
this.toggling = null;
|
||||
this.replace(u);
|
||||
this.info = `${u.code} is now ${u.whitelisted ? 'whitelisted — enquiries can be run against it' : 'not whitelisted'}.`;
|
||||
},
|
||||
error: (e) => {
|
||||
this.toggling = null;
|
||||
this.error = cicError(e, 'Could not change the whitelist.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
edit(b: CicBureau): void {
|
||||
this.editing = b;
|
||||
this.info = null;
|
||||
this.error = null;
|
||||
this.form = {
|
||||
name: b.name,
|
||||
description: b.description ?? '',
|
||||
environment: b.environment,
|
||||
baseUrl: b.baseUrl ?? '',
|
||||
memberCode: b.memberCode ?? '',
|
||||
authType: b.authType,
|
||||
username: b.username ?? '',
|
||||
apiKeyHeader: b.apiKeyHeader ?? 'X-API-KEY',
|
||||
secret: '',
|
||||
clearSecret: false,
|
||||
tokenUrl: b.tokenUrl ?? '',
|
||||
clientId: b.clientId ?? '',
|
||||
timeoutMs: b.timeoutMs,
|
||||
reportValidityDays: b.reportValidityDays,
|
||||
enquiryCharge: b.enquiryCharge,
|
||||
isDefault: b.isDefault
|
||||
};
|
||||
}
|
||||
|
||||
save(): void {
|
||||
if (!this.editing) return;
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
const body = { ...this.form };
|
||||
if (!body.secret) delete body.secret;
|
||||
this.cic.updateBureau(this.editing.id, body).subscribe({
|
||||
next: (u) => {
|
||||
this.saving = false;
|
||||
this.editing = null;
|
||||
this.info = `${u.code} configuration saved.`;
|
||||
this.load();
|
||||
},
|
||||
error: (e) => {
|
||||
this.saving = false;
|
||||
this.error = cicError(e, 'Could not save the configuration.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
test(b: CicBureau): void {
|
||||
this.testing = b.id;
|
||||
this.error = null;
|
||||
this.info = null;
|
||||
this.cic.testConnection(b.id).subscribe({
|
||||
next: (r) => {
|
||||
this.testing = null;
|
||||
if (r.status === 'OK') this.info = `${b.code}: ${r.message}`;
|
||||
else this.error = `${b.code}: ${r.message}`;
|
||||
this.load();
|
||||
},
|
||||
error: (e) => {
|
||||
this.testing = null;
|
||||
this.error = cicError(e, 'Connection test failed.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
needsSecret(auth: string): boolean {
|
||||
return auth !== 'NONE';
|
||||
}
|
||||
|
||||
secretLabel(auth: string): string {
|
||||
return auth === 'BASIC'
|
||||
? 'Password'
|
||||
: auth === 'API_KEY'
|
||||
? 'API key'
|
||||
: auth === 'BEARER_TOKEN'
|
||||
? 'Bearer token'
|
||||
: 'Client secret';
|
||||
}
|
||||
|
||||
envTone(env: string): string {
|
||||
return env === 'PRODUCTION' ? 'good' : env === 'UAT' ? 'ok' : 'warn';
|
||||
}
|
||||
|
||||
private replace(u: CicBureau): void {
|
||||
this.bureaus = this.bureaus.map((b) => (b.id === u.id ? u : b));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
<!--
|
||||
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="cic-page">
|
||||
<div class="cic-head">
|
||||
<div>
|
||||
<h1>Consent Register</h1>
|
||||
<p>Borrowers' consents to pull their credit report. No enquiry runs without an active, unexpired consent.</p>
|
||||
</div>
|
||||
<div class="cic-actions">
|
||||
<button class="cic-btn primary" (click)="startCapture()" *mifosxHasPermission="'CREATE_CICCONSENT'">
|
||||
Record Consent
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (error) {
|
||||
<div class="cic-alert error">{{ error }}</div>
|
||||
}
|
||||
@if (info) {
|
||||
<div class="cic-alert success">{{ info }}</div>
|
||||
}
|
||||
|
||||
@if (capturing) {
|
||||
<div class="cic-card">
|
||||
<h2>Record a consent <button class="cic-btn sm" (click)="capturing = false">Close</button></h2>
|
||||
<div class="cic-grid cols-3">
|
||||
<div class="cic-field">
|
||||
<label>Customer *</label>
|
||||
<div style="display: flex; gap: 8px; align-items: center">
|
||||
<input
|
||||
[value]="formClient ? formClient.name + ' (#' + formClient.id + ')' : ''"
|
||||
placeholder="Search a customer"
|
||||
readonly
|
||||
/>
|
||||
<button class="cic-btn sm" (click)="pickClient()">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Applies to</label>
|
||||
<select [(ngModel)]="form.bureauId">
|
||||
<option value="">Any credit bureau</option>
|
||||
@for (b of bureaus; track b.id) {
|
||||
<option [value]="b.id">Only {{ b.code }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Purpose</label>
|
||||
<select [(ngModel)]="form.purpose">
|
||||
@for (p of purposes; track p.code) {
|
||||
<option [value]="p.code">{{ p.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Consent mode</label>
|
||||
<select [(ngModel)]="form.consentMode">
|
||||
<option value="SIGNED_FORM">Signed consent form</option>
|
||||
<option value="OTP">OTP verified</option>
|
||||
<option value="DIGITAL_ACCEPTANCE">Digital acceptance</option>
|
||||
</select>
|
||||
</div>
|
||||
@if (form.consentMode === 'OTP') {
|
||||
<div class="cic-field">
|
||||
<label>OTP / transaction reference *</label>
|
||||
<input [(ngModel)]="form.otpReference" />
|
||||
</div>
|
||||
} @else {
|
||||
<div class="cic-field">
|
||||
<label>Form / document reference {{ form.consentMode === 'SIGNED_FORM' ? '*' : '' }}</label>
|
||||
<input [(ngModel)]="form.documentRef" />
|
||||
</div>
|
||||
}
|
||||
<div class="cic-field">
|
||||
<label>Valid for (days)</label>
|
||||
<input type="number" min="1" max="365" [(ngModel)]="form.validityDays" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Loan application no. (optional)</label>
|
||||
<input [(ngModel)]="form.applicationNo" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="cic-field" style="margin-top: 12px">
|
||||
<label>Consent declaration</label>
|
||||
<textarea rows="4" [(ngModel)]="form.consentText"></textarea>
|
||||
</div>
|
||||
<label style="display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 12px 0">
|
||||
<input type="checkbox" [(ngModel)]="form.customerDeclarationAccepted" style="margin-top: 3px" />
|
||||
<span>The customer has read the declaration above and given consent in the selected mode.</span>
|
||||
</label>
|
||||
<button
|
||||
class="cic-btn primary"
|
||||
(click)="save()"
|
||||
[disabled]="saving || !formClient || !form.customerDeclarationAccepted"
|
||||
>
|
||||
{{ saving ? 'Saving…' : 'Record Consent' }}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="cic-card">
|
||||
<div class="cic-grid cols-3" style="align-items: end; margin-bottom: 14px">
|
||||
<div class="cic-field">
|
||||
<label>Search</label>
|
||||
<input [(ngModel)]="filter.search" placeholder="Customer, consent ref or application" (keyup.enter)="apply()" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Status</label>
|
||||
<select [(ngModel)]="filter.status" (ngModelChange)="apply()">
|
||||
<option value="">All</option>
|
||||
<option value="ACTIVE">Active</option>
|
||||
<option value="EXPIRED">Expired</option>
|
||||
<option value="REVOKED">Revoked</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-actions">
|
||||
<button class="cic-btn" (click)="apply()">Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (loading) {
|
||||
<div class="cic-empty">Loading…</div>
|
||||
} @else if (!items.length) {
|
||||
<div class="cic-empty">No consent recorded yet.</div>
|
||||
} @else {
|
||||
<div class="cic-table-wrap">
|
||||
<table class="cic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Consent ref</th>
|
||||
<th>Customer</th>
|
||||
<th>Bureau</th>
|
||||
<th>Purpose</th>
|
||||
<th>Mode</th>
|
||||
<th>Valid</th>
|
||||
<th>Status</th>
|
||||
<th>Captured by</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (c of items; track c.id) {
|
||||
<tr>
|
||||
<td class="cic-mono">{{ c.consentRef }}</td>
|
||||
<td>
|
||||
{{ c.clientName }} <span class="muted">#{{ c.clientId }}</span>
|
||||
@if (c.applicationNo) {
|
||||
<div class="muted" style="font-size: 11px">App {{ c.applicationNo }}</div>
|
||||
}
|
||||
</td>
|
||||
<td>{{ c.bureauCode }}</td>
|
||||
<td>{{ c.purpose }}</td>
|
||||
<td>{{ c.consentMode }}</td>
|
||||
<td class="muted">{{ c.validFrom }} → {{ c.validUntil }}</td>
|
||||
<td>
|
||||
<span class="cic-badge" [class]="'cic-badge ' + tone(c.status)">{{ c.status }}</span>
|
||||
</td>
|
||||
<td>
|
||||
{{ c.capturedByName }}
|
||||
<div class="muted" style="font-size: 11px">{{ c.capturedOn | slice: 0 : 16 }}</div>
|
||||
</td>
|
||||
<td style="white-space: nowrap">
|
||||
<button class="cic-btn sm" (click)="viewing = c">View</button>
|
||||
@if (c.status === 'ACTIVE') {
|
||||
<button
|
||||
class="cic-btn sm danger"
|
||||
(click)="revoking = c; revokeReason = ''"
|
||||
*mifosxHasPermission="'REVOKE_CICCONSENT'"
|
||||
>
|
||||
Revoke
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="cic-pager">
|
||||
<span>{{ offset + 1 }}–{{ offset + items.length }} of {{ total }}</span>
|
||||
<div class="cic-actions">
|
||||
<button class="cic-btn sm" (click)="page(-1)" [disabled]="offset === 0">Previous</button>
|
||||
<button class="cic-btn sm" (click)="page(1)" [disabled]="offset + limit >= total">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (revoking) {
|
||||
<div class="cic-modal-backdrop" (click)="revoking = null">
|
||||
<div class="cic-modal" (click)="$event.stopPropagation()">
|
||||
<h3>Revoke consent {{ revoking.consentRef }}</h3>
|
||||
<p class="muted" style="font-size: 13px">
|
||||
{{ revoking.clientName }} — no further enquiry can run under this consent. Enquiries already made are not
|
||||
affected.
|
||||
</p>
|
||||
<div class="cic-field">
|
||||
<label>Reason *</label>
|
||||
<textarea
|
||||
rows="3"
|
||||
[(ngModel)]="revokeReason"
|
||||
placeholder="e.g. customer withdrew consent in writing"
|
||||
></textarea>
|
||||
</div>
|
||||
<div class="foot">
|
||||
<button class="cic-btn" (click)="revoking = null">Cancel</button>
|
||||
<button class="cic-btn danger" (click)="confirmRevoke()" [disabled]="!revokeReason.trim()">Revoke</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (viewing) {
|
||||
<div class="cic-modal-backdrop" (click)="viewing = null">
|
||||
<div class="cic-modal" (click)="$event.stopPropagation()">
|
||||
<h3>Consent {{ viewing.consentRef }}</h3>
|
||||
<dl class="cic-kv">
|
||||
<dt>Customer</dt>
|
||||
<dd>{{ viewing.clientName }} (#{{ viewing.clientId }})</dd>
|
||||
<dt>Bureau</dt>
|
||||
<dd>{{ viewing.bureauCode }}</dd>
|
||||
<dt>Purpose / mode</dt>
|
||||
<dd>{{ viewing.purpose }} · {{ viewing.consentMode }}</dd>
|
||||
<dt>Document / OTP ref</dt>
|
||||
<dd>{{ viewing.documentRef || viewing.otpReference || '—' }}</dd>
|
||||
<dt>Valid</dt>
|
||||
<dd>{{ viewing.validFrom }} → {{ viewing.validUntil }}</dd>
|
||||
<dt>Status</dt>
|
||||
<dd>{{ viewing.status }}{{ viewing.revokedReason ? ' — ' + viewing.revokedReason : '' }}</dd>
|
||||
<dt>Captured</dt>
|
||||
<dd>
|
||||
{{ viewing.capturedOn | slice: 0 : 19 }} by {{ viewing.capturedByName }} ({{
|
||||
viewing.ipAddress || 'IP n/a'
|
||||
}})
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="cic-field" style="margin-top: 12px">
|
||||
<label>Declaration</label>
|
||||
<div style="font-size: 13px; background: #f8fafc; border-radius: 8px; padding: 10px">
|
||||
{{ viewing.consentText }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="foot"><button class="cic-btn" (click)="viewing = null">Close</button></div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
* 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 { CommonModule } from '@angular/common';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { HasPermissionDirective } from 'app/directives/has-permission/has-permission.directive';
|
||||
import {
|
||||
CustomerSearchDialogComponent,
|
||||
CustomerSearchResult
|
||||
} from 'app/shared/customer-search-dialog/customer-search-dialog.component';
|
||||
import { CicBureau, CicCatalog, CicConsent, CicService, cicError } from '../cic.service';
|
||||
|
||||
/** Register of borrower consents to a credit bureau pull: capture, view, revoke. */
|
||||
@Component({
|
||||
selector: 'mifosx-cic-consents',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
RouterModule,
|
||||
MatDialogModule,
|
||||
HasPermissionDirective
|
||||
],
|
||||
templateUrl: './cic-consents.component.html',
|
||||
styleUrls: ['../cic-shared.scss']
|
||||
})
|
||||
export class CicConsentsComponent implements OnInit {
|
||||
private cic = inject(CicService);
|
||||
private dialog = inject(MatDialog);
|
||||
|
||||
catalog: CicCatalog | null = null;
|
||||
bureaus: CicBureau[] = [];
|
||||
purposes: { code: string; label: string }[] = [];
|
||||
|
||||
items: CicConsent[] = [];
|
||||
total = 0;
|
||||
loading = false;
|
||||
error: string | null = null;
|
||||
info: string | null = null;
|
||||
|
||||
filter = { search: '', status: '' };
|
||||
offset = 0;
|
||||
readonly limit = 20;
|
||||
|
||||
// capture
|
||||
capturing = false;
|
||||
saving = false;
|
||||
form = this.blankForm();
|
||||
formClient: { id: number; name: string } | null = null;
|
||||
|
||||
// revoke / view
|
||||
revoking: CicConsent | null = null;
|
||||
revokeReason = '';
|
||||
viewing: CicConsent | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.cic.catalog().subscribe({
|
||||
next: (c) => {
|
||||
this.catalog = c;
|
||||
this.purposes = Object.entries(c.purposes).map(
|
||||
([
|
||||
code,
|
||||
label
|
||||
]) => ({ code, label })
|
||||
);
|
||||
this.form.consentText = c.defaultConsentText;
|
||||
},
|
||||
error: (e) => (this.error = cicError(e))
|
||||
});
|
||||
this.cic.bureaus().subscribe({ next: (b) => (this.bureaus = b), error: () => (this.bureaus = []) });
|
||||
this.load();
|
||||
}
|
||||
|
||||
private blankForm() {
|
||||
return {
|
||||
bureauId: '' as any,
|
||||
applicationNo: '',
|
||||
purpose: 'NEW_LOAN',
|
||||
consentMode: 'SIGNED_FORM',
|
||||
documentRef: '',
|
||||
otpReference: '',
|
||||
validityDays: 30,
|
||||
consentText: this.catalog?.defaultConsentText ?? '',
|
||||
customerDeclarationAccepted: false
|
||||
};
|
||||
}
|
||||
|
||||
load(): void {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
this.cic.consents({ ...this.filter, offset: this.offset, limit: this.limit }).subscribe({
|
||||
next: (p) => {
|
||||
this.items = p.pageItems;
|
||||
this.total = p.totalFilteredRecords;
|
||||
this.loading = false;
|
||||
},
|
||||
error: (e) => {
|
||||
this.error = cicError(e, 'Could not load consents.');
|
||||
this.loading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
apply(): void {
|
||||
this.offset = 0;
|
||||
this.load();
|
||||
}
|
||||
|
||||
page(delta: number): void {
|
||||
this.offset = Math.max(0, this.offset + delta * this.limit);
|
||||
this.load();
|
||||
}
|
||||
|
||||
tone(status: string): string {
|
||||
return status === 'ACTIVE' ? 'good' : status === 'EXPIRED' ? 'warn' : 'bad';
|
||||
}
|
||||
|
||||
startCapture(): void {
|
||||
this.capturing = true;
|
||||
this.form = this.blankForm();
|
||||
this.formClient = null;
|
||||
this.info = null;
|
||||
}
|
||||
|
||||
pickClient(): void {
|
||||
this.dialog
|
||||
.open(CustomerSearchDialogComponent, { width: '960px', maxWidth: '95vw', data: { requireAccount: false } })
|
||||
.afterClosed()
|
||||
.subscribe((r: CustomerSearchResult | undefined) => {
|
||||
if (r?.clientId) this.formClient = { id: r.clientId, name: r.displayName };
|
||||
});
|
||||
}
|
||||
|
||||
save(): void {
|
||||
if (!this.formClient) return;
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
this.cic
|
||||
.createConsent({
|
||||
clientId: this.formClient.id,
|
||||
bureauId: this.form.bureauId ? Number(this.form.bureauId) : null,
|
||||
applicationNo: this.form.applicationNo || null,
|
||||
purpose: this.form.purpose,
|
||||
consentMode: this.form.consentMode,
|
||||
documentRef: this.form.documentRef || null,
|
||||
otpReference: this.form.otpReference || null,
|
||||
validityDays: this.form.validityDays,
|
||||
consentText: this.form.consentText,
|
||||
customerDeclarationAccepted: this.form.customerDeclarationAccepted
|
||||
})
|
||||
.subscribe({
|
||||
next: (c) => {
|
||||
this.saving = false;
|
||||
this.capturing = false;
|
||||
this.info = `Consent ${c.consentRef} recorded for ${c.clientName}, valid until ${c.validUntil}.`;
|
||||
this.apply();
|
||||
},
|
||||
error: (e) => {
|
||||
this.saving = false;
|
||||
this.error = cicError(e, 'Could not record the consent.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
confirmRevoke(): void {
|
||||
if (!this.revoking) return;
|
||||
const target = this.revoking;
|
||||
this.cic.revokeConsent(target.id, this.revokeReason).subscribe({
|
||||
next: () => {
|
||||
this.info = `Consent ${target.consentRef} revoked.`;
|
||||
this.revoking = null;
|
||||
this.revokeReason = '';
|
||||
this.load();
|
||||
},
|
||||
error: (e) => (this.error = cicError(e, 'Could not revoke the consent.'))
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
<!--
|
||||
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="cic-page">
|
||||
<div class="cic-head">
|
||||
<div>
|
||||
<h1>Credit Bureau Dashboard</h1>
|
||||
<p>
|
||||
Enquiries to the Credit Information Companies (CIBIL, Experian, Equifax, CRIF High Mark) over the last 30 days.
|
||||
</p>
|
||||
</div>
|
||||
<div class="cic-actions">
|
||||
<button class="cic-btn" (click)="load()" [disabled]="loading">Refresh</button>
|
||||
<a class="cic-btn primary" routerLink="/credit-bureau/new-enquiry">New Enquiry</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (error) {
|
||||
<div class="cic-alert error">{{ error }}</div>
|
||||
}
|
||||
@if (loading && !data) {
|
||||
<div class="cic-card cic-empty">Loading…</div>
|
||||
}
|
||||
|
||||
@if (data) {
|
||||
@if (whitelistedCount === 0) {
|
||||
<div class="cic-alert warn">
|
||||
No credit bureau is whitelisted yet, so no enquiry can be run.
|
||||
<a routerLink="/credit-bureau/bureaus">Open CIC Whitelist & Configuration</a> to enable one.
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="cic-grid cols-4" style="margin-bottom: 16px">
|
||||
<div class="cic-stat">
|
||||
<div class="k">Enquiries today</div>
|
||||
<div class="v">{{ data.enquiriesToday }}</div>
|
||||
<div class="s">{{ data.enquiriesLast30Days }} in the last 30 days</div>
|
||||
</div>
|
||||
<div class="cic-stat">
|
||||
<div class="k">Success rate</div>
|
||||
<div class="v">{{ successRate }}%</div>
|
||||
<div class="s">{{ statusCount('FAILED') }} failed · {{ statusCount('NO_HIT') }} no-hit</div>
|
||||
</div>
|
||||
<div class="cic-stat">
|
||||
<div class="k">Average score</div>
|
||||
<div class="v" [class]="'tone-' + scoreBand(data.averageScoreLast30Days).tone">
|
||||
{{ data.averageScoreLast30Days ? (data.averageScoreLast30Days | number: '1.0-0') : '—' }}
|
||||
</div>
|
||||
<div class="s">{{ scoreBand(data.averageScoreLast30Days).label }}</div>
|
||||
</div>
|
||||
<div class="cic-stat">
|
||||
<div class="k">Active consents</div>
|
||||
<div class="v">{{ data.activeConsents }}</div>
|
||||
<div class="s">
|
||||
Charges ₹{{ data.chargesLast30Days | number: '1.0-2' }} · {{ statusCount('REUSED') }} reports reused
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cic-split">
|
||||
<div class="cic-card">
|
||||
<h2>
|
||||
Bureaus <span class="cic-card-sub">{{ whitelistedCount }} of {{ data.bureaus.length }} whitelisted</span>
|
||||
</h2>
|
||||
<div class="cic-table-wrap">
|
||||
<table class="cic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bureau</th>
|
||||
<th>Whitelisted</th>
|
||||
<th>Environment</th>
|
||||
<th class="num">Enquiries (30d)</th>
|
||||
<th class="num">Failed</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (b of data.bureaus; track b.id) {
|
||||
<tr>
|
||||
<td>
|
||||
<b>{{ b.code }}</b>
|
||||
@if (b.isDefault) {
|
||||
<span class="cic-badge brand">Default</span>
|
||||
}
|
||||
<div class="muted" style="font-size: 12px">{{ b.name }}</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="cic-badge" [class.good]="b.whitelisted">{{ b.whitelisted ? 'Yes' : 'No' }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
class="cic-badge"
|
||||
[class.warn]="b.environment === 'SIMULATOR'"
|
||||
[class.ok]="b.environment === 'UAT'"
|
||||
[class.good]="b.environment === 'PRODUCTION'"
|
||||
>{{ b.environment }}</span
|
||||
>
|
||||
</td>
|
||||
<td class="num">{{ b.enquiries }}</td>
|
||||
<td class="num" [class.tone-bad]="b.failed > 0">{{ b.failed }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cic-card">
|
||||
<h2>Score spread <span class="cic-card-sub">successful enquiries, 30 days</span></h2>
|
||||
@for (band of data.scoreBandsLast30Days; track band.label) {
|
||||
<div style="margin-bottom: 10px">
|
||||
<div style="display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px">
|
||||
<span>{{ band.label }}</span
|
||||
><b>{{ band.count }}</b>
|
||||
</div>
|
||||
<div class="cic-bar"><div [style.width.%]="(band.count / maxBand) * 100"></div></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cic-card">
|
||||
<h2>
|
||||
Recent enquiries
|
||||
<a class="cic-btn sm" routerLink="/credit-bureau/enquiries">View all</a>
|
||||
</h2>
|
||||
@if (!data.recent?.length) {
|
||||
<div class="cic-empty">No enquiry yet.</div>
|
||||
} @else {
|
||||
<div class="cic-table-wrap">
|
||||
<table class="cic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Reference</th>
|
||||
<th>Customer</th>
|
||||
<th>Bureau</th>
|
||||
<th>Status</th>
|
||||
<th class="num">Score</th>
|
||||
<th>By</th>
|
||||
<th>When</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (e of data.recent; track e.id) {
|
||||
<tr class="clickable" (click)="open(e.id)">
|
||||
<td class="cic-mono">{{ e.enquiryRef }}</td>
|
||||
<td>{{ e.clientName }}</td>
|
||||
<td>{{ e.bureauCode }}</td>
|
||||
<td>
|
||||
<span class="cic-badge" [class]="'cic-badge ' + statusTone(e.status)">{{ e.status }}</span>
|
||||
</td>
|
||||
<td class="num">
|
||||
<b [class]="'tone-' + scoreBand(e.score).tone">{{ e.score ?? '—' }}</b>
|
||||
</td>
|
||||
<td>{{ e.requestedByName }}</td>
|
||||
<td class="muted">{{ e.requestedOn | slice: 0 : 16 }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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 { CommonModule } from '@angular/common';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { Router, RouterModule } from '@angular/router';
|
||||
|
||||
import { CicService, cicError, cicScoreBand } from '../cic.service';
|
||||
|
||||
/** Credit Bureau overview: volumes, outcomes, score spread and the state of each bureau. */
|
||||
@Component({
|
||||
selector: 'mifosx-cic-dashboard',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule
|
||||
],
|
||||
templateUrl: './cic-dashboard.component.html',
|
||||
styleUrls: ['../cic-shared.scss']
|
||||
})
|
||||
export class CicDashboardComponent implements OnInit {
|
||||
private cic = inject(CicService);
|
||||
private router = inject(Router);
|
||||
|
||||
loading = false;
|
||||
error: string | null = null;
|
||||
data: any = null;
|
||||
|
||||
readonly scoreBand = cicScoreBand;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.load();
|
||||
}
|
||||
|
||||
load(): void {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
this.cic.dashboard().subscribe({
|
||||
next: (d) => {
|
||||
this.data = d;
|
||||
this.loading = false;
|
||||
},
|
||||
error: (e) => {
|
||||
this.error = cicError(e, 'Could not load the credit bureau dashboard.');
|
||||
this.loading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
statusCount(status: string): number {
|
||||
return Number(this.data?.byStatusLast30Days?.[status] ?? 0);
|
||||
}
|
||||
|
||||
get successRate(): number {
|
||||
const total = Number(this.data?.enquiriesLast30Days ?? 0);
|
||||
if (!total) return 0;
|
||||
return Math.round(((this.statusCount('SUCCESS') + this.statusCount('REUSED')) / total) * 100);
|
||||
}
|
||||
|
||||
get maxBand(): number {
|
||||
return Math.max(1, ...(this.data?.scoreBandsLast30Days ?? []).map((b: any) => Number(b.count)));
|
||||
}
|
||||
|
||||
get whitelistedCount(): number {
|
||||
return (this.data?.bureaus ?? []).filter((b: any) => b.whitelisted).length;
|
||||
}
|
||||
|
||||
statusTone(status: string): string {
|
||||
return status === 'SUCCESS' ? 'good' : status === 'REUSED' ? 'ok' : status === 'NO_HIT' ? 'warn' : 'bad';
|
||||
}
|
||||
|
||||
open(id: number): void {
|
||||
this.router.navigate([
|
||||
'/credit-bureau/enquiries',
|
||||
id
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<!--
|
||||
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="cic-page">
|
||||
<div class="cic-head">
|
||||
<div>
|
||||
<h1>Enquiry {{ enquiry?.enquiryRef ?? '' }}</h1>
|
||||
<p>{{ enquiry?.clientName }} · {{ enquiry?.bureauName ?? enquiry?.bureauCode }}</p>
|
||||
</div>
|
||||
<div class="cic-actions">
|
||||
<a class="cic-btn" routerLink="/credit-bureau/enquiries">Back to history</a>
|
||||
<button class="cic-btn" (click)="print()" [disabled]="!enquiry">Print</button>
|
||||
@if (enquiry) {
|
||||
<a
|
||||
class="cic-btn primary"
|
||||
routerLink="/credit-bureau/new-enquiry"
|
||||
[queryParams]="{
|
||||
clientId: enquiry.clientId,
|
||||
amount: enquiry.loanAmount,
|
||||
applicationNo: enquiry.applicationNo || null
|
||||
}"
|
||||
>Enquire again</a
|
||||
>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (error) {
|
||||
<div class="cic-alert error">{{ error }}</div>
|
||||
}
|
||||
|
||||
@if (enquiry) {
|
||||
<div class="cic-card">
|
||||
<dl class="cic-kv">
|
||||
<dt>Customer</dt>
|
||||
<dd>
|
||||
{{ enquiry.clientName }} <span class="muted">(client #{{ enquiry.clientId }})</span>
|
||||
</dd>
|
||||
<dt>Bureau / environment</dt>
|
||||
<dd>{{ enquiry.bureauCode }} · {{ enquiry.environment }}</dd>
|
||||
<dt>Type / purpose</dt>
|
||||
<dd>{{ enquiry.enquiryType }} · {{ enquiry.purpose }}</dd>
|
||||
<dt>Amount</dt>
|
||||
<dd>₹{{ enquiry.loanAmount | number: '1.0-2' }}</dd>
|
||||
<dt>Loan application</dt>
|
||||
<dd>{{ enquiry.applicationNo || '—' }}</dd>
|
||||
<dt>Consent</dt>
|
||||
<dd class="cic-mono">{{ enquiry.consentRef || '—' }}</dd>
|
||||
@if (enquiry.reusedFromRef) {
|
||||
<dt>Reused report of</dt>
|
||||
<dd class="cic-mono">{{ enquiry.reusedFromRef }}</dd>
|
||||
}
|
||||
<dt>Charge</dt>
|
||||
<dd>₹{{ enquiry.chargeAmount ?? 0 | number: '1.0-2' }}</dd>
|
||||
<dt>Requested</dt>
|
||||
<dd>{{ enquiry.requestedOn | slice: 0 : 19 }} by {{ enquiry.requestedByName }}</dd>
|
||||
<dt>Response time</dt>
|
||||
<dd>
|
||||
{{ enquiry.durationMs ?? 0 }} ms
|
||||
@if (enquiry.httpStatus) {
|
||||
· HTTP {{ enquiry.httpStatus }}
|
||||
}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="cic-tabs">
|
||||
<button [class.active]="tab === 'report'" (click)="tab = 'report'">Report</button>
|
||||
<button [class.active]="tab === 'request'" (click)="tab = 'request'">Request sent (masked)</button>
|
||||
<button [class.active]="tab === 'response'" (click)="tab = 'response'">Raw bureau response</button>
|
||||
</div>
|
||||
|
||||
@if (tab === 'report') {
|
||||
<mifosx-cic-report-view [enquiry]="enquiry"></mifosx-cic-report-view>
|
||||
}
|
||||
@if (tab === 'request') {
|
||||
<div class="cic-card">
|
||||
<h2>
|
||||
Request <span class="cic-card-sub">PAN, mobile and e-mail are masked; credentials are never stored</span>
|
||||
</h2>
|
||||
<pre class="cic-code">{{ pretty(enquiry.requestMasked) }}</pre>
|
||||
</div>
|
||||
}
|
||||
@if (tab === 'response') {
|
||||
<div class="cic-card">
|
||||
<h2>Raw response <span class="cic-card-sub">as returned by the bureau</span></h2>
|
||||
<pre class="cic-code">{{ pretty(enquiry.responseRaw) }}</pre>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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 { CommonModule } from '@angular/common';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { ActivatedRoute, RouterModule } from '@angular/router';
|
||||
|
||||
import { CicEnquiry, CicService, cicError } from '../cic.service';
|
||||
import { CicReportViewComponent } from '../cic-report-view/cic-report-view.component';
|
||||
|
||||
/** One enquiry in full: report, audit trail, the masked request sent and the bureau's raw response. */
|
||||
@Component({
|
||||
selector: 'mifosx-cic-enquiry-detail',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule,
|
||||
CicReportViewComponent
|
||||
],
|
||||
templateUrl: './cic-enquiry-detail.component.html',
|
||||
styleUrls: ['../cic-shared.scss']
|
||||
})
|
||||
export class CicEnquiryDetailComponent implements OnInit {
|
||||
private cic = inject(CicService);
|
||||
private route = inject(ActivatedRoute);
|
||||
|
||||
enquiry: CicEnquiry | null = null;
|
||||
error: string | null = null;
|
||||
tab: 'report' | 'request' | 'response' = 'report';
|
||||
|
||||
ngOnInit(): void {
|
||||
const id = Number(this.route.snapshot.paramMap.get('id'));
|
||||
this.cic.enquiry(id).subscribe({
|
||||
next: (e) => (this.enquiry = e),
|
||||
error: (e) => (this.error = cicError(e, 'Could not load the enquiry.'))
|
||||
});
|
||||
}
|
||||
|
||||
pretty(text?: string | null): string {
|
||||
if (!text) return '—';
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(text), null, 2);
|
||||
} catch {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
print(): void {
|
||||
window.print();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<!--
|
||||
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="cic-page">
|
||||
<div class="cic-head">
|
||||
<div>
|
||||
<h1>Enquiry History</h1>
|
||||
<p>Every credit bureau enquiry made from this bank, with its outcome and score.</p>
|
||||
</div>
|
||||
<div class="cic-actions">
|
||||
<button class="cic-btn" (click)="exportCsv()" [disabled]="!items.length">Export CSV</button>
|
||||
<a class="cic-btn primary" routerLink="/credit-bureau/new-enquiry">New Enquiry</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cic-card">
|
||||
<div class="cic-grid cols-4" style="align-items: end">
|
||||
<div class="cic-field">
|
||||
<label>Search</label>
|
||||
<input [(ngModel)]="filter.search" placeholder="Customer, reference or application" (keyup.enter)="apply()" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Bureau</label>
|
||||
<select [(ngModel)]="filter.bureauId">
|
||||
<option value="">All</option>
|
||||
@for (b of bureaus; track b.id) {
|
||||
<option [value]="b.id">{{ b.code }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Status</label>
|
||||
<select [(ngModel)]="filter.status">
|
||||
<option value="">All</option>
|
||||
@for (s of statuses; track s) {
|
||||
<option [value]="s">{{ s }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-grid cols-2" style="gap: 8px">
|
||||
<div class="cic-field">
|
||||
<label>From</label>
|
||||
<input type="date" [(ngModel)]="filter.fromDate" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>To</label>
|
||||
<input type="date" [(ngModel)]="filter.toDate" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cic-actions" style="margin-top: 12px">
|
||||
<button class="cic-btn primary" (click)="apply()">Apply</button>
|
||||
<button class="cic-btn" (click)="reset()">Reset</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (error) {
|
||||
<div class="cic-alert error">{{ error }}</div>
|
||||
}
|
||||
|
||||
<div class="cic-card">
|
||||
@if (loading) {
|
||||
<div class="cic-empty">Loading…</div>
|
||||
} @else if (!items.length) {
|
||||
<div class="cic-empty">No enquiry matches these filters.</div>
|
||||
} @else {
|
||||
<div class="cic-table-wrap">
|
||||
<table class="cic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Reference</th>
|
||||
<th>Customer</th>
|
||||
<th>Bureau</th>
|
||||
<th>Purpose</th>
|
||||
<th class="num">Amount</th>
|
||||
<th>Status</th>
|
||||
<th class="num">Score</th>
|
||||
<th>Requested by</th>
|
||||
<th>When</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (e of items; track e.id) {
|
||||
<tr class="clickable" (click)="open(e)">
|
||||
<td class="cic-mono">
|
||||
{{ e.enquiryRef }}
|
||||
@if (e.environment === 'SIMULATOR') {
|
||||
<span class="cic-badge warn" title="Answered by the simulator">SIM</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{{ e.clientName }}
|
||||
@if (e.applicationNo) {
|
||||
<div class="muted" style="font-size: 11px">App {{ e.applicationNo }}</div>
|
||||
}
|
||||
</td>
|
||||
<td>{{ e.bureauCode }}</td>
|
||||
<td>{{ e.purpose }}</td>
|
||||
<td class="num">₹{{ e.loanAmount | number: '1.0-0' }}</td>
|
||||
<td>
|
||||
<span class="cic-badge" [class]="'cic-badge ' + statusTone(e.status)">{{ e.status }}</span>
|
||||
</td>
|
||||
<td class="num">
|
||||
<b [class]="'tone-' + scoreBand(e.score).tone">{{ e.score ?? '—' }}</b>
|
||||
</td>
|
||||
<td>{{ e.requestedByName }}</td>
|
||||
<td class="muted">{{ e.requestedOn | slice: 0 : 16 }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="cic-pager">
|
||||
<span>{{ offset + 1 }}–{{ offset + items.length }} of {{ total }}</span>
|
||||
<div class="cic-actions">
|
||||
<button class="cic-btn sm" (click)="page(-1)" [disabled]="offset === 0">Previous</button>
|
||||
<button class="cic-btn sm" (click)="page(1)" [disabled]="offset + limit >= total">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* 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 { CommonModule } from '@angular/common';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { Router, RouterModule } from '@angular/router';
|
||||
|
||||
import { CicBureau, CicEnquiry, CicService, cicError, cicScoreBand } from '../cic.service';
|
||||
|
||||
/** Every bureau enquiry made, with filters, paging and CSV export. */
|
||||
@Component({
|
||||
selector: 'mifosx-cic-enquiry-history',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
RouterModule
|
||||
],
|
||||
templateUrl: './cic-enquiry-history.component.html',
|
||||
styleUrls: ['../cic-shared.scss']
|
||||
})
|
||||
export class CicEnquiryHistoryComponent implements OnInit {
|
||||
private cic = inject(CicService);
|
||||
private router = inject(Router);
|
||||
|
||||
bureaus: CicBureau[] = [];
|
||||
items: CicEnquiry[] = [];
|
||||
total = 0;
|
||||
loading = false;
|
||||
error: string | null = null;
|
||||
|
||||
filter = { search: '', bureauId: '', status: '', fromDate: '', toDate: '' };
|
||||
offset = 0;
|
||||
readonly limit = 20;
|
||||
readonly statuses = [
|
||||
'SUCCESS',
|
||||
'NO_HIT',
|
||||
'FAILED',
|
||||
'REUSED'
|
||||
];
|
||||
readonly scoreBand = cicScoreBand;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.cic.bureaus().subscribe({ next: (b) => (this.bureaus = b), error: () => (this.bureaus = []) });
|
||||
this.load();
|
||||
}
|
||||
|
||||
load(): void {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
this.cic.enquiries({ ...this.filter, offset: this.offset, limit: this.limit }).subscribe({
|
||||
next: (p) => {
|
||||
this.items = p.pageItems;
|
||||
this.total = p.totalFilteredRecords;
|
||||
this.loading = false;
|
||||
},
|
||||
error: (e) => {
|
||||
this.error = cicError(e, 'Could not load enquiries.');
|
||||
this.loading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
apply(): void {
|
||||
this.offset = 0;
|
||||
this.load();
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.filter = { search: '', bureauId: '', status: '', fromDate: '', toDate: '' };
|
||||
this.apply();
|
||||
}
|
||||
|
||||
page(delta: number): void {
|
||||
this.offset = Math.max(0, this.offset + delta * this.limit);
|
||||
this.load();
|
||||
}
|
||||
|
||||
open(e: CicEnquiry): void {
|
||||
this.router.navigate([
|
||||
'/credit-bureau/enquiries',
|
||||
e.id
|
||||
]);
|
||||
}
|
||||
|
||||
statusTone(status: string): string {
|
||||
return status === 'SUCCESS' ? 'good' : status === 'REUSED' ? 'ok' : status === 'NO_HIT' ? 'warn' : 'bad';
|
||||
}
|
||||
|
||||
/** CSV of the current page, for audit / MIS. */
|
||||
exportCsv(): void {
|
||||
const head = [
|
||||
'Reference',
|
||||
'Customer',
|
||||
'Client id',
|
||||
'Bureau',
|
||||
'Type',
|
||||
'Purpose',
|
||||
'Amount',
|
||||
'Status',
|
||||
'Score',
|
||||
'Requested by',
|
||||
'Requested on'
|
||||
];
|
||||
const rows = this.items.map((e) => [
|
||||
e.enquiryRef,
|
||||
e.clientName,
|
||||
e.clientId,
|
||||
e.bureauCode,
|
||||
e.enquiryType,
|
||||
e.purpose,
|
||||
e.loanAmount,
|
||||
e.status,
|
||||
e.score ?? '',
|
||||
e.requestedByName,
|
||||
e.requestedOn
|
||||
]);
|
||||
const csv = [
|
||||
head,
|
||||
...rows
|
||||
]
|
||||
.map((r) => r.map((v) => `"${String(v ?? '').replace(/"/g, '""')}"`).join(','))
|
||||
.join('\n');
|
||||
const url = URL.createObjectURL(new Blob([csv], { type: 'text/csv;charset=utf-8' }));
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `cic-enquiries-${new Date().toISOString().slice(0, 10)}.csv`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
<!--
|
||||
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="cic-page">
|
||||
<div class="cic-head">
|
||||
<div>
|
||||
<h1>New Credit Bureau Enquiry</h1>
|
||||
<p>
|
||||
Pull a customer's credit report from a whitelisted Credit Information Company, under their recorded consent.
|
||||
</p>
|
||||
</div>
|
||||
<div class="cic-actions">
|
||||
<a class="cic-btn" routerLink="/credit-bureau/enquiries">Enquiry History</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cic-steps">
|
||||
<div class="step" [class.done]="step > 1" [class.current]="step === 1"><i>1</i>Customer</div>
|
||||
<div class="step" [class.done]="step > 2" [class.current]="step === 2"><i>2</i>Consent</div>
|
||||
<div class="step" [class.done]="!!result" [class.current]="step === 3 && !result"><i>3</i>Enquiry</div>
|
||||
</div>
|
||||
|
||||
@if (error) {
|
||||
<div class="cic-alert error">{{ error }}</div>
|
||||
}
|
||||
@if (info) {
|
||||
<div class="cic-alert success">{{ info }}</div>
|
||||
}
|
||||
|
||||
<div class="cic-split">
|
||||
<div>
|
||||
<!-- 1. Customer -->
|
||||
<div class="cic-card">
|
||||
<h2>
|
||||
1. Customer
|
||||
@if (client) {
|
||||
<button class="cic-btn sm" (click)="clearClient()">Change</button>
|
||||
}
|
||||
</h2>
|
||||
@if (!client) {
|
||||
<div class="cic-grid cols-2" style="align-items: end">
|
||||
<div class="cic-field">
|
||||
<label>Client id</label>
|
||||
<input type="number" [(ngModel)]="clientIdInput" placeholder="e.g. 12" (keyup.enter)="loadClientById()" />
|
||||
</div>
|
||||
<div class="cic-actions">
|
||||
<button class="cic-btn" (click)="loadClientById()" [disabled]="!clientIdInput">Load</button>
|
||||
<button class="cic-btn primary" (click)="openSearch()">Search Customer</button>
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<div style="display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap">
|
||||
<div>
|
||||
<div style="font-size: 16px; font-weight: 700">{{ client.name }}</div>
|
||||
<div class="muted" style="font-size: 12px">
|
||||
Client #{{ client.id }}
|
||||
@if (client.office) {
|
||||
· {{ client.office }}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (loadingProfile) {
|
||||
<span class="muted">Loading…</span>
|
||||
}
|
||||
</div>
|
||||
@if (profile) {
|
||||
@if (missingEssentials.length) {
|
||||
<div class="cic-alert warn" style="margin-top: 12px">
|
||||
Missing on the customer record: <b>{{ missingEssentials.join(', ') }}</b
|
||||
>. Bureaus match a customer on these — update the customer's KYC before enquiring, or the enquiry will
|
||||
be refused.
|
||||
</div>
|
||||
}
|
||||
<details style="margin-top: 12px">
|
||||
<summary class="muted" style="cursor: pointer; font-size: 12px">Data that will be sent (masked)</summary>
|
||||
<dl class="cic-kv" style="margin-top: 10px">
|
||||
@for (r of dataRows(); track r.label) {
|
||||
<dt>{{ r.label }}</dt>
|
||||
<dd>{{ r.value ?? '—' }}</dd>
|
||||
}
|
||||
</dl>
|
||||
</details>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- 2. Consent -->
|
||||
@if (client && profile) {
|
||||
<div class="cic-card">
|
||||
<h2>2. Customer consent</h2>
|
||||
@if (profile.validConsent) {
|
||||
<div class="cic-alert success" style="margin-bottom: 8px">
|
||||
Consent <b>{{ profile.validConsent.consentRef }}</b> ({{ profile.validConsent.consentMode }}) on record,
|
||||
valid until <b>{{ profile.validConsent.validUntil }}</b
|
||||
>.
|
||||
</div>
|
||||
@if (!showConsentForm) {
|
||||
<button class="cic-btn sm" (click)="showConsentForm = true">Record a new consent</button>
|
||||
}
|
||||
} @else {
|
||||
<div class="cic-alert warn">
|
||||
No valid consent for this customer{{ selectedBureau ? ' and ' + selectedBureau.code : '' }}. RBI requires
|
||||
the borrower's consent before a credit report is pulled — record it below.
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (showConsentForm) {
|
||||
<div class="cic-grid cols-2">
|
||||
<div class="cic-field">
|
||||
<label>Consent mode</label>
|
||||
<select [(ngModel)]="consent.consentMode">
|
||||
<option value="SIGNED_FORM">Signed consent form</option>
|
||||
<option value="OTP">OTP verified</option>
|
||||
<option value="DIGITAL_ACCEPTANCE">Digital acceptance</option>
|
||||
</select>
|
||||
</div>
|
||||
@if (consent.consentMode === 'SIGNED_FORM') {
|
||||
<div class="cic-field">
|
||||
<label>Form / document reference *</label>
|
||||
<input [(ngModel)]="consent.documentRef" placeholder="Form no. or uploaded document name" />
|
||||
</div>
|
||||
} @else if (consent.consentMode === 'OTP') {
|
||||
<div class="cic-field">
|
||||
<label>OTP / transaction reference *</label>
|
||||
<input [(ngModel)]="consent.otpReference" placeholder="OTP log or transaction id" />
|
||||
</div>
|
||||
} @else {
|
||||
<div class="cic-field">
|
||||
<label>Reference (optional)</label>
|
||||
<input [(ngModel)]="consent.documentRef" placeholder="Channel / session reference" />
|
||||
</div>
|
||||
}
|
||||
<div class="cic-field">
|
||||
<label>Valid for (days)</label>
|
||||
<input type="number" min="1" max="365" [(ngModel)]="consent.validityDays" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Applies to</label>
|
||||
<select [(ngModel)]="consent.bureauScope">
|
||||
<option value="ANY">Any credit bureau</option>
|
||||
<option value="THIS" [disabled]="!selectedBureau">
|
||||
Only {{ selectedBureau?.code ?? 'the selected bureau' }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cic-field" style="margin-top: 12px">
|
||||
<label>Consent declaration</label>
|
||||
<textarea [(ngModel)]="consent.consentText" rows="4"></textarea>
|
||||
</div>
|
||||
<label style="display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 12px 0">
|
||||
<input type="checkbox" [(ngModel)]="consent.customerDeclarationAccepted" style="margin-top: 3px" />
|
||||
<span>The customer has read the declaration above and given consent in the selected mode.</span>
|
||||
</label>
|
||||
<div class="cic-actions">
|
||||
<button
|
||||
class="cic-btn primary"
|
||||
(click)="saveConsent()"
|
||||
[disabled]="savingConsent || !consent.customerDeclarationAccepted"
|
||||
>
|
||||
{{ savingConsent ? 'Saving…' : 'Record Consent' }}
|
||||
</button>
|
||||
@if (profile.validConsent) {
|
||||
<button class="cic-btn" (click)="showConsentForm = false">Cancel</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- 3. Enquiry -->
|
||||
@if (client && profile) {
|
||||
<div class="cic-card">
|
||||
<h2>3. Enquiry</h2>
|
||||
<div class="cic-grid cols-2">
|
||||
<div class="cic-field">
|
||||
<label>Credit bureau (whitelisted)</label>
|
||||
<select [(ngModel)]="bureauId" (ngModelChange)="onBureauChange()">
|
||||
@for (b of bureaus; track b.id) {
|
||||
<option [ngValue]="b.id">
|
||||
{{ b.code }} — {{ b.name }}{{ b.environment === 'SIMULATOR' ? ' (simulator)' : '' }}
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
@if (selectedBureau) {
|
||||
<span class="hint">
|
||||
{{ selectedBureau.environment }} · reuses a report up to {{ selectedBureau.reportValidityDays }} days
|
||||
old · charge ₹{{ selectedBureau.enquiryCharge | number: '1.0-2' }}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Enquiry type</label>
|
||||
<select [(ngModel)]="enquiryType">
|
||||
@for (t of catalog?.endpointTypes ?? []; track t) {
|
||||
<option [value]="t">
|
||||
{{ t === 'CONSUMER_ENQUIRY' ? 'Consumer (individual)' : 'Commercial (business)' }}
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Purpose</label>
|
||||
<select [(ngModel)]="purpose">
|
||||
@for (p of purposes; track p.code) {
|
||||
<option [value]="p.code">{{ p.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Loan / credit amount (₹) *</label>
|
||||
<input type="number" min="1" [(ngModel)]="loanAmount" placeholder="e.g. 500000" />
|
||||
</div>
|
||||
<div class="cic-field">
|
||||
<label>Loan application no. (optional)</label>
|
||||
<input [(ngModel)]="applicationNo" placeholder="Links the enquiry to an application" />
|
||||
</div>
|
||||
<div class="cic-field" style="justify-content: flex-end">
|
||||
<label style="display: flex; gap: 8px; align-items: center; font-weight: 500">
|
||||
<input type="checkbox" [(ngModel)]="forceFresh" style="width: auto" />
|
||||
Pull a fresh report (don't reuse a recent one)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cic-actions" style="margin-top: 14px">
|
||||
<button
|
||||
class="cic-btn primary"
|
||||
(click)="runEnquiry()"
|
||||
[disabled]="running || !bureauId || !loanAmount || !profile.validConsent"
|
||||
>
|
||||
{{ running ? 'Contacting bureau…' : 'Pull Credit Report' }}
|
||||
</button>
|
||||
@if (!profile.validConsent) {
|
||||
<span class="muted" style="font-size: 12px">Record the customer's consent first.</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Result / recent -->
|
||||
<div>
|
||||
@if (result) {
|
||||
<div class="cic-card" style="padding-bottom: 6px">
|
||||
<h2>
|
||||
Result
|
||||
<a class="cic-btn sm" [routerLink]="['/credit-bureau/enquiries', result.id]">Full details</a>
|
||||
</h2>
|
||||
</div>
|
||||
<mifosx-cic-report-view [enquiry]="result"></mifosx-cic-report-view>
|
||||
} @else if (profile?.recentEnquiries?.length) {
|
||||
<div class="cic-card">
|
||||
<h2>Previous enquiries of this customer</h2>
|
||||
<div class="cic-table-wrap">
|
||||
<table class="cic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Reference</th>
|
||||
<th>Bureau</th>
|
||||
<th>Status</th>
|
||||
<th class="num">Score</th>
|
||||
<th>When</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (e of profile.recentEnquiries; track e.id) {
|
||||
<tr class="clickable" [routerLink]="['/credit-bureau/enquiries', e.id]">
|
||||
<td class="cic-mono">{{ e.enquiryRef }}</td>
|
||||
<td>{{ e.bureauCode }}</td>
|
||||
<td>
|
||||
<span class="cic-badge">{{ e.status }}</span>
|
||||
</td>
|
||||
<td class="num">{{ e.score ?? '—' }}</td>
|
||||
<td class="muted">{{ e.requestedOn | slice: 0 : 16 }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="cic-card cic-empty">
|
||||
The credit report appears here once the enquiry is run.
|
||||
<div style="margin-top: 8px; font-size: 12px">
|
||||
Bureaus in <b>SIMULATOR</b> mode answer with a realistic test report — no real bureau is contacted and no
|
||||
charge applies.
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,260 @@
|
||||
/**
|
||||
* 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 { CommonModule } from '@angular/common';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, RouterModule } from '@angular/router';
|
||||
|
||||
import {
|
||||
CustomerSearchDialogComponent,
|
||||
CustomerSearchResult
|
||||
} from 'app/shared/customer-search-dialog/customer-search-dialog.component';
|
||||
import { CicBureau, CicCatalog, CicEnquiry, CicService, cicError } from '../cic.service';
|
||||
import { CicReportViewComponent } from '../cic-report-view/cic-report-view.component';
|
||||
|
||||
/**
|
||||
* Pull a credit report: pick the customer, make sure their bureau consent is on record (capture it here if not),
|
||||
* choose a whitelisted bureau, purpose and amount, and run the enquiry.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-cic-new-enquiry',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
RouterModule,
|
||||
MatDialogModule,
|
||||
CicReportViewComponent
|
||||
],
|
||||
templateUrl: './cic-new-enquiry.component.html',
|
||||
styleUrls: ['../cic-shared.scss']
|
||||
})
|
||||
export class CicNewEnquiryComponent implements OnInit {
|
||||
private cic = inject(CicService);
|
||||
private dialog = inject(MatDialog);
|
||||
private route = inject(ActivatedRoute);
|
||||
|
||||
catalog: CicCatalog | null = null;
|
||||
bureaus: CicBureau[] = [];
|
||||
purposes: { code: string; label: string }[] = [];
|
||||
|
||||
clientIdInput: number | null = null;
|
||||
client: { id: number; name: string; mobile?: string | null; office?: string | null } | null = null;
|
||||
profile: any = null;
|
||||
loadingProfile = false;
|
||||
|
||||
bureauId: number | null = null;
|
||||
enquiryType = 'CONSUMER_ENQUIRY';
|
||||
purpose = 'NEW_LOAN';
|
||||
loanAmount: number | null = null;
|
||||
applicationNo = '';
|
||||
forceFresh = false;
|
||||
|
||||
showConsentForm = false;
|
||||
consent = {
|
||||
consentMode: 'SIGNED_FORM',
|
||||
documentRef: '',
|
||||
otpReference: '',
|
||||
validityDays: 30,
|
||||
bureauScope: 'ANY',
|
||||
customerDeclarationAccepted: false,
|
||||
consentText: ''
|
||||
};
|
||||
savingConsent = false;
|
||||
|
||||
running = false;
|
||||
result: CicEnquiry | null = null;
|
||||
error: string | null = null;
|
||||
info: string | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.cic.catalog().subscribe({
|
||||
next: (c) => {
|
||||
this.catalog = c;
|
||||
this.purposes = Object.entries(c.purposes).map(
|
||||
([
|
||||
code,
|
||||
label
|
||||
]) => ({ code, label })
|
||||
);
|
||||
this.consent.consentText = c.defaultConsentText;
|
||||
},
|
||||
error: (e) => (this.error = cicError(e))
|
||||
});
|
||||
this.cic.bureaus(true).subscribe({
|
||||
next: (b) => {
|
||||
this.bureaus = b;
|
||||
this.bureauId = (b.find((x) => x.isDefault) ?? b[0])?.id ?? null;
|
||||
if (!b.length) {
|
||||
this.error =
|
||||
'No credit bureau is whitelisted for this bank yet. Ask an administrator to whitelist one under CIC Configuration.';
|
||||
}
|
||||
this.reloadProfile();
|
||||
},
|
||||
error: (e) => (this.error = cicError(e))
|
||||
});
|
||||
// Deep link from another screen (e.g. a loan application): /credit-bureau/new-enquiry?clientId=..&amount=..&applicationNo=..
|
||||
const q = this.route.snapshot.queryParamMap;
|
||||
if (q.get('applicationNo')) this.applicationNo = q.get('applicationNo')!;
|
||||
if (q.get('amount')) this.loanAmount = Number(q.get('amount'));
|
||||
if (q.get('clientId')) {
|
||||
this.clientIdInput = Number(q.get('clientId'));
|
||||
this.loadClientById();
|
||||
}
|
||||
}
|
||||
|
||||
get selectedBureau(): CicBureau | undefined {
|
||||
return this.bureaus.find((b) => b.id === this.bureauId);
|
||||
}
|
||||
|
||||
get step(): number {
|
||||
if (!this.client) return 1;
|
||||
if (!this.profile?.validConsent) return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
/** Data the default mapping cannot work without; the server checks the real mapping on submit. */
|
||||
get missingEssentials(): string[] {
|
||||
const d = this.profile?.data ?? {};
|
||||
const missing: string[] = [];
|
||||
if (!d['client.pan']) missing.push('PAN');
|
||||
if (!d['client.dob']) missing.push('Date of birth');
|
||||
if (!d['client.firstName'] && !d['client.fullName']) missing.push('Name');
|
||||
return missing;
|
||||
}
|
||||
|
||||
openSearch(): void {
|
||||
this.dialog
|
||||
.open(CustomerSearchDialogComponent, { width: '960px', maxWidth: '95vw', data: { requireAccount: false } })
|
||||
.afterClosed()
|
||||
.subscribe((r: CustomerSearchResult | undefined) => {
|
||||
if (!r?.clientId) return;
|
||||
this.client = { id: r.clientId, name: r.displayName, mobile: r.mobileNo, office: r.officeName };
|
||||
this.clientIdInput = r.clientId;
|
||||
this.resetOutcome();
|
||||
this.reloadProfile();
|
||||
});
|
||||
}
|
||||
|
||||
loadClientById(): void {
|
||||
if (!this.clientIdInput) return;
|
||||
this.client = { id: Number(this.clientIdInput), name: `Client #${this.clientIdInput}` };
|
||||
this.resetOutcome();
|
||||
this.reloadProfile();
|
||||
}
|
||||
|
||||
reloadProfile(): void {
|
||||
if (!this.client) return;
|
||||
this.loadingProfile = true;
|
||||
this.cic.clientProfile(this.client.id, this.bureauId).subscribe({
|
||||
next: (p) => {
|
||||
this.profile = p;
|
||||
this.loadingProfile = false;
|
||||
const name = p?.data?.['client.fullName'];
|
||||
if (name && this.client) this.client.name = name;
|
||||
if (this.client && p?.data?.['client.branch']) this.client.office = p.data['client.branch'];
|
||||
this.showConsentForm = !p?.validConsent;
|
||||
},
|
||||
error: (e) => {
|
||||
this.error = cicError(e, 'Could not load the customer.');
|
||||
this.profile = null;
|
||||
this.client = null;
|
||||
this.loadingProfile = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onBureauChange(): void {
|
||||
this.resetOutcome();
|
||||
this.reloadProfile();
|
||||
}
|
||||
|
||||
saveConsent(): void {
|
||||
if (!this.client) return;
|
||||
this.error = null;
|
||||
this.savingConsent = true;
|
||||
this.cic
|
||||
.createConsent({
|
||||
clientId: this.client.id,
|
||||
bureauId: this.consent.bureauScope === 'THIS' ? this.bureauId : null,
|
||||
applicationNo: this.applicationNo || null,
|
||||
purpose: this.purpose,
|
||||
consentMode: this.consent.consentMode,
|
||||
documentRef: this.consent.documentRef || null,
|
||||
otpReference: this.consent.otpReference || null,
|
||||
validityDays: this.consent.validityDays,
|
||||
consentText: this.consent.consentText,
|
||||
customerDeclarationAccepted: this.consent.customerDeclarationAccepted
|
||||
})
|
||||
.subscribe({
|
||||
next: (c) => {
|
||||
this.savingConsent = false;
|
||||
this.info = `Consent ${c.consentRef} recorded, valid until ${c.validUntil}.`;
|
||||
this.consent.customerDeclarationAccepted = false;
|
||||
this.reloadProfile();
|
||||
},
|
||||
error: (e) => {
|
||||
this.savingConsent = false;
|
||||
this.error = cicError(e, 'Could not record the consent.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
runEnquiry(): void {
|
||||
if (!this.client || !this.bureauId) return;
|
||||
this.error = null;
|
||||
this.info = null;
|
||||
this.result = null;
|
||||
this.running = true;
|
||||
this.cic
|
||||
.enquire({
|
||||
clientId: this.client.id,
|
||||
bureauId: this.bureauId,
|
||||
enquiryType: this.enquiryType,
|
||||
purpose: this.purpose,
|
||||
loanAmount: this.loanAmount,
|
||||
applicationNo: this.applicationNo || null,
|
||||
consentId: this.profile?.validConsent?.id ?? null,
|
||||
forceFresh: this.forceFresh
|
||||
})
|
||||
.subscribe({
|
||||
next: (r) => {
|
||||
this.running = false;
|
||||
this.result = r;
|
||||
this.reloadProfile();
|
||||
},
|
||||
error: (e) => {
|
||||
this.running = false;
|
||||
this.error = cicError(e, 'The enquiry could not be run.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
clearClient(): void {
|
||||
this.client = null;
|
||||
this.profile = null;
|
||||
this.clientIdInput = null;
|
||||
this.resetOutcome();
|
||||
}
|
||||
|
||||
private resetOutcome(): void {
|
||||
this.result = null;
|
||||
this.error = null;
|
||||
this.info = null;
|
||||
}
|
||||
|
||||
dataRows(): { label: string; value: any }[] {
|
||||
const d = this.profile?.data ?? {};
|
||||
const fields = this.catalog?.cbsFields ?? {};
|
||||
return Object.keys(d)
|
||||
.filter((k) => !['client.id'].includes(k))
|
||||
.map((k) => ({ label: fields[k] ?? k, value: d[k] }));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<!--
|
||||
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/.
|
||||
-->
|
||||
|
||||
@if (enquiry.status === 'FAILED') {
|
||||
<div class="cic-alert error">
|
||||
<b>Enquiry failed.</b> {{ enquiry.errorMessage }}
|
||||
@if (enquiry.httpStatus) {
|
||||
<div class="muted">HTTP status {{ enquiry.httpStatus }}</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@if (enquiry.status === 'NO_HIT') {
|
||||
<div class="cic-alert warn"><b>No record found.</b> {{ enquiry.errorMessage }}</div>
|
||||
}
|
||||
@if (enquiry.status === 'REUSED') {
|
||||
<div class="cic-alert info">{{ enquiry.errorMessage }}</div>
|
||||
}
|
||||
|
||||
@if (enquiry.status === 'SUCCESS' || enquiry.status === 'REUSED') {
|
||||
<div class="cic-card">
|
||||
<div class="cic-score">
|
||||
<div class="ring" [style.background]="ringStyle">
|
||||
<div class="inner">
|
||||
<div>
|
||||
<b [class]="'tone-' + band.tone">{{ enquiry.score ?? '—' }}</b
|
||||
><small>{{ band.label }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="flex: 1; min-width: 0">
|
||||
<div style="display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px">
|
||||
<span class="cic-badge" [class]="'cic-badge ' + statusTone(enquiry.status)">{{ enquiry.status }}</span>
|
||||
<span class="cic-badge brand">{{ enquiry.bureauCode }}</span>
|
||||
@if (enquiry.environment === 'SIMULATOR') {
|
||||
<span class="cic-badge warn">SIMULATOR — not a real bureau report</span>
|
||||
}
|
||||
</div>
|
||||
<dl class="cic-kv">
|
||||
<dt>Report / control no.</dt>
|
||||
<dd class="cic-mono">{{ result.reportId ?? '—' }}</dd>
|
||||
<dt>Score model</dt>
|
||||
<dd>{{ result.scoreVersion ?? '—' }}</dd>
|
||||
<dt>Enquiry reference</dt>
|
||||
<dd class="cic-mono">{{ enquiry.enquiryRef }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cic-grid cols-4" style="margin-bottom: 16px">
|
||||
<div class="cic-stat">
|
||||
<div class="k">Accounts</div>
|
||||
<div class="v">{{ result.totalAccounts ?? '—' }}</div>
|
||||
<div class="s">{{ result.activeAccounts ?? 0 }} active</div>
|
||||
</div>
|
||||
<div class="cic-stat">
|
||||
<div class="k">Outstanding</div>
|
||||
<div class="v">₹{{ result.totalOutstanding ?? 0 | number: '1.0-0' }}</div>
|
||||
<div class="s">across active accounts</div>
|
||||
</div>
|
||||
<div class="cic-stat">
|
||||
<div class="k">Overdue</div>
|
||||
<div class="v" [class.tone-bad]="(result.totalOverdue ?? 0) > 0">
|
||||
₹{{ result.totalOverdue ?? 0 | number: '1.0-0' }}
|
||||
</div>
|
||||
<div class="s">
|
||||
{{ result.overdueAccounts ?? 0 }} account(s) · max DPD {{ result.maxDpd ?? 0 }}
|
||||
@if ((result.writtenOffAccounts ?? 0) > 0) {
|
||||
· <b class="tone-bad">{{ result.writtenOffAccounts }} written-off</b>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="cic-stat">
|
||||
<div class="k">Enquiries (6 months)</div>
|
||||
<div class="v" [class.tone-warn]="(result.enquiriesLast6Months ?? 0) > 4">
|
||||
{{ result.enquiriesLast6Months ?? '—' }}
|
||||
</div>
|
||||
<div class="s">credit hunger indicator</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (extraFields.length) {
|
||||
<div class="cic-card">
|
||||
<h2>Other mapped fields</h2>
|
||||
<dl class="cic-kv">
|
||||
@for (f of extraFields; track f.key) {
|
||||
<dt>{{ f.key }}</dt>
|
||||
<dd>{{ f.value ?? '—' }}</dd>
|
||||
}
|
||||
</dl>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="cic-card">
|
||||
<h2>
|
||||
Credit accounts <span class="cic-card-sub">{{ accounts.length }} reported</span>
|
||||
</h2>
|
||||
@if (!accounts.length) {
|
||||
<div class="cic-empty">The bureau reported no account (or the response mapping has no "accounts" field).</div>
|
||||
} @else {
|
||||
<div class="cic-table-wrap">
|
||||
<table class="cic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@for (k of keys(accounts[0]); track k) {
|
||||
<th>{{ k }}</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (a of accounts; track $index) {
|
||||
<tr>
|
||||
@for (k of keys(accounts[0]); track k) {
|
||||
<td>
|
||||
@if (k === 'status') {
|
||||
<span class="cic-badge" [class]="'cic-badge ' + accountTone(a)">{{ a[k] }}</span>
|
||||
} @else {
|
||||
{{ a[k] }}
|
||||
}
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="cic-card">
|
||||
<h2>
|
||||
Recent enquiries by other lenders <span class="cic-card-sub">{{ enquiries.length }}</span>
|
||||
</h2>
|
||||
@if (!enquiries.length) {
|
||||
<div class="cic-empty">No enquiry reported.</div>
|
||||
} @else {
|
||||
<div class="cic-table-wrap">
|
||||
<table class="cic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@for (k of keys(enquiries[0]); track k) {
|
||||
<th>{{ k }}</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (q of enquiries; track $index) {
|
||||
<tr>
|
||||
@for (k of keys(enquiries[0]); track k) {
|
||||
<td>{{ q[k] }}</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* 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 { CommonModule } from '@angular/common';
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { CicEnquiry, cicScoreBand } from '../cic.service';
|
||||
|
||||
/** The outcome of one enquiry: score, summary, accounts and enquiries, read from the normalised result. */
|
||||
@Component({
|
||||
selector: 'mifosx-cic-report-view',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule
|
||||
],
|
||||
templateUrl: './cic-report-view.component.html',
|
||||
styleUrls: ['../cic-shared.scss']
|
||||
})
|
||||
export class CicReportViewComponent {
|
||||
@Input({ required: true }) enquiry!: CicEnquiry;
|
||||
|
||||
get result(): any {
|
||||
return this.enquiry?.result ?? {};
|
||||
}
|
||||
|
||||
get band() {
|
||||
return cicScoreBand(this.enquiry?.score);
|
||||
}
|
||||
|
||||
/** Conic ring filled in proportion to the score on the 300-900 scale. */
|
||||
get ringStyle(): string {
|
||||
const score = this.enquiry?.score;
|
||||
const pct = score ? Math.max(0, Math.min(100, ((score - 300) / 600) * 100)) : 0;
|
||||
const colors: Record<string, string> = {
|
||||
good: '#047857',
|
||||
ok: '#0369a1',
|
||||
warn: '#b45309',
|
||||
bad: '#b91c1c',
|
||||
muted: '#94a3b8'
|
||||
};
|
||||
const color = colors[this.band.tone] ?? colors['muted'];
|
||||
return `conic-gradient(${color} ${pct}%, #e2e8f0 ${pct}% 100%)`;
|
||||
}
|
||||
|
||||
get accounts(): any[] {
|
||||
return Array.isArray(this.result.accounts) ? this.result.accounts : [];
|
||||
}
|
||||
|
||||
get enquiries(): any[] {
|
||||
return Array.isArray(this.result.enquiries) ? this.result.enquiries : [];
|
||||
}
|
||||
|
||||
/** Result fields beyond the standard ones a custom RESPONSE mapping may have added. */
|
||||
get extraFields(): { key: string; value: any }[] {
|
||||
const standard = new Set([
|
||||
'hit',
|
||||
'reportId',
|
||||
'score',
|
||||
'scoreVersion',
|
||||
'totalAccounts',
|
||||
'activeAccounts',
|
||||
'overdueAccounts',
|
||||
'writtenOffAccounts',
|
||||
'totalOutstanding',
|
||||
'totalOverdue',
|
||||
'enquiriesLast6Months',
|
||||
'maxDpd',
|
||||
'accounts',
|
||||
'enquiries'
|
||||
]);
|
||||
return Object.entries(this.result)
|
||||
.filter(
|
||||
([
|
||||
k,
|
||||
v
|
||||
]) => !standard.has(k) && (v === null || typeof v !== 'object')
|
||||
)
|
||||
.map(
|
||||
([
|
||||
key,
|
||||
value
|
||||
]) => ({ key, value })
|
||||
);
|
||||
}
|
||||
|
||||
statusTone(status: string): string {
|
||||
return status === 'SUCCESS' ? 'good' : status === 'REUSED' ? 'ok' : status === 'NO_HIT' ? 'warn' : 'bad';
|
||||
}
|
||||
|
||||
accountTone(a: any): string {
|
||||
const status = String(a?.status ?? '').toUpperCase();
|
||||
if (status.includes('WRITTEN') || status.includes('SETTLED')) return 'bad';
|
||||
if (Number(a?.dpd ?? 0) > 0 || Number(a?.amountOverdue ?? 0) > 0) return 'warn';
|
||||
if (status === 'CLOSED') return '';
|
||||
return 'good';
|
||||
}
|
||||
|
||||
keys(o: any): string[] {
|
||||
return o && typeof o === 'object' ? Object.keys(o) : [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,681 @@
|
||||
/**
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
/* Shared look for the Credit Bureau (CIC) screens. */
|
||||
|
||||
:host {
|
||||
--cic-ink: #0f172a;
|
||||
--cic-muted: #64748b;
|
||||
--cic-line: #e2e8f0;
|
||||
--cic-soft: #f8fafc;
|
||||
--cic-brand: #1d4ed8;
|
||||
--cic-brand-soft: #eff6ff;
|
||||
--cic-good: #047857;
|
||||
--cic-good-soft: #ecfdf5;
|
||||
--cic-ok: #0369a1;
|
||||
--cic-ok-soft: #f0f9ff;
|
||||
--cic-warn: #b45309;
|
||||
--cic-warn-soft: #fffbeb;
|
||||
--cic-bad: #b91c1c;
|
||||
--cic-bad-soft: #fef2f2;
|
||||
|
||||
display: block;
|
||||
color: var(--cic-ink);
|
||||
}
|
||||
|
||||
.cic-page {
|
||||
padding: 20px 24px 40px;
|
||||
max-width: 1440px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.cic-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 18px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0 0;
|
||||
color: var(--cic-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.cic-card {
|
||||
background: #fff;
|
||||
border: 1px solid var(--cic-line);
|
||||
border-radius: 12px;
|
||||
padding: 18px 20px;
|
||||
margin-bottom: 16px;
|
||||
box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
|
||||
|
||||
> h2,
|
||||
.cic-card-title {
|
||||
margin: 0 0 14px;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.cic-card-sub {
|
||||
color: var(--cic-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-grid {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
|
||||
&.cols-2 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
&.cols-3 {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
&.cols-4 {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
@media (width <= 960px) {
|
||||
&.cols-3,
|
||||
&.cols-4 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 640px) {
|
||||
&.cols-2,
|
||||
&.cols-3,
|
||||
&.cols-4 {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cic-split {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
|
||||
gap: 16px;
|
||||
|
||||
@media (width <= 1100px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-stat {
|
||||
background: #fff;
|
||||
border: 1px solid var(--cic-line);
|
||||
border-radius: 12px;
|
||||
padding: 14px 16px;
|
||||
|
||||
.k {
|
||||
font-size: 12px;
|
||||
color: var(--cic-muted);
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.v {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
margin-top: 6px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.s {
|
||||
font-size: 12px;
|
||||
color: var(--cic-muted);
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
|
||||
label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
.hint {
|
||||
font-size: 11px;
|
||||
color: var(--cic-muted);
|
||||
}
|
||||
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
width: 100%;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
padding: 8px 10px;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
background: #fff;
|
||||
color: var(--cic-ink);
|
||||
box-sizing: border-box;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--cic-brand);
|
||||
box-shadow: 0 0 0 3px rgb(29 78 216 / 12%);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background: var(--cic-soft);
|
||||
color: var(--cic-muted);
|
||||
}
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
min-height: 90px;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-mono,
|
||||
textarea.cic-mono {
|
||||
font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace !important;
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
.cic-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
border: 1px solid var(--cic-line);
|
||||
background: #fff;
|
||||
color: var(--cic-ink);
|
||||
border-radius: 8px;
|
||||
padding: 8px 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--cic-soft);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&.primary {
|
||||
background: var(--cic-brand);
|
||||
border-color: var(--cic-brand);
|
||||
color: #fff;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #1e40af;
|
||||
}
|
||||
}
|
||||
|
||||
&.danger {
|
||||
color: var(--cic-bad);
|
||||
border-color: #fecaca;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--cic-bad-soft);
|
||||
}
|
||||
}
|
||||
|
||||
&.sm {
|
||||
padding: 5px 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 2px 9px;
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
background: var(--cic-soft);
|
||||
color: var(--cic-muted);
|
||||
border: 1px solid var(--cic-line);
|
||||
white-space: nowrap;
|
||||
|
||||
&.good {
|
||||
background: var(--cic-good-soft);
|
||||
color: var(--cic-good);
|
||||
border-color: #a7f3d0;
|
||||
}
|
||||
|
||||
&.ok {
|
||||
background: var(--cic-ok-soft);
|
||||
color: var(--cic-ok);
|
||||
border-color: #bae6fd;
|
||||
}
|
||||
|
||||
&.warn {
|
||||
background: var(--cic-warn-soft);
|
||||
color: var(--cic-warn);
|
||||
border-color: #fde68a;
|
||||
}
|
||||
|
||||
&.bad {
|
||||
background: var(--cic-bad-soft);
|
||||
color: var(--cic-bad);
|
||||
border-color: #fecaca;
|
||||
}
|
||||
|
||||
&.brand {
|
||||
background: var(--cic-brand-soft);
|
||||
color: var(--cic-brand);
|
||||
border-color: #bfdbfe;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-alert {
|
||||
border-radius: 10px;
|
||||
padding: 10px 14px;
|
||||
font-size: 13px;
|
||||
margin-bottom: 14px;
|
||||
border: 1px solid;
|
||||
|
||||
&.error {
|
||||
background: var(--cic-bad-soft);
|
||||
border-color: #fecaca;
|
||||
color: var(--cic-bad);
|
||||
}
|
||||
|
||||
&.success {
|
||||
background: var(--cic-good-soft);
|
||||
border-color: #a7f3d0;
|
||||
color: var(--cic-good);
|
||||
}
|
||||
|
||||
&.info {
|
||||
background: var(--cic-brand-soft);
|
||||
border-color: #bfdbfe;
|
||||
color: #1e3a8a;
|
||||
}
|
||||
|
||||
&.warn {
|
||||
background: var(--cic-warn-soft);
|
||||
border-color: #fde68a;
|
||||
color: var(--cic-warn);
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 6px 0 0;
|
||||
padding-left: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-table-wrap {
|
||||
overflow-x: auto;
|
||||
border: 1px solid var(--cic-line);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.cic-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: var(--cic-muted);
|
||||
font-weight: 700;
|
||||
background: var(--cic-soft);
|
||||
padding: 9px 12px;
|
||||
border-bottom: 1px solid var(--cic-line);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 9px 12px;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
tr.clickable {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover td {
|
||||
background: #f8fafc;
|
||||
}
|
||||
}
|
||||
|
||||
.num {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
td input,
|
||||
td select {
|
||||
width: 100%;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 6px;
|
||||
padding: 5px 7px;
|
||||
font-size: 12px;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-empty {
|
||||
text-align: center;
|
||||
color: var(--cic-muted);
|
||||
padding: 28px 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.cic-pager {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 12px;
|
||||
font-size: 12px;
|
||||
color: var(--cic-muted);
|
||||
}
|
||||
|
||||
.cic-switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 40px;
|
||||
height: 22px;
|
||||
flex: none;
|
||||
|
||||
input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
span {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: #cbd5e1;
|
||||
border-radius: 999px;
|
||||
transition: background 0.15s;
|
||||
cursor: pointer;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
left: 3px;
|
||||
top: 3px;
|
||||
background: #fff;
|
||||
border-radius: 50%;
|
||||
transition: transform 0.15s;
|
||||
box-shadow: 0 1px 2px rgb(0 0 0 / 20%);
|
||||
}
|
||||
}
|
||||
|
||||
input:checked + span {
|
||||
background: var(--cic-good);
|
||||
}
|
||||
|
||||
input:checked + span::before {
|
||||
transform: translateX(18px);
|
||||
}
|
||||
|
||||
input:disabled + span {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-tabs {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
border-bottom: 1px solid var(--cic-line);
|
||||
margin-bottom: 14px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
button {
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 9px 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--cic-muted);
|
||||
cursor: pointer;
|
||||
border-bottom: 2px solid transparent;
|
||||
margin-bottom: -1px;
|
||||
|
||||
&.active {
|
||||
color: var(--cic-brand);
|
||||
border-bottom-color: var(--cic-brand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cic-score {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18px;
|
||||
|
||||
.ring {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex: none;
|
||||
|
||||
.inner {
|
||||
width: 92px;
|
||||
height: 92px;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
text-align: center;
|
||||
|
||||
b {
|
||||
font-size: 28px;
|
||||
display: block;
|
||||
line-height: 1;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 10px;
|
||||
color: var(--cic-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cic-kv {
|
||||
display: grid;
|
||||
grid-template-columns: 170px minmax(0, 1fr);
|
||||
gap: 7px 12px;
|
||||
font-size: 13px;
|
||||
|
||||
dt {
|
||||
color: var(--cic-muted);
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-code {
|
||||
background: #0f172a;
|
||||
color: #e2e8f0;
|
||||
border-radius: 10px;
|
||||
padding: 12px 14px;
|
||||
font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
|
||||
font-size: 12px;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
max-height: 420px;
|
||||
overflow: auto;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.cic-steps {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.step {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 7px 12px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--cic-line);
|
||||
background: #fff;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--cic-muted);
|
||||
|
||||
i {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: var(--cic-soft);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-style: normal;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
&.done {
|
||||
color: var(--cic-good);
|
||||
border-color: #a7f3d0;
|
||||
background: var(--cic-good-soft);
|
||||
|
||||
i {
|
||||
background: var(--cic-good);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
&.current {
|
||||
color: var(--cic-brand);
|
||||
border-color: #bfdbfe;
|
||||
background: var(--cic-brand-soft);
|
||||
|
||||
i {
|
||||
background: var(--cic-brand);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cic-modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgb(15 23 42 / 45%);
|
||||
z-index: 1000;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.cic-modal {
|
||||
background: #fff;
|
||||
border-radius: 14px;
|
||||
width: min(640px, 100%);
|
||||
max-height: 90vh;
|
||||
overflow: auto;
|
||||
padding: 20px 22px;
|
||||
box-shadow: 0 20px 50px rgb(15 23 42 / 25%);
|
||||
|
||||
h3 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.foot {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.cic-bar {
|
||||
height: 8px;
|
||||
border-radius: 999px;
|
||||
background: #f1f5f9;
|
||||
overflow: hidden;
|
||||
|
||||
> div {
|
||||
height: 100%;
|
||||
background: var(--cic-brand);
|
||||
border-radius: 999px;
|
||||
}
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--cic-muted);
|
||||
}
|
||||
|
||||
.tone-good {
|
||||
color: var(--cic-good);
|
||||
}
|
||||
|
||||
.tone-ok {
|
||||
color: var(--cic-ok);
|
||||
}
|
||||
|
||||
.tone-warn {
|
||||
color: var(--cic-warn);
|
||||
}
|
||||
|
||||
.tone-bad {
|
||||
color: var(--cic-bad);
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
/**
|
||||
* 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 { HttpClient, HttpContext, HttpParams } from '@angular/common/http';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { SILENT_HTTP_ERROR } from '../core/http/silent-error.token';
|
||||
|
||||
/** A credit bureau (CIC) as configured for the bank. Never carries the secret itself. */
|
||||
export interface CicBureau {
|
||||
id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
whitelisted: boolean;
|
||||
isDefault: boolean;
|
||||
environment: 'SIMULATOR' | 'UAT' | 'PRODUCTION';
|
||||
baseUrl?: string;
|
||||
memberCode?: string;
|
||||
authType: string;
|
||||
username?: string;
|
||||
apiKeyHeader?: string;
|
||||
hasSecret: boolean;
|
||||
tokenUrl?: string;
|
||||
clientId?: string;
|
||||
timeoutMs: number;
|
||||
reportValidityDays: number;
|
||||
enquiryCharge: number;
|
||||
lastTestStatus?: string;
|
||||
lastTestMessage?: string;
|
||||
lastTestedOn?: string;
|
||||
updatedOn?: string;
|
||||
activeEndpoints: number;
|
||||
enquiriesLast30Days: number;
|
||||
}
|
||||
|
||||
export interface CicMapping {
|
||||
id?: number;
|
||||
sourceField: string | null;
|
||||
targetField: string;
|
||||
transform: string;
|
||||
defaultValue: string | null;
|
||||
mandatory: boolean;
|
||||
sortOrder?: number;
|
||||
}
|
||||
|
||||
export interface CicEndpoint {
|
||||
bureauId: number;
|
||||
endpointType: string;
|
||||
exists: boolean;
|
||||
id?: number;
|
||||
httpMethod: string;
|
||||
path?: string;
|
||||
contentType: string;
|
||||
headersJson: string;
|
||||
baseBody: string;
|
||||
isActive: boolean;
|
||||
requestMappings: CicMapping[];
|
||||
responseMappings: CicMapping[];
|
||||
}
|
||||
|
||||
export interface CicCatalog {
|
||||
environments: string[];
|
||||
authTypes: string[];
|
||||
endpointTypes: string[];
|
||||
httpMethods: string[];
|
||||
consentModes: string[];
|
||||
purposes: Record<string, string>;
|
||||
cbsFields: Record<string, string>;
|
||||
resultFields: Record<string, string>;
|
||||
transforms: Record<string, string>;
|
||||
defaultConsentText: string;
|
||||
}
|
||||
|
||||
export interface CicConsent {
|
||||
id: number;
|
||||
consentRef: string;
|
||||
clientId: number;
|
||||
clientName: string;
|
||||
applicationNo?: string;
|
||||
bureauId?: number;
|
||||
bureauCode: string;
|
||||
purpose: string;
|
||||
consentMode: string;
|
||||
consentText?: string;
|
||||
documentRef?: string;
|
||||
otpReference?: string;
|
||||
validFrom: string;
|
||||
validUntil: string;
|
||||
status: 'ACTIVE' | 'EXPIRED' | 'REVOKED';
|
||||
revokedReason?: string;
|
||||
revokedOn?: string;
|
||||
capturedByName?: string;
|
||||
capturedOn?: string;
|
||||
ipAddress?: string;
|
||||
}
|
||||
|
||||
export interface CicEnquiry {
|
||||
id: number;
|
||||
enquiryRef: string;
|
||||
bureauId: number;
|
||||
bureauCode: string;
|
||||
bureauName?: string;
|
||||
clientId: number;
|
||||
clientName: string;
|
||||
applicationNo?: string;
|
||||
enquiryType: string;
|
||||
purpose: string;
|
||||
loanAmount: number;
|
||||
status: 'SUCCESS' | 'NO_HIT' | 'FAILED' | 'REUSED';
|
||||
score?: number;
|
||||
errorMessage?: string;
|
||||
chargeAmount?: number;
|
||||
environment?: string;
|
||||
requestedByName?: string;
|
||||
requestedOn: string;
|
||||
durationMs?: number;
|
||||
consentRef?: string;
|
||||
reusedFromRef?: string;
|
||||
httpStatus?: number;
|
||||
requestMasked?: string;
|
||||
responseRaw?: string;
|
||||
result?: any;
|
||||
}
|
||||
|
||||
export interface CicPage<T> {
|
||||
totalFilteredRecords: number;
|
||||
pageItems: T[];
|
||||
}
|
||||
|
||||
/** Score band used everywhere a score is shown. */
|
||||
export function cicScoreBand(score: number | null | undefined): { label: string; tone: string } {
|
||||
if (score === null || score === undefined) return { label: 'No score', tone: 'muted' };
|
||||
if (score >= 750) return { label: 'Excellent', tone: 'good' };
|
||||
if (score >= 700) return { label: 'Very good', tone: 'good' };
|
||||
if (score >= 650) return { label: 'Good', tone: 'ok' };
|
||||
if (score >= 550) return { label: 'Fair', tone: 'warn' };
|
||||
return { label: 'Poor', tone: 'bad' };
|
||||
}
|
||||
|
||||
/** The server's own message for a failed call. */
|
||||
export function cicError(err: any, fallback = 'Something went wrong. Please try again.'): string {
|
||||
return (
|
||||
err?.error?.errors?.[0]?.defaultUserMessage ??
|
||||
err?.error?.defaultUserMessage ??
|
||||
err?.error?.message ??
|
||||
err?.message ??
|
||||
fallback
|
||||
);
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CicService {
|
||||
private http = inject(HttpClient);
|
||||
private base = '/cic';
|
||||
/** Errors are shown inline on these screens, so the global alert is suppressed. */
|
||||
private silent = { context: new HttpContext().set(SILENT_HTTP_ERROR, true) };
|
||||
|
||||
catalog(): Observable<CicCatalog> {
|
||||
return this.http.get<CicCatalog>(`${this.base}/catalog`, this.silent);
|
||||
}
|
||||
|
||||
bureaus(whitelistedOnly = false): Observable<CicBureau[]> {
|
||||
return this.http.get<CicBureau[]>(`${this.base}/bureaus`, {
|
||||
...this.silent,
|
||||
params: new HttpParams().set('whitelistedOnly', String(whitelistedOnly))
|
||||
});
|
||||
}
|
||||
|
||||
updateBureau(id: number, body: any): Observable<CicBureau> {
|
||||
return this.http.put<CicBureau>(`${this.base}/bureaus/${id}`, body, this.silent);
|
||||
}
|
||||
|
||||
setWhitelisted(id: number, whitelisted: boolean): Observable<CicBureau> {
|
||||
return this.http.put<CicBureau>(`${this.base}/bureaus/${id}/whitelist`, { whitelisted }, this.silent);
|
||||
}
|
||||
|
||||
testConnection(id: number): Observable<{ status: string; message: string }> {
|
||||
return this.http.post<{ status: string; message: string }>(
|
||||
`${this.base}/bureaus/${id}/test-connection`,
|
||||
{},
|
||||
this.silent
|
||||
);
|
||||
}
|
||||
|
||||
endpoint(bureauId: number, type: string): Observable<CicEndpoint> {
|
||||
return this.http.get<CicEndpoint>(`${this.base}/bureaus/${bureauId}/endpoints/${type}`, this.silent);
|
||||
}
|
||||
|
||||
saveEndpoint(bureauId: number, type: string, body: any): Observable<CicEndpoint> {
|
||||
return this.http.put<CicEndpoint>(`${this.base}/bureaus/${bureauId}/endpoints/${type}`, body, this.silent);
|
||||
}
|
||||
|
||||
preview(bureauId: number, body: any): Observable<any> {
|
||||
return this.http.post<any>(`${this.base}/bureaus/${bureauId}/preview`, body, this.silent);
|
||||
}
|
||||
|
||||
clientProfile(clientId: number, bureauId?: number | null): Observable<any> {
|
||||
let params = new HttpParams();
|
||||
if (bureauId) params = params.set('bureauId', String(bureauId));
|
||||
return this.http.get<any>(`${this.base}/clients/${clientId}/profile`, { ...this.silent, params });
|
||||
}
|
||||
|
||||
consents(filter: Record<string, any>): Observable<CicPage<CicConsent>> {
|
||||
return this.http.get<CicPage<CicConsent>>(`${this.base}/consents`, { ...this.silent, params: this.params(filter) });
|
||||
}
|
||||
|
||||
createConsent(body: any): Observable<CicConsent> {
|
||||
return this.http.post<CicConsent>(`${this.base}/consents`, body, this.silent);
|
||||
}
|
||||
|
||||
revokeConsent(id: number, reason: string): Observable<CicConsent> {
|
||||
return this.http.post<CicConsent>(`${this.base}/consents/${id}/revoke`, { reason }, this.silent);
|
||||
}
|
||||
|
||||
enquiries(filter: Record<string, any>): Observable<CicPage<CicEnquiry>> {
|
||||
return this.http.get<CicPage<CicEnquiry>>(`${this.base}/enquiries`, {
|
||||
...this.silent,
|
||||
params: this.params(filter)
|
||||
});
|
||||
}
|
||||
|
||||
enquiry(id: number): Observable<CicEnquiry> {
|
||||
return this.http.get<CicEnquiry>(`${this.base}/enquiries/${id}`, this.silent);
|
||||
}
|
||||
|
||||
enquire(body: any): Observable<CicEnquiry> {
|
||||
return this.http.post<CicEnquiry>(`${this.base}/enquiries`, body, this.silent);
|
||||
}
|
||||
|
||||
dashboard(): Observable<any> {
|
||||
return this.http.get<any>(`${this.base}/dashboard`, this.silent);
|
||||
}
|
||||
|
||||
private params(filter: Record<string, any>): HttpParams {
|
||||
let params = new HttpParams();
|
||||
Object.entries(filter).forEach(
|
||||
([
|
||||
k,
|
||||
v
|
||||
]) => {
|
||||
if (v !== null && v !== undefined && v !== '') params = params.set(k, String(v));
|
||||
}
|
||||
);
|
||||
return params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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 { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { Route } from '../core/route/route.service';
|
||||
import { CicDashboardComponent } from './cic-dashboard/cic-dashboard.component';
|
||||
import { CicNewEnquiryComponent } from './cic-new-enquiry/cic-new-enquiry.component';
|
||||
import { CicEnquiryHistoryComponent } from './cic-enquiry-history/cic-enquiry-history.component';
|
||||
import { CicEnquiryDetailComponent } from './cic-enquiry-detail/cic-enquiry-detail.component';
|
||||
import { CicConsentsComponent } from './cic-consents/cic-consents.component';
|
||||
import { CicBureauConfigComponent } from './cic-bureau-config/cic-bureau-config.component';
|
||||
import { CicApiMappingComponent } from './cic-api-mapping/cic-api-mapping.component';
|
||||
|
||||
const routes: Routes = [
|
||||
Route.withShell([
|
||||
{
|
||||
path: 'credit-bureau',
|
||||
data: { title: 'Credit Bureau', breadcrumb: 'Credit Bureau' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
redirectTo: 'dashboard',
|
||||
pathMatch: 'full'
|
||||
},
|
||||
{
|
||||
path: 'dashboard',
|
||||
component: CicDashboardComponent,
|
||||
data: { title: 'Credit Bureau Dashboard', breadcrumb: 'Dashboard' }
|
||||
},
|
||||
{
|
||||
path: 'new-enquiry',
|
||||
component: CicNewEnquiryComponent,
|
||||
data: { title: 'New Bureau Enquiry', breadcrumb: 'New Enquiry' }
|
||||
},
|
||||
{
|
||||
path: 'enquiries',
|
||||
data: { breadcrumb: 'Enquiry History' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: CicEnquiryHistoryComponent,
|
||||
data: { title: 'Bureau Enquiry History' }
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: CicEnquiryDetailComponent,
|
||||
data: { title: 'Bureau Report', breadcrumb: 'Report' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'consents',
|
||||
component: CicConsentsComponent,
|
||||
data: { title: 'Bureau Consent Register', breadcrumb: 'Consent Register' }
|
||||
},
|
||||
{
|
||||
path: 'bureaus',
|
||||
component: CicBureauConfigComponent,
|
||||
data: { title: 'CIC Whitelist & Configuration', breadcrumb: 'CIC Configuration' }
|
||||
},
|
||||
{
|
||||
path: 'api-mapping',
|
||||
component: CicApiMappingComponent,
|
||||
data: { title: 'CIC API Mapping', breadcrumb: 'API Mapping' }
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class CreditBureauRoutingModule {}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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 { NgModule } from '@angular/core';
|
||||
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { CreditBureauRoutingModule } from './credit-bureau-routing.module';
|
||||
import { CicDashboardComponent } from './cic-dashboard/cic-dashboard.component';
|
||||
import { CicNewEnquiryComponent } from './cic-new-enquiry/cic-new-enquiry.component';
|
||||
import { CicEnquiryHistoryComponent } from './cic-enquiry-history/cic-enquiry-history.component';
|
||||
import { CicEnquiryDetailComponent } from './cic-enquiry-detail/cic-enquiry-detail.component';
|
||||
import { CicConsentsComponent } from './cic-consents/cic-consents.component';
|
||||
import { CicBureauConfigComponent } from './cic-bureau-config/cic-bureau-config.component';
|
||||
import { CicApiMappingComponent } from './cic-api-mapping/cic-api-mapping.component';
|
||||
|
||||
/** CIC / credit bureau enquiries (CIBIL, Experian, Equifax, CRIF) — its own top-level menu. */
|
||||
@NgModule({
|
||||
imports: [
|
||||
SharedModule,
|
||||
CreditBureauRoutingModule,
|
||||
CicDashboardComponent,
|
||||
CicNewEnquiryComponent,
|
||||
CicEnquiryHistoryComponent,
|
||||
CicEnquiryDetailComponent,
|
||||
CicConsentsComponent,
|
||||
CicBureauConfigComponent,
|
||||
CicApiMappingComponent
|
||||
]
|
||||
})
|
||||
export class CreditBureauModule {}
|
||||
@@ -47,23 +47,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Pending investment interest vouchers (coupon / provision due now or within two days) -->
|
||||
@if (pendingInvestmentInterest.length) {
|
||||
<a class="investment-interest-alert" routerLink="/investment/bonds" [queryParams]="{ tab: 'interest' }">
|
||||
<span class="iia-icon">🔔</span>
|
||||
<span class="iia-text">
|
||||
<strong>{{ pendingInvestmentInterest.length }} investment interest voucher(s) pending</strong>
|
||||
@for (t of pendingInvestmentInterest; track t.purchaseId) {
|
||||
<span class="iia-item">
|
||||
{{ t.lineType === 'COUPON' ? 'Coupon' : 'Provision' }} · {{ t.scriptDesc }} · deal {{ t.dealNo }} ·
|
||||
{{ t.overdue ? 'overdue since ' + t.intDate : t.postable ? 'due today' : 'due ' + t.intDate }}
|
||||
</span>
|
||||
}
|
||||
</span>
|
||||
<span class="iia-action">Open Interest Entry →</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
<!-- Quick Action Cards -->
|
||||
<div class="quick-actions">
|
||||
<a class="qa-card" [routerLink]="['/dashboard']" #buttonDashboard>
|
||||
|
||||
@@ -424,39 +424,3 @@ $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: 2px;
|
||||
}
|
||||
|
||||
.iia-item {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.iia-action {
|
||||
align-self: center;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ 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 { InvestmentInterestDueDto, InvestmentService } from 'app/investment/investment.service';
|
||||
|
||||
/** Custom Components */
|
||||
import { NextStepDialogComponent } from '../configuration-wizard/next-step-dialog/next-step-dialog.component';
|
||||
@@ -110,7 +109,6 @@ 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,
|
||||
@@ -120,18 +118,6 @@ 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[] = [];
|
||||
private readonly investmentService = inject(InvestmentService);
|
||||
|
||||
/** 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 = [])
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Surface a small "DSC verified" badge in the welcome banner when the
|
||||
* signed-in user has at least one ACTIVE DSC certificate. Silent on
|
||||
|
||||
@@ -137,12 +137,11 @@
|
||||
<th class="num">Units</th>
|
||||
<th class="num">Face Value</th>
|
||||
<th class="num">Rate</th>
|
||||
<th>Settlement Date</th>
|
||||
<th>Purchase Date</th>
|
||||
<th>Maturity Date</th>
|
||||
<th class="num col-in">Accrued Interest</th>
|
||||
<th class="num col-net">Maturity Value</th>
|
||||
<th>Status</th>
|
||||
<th>Settlement</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -161,23 +160,12 @@
|
||||
<td class="num col-in">₹{{ accrued(h) | number: '1.2-2' }}</td>
|
||||
<td class="num col-net">₹{{ maturity(h) | number: '1.2-2' }}</td>
|
||||
<td>
|
||||
<span [class]="statusClass(h)">{{
|
||||
h.status === 'PENDING_SETTLEMENT' ? 'PENDING SETTLEMENT' : h.status
|
||||
}}</span>
|
||||
</td>
|
||||
<td>
|
||||
@if (h.status === 'PENDING_SETTLEMENT') {
|
||||
<button type="button" class="pg-btn pg-btn--primary" (click)="settleDeal(h)">
|
||||
Settle ({{ h.settlementDate }})
|
||||
</button>
|
||||
} @else if (h.glTransactionId) {
|
||||
<span class="pg-chip" title="Journal entry transaction">GL {{ h.glTransactionId }}</span>
|
||||
}
|
||||
<span [class]="statusClass(h)">{{ h.status }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
} @empty {
|
||||
<tr>
|
||||
<td colspan="12" class="pg-empty">No {{ instrumentLabel(bondType) }} holdings yet.</td>
|
||||
<td colspan="11" class="pg-empty">No {{ instrumentLabel(bondType) }} holdings yet.</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -188,9 +176,8 @@
|
||||
<!-- ===================== 01 PURCHASE ENTRY ===================== -->
|
||||
@if (activeTab === 'purchase') {
|
||||
<div class="pg-card">
|
||||
<!-- 1. Deal details — the only fields the dealer has to fill -->
|
||||
<div class="pos-section-label">
|
||||
Purchase Entry — {{ instrumentLabel(purchaseForm.bondType) }} (fields marked * are mandatory)
|
||||
Investment - Govt.Security/Bond Entry ({{ instrumentLabel(purchaseForm.bondType) }})
|
||||
</div>
|
||||
<div class="inv-form-grid">
|
||||
<label class="inv-form-field">
|
||||
@@ -201,6 +188,17 @@
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>Deal No</span><input type="text" [(ngModel)]="purchaseForm.dealNo" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>* Deal Date</span><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.dealDate"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field"
|
||||
><span>* Deal Time (24 hr, HH:mm:ss)</span
|
||||
><input type="text" [(ngModel)]="purchaseForm.dealTime" placeholder="HH:mm:ss"
|
||||
/></label>
|
||||
<label class="inv-form-field"><span>* ISIN</span><input type="text" [(ngModel)]="purchaseForm.isin" /></label>
|
||||
<label class="inv-form-field">
|
||||
<span>* Script Code</span>
|
||||
<select [(ngModel)]="purchaseForm.scriptCode" (ngModelChange)="onScriptChange()">
|
||||
@@ -210,50 +208,167 @@
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>* Party Code</span>
|
||||
<select [(ngModel)]="purchaseForm.partyCode">
|
||||
<option value="">-- Select --</option>
|
||||
@for (p of activePartyOptions; track p.partyCode) {
|
||||
<option [value]="p.partyCode">{{ p.partyCode }} — {{ p.partyName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>* Deal Date</span
|
||||
><mifosx-date-ddmmyyyy
|
||||
[(ngModel)]="purchaseForm.dealDate"
|
||||
(ngModelChange)="onDealDateChange()"
|
||||
></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field"
|
||||
><span>* Deal Time (HH:mm:ss)</span
|
||||
><input type="text" [(ngModel)]="purchaseForm.dealTime" placeholder="HH:mm:ss"
|
||||
><span>* Cert No</span><input type="text" [(ngModel)]="purchaseForm.certNo"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>* Settlement Type</span>
|
||||
<span>Settlement Type</span>
|
||||
<select [(ngModel)]="purchaseForm.settlementType">
|
||||
<option value="T+0">T+0</option>
|
||||
<option value="T+1">T+1</option>
|
||||
<option value="T+2">T+2</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>Settlement Dt</span
|
||||
><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.settlementDt"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field">
|
||||
<span>* Party Code</span>
|
||||
<select [(ngModel)]="purchaseForm.partyCode">
|
||||
<option value="">-- Select --</option>
|
||||
@for (p of partyOptions; track p.partyCode) {
|
||||
<option [value]="p.partyName">{{ p.partyName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Sub Type</span>
|
||||
<select [(ngModel)]="purchaseForm.subType">
|
||||
@for (s of subTypeOptions; track s.subTypeCode + s.subTypeName) {
|
||||
<option [value]="s.subTypeName">{{ s.subTypeName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
@if (isMutualFund) {
|
||||
<label class="inv-form-field">
|
||||
<span>* Product Name</span>
|
||||
<select [(ngModel)]="purchaseForm.productName">
|
||||
<option value="">-- Select --</option>
|
||||
@for (p of mfProductOptions; track p.productCode) {
|
||||
<option [value]="p.productName">{{ p.productName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>* Consider Amt (₹)</span><input type="number" [(ngModel)]="purchaseForm.considerAmt" min="0"
|
||||
><span>Holding Days</span><input type="number" [(ngModel)]="purchaseForm.holdingDays" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>* NAV</span><input type="number" [(ngModel)]="purchaseForm.nav" min="0" step="0.0001"
|
||||
><span>* Consider Amt</span><input type="number" [(ngModel)]="purchaseForm.considerAmt" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Trade Amt</span><input type="number" [(ngModel)]="purchaseForm.tradeAmt" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>NAV</span><input type="number" [(ngModel)]="purchaseForm.nav" min="0" step="0.0001"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Stamp Duty</span><input type="number" [(ngModel)]="purchaseForm.stampDuty" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>StampDuty A/c</span><input type="text" [(ngModel)]="purchaseForm.stampDutyAc"
|
||||
/></label>
|
||||
} @else {
|
||||
<label class="inv-form-field"
|
||||
><span>* Face Value (₹)</span><input type="number" [(ngModel)]="purchaseForm.faceValue" min="0"
|
||||
><span>Face Value</span><input type="number" [(ngModel)]="purchaseForm.faceValue" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>* Purchase Rate (per ₹100)</span
|
||||
><span>Purchase Rate (per 100)</span
|
||||
><input type="number" [(ngModel)]="purchaseForm.purchaseRate" min="0" step="0.0001"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Unit Val</span><input type="text" [value]="purchaseUnitVal" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Book Value</span><input type="text" [value]="purchaseBookValue | number: '1.2-2'" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Premium Amt.</span><input type="number" [(ngModel)]="purchaseForm.premiumAmt"
|
||||
/></label>
|
||||
}
|
||||
<label class="inv-form-field"
|
||||
><span>* No Unit</span><input type="text" [value]="purchaseUnits" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>* CR. To A/c</span><input type="text" [(ngModel)]="purchaseForm.crToAc"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>TBill GL.A/C.</span><input type="text" [(ngModel)]="purchaseForm.tbillGlAc"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Brokerage</span><input type="number" [(ngModel)]="purchaseForm.brokerage" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>Broker Nm.</span>
|
||||
<select [(ngModel)]="purchaseForm.brokerName">
|
||||
<option value="">-- Select --</option>
|
||||
@for (b of brokerOptions; track b.brokerCode) {
|
||||
<option [value]="b.brokerCode">{{ b.brokerCode }} — {{ b.brokerName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>Trade No.</span><input type="text" [(ngModel)]="purchaseForm.tradeNo"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Order No.</span><input type="text" [(ngModel)]="purchaseForm.orderNo"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>Recomm. Authority</span>
|
||||
<select [(ngModel)]="purchaseForm.recommAuthority">
|
||||
<option value="">-- Select --</option>
|
||||
@for (a of authorityOptions; track a) {
|
||||
<option [value]="a">{{ a }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Sanction Authority</span>
|
||||
<select [(ngModel)]="purchaseForm.sanctionAuthority">
|
||||
<option value="">-- Select --</option>
|
||||
@for (a of authorityOptions; track a) {
|
||||
<option [value]="a">{{ a }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>* Issue Date</span><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.issueDate"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Period(Year)</span><input type="number" [(ngModel)]="purchaseForm.periodYear" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Period(Month)</span><input type="number" [(ngModel)]="purchaseForm.periodMonth" min="0" max="11"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Period(Days)</span><input type="number" [(ngModel)]="purchaseForm.periodDays" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Desc Inv</span><input type="text" [(ngModel)]="purchaseForm.descInv"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Folio No</span><input type="text" [(ngModel)]="purchaseForm.folioNo"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Call Option</span><input type="text" [(ngModel)]="purchaseForm.callOption"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Meet Dt</span><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.meetDt"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Reso No</span><input type="text" [(ngModel)]="purchaseForm.resoNo"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>From Dist</span><input type="text" [(ngModel)]="purchaseForm.fromDist"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>To Dist</span><input type="text" [(ngModel)]="purchaseForm.toDist"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Redum/Mat Dt</span
|
||||
><input type="text" [(ngModel)]="purchaseForm.redumMatDt" placeholder="DD-MM-YYYY (blank = use period)"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>* Category</span>
|
||||
<select [(ngModel)]="purchaseForm.category">
|
||||
@@ -265,258 +380,32 @@
|
||||
</label>
|
||||
@if (!isMutualFund) {
|
||||
<label class="inv-form-field"
|
||||
><span>* Last Interest Date</span
|
||||
><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.lastIntDt"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
}
|
||||
<label class="inv-form-field">
|
||||
<span>* CR. To A/c (Paid From)</span>
|
||||
<select [(ngModel)]="purchaseForm.crToAc">
|
||||
@for (g of settlementBankOptions; track g.glCode) {
|
||||
<option [value]="g.glCode">{{ g.glCode }} — {{ g.glName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>Stamp Duty (₹)</span><input type="number" [(ngModel)]="purchaseForm.stampDuty" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Brokerage (₹)</span><input type="number" [(ngModel)]="purchaseForm.brokerage" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Other Charges (₹)</span><input type="number" [(ngModel)]="purchaseForm.otherCharges" min="0"
|
||||
/></label>
|
||||
</div>
|
||||
@if (purchaseMarketRate) {
|
||||
<p class="pg-sub" style="padding: 0 16px 8px">
|
||||
Market rate (Daily Script Master) as on {{ purchaseMarketRate.rateDate }}: Close
|
||||
{{ purchaseMarketRate.closeRate | number: '1.2-4' }}
|
||||
@if (purchaseMarketRate.lowRate && purchaseMarketRate.highRate) {
|
||||
(Low {{ purchaseMarketRate.lowRate | number: '1.2-4' }} – High
|
||||
{{ purchaseMarketRate.highRate | number: '1.2-4' }})
|
||||
}
|
||||
@if (purchaseMarketRate.rateDate !== purchaseForm.dealDate) {
|
||||
— no rate entered for the deal date, the latest earlier rate is used.
|
||||
}
|
||||
</p>
|
||||
@if (purchaseRateOutOfRange) {
|
||||
<p class="pg-sub" style="padding: 0 16px 8px; color: #b42318; font-weight: 600">
|
||||
Warning: the rate entered is outside the day's market range.
|
||||
</p>
|
||||
}
|
||||
} @else if (purchaseMarketRate === null) {
|
||||
<p class="pg-sub" style="padding: 0 16px 8px; color: #b42318">
|
||||
No rate in the Daily Script Master for this script — enter the day's rate there first.
|
||||
</p>
|
||||
}
|
||||
|
||||
<!-- 2. Calculated — filled by the system, read-only -->
|
||||
<div class="pos-section-label">Calculated by System</div>
|
||||
<div class="inv-form-grid">
|
||||
<label class="inv-form-field"
|
||||
><span>Deal No</span><input type="text" [value]="purchaseForm.dealNo" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Cert No</span><input type="text" [value]="purchaseForm.certNo" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Settlement Date</span><input type="text" [value]="purchaseSettlementDate" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>ISIN</span><input type="text" [value]="purchaseForm.isin || '—'" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Sub Type</span><input type="text" [value]="purchaseForm.subType || '—'" readonly
|
||||
/></label>
|
||||
@if (!isMutualFund) {
|
||||
<label class="inv-form-field"
|
||||
><span>Int Rate %</span><input type="text" [value]="purchaseForm.intRate ?? '—'" readonly
|
||||
><span>Int Rate</span><input type="number" [(ngModel)]="purchaseForm.intRate" min="0" step="0.01"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Issue Date</span><input type="text" [value]="purchaseForm.issueDate || '—'" readonly
|
||||
><span>YTM (computed)</span><input type="text" [value]="purchaseYtm" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Maturity Date</span><input type="text" [value]="purchaseMaturityDate || '—'" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Period (Y / M / D)</span
|
||||
><input
|
||||
type="text"
|
||||
[value]="purchaseForm.periodYear + ' / ' + purchaseForm.periodMonth + ' / ' + purchaseForm.periodDays"
|
||||
readonly
|
||||
/></label>
|
||||
}
|
||||
<label class="inv-form-field"
|
||||
><span>No. of Units</span><input type="text" [value]="purchaseUnits | number: '1.0-4'" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Book Value</span><input type="text" [value]="'₹' + (purchaseBookValue | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
@if (!isMutualFund) {
|
||||
<label class="inv-form-field"
|
||||
><span>Premium (+) / Discount (−)</span
|
||||
><input type="text" [value]="'₹' + (purchasePremiumDiscount | number: '1.0-0')" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Accrued Interest ({{ purchaseAccruedDays }} days)</span
|
||||
><input type="text" [value]="'₹' + (purchaseAccruedInterest | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"><span>YTM %</span><input type="text" [value]="purchaseYtm" readonly /></label>
|
||||
}
|
||||
<label class="inv-form-field"
|
||||
><span>Charges (expense)</span
|
||||
><input type="text" [value]="'₹' + (purchaseTotalCharges | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Total Settlement Amount</span
|
||||
><input type="text" [value]="'₹' + (purchaseSettlementAmount | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
</div>
|
||||
|
||||
@if (!isMutualFund && purchaseCouponDates) {
|
||||
<div class="pos-section-label">Interest Cycle</div>
|
||||
<div class="inv-form-grid">
|
||||
<label class="inv-form-field"
|
||||
><span>Interest Dates (half-yearly)</span><input type="text" [value]="purchaseCouponDates" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Last Coupon</span><input type="text" [value]="purchaseForm.lastIntDt || '—'" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Next Coupon</span><input type="text" [value]="purchaseNextCouponDate || '—'" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Next Coupon Amount</span
|
||||
><input type="text" [value]="'₹' + (purchaseNextCouponAmount | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Days to Next Coupon</span><input type="text" [value]="purchaseDaysToNextCoupon" readonly
|
||||
/></label>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- 3. Accounting preview -->
|
||||
<div class="pos-section-label">Accounting Preview (posted on Settle, dated the settlement date)</div>
|
||||
@if (purchaseAccountingPreview.length) {
|
||||
<table class="pg-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Dr / Cr</th>
|
||||
<th>GL Code</th>
|
||||
<th>GL Name</th>
|
||||
<th class="num">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (l of purchaseAccountingPreview; track l.side + l.glCode) {
|
||||
<tr>
|
||||
<td>{{ l.side }}</td>
|
||||
<td>{{ l.glCode }}</td>
|
||||
<td>{{ l.glName || '—' }}</td>
|
||||
<td class="num">₹{{ l.amount | number: '1.2-2' }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
} @else {
|
||||
<p class="pg-sub">Select a script, enter the amount and CR. To A/c to see the entry.</p>
|
||||
}
|
||||
|
||||
<!-- 4. More details — optional, collapsed by default -->
|
||||
<div class="inv-form-actions">
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="showMoreDetails = !showMoreDetails">
|
||||
{{ showMoreDetails ? '▾ Hide More Details' : '▸ More Details (optional)' }}
|
||||
</button>
|
||||
</div>
|
||||
@if (showMoreDetails) {
|
||||
<div class="pos-section-label">More Details (optional)</div>
|
||||
<div class="inv-form-grid">
|
||||
<label class="inv-form-field">
|
||||
<span>Sub Type</span>
|
||||
<select [(ngModel)]="purchaseForm.subType">
|
||||
@for (s of subTypeOptions; track s.subTypeCode + s.subTypeName) {
|
||||
<option [value]="s.subTypeName">{{ s.subTypeName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
@if (isMutualFund) {
|
||||
<label class="inv-form-field"
|
||||
><span>Trade Amt</span><input type="number" [(ngModel)]="purchaseForm.tradeAmt" min="0"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Stamp Duty A/c</span><input type="text" [(ngModel)]="purchaseForm.stampDutyAc"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Holding Days</span><input type="number" [(ngModel)]="purchaseForm.holdingDays" min="0"
|
||||
/></label>
|
||||
} @else {
|
||||
<label class="inv-form-field">
|
||||
<span>Int Type</span>
|
||||
<select [(ngModel)]="purchaseForm.intType">
|
||||
@for (i of intTypeOptions; track i.value) {
|
||||
<option [value]="i.value">{{ i.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Bond Rating</span>
|
||||
<select [(ngModel)]="purchaseForm.bondRating">
|
||||
@for (r of bondRatingOptions; track r) {
|
||||
<option [value]="r">{{ r }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>SGL with Bank</span>
|
||||
<select [(ngModel)]="purchaseForm.sglWithBank">
|
||||
<option value="">-- Select --</option>
|
||||
@for (s of sglBankOptions; track s.sglCode) {
|
||||
<option [value]="s.bankName">{{ s.bankName }} — {{ s.branch }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>TBill GL A/c</span><input type="text" [(ngModel)]="purchaseForm.tbillGlAc"
|
||||
/></label>
|
||||
}
|
||||
<label class="inv-form-field">
|
||||
<span>Broker</span>
|
||||
<select [(ngModel)]="purchaseForm.brokerName">
|
||||
<option value="">-- Select --</option>
|
||||
@for (b of brokerOptions; track b.brokerCode) {
|
||||
<option [value]="b.brokerCode">{{ b.brokerCode }} — {{ b.brokerName }}</option>
|
||||
<span>Int Type</span>
|
||||
<select [(ngModel)]="purchaseForm.intType">
|
||||
@for (i of intTypeOptions; track i.value) {
|
||||
<option [value]="i.value">{{ i.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>Trade No.</span><input type="text" [(ngModel)]="purchaseForm.tradeNo"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Order No.</span><input type="text" [(ngModel)]="purchaseForm.orderNo"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>Recomm. Authority</span>
|
||||
<select [(ngModel)]="purchaseForm.recommAuthority">
|
||||
<option value="">-- Select --</option>
|
||||
@for (a of authorityOptions; track a) {
|
||||
<option [value]="a">{{ a }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Sanction Authority</span>
|
||||
<select [(ngModel)]="purchaseForm.sanctionAuthority">
|
||||
<option value="">-- Select --</option>
|
||||
@for (a of authorityOptions; track a) {
|
||||
<option [value]="a">{{ a }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>Meet Date</span><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.meetDt"></mifosx-date-ddmmyyyy
|
||||
><span>Int Date</span><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.intDate"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Reso No</span><input type="text" [(ngModel)]="purchaseForm.resoNo"
|
||||
><span>* Last Int.dt</span><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.lastIntDt"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Accrued Interest (computed)</span
|
||||
><input type="text" [value]="purchaseAccruedInterest | number: '1.2-2'" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Settlement Amt of Pur. (computed)</span
|
||||
><input type="text" [value]="purchaseSettlementAmount | number: '1.4-4'" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>Deal Type</span>
|
||||
@@ -534,80 +423,6 @@
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Payment Mode</span>
|
||||
<select [(ngModel)]="purchaseForm.paymentMode">
|
||||
<option value="">-- Select --</option>
|
||||
@for (p of paymentModeOptions; track p) {
|
||||
<option [value]="p">{{ p }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Delivery Mode</span>
|
||||
<select [(ngModel)]="purchaseForm.deliveryMode">
|
||||
<option value="">-- Select --</option>
|
||||
@for (d of deliveryModeOptions; track d) {
|
||||
<option [value]="d">{{ d }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>LIEN</span>
|
||||
<select [(ngModel)]="purchaseForm.lien">
|
||||
<option value="NO">NO</option>
|
||||
<option value="YES">YES</option>
|
||||
</select>
|
||||
</label>
|
||||
@if (purchaseForm.lien === 'YES') {
|
||||
<label class="inv-form-field"
|
||||
><span>LIEN Amount</span><input type="number" [(ngModel)]="purchaseForm.lienAmount"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>LIEN Reason</span>
|
||||
<select [(ngModel)]="purchaseForm.lienReason">
|
||||
<option value="">-- Select --</option>
|
||||
@for (l of lienReasonOptions; track l.reasonCode) {
|
||||
<option [value]="l.reasonDescription">{{ l.reasonDescription }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
}
|
||||
<label class="inv-form-field"
|
||||
><span>Folio No</span><input type="text" [(ngModel)]="purchaseForm.folioNo"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Call Option</span><input type="text" [(ngModel)]="purchaseForm.callOption"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Register Address</span><input type="text" [(ngModel)]="purchaseForm.registerAdd"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Register City</span><input type="text" [(ngModel)]="purchaseForm.regiCity"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Register Pin</span><input type="text" [(ngModel)]="purchaseForm.regiPin"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Issue Date (override)</span
|
||||
><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.issueDate"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Redum / Mat Date (override)</span
|
||||
><input type="text" [(ngModel)]="purchaseForm.redumMatDt" placeholder="DD-MM-YYYY"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Int Date</span><mifosx-date-ddmmyyyy [(ngModel)]="purchaseForm.intDate"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Desc Inv</span><input type="text" [(ngModel)]="purchaseForm.descInv"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>From Dist</span><input type="text" [(ngModel)]="purchaseForm.fromDist"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>To Dist</span><input type="text" [(ngModel)]="purchaseForm.toDist"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>Mark CBLO</span>
|
||||
<select [(ngModel)]="purchaseForm.markCblo">
|
||||
@@ -618,6 +433,14 @@
|
||||
<label class="inv-form-field"
|
||||
><span>Amortize Amt.</span><input type="number" [(ngModel)]="purchaseForm.amortizeAmt"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>Bond Rating</span>
|
||||
<select [(ngModel)]="purchaseForm.bondRating">
|
||||
@for (r of bondRatingOptions; track r) {
|
||||
<option [value]="r">{{ r }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Corp. Bond</span>
|
||||
<select [(ngModel)]="purchaseForm.corpBond">
|
||||
@@ -625,19 +448,76 @@
|
||||
<option value="YES">YES</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>SGL with Bank</span>
|
||||
<select [(ngModel)]="purchaseForm.sglWithBank">
|
||||
<option value="">-- Select --</option>
|
||||
@for (s of sglBankOptions; track s.sglCode) {
|
||||
<option [value]="s.bankName">{{ s.bankName }} — {{ s.branch }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>Remarks</span><input type="text" [(ngModel)]="purchaseForm.remarks"
|
||||
><span>Register Add</span><input type="text" [(ngModel)]="purchaseForm.registerAdd"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Description</span><input type="text" [(ngModel)]="purchaseForm.description"
|
||||
><span>Regi City</span><input type="text" [(ngModel)]="purchaseForm.regiCity"
|
||||
/></label>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="inv-form-actions">
|
||||
<label class="inv-form-field"
|
||||
><span>Regi Pin</span><input type="text" [(ngModel)]="purchaseForm.regiPin"
|
||||
/></label>
|
||||
}
|
||||
<label class="inv-form-field">
|
||||
<span>LIEN</span>
|
||||
<select [(ngModel)]="purchaseForm.lien">
|
||||
<option value="NO">NO</option>
|
||||
<option value="YES">YES</option>
|
||||
</select>
|
||||
</label>
|
||||
@if (purchaseForm.lien === 'YES') {
|
||||
<label class="inv-form-field"
|
||||
><span>LIEN Amount</span><input type="number" [(ngModel)]="purchaseForm.lienAmount"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>LIEN Reason</span>
|
||||
<select [(ngModel)]="purchaseForm.lienReason">
|
||||
<option value="">-- Select --</option>
|
||||
@for (l of lienReasonOptions; track l.reasonCode) {
|
||||
<option [value]="l.reasonDescription">{{ l.reasonDescription }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
}
|
||||
<label class="inv-form-field">
|
||||
<span>Payment Mode</span>
|
||||
<select [(ngModel)]="purchaseForm.paymentMode">
|
||||
<option value="">--Select--</option>
|
||||
@for (p of paymentModeOptions; track p) {
|
||||
<option [value]="p">{{ p }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Delivery Mode</span>
|
||||
<select [(ngModel)]="purchaseForm.deliveryMode">
|
||||
<option value="">--Select--</option>
|
||||
@for (d of deliveryModeOptions; track d) {
|
||||
<option [value]="d">{{ d }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>Retrieve Cert No</span><input type="text" placeholder="e.g. 30" [(ngModel)]="retrieveCertNo"
|
||||
><span>Remarks</span><input type="text" [(ngModel)]="purchaseForm.remarks"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Description</span><input type="text" [(ngModel)]="purchaseForm.description"
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Maturity / Redemption Value (computed)</span
|
||||
><input type="text" [value]="'₹' + (purchaseMaturityAmount | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
</div>
|
||||
<div class="inv-form-actions">
|
||||
<button type="button" class="pg-btn pg-btn--primary" (click)="savePurchase()">Save</button>
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="retrievePurchase()">Retrieve</button>
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="dropPurchase()">Drop</button>
|
||||
@@ -689,47 +569,20 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- ===================== 03 INTEREST ENTRY ===================== -->
|
||||
<!-- ===================== 03 INTEREST ENTRY / CALCULATION ===================== -->
|
||||
@if (activeTab === 'interest') {
|
||||
<div class="pg-card">
|
||||
<div class="pos-section-label">Interest Entry — coupon and 31 Mar / 30 Sep provision schedule</div>
|
||||
@if (intDueTasks.length) {
|
||||
<div class="pos-section-label">🔔 Interest entries due ({{ intDueTasks.length }})</div>
|
||||
<table class="pg-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Deal No</th>
|
||||
<th>Script</th>
|
||||
<th>Type</th>
|
||||
<th>Int Date</th>
|
||||
<th class="num">Amount</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (t of intDueTasks; track t.purchaseId) {
|
||||
<tr>
|
||||
<td>
|
||||
<span class="pg-chip">{{ t.dealNo }}</span>
|
||||
</td>
|
||||
<td>{{ t.scriptCode }} — {{ t.scriptDesc }}</td>
|
||||
<td>{{ t.lineType === 'COUPON' ? 'Coupon' : 'Provision' }}</td>
|
||||
<td>{{ t.intDate }}</td>
|
||||
<td class="num">₹{{ (t.lineType === 'COUPON' ? t.grossInterest : t.amount) | number: '1.2-2' }}</td>
|
||||
<td>{{ t.overdue ? 'Overdue — post now' : t.postable ? 'Due today' : 'Due on ' + t.intDate }}</td>
|
||||
<td>
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="openDueTask(t)">Open</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<div class="pos-section-label">Investment - Govt./Bond Interest calculation</div>
|
||||
<div class="inv-form-grid">
|
||||
<label class="inv-form-field"
|
||||
><span>From Date</span><mifosx-date-ddmmyyyy [(ngModel)]="intCalcFromDate"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field"
|
||||
><span>To Date</span><mifosx-date-ddmmyyyy [(ngModel)]="intCalcToDate"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
<label class="inv-form-field">
|
||||
<span>Type</span>
|
||||
<select [(ngModel)]="intType" (ngModelChange)="onIntFilterChange()">
|
||||
<select [(ngModel)]="intCalcType" (ngModelChange)="onIntCalcTypeChange()">
|
||||
<option value="">-- All Types --</option>
|
||||
@for (o of bondTypeOptions; track o.value) {
|
||||
<option [value]="o.value">{{ o.label }}</option>
|
||||
@@ -738,182 +591,67 @@
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Script</span>
|
||||
<select [(ngModel)]="intScript" (ngModelChange)="onIntFilterChange()">
|
||||
<select [(ngModel)]="intCalcScript">
|
||||
<option value="">-- All Scripts --</option>
|
||||
@for (s of intScriptOptions; track s.scriptCode) {
|
||||
@for (s of scriptOptions; track s.scriptCode) {
|
||||
<option [value]="s.scriptCode">{{ s.scriptCode }} — {{ s.scriptName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"><span>Deal No</span><input type="text" [(ngModel)]="intCalcDealNo" /></label>
|
||||
<label class="inv-form-field"
|
||||
><span>ALL</span><input type="checkbox" [(ngModel)]="intCalcAll" style="height: 18px; width: 18px"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>* Deal No</span>
|
||||
<select [(ngModel)]="intPurchaseId" (ngModelChange)="intSchedule = null">
|
||||
<option [ngValue]="null">-- Select --</option>
|
||||
@for (h of intDealOptions; track h.id) {
|
||||
<option [ngValue]="h.id">{{ h.dealNo }} — {{ h.scriptCode }} (Cert {{ h.certNo }})</option>
|
||||
<span>Post To (Interest Income GL)</span>
|
||||
<select [(ngModel)]="intCalcGlCode">
|
||||
@for (g of interestIncomeGlOptions; track g.glCode) {
|
||||
<option [value]="g.glCode">{{ g.glCode }} — {{ g.glName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"
|
||||
><span>As On Date</span><mifosx-date-ddmmyyyy [(ngModel)]="intAsOnDate"></mifosx-date-ddmmyyyy
|
||||
></label>
|
||||
</div>
|
||||
<div class="inv-form-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="pg-btn pg-btn--primary"
|
||||
[disabled]="intLoading"
|
||||
(click)="retrieveInterestSchedule()"
|
||||
>
|
||||
{{ intLoading ? 'Retrieving…' : 'Retrieve' }}
|
||||
</button>
|
||||
<button type="button" class="pg-btn pg-btn--primary" (click)="processInterest()">Process</button>
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="setTab('holdings')">Exit</button>
|
||||
</div>
|
||||
|
||||
@if (intSchedule; as sc) {
|
||||
<div class="pos-section-label">Purchase Details</div>
|
||||
<div class="inv-form-grid">
|
||||
<label class="inv-form-field"
|
||||
><span>Deal No / Cert No</span><input type="text" [value]="sc.dealNo + ' / ' + sc.certNo" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Script</span><input type="text" [value]="sc.scriptCode + ' — ' + sc.scriptDesc" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Face Value Held</span><input type="text" [value]="'₹' + (sc.faceValue | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Interest Rate</span><input type="text" [value]="sc.intRate + '%'" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Coupon per Half-Year</span
|
||||
><input type="text" [value]="'₹' + (sc.couponPerHalfYear | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Deal Date</span><input type="text" [value]="sc.dealDate" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Last Interest Date</span><input type="text" [value]="sc.lastIntDate" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Maturity Date</span><input type="text" [value]="sc.maturityDate" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Broken Period Interest Paid (expense 500606)</span
|
||||
><input type="text" [value]="'₹' + (sc.purchasedAccruedInterest | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
<label class="inv-form-field"
|
||||
><span>Book Value</span><input type="text" [value]="'₹' + (sc.bookValue | number: '1.2-2')" readonly
|
||||
/></label>
|
||||
</div>
|
||||
|
||||
<div class="pos-section-label">
|
||||
Interest Schedule ({{ intVisibleRows.length }} of {{ sc.rows.length }} lines) — due up to {{ sc.asOnDate }}:
|
||||
₹{{ intDueTotal | number: '1.2-2' }}
|
||||
</div>
|
||||
<p class="pg-sub" style="padding: 0 16px">
|
||||
Days are 30/360. A provision books the interest earned since the last coupon; the coupon then clears what is
|
||||
already booked. Post each line with Generate Voucher on or after its date, in date order — the JV voucher is
|
||||
passed as it is raised.
|
||||
</p>
|
||||
<div class="inv-form-grid">
|
||||
<label class="inv-form-field">
|
||||
<span>Coupon received into (Bank)</span>
|
||||
<select [(ngModel)]="intBankGlCode">
|
||||
@for (g of settlementBankOptions; track g.glCode) {
|
||||
<option [value]="g.glCode">{{ g.glCode }} — {{ g.glName }}</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field">
|
||||
<span>Schedule</span>
|
||||
<button type="button" class="pg-btn pg-btn--ghost" (click)="intShowFullSchedule = !intShowFullSchedule">
|
||||
{{ intShowFullSchedule ? 'Show up to next year' : 'Show full schedule to maturity' }}
|
||||
</button>
|
||||
</label>
|
||||
</div>
|
||||
<table class="pg-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Int Date</th>
|
||||
<th>From</th>
|
||||
<th>To</th>
|
||||
<th class="num">Days</th>
|
||||
<th class="num">Int %</th>
|
||||
<th class="num">Gross Interest</th>
|
||||
<th class="num">Already Booked</th>
|
||||
<th class="num col-in">Amount</th>
|
||||
<th>Accounting</th>
|
||||
<th>Voucher</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (r of intVisibleRows; track r.type + r.intDate) {
|
||||
<tr [style.opacity]="r.due ? 1 : 0.6">
|
||||
<td>
|
||||
<span class="pg-chip">{{ r.type === 'COUPON' ? 'Coupon' : 'Provision' }}</span>
|
||||
@if (r.due) {
|
||||
<span class="pg-chip">Due</span>
|
||||
}
|
||||
</td>
|
||||
<td>{{ r.intDate }}</td>
|
||||
<td>{{ r.fromDate }}</td>
|
||||
<td>{{ r.toDate }}</td>
|
||||
<td class="num">{{ r.days }}</td>
|
||||
<td class="num">{{ sc.intRate }}</td>
|
||||
<td class="num">₹{{ r.grossInterest | number: '1.2-2' }}</td>
|
||||
<td class="num">₹{{ r.alreadyBooked | number: '1.2-2' }}</td>
|
||||
<td class="num col-in">₹{{ r.amount | number: '1.2-2' }}</td>
|
||||
<td style="white-space: nowrap; font-size: 12px">
|
||||
@if (r.type === 'COUPON') {
|
||||
<div>Dr Bank ₹{{ r.grossInterest | number: '1.0-0' }}</div>
|
||||
@if (r.alreadyBooked > 0) {
|
||||
<div>
|
||||
Cr {{ interestReceivableGl.glCode }} Int. Receivable ₹{{ r.alreadyBooked | number: '1.0-0' }}
|
||||
</div>
|
||||
}
|
||||
<div>Cr {{ sc.interestGlCode }} Int. Income ₹{{ r.amount | number: '1.0-0' }}</div>
|
||||
} @else {
|
||||
<div>Dr {{ interestReceivableGl.glCode }} Int. Receivable ₹{{ r.amount | number: '1.0-0' }}</div>
|
||||
<div>Cr {{ sc.interestGlCode }} Int. Income ₹{{ r.amount | number: '1.0-0' }}</div>
|
||||
}
|
||||
</td>
|
||||
<td style="white-space: nowrap">
|
||||
@if (r.posted) {
|
||||
<span class="pg-chip" [title]="'GL ' + r.glTransactionId">Posted · {{ r.voucherNo }}</span>
|
||||
} @else if (r.postable) {
|
||||
<button
|
||||
type="button"
|
||||
class="pg-btn pg-btn--primary"
|
||||
[disabled]="intPosting"
|
||||
(click)="generateVoucher(r)"
|
||||
>
|
||||
Generate Voucher
|
||||
</button>
|
||||
} @else if (r.dueSoon) {
|
||||
<span class="pg-chip">🔔 Due {{ r.intDate }}</span>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
} @empty {
|
||||
<tr>
|
||||
<td colspan="11" class="pg-empty">
|
||||
No interest lines — check the rate, last interest date and maturity date.
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="pg-sub" style="padding: 8px 16px 12px">
|
||||
Interest income GL: {{ sc.interestGlCode }} — {{ sc.interestGlName }} · Interest receivable GL:
|
||||
{{ interestReceivableGl.glCode }}.
|
||||
</p>
|
||||
} @else {
|
||||
@if (intCalcExcludedNpi.length > 0) {
|
||||
<p class="pg-sub" style="padding: 0 16px 12px">
|
||||
Select a Deal No and press Retrieve to see its interest schedule.
|
||||
{{ intCalcExcludedNpi.length }} holding(s) excluded — classified Non-Performing, interest is not posted on
|
||||
accrual basis (collectible on cash basis only, via Interest Receive in the Investment Interest module).
|
||||
</p>
|
||||
}
|
||||
<div class="pos-section-label">Holdings matching the filter ({{ intCalcTargets.length }})</div>
|
||||
<table class="pg-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Cert No</th>
|
||||
<th>Script</th>
|
||||
<th>Type</th>
|
||||
<th class="num">Rate</th>
|
||||
<th>Frequency</th>
|
||||
<th class="num col-in">Interest to Post</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (h of intCalcTargets; track h.certNo) {
|
||||
<tr>
|
||||
<td>
|
||||
<span class="pg-chip">{{ h.certNo }}</span>
|
||||
</td>
|
||||
<td>{{ h.scriptName }}</td>
|
||||
<td>{{ instrumentLabel(h.instrumentType) }}</td>
|
||||
<td class="num">{{ h.interestRate }}%</td>
|
||||
<td>{{ h.interestFreq }}</td>
|
||||
<td class="num col-in">₹{{ interestAccrued(h) | number: '1.2-2' }}</td>
|
||||
</tr>
|
||||
} @empty {
|
||||
<tr>
|
||||
<td colspan="6" class="pg-empty">No holdings match the selected filters.</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1362,7 +1100,7 @@
|
||||
<td>{{ t.certNo }}</td>
|
||||
<td>{{ t.txnType }}</td>
|
||||
<td>{{ t.particulars }}</td>
|
||||
<td>{{ t.glCode ? t.glCode + ' — ' + t.glName : t.glName || '—' }}</td>
|
||||
<td>{{ t.glCode ? t.glCode + ' — ' + t.glName : '—' }}</td>
|
||||
<td class="num">₹{{ t.amount | number: '1.2-2' }}</td>
|
||||
</tr>
|
||||
} @empty {
|
||||
|
||||
@@ -6,12 +6,16 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { DateDdmmyyyyPickerComponent } from '../date-ddmmyyyy-picker/date-ddmmyyyy-picker.component';
|
||||
import {
|
||||
GOVT_SECURITY_HOLDINGS,
|
||||
NON_SLR_HOLDINGS,
|
||||
BOND_HOLDINGS,
|
||||
MUTUAL_FUND_HOLDINGS,
|
||||
ALL_TXNS,
|
||||
SCRIPT_MASTER,
|
||||
PARTY_MASTER,
|
||||
SUBTYPE_MASTER,
|
||||
@@ -27,26 +31,16 @@ import {
|
||||
BOND_RATING_OPTIONS,
|
||||
INT_TYPE_OPTIONS,
|
||||
AUTHORITY_OPTIONS,
|
||||
INVESTMENT_GL_BY_TYPE,
|
||||
INVESTMENT_GL_LOOKUP,
|
||||
INTEREST_RECEIVABLE_GL,
|
||||
BROKEN_PERIOD_INTEREST_GL,
|
||||
STAMP_DUTY_GL,
|
||||
BROKERAGE_GL,
|
||||
OTHER_CHARGES_GL,
|
||||
SETTLEMENT_BANK_GL_OPTIONS,
|
||||
periodBetween,
|
||||
parseDDMMYYYY,
|
||||
days360,
|
||||
lastHalfYearlyCouponDate,
|
||||
nextHalfYearlyCouponDate,
|
||||
couponDatesLabel,
|
||||
INTEREST_INCOME_GL_MASTER,
|
||||
INTEREST_INCOME_GL_BY_TYPE,
|
||||
InvestmentHolding,
|
||||
InvestmentTxn,
|
||||
InstrumentType,
|
||||
InterestFreq,
|
||||
INSTRUMENT_LABELS,
|
||||
accruedInterest,
|
||||
accruedInterestBetween,
|
||||
canAccrueInterest,
|
||||
daysToMaturity,
|
||||
maturityAmount,
|
||||
addPeriod,
|
||||
@@ -55,16 +49,6 @@ import {
|
||||
todayDDMMYYYY
|
||||
} from '../investment-data';
|
||||
import { exportWorkbook } from '../investment-export';
|
||||
import {
|
||||
InvestmentDailyRateDto,
|
||||
InvestmentInterestDueDto,
|
||||
InvestmentInterestRowDto,
|
||||
InvestmentInterestScheduleDto,
|
||||
InvestmentPurchaseDto,
|
||||
InvestmentService,
|
||||
apiErrorMessage,
|
||||
toHolding
|
||||
} from '../investment.service';
|
||||
|
||||
type BondType = 'GOVT_SECURITY' | 'NON_SLR' | 'BOND' | 'MUTUAL_FUND';
|
||||
type BondTab =
|
||||
@@ -145,14 +129,6 @@ interface BondPurchaseForm {
|
||||
holdingDays: number | null;
|
||||
stampDuty: number | null;
|
||||
stampDutyAc: string;
|
||||
otherCharges: number | null;
|
||||
}
|
||||
|
||||
interface AccountingPreviewLine {
|
||||
side: 'Dr' | 'Cr';
|
||||
glCode: string;
|
||||
glName: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
interface BondSellForm {
|
||||
@@ -206,75 +182,23 @@ interface BondSellForm {
|
||||
DateDdmmyyyyPickerComponent
|
||||
]
|
||||
})
|
||||
export class BondInvestmentComponent implements OnInit {
|
||||
private readonly investmentService = inject(InvestmentService);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
|
||||
/** Script and party dropdowns offer the masters saved in the backend. */
|
||||
ngOnInit(): void {
|
||||
// The home-screen interest alert links here with ?tab=interest.
|
||||
if (this.route.snapshot.queryParamMap.get('tab') === 'interest') {
|
||||
this.activeTab = 'interest';
|
||||
}
|
||||
this.investmentService.syncSharedMasters().subscribe({
|
||||
error: (err) => this.toast(`Could not load Script / Party masters: ${apiErrorMessage(err)}`)
|
||||
});
|
||||
this.investmentService.getAssetGlAccounts().subscribe({
|
||||
next: (gls) =>
|
||||
(this.glIdByCode = new Map(
|
||||
gls.map((g) => [
|
||||
g.glCode,
|
||||
g.id
|
||||
])
|
||||
)),
|
||||
error: (err) => this.toast(`Could not load GL accounts: ${apiErrorMessage(err)}`)
|
||||
});
|
||||
this.loadPurchases();
|
||||
this.loadDueInterest();
|
||||
}
|
||||
|
||||
/** GL id for a GL code — the purchase API takes ids, the form works with codes. */
|
||||
private glIdByCode = new Map<string, number>();
|
||||
|
||||
/** The Holdings register and transaction log are the purchases saved in the backend. */
|
||||
private loadPurchases(): void {
|
||||
this.investmentService.getPurchases().subscribe({
|
||||
next: (purchases) => {
|
||||
this.holdings = purchases.map(toHolding);
|
||||
this.txns = purchases.map((d) => this.purchaseTxn(d));
|
||||
this.purchaseForm = this.blankPurchaseForm();
|
||||
},
|
||||
error: (err) => this.toast(`Could not load purchases: ${apiErrorMessage(err)}`)
|
||||
});
|
||||
}
|
||||
|
||||
/** A purchase reaches the GL only when it is settled, dated the settlement date. */
|
||||
private purchaseTxn(d: InvestmentPurchaseDto): InvestmentTxn {
|
||||
const posted = !!d.glTransactionId;
|
||||
return {
|
||||
certNo: d.certNo,
|
||||
instrumentType: d.bondType,
|
||||
txnType: 'PURCHASE',
|
||||
voucherNo: `INV/PUR/${d.dealNo}`,
|
||||
txnDate: d.settlementDate,
|
||||
amount: d.settlementAmount,
|
||||
particulars: `Purchase Deal ${d.dealNo} - ${d.scriptDesc} - ${d.partyName} [${d.category}]`,
|
||||
glCode: posted ? d.investmentGlCode : '',
|
||||
glName: posted ? `${d.investmentGlName} (txn ${d.glTransactionId})` : 'Not posted (pending settlement)'
|
||||
};
|
||||
}
|
||||
|
||||
export class BondInvestmentComponent {
|
||||
activeTab: BondTab = 'holdings';
|
||||
/** Purchase Entry shows only the mandatory fields; the rest sit under "More Details". */
|
||||
showMoreDetails = false;
|
||||
/** Cert No typed in the Retrieve box (Cert No itself is system-generated and read-only). */
|
||||
retrieveCertNo = '';
|
||||
bondType: BondType = 'GOVT_SECURITY';
|
||||
asOnDate = todayDDMMYYYY();
|
||||
|
||||
/** Loaded from the backend (saved purchases) in ngOnInit. */
|
||||
holdings: InvestmentHolding[] = [];
|
||||
txns: InvestmentTxn[] = [];
|
||||
holdings: InvestmentHolding[] = [
|
||||
...GOVT_SECURITY_HOLDINGS,
|
||||
...NON_SLR_HOLDINGS,
|
||||
...BOND_HOLDINGS,
|
||||
...MUTUAL_FUND_HOLDINGS
|
||||
];
|
||||
txns: InvestmentTxn[] = ALL_TXNS.filter((t) => ([
|
||||
'GOVT_SECURITY',
|
||||
'NON_SLR',
|
||||
'BOND',
|
||||
'MUTUAL_FUND'
|
||||
] as InstrumentType[]).includes(t.instrumentType));
|
||||
|
||||
// Master-driven dropdown sources
|
||||
readonly scriptOptions = SCRIPT_MASTER;
|
||||
@@ -300,30 +224,23 @@ export class BondInvestmentComponent implements OnInit {
|
||||
|
||||
purchaseForm: BondPurchaseForm = this.blankPurchaseForm();
|
||||
sellForm: BondSellForm = this.blankSellForm();
|
||||
readonly settlementBankOptions = SETTLEMENT_BANK_GL_OPTIONS;
|
||||
|
||||
// Redemption Entry
|
||||
redeemCertNo = '';
|
||||
redeemDate = this.asOnDate;
|
||||
redeemRemarks = '';
|
||||
|
||||
// 03 Interest Entry (legacy: Type / Script / Deal No + Retrieve) — the backend works out every
|
||||
// half-yearly coupon and 31 Mar / 30 Sep closing provision of the holding. Display only:
|
||||
// nothing is posted to GL until the posting rules are approved.
|
||||
intType: BondType | '' = '';
|
||||
intScript = '';
|
||||
intPurchaseId: number | null = null;
|
||||
intAsOnDate = this.asOnDate;
|
||||
intSchedule: InvestmentInterestScheduleDto | null = null;
|
||||
intLoading = false;
|
||||
/** Interest lines of all holdings due now or within two days — what Jitendra Sir asked to be reminded of. */
|
||||
intDueTasks: InvestmentInterestDueDto[] = [];
|
||||
/** By default the schedule shows only lines up to the end of next year (and anything already posted). */
|
||||
intShowFullSchedule = false;
|
||||
/** Bank a coupon is received into; defaults to the purchase's paying bank. */
|
||||
intBankGlCode = '';
|
||||
intPosting = false;
|
||||
readonly interestReceivableGl = INTEREST_RECEIVABLE_GL;
|
||||
// Interest Calculation (legacy: From/To Date / Type / Script / Deal No / ALL + Process) —
|
||||
// posts interest accrued strictly within [intCalcFromDate, intCalcToDate], same period-based
|
||||
// basis as the Investment Interest module's Govt./Bond Interest Calculation.
|
||||
intCalcFromDate = addPeriod(this.asOnDate, 0, -3);
|
||||
intCalcToDate = this.asOnDate;
|
||||
intCalcType: BondType | '' = '';
|
||||
intCalcScript = '';
|
||||
intCalcDealNo = '';
|
||||
intCalcAll = false;
|
||||
intCalcGlCode = INTEREST_INCOME_GL_BY_TYPE.GOVT_SECURITY;
|
||||
readonly interestIncomeGlOptions = INTEREST_INCOME_GL_MASTER;
|
||||
|
||||
// Write-off
|
||||
writeoffCertNo = '';
|
||||
@@ -388,38 +305,20 @@ export class BondInvestmentComponent implements OnInit {
|
||||
return INSTRUMENT_LABELS[type];
|
||||
}
|
||||
|
||||
/** Preview of the deal number the backend will assign: FY prefix (e.g. 202627) + running number. */
|
||||
private nextDealNo(): string {
|
||||
const d = parseDDMMYYYY(this.asOnDate);
|
||||
const fyStart = d.getMonth() >= 3 ? d.getFullYear() : d.getFullYear() - 1;
|
||||
const prefix = `${fyStart}${String((fyStart + 1) % 100).padStart(2, '0')}`;
|
||||
const nums = (this.holdings ?? [])
|
||||
.map((h) => h.dealNo)
|
||||
.filter((n): n is string => !!n && n.startsWith(prefix))
|
||||
.map((n) => parseInt(n.slice(prefix.length), 10));
|
||||
return `${prefix}${String((nums.length ? Math.max(...nums) : 0) + 1).padStart(6, '0')}`;
|
||||
}
|
||||
|
||||
/** Certificate No is system-generated, as in the existing CBS (greyed there). */
|
||||
/** Preview of the certificate number the backend will assign (running number). */
|
||||
private nextCertNo(): string {
|
||||
const nums = (this.holdings ?? []).map((h) => parseInt(h.certNo, 10)).filter((n) => !isNaN(n));
|
||||
return String((nums.length ? Math.max(...nums) : 0) + 1);
|
||||
return `2026${String(27000039 + this.holdings.length).padStart(9, '0')}`;
|
||||
}
|
||||
|
||||
private blankPurchaseForm(): BondPurchaseForm {
|
||||
const type = this.bondType ?? 'GOVT_SECURITY';
|
||||
this.showMoreDetails = false;
|
||||
this.retrieveCertNo = '';
|
||||
this.purchaseMarketRate = undefined;
|
||||
return {
|
||||
bondType: type,
|
||||
dealNo: this.nextDealNo(),
|
||||
dealDate: this.asOnDate,
|
||||
dealTime: new Date().toTimeString().slice(0, 8),
|
||||
dealTime: '',
|
||||
isin: '',
|
||||
scriptCode: '',
|
||||
certNo: this.nextCertNo(),
|
||||
certNo: '',
|
||||
settlementType: 'T+0',
|
||||
settlementDt: this.asOnDate,
|
||||
faceValue: null,
|
||||
@@ -427,7 +326,7 @@ export class BondInvestmentComponent implements OnInit {
|
||||
partyCode: '',
|
||||
subType: type === 'GOVT_SECURITY' ? 'SLR' : type === 'NON_SLR' ? 'NON SLR' : 'CORPORATE BOND',
|
||||
tbillGlAc: '',
|
||||
crToAc: SETTLEMENT_BANK_GL_OPTIONS[0]?.glCode ?? '',
|
||||
crToAc: '310070',
|
||||
premiumAmt: null,
|
||||
brokerage: null,
|
||||
brokerName: '',
|
||||
@@ -475,8 +374,7 @@ export class BondInvestmentComponent implements OnInit {
|
||||
nav: null,
|
||||
holdingDays: null,
|
||||
stampDuty: null,
|
||||
stampDutyAc: '',
|
||||
otherCharges: null
|
||||
stampDutyAc: ''
|
||||
};
|
||||
}
|
||||
|
||||
@@ -546,41 +444,14 @@ export class BondInvestmentComponent implements OnInit {
|
||||
return this.isMutualFund ? this.purchaseForm.nav || 0 : 100;
|
||||
}
|
||||
|
||||
/** Book Value — the price paid for the security. Charges are expenses and stay out of it (Jitendra Sir). */
|
||||
/** Book Value — what the investment is carried at, i.e. amount actually paid. */
|
||||
get purchaseBookValue(): number {
|
||||
const f = this.purchaseForm;
|
||||
if (this.isMutualFund) {
|
||||
return this.purchaseBaseAmount;
|
||||
return this.purchaseBaseAmount + (f.stampDuty || 0) + (f.brokerage || 0);
|
||||
}
|
||||
const rate = f.purchaseRate || 100;
|
||||
return Math.round((this.purchaseBaseAmount * rate) / 100);
|
||||
}
|
||||
|
||||
/** Stamp duty + brokerage + other charges — paid with the settlement, booked to expense GLs. */
|
||||
get purchaseTotalCharges(): number {
|
||||
const f = this.purchaseForm;
|
||||
return (f.stampDuty || 0) + (f.brokerage || 0) + (f.otherCharges || 0);
|
||||
}
|
||||
|
||||
// Interest cycle of the security being bought: its two coupon days and the next coupon after the deal.
|
||||
get purchaseCouponDates(): string {
|
||||
return this.purchaseMaturityDate ? couponDatesLabel(this.purchaseMaturityDate) : '';
|
||||
}
|
||||
|
||||
get purchaseNextCouponDate(): string {
|
||||
const f = this.purchaseForm;
|
||||
return this.purchaseMaturityDate && f.dealDate
|
||||
? nextHalfYearlyCouponDate(this.purchaseMaturityDate, f.dealDate)
|
||||
: '';
|
||||
}
|
||||
|
||||
get purchaseNextCouponAmount(): number {
|
||||
const f = this.purchaseForm;
|
||||
return f.intRate ? Math.round((this.purchaseBaseAmount * f.intRate) / 200) : 0;
|
||||
}
|
||||
|
||||
get purchaseDaysToNextCoupon(): number {
|
||||
return this.purchaseNextCouponDate ? days360(this.purchaseForm.dealDate, this.purchaseNextCouponDate) : 0;
|
||||
return Math.round((this.purchaseBaseAmount * rate) / 100) + (f.brokerage || 0);
|
||||
}
|
||||
|
||||
get purchaseYtm(): number {
|
||||
@@ -591,47 +462,19 @@ export class BondInvestmentComponent implements OnInit {
|
||||
return approxYtm(f.intRate, f.purchaseRate || 100, yearsBetween(f.issueDate, this.purchaseMaturityDate));
|
||||
}
|
||||
|
||||
/** Broken-period interest owed to the seller from the last coupon date up to the settlement date, 30/360. */
|
||||
/** Accrued Interest at purchase — interest earned by the seller since the last coupon date. */
|
||||
get purchaseAccruedInterest(): number {
|
||||
const f = this.purchaseForm;
|
||||
if (!f.intRate || !f.lastIntDt || !f.dealDate) {
|
||||
return 0;
|
||||
}
|
||||
return Math.round((this.purchaseBaseAmount * (f.intRate / 100) * this.purchaseAccruedDays) / 360);
|
||||
const yrs = Math.max(0, yearsBetween(f.lastIntDt, f.dealDate));
|
||||
return Math.round(this.purchaseBaseAmount * (f.intRate / 100) * yrs);
|
||||
}
|
||||
|
||||
get purchaseAccruedDays(): number {
|
||||
const f = this.purchaseForm;
|
||||
// Up to the settlement date, when the bond leaves the seller (RBI para 83; Jitendra Sir).
|
||||
return f.lastIntDt && this.purchaseSettlementDate ? days360(f.lastIntDt, this.purchaseSettlementDate) : 0;
|
||||
}
|
||||
|
||||
/** Premium (+) or discount (−) paid over face value. */
|
||||
get purchasePremiumDiscount(): number {
|
||||
const f = this.purchaseForm;
|
||||
if (this.isMutualFund || !f.faceValue || !f.purchaseRate) {
|
||||
return 0;
|
||||
}
|
||||
return Math.round((f.faceValue * (f.purchaseRate - 100)) / 100);
|
||||
}
|
||||
|
||||
/** Re-suggests the last coupon date when the deal date changes. */
|
||||
onDealDateChange(): void {
|
||||
this.suggestLastIntDate();
|
||||
this.loadMarketRate();
|
||||
}
|
||||
|
||||
private suggestLastIntDate(): void {
|
||||
const f = this.purchaseForm;
|
||||
const s = this.purchaseScript;
|
||||
if (!this.isMutualFund && s?.maturityDate && f.dealDate) {
|
||||
f.lastIntDt = lastHalfYearlyCouponDate(s.maturityDate, f.dealDate) || f.lastIntDt;
|
||||
}
|
||||
}
|
||||
|
||||
/** Settlement Amt of Purchase — book value, accrued interest payable to the seller and the charges. */
|
||||
/** Settlement Amt of Purchase — book value plus accrued interest payable to the seller. */
|
||||
get purchaseSettlementAmount(): number {
|
||||
return this.purchaseBookValue + this.purchaseAccruedInterest + this.purchaseTotalCharges;
|
||||
return this.purchaseBookValue + this.purchaseAccruedInterest;
|
||||
}
|
||||
|
||||
get purchaseMaturityAmount(): number {
|
||||
@@ -661,264 +504,69 @@ export class BondInvestmentComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
get purchaseScript(): (typeof SCRIPT_MASTER)[number] | undefined {
|
||||
return this.scriptOptions.find((x) => x.scriptCode === this.purchaseForm.scriptCode);
|
||||
}
|
||||
|
||||
/** Picking a script pulls its master details into the deal, as the existing CBS does. */
|
||||
/** Fills ISIN + interest rate when a script is picked, mirroring the legacy form's lookup. */
|
||||
onScriptChange(): void {
|
||||
const s = this.purchaseScript;
|
||||
if (!s) {
|
||||
return;
|
||||
const s = this.scriptOptions.find((x) => x.scriptCode === this.purchaseForm.scriptCode);
|
||||
if (s) {
|
||||
this.purchaseForm.isin = s.isin;
|
||||
}
|
||||
const f = this.purchaseForm;
|
||||
f.isin = s.isin;
|
||||
if (s.couponRate != null) {
|
||||
f.intRate = s.couponRate;
|
||||
}
|
||||
if (s.issueDate) {
|
||||
f.issueDate = s.issueDate;
|
||||
}
|
||||
if (s.maturityDate) {
|
||||
f.redumMatDt = s.maturityDate;
|
||||
const p = periodBetween(s.issueDate, s.maturityDate);
|
||||
f.periodYear = p.years;
|
||||
f.periodMonth = p.months;
|
||||
f.periodDays = p.days;
|
||||
}
|
||||
if (s.slrType) {
|
||||
f.subType = s.slrType === 'NON_SLR' ? 'NON SLR' : 'SLR';
|
||||
}
|
||||
if (this.isMutualFund) {
|
||||
f.productName = s.scriptName;
|
||||
}
|
||||
this.suggestLastIntDate();
|
||||
this.loadMarketRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Market rate of the script for the deal date from the Daily Script Master (newest rate on or before it). It fills
|
||||
* the purchase rate (NAV for a mutual fund); the dealer may still change it. undefined = not looked up yet,
|
||||
* null = no rate entered for the script.
|
||||
*/
|
||||
purchaseMarketRate: InvestmentDailyRateDto | null | undefined;
|
||||
|
||||
private loadMarketRate(): void {
|
||||
const s = this.purchaseScript;
|
||||
const f = this.purchaseForm;
|
||||
if (!s?.id || !f.dealDate) {
|
||||
this.purchaseMarketRate = undefined;
|
||||
return;
|
||||
}
|
||||
this.investmentService.getLatestDailyRate(s.id, f.dealDate).subscribe({
|
||||
next: (rate) => {
|
||||
this.purchaseMarketRate = rate;
|
||||
// No market rate: clear the field rather than leave another script's rate in it.
|
||||
if (this.isMutualFund) {
|
||||
f.nav = rate ? rate.closeRate : null;
|
||||
} else {
|
||||
f.purchaseRate = rate ? rate.closeRate : null;
|
||||
}
|
||||
},
|
||||
error: (err) => this.toast(`Could not read the market rate: ${apiErrorMessage(err)}`)
|
||||
});
|
||||
}
|
||||
|
||||
/** True when the rate entered is outside the day's low–high in the Daily Script Master. */
|
||||
get purchaseRateOutOfRange(): boolean {
|
||||
const m = this.purchaseMarketRate;
|
||||
const f = this.purchaseForm;
|
||||
const rate = this.isMutualFund ? f.nav : f.purchaseRate;
|
||||
if (!m || rate == null) {
|
||||
return false;
|
||||
}
|
||||
return (m.lowRate != null && rate < m.lowRate) || (m.highRate != null && rate > m.highRate);
|
||||
}
|
||||
|
||||
/** Settlement Date = Deal Date + T+n days (greyed / auto in the existing CBS). */
|
||||
get purchaseSettlementDate(): string {
|
||||
const f = this.purchaseForm;
|
||||
if (!f.dealDate) {
|
||||
return '';
|
||||
}
|
||||
const n = parseInt(f.settlementType.replace('T+', ''), 10) || 0;
|
||||
return addPeriod(f.dealDate, 0, 0, n);
|
||||
}
|
||||
|
||||
/** Parties offered for a new deal — inactive parties are hidden. */
|
||||
get activePartyOptions(): typeof PARTY_MASTER {
|
||||
return this.partyOptions.filter((p) => p.status !== 'INACTIVE');
|
||||
}
|
||||
|
||||
get purchaseInvestmentGlCode(): string {
|
||||
return this.purchaseScript?.glCode || INVESTMENT_GL_BY_TYPE[this.purchaseForm.bondType];
|
||||
}
|
||||
|
||||
glNameOf(glCode: string): string {
|
||||
return INVESTMENT_GL_LOOKUP.find((g) => g.glCode === glCode)?.glName ?? '';
|
||||
}
|
||||
|
||||
/** The journal entry this purchase will post once the checker approves it. */
|
||||
get purchaseAccountingPreview(): AccountingPreviewLine[] {
|
||||
const book = this.purchaseBookValue;
|
||||
const accrued = this.purchaseAccruedInterest;
|
||||
const total = this.purchaseSettlementAmount;
|
||||
const crGl = this.purchaseForm.crToAc;
|
||||
if (!book || !crGl) {
|
||||
return [];
|
||||
}
|
||||
const invGl = this.purchaseInvestmentGlCode;
|
||||
const lines: AccountingPreviewLine[] = [
|
||||
{ side: 'Dr', glCode: invGl, glName: this.glNameOf(invGl), amount: book }];
|
||||
// Broken-period interest paid to the seller is an expense (RBI para 152, confirmed by Jitendra Sir).
|
||||
if (accrued > 0) {
|
||||
lines.push({
|
||||
side: 'Dr',
|
||||
glCode: BROKEN_PERIOD_INTEREST_GL.glCode,
|
||||
glName: BROKEN_PERIOD_INTEREST_GL.glName,
|
||||
amount: accrued
|
||||
});
|
||||
}
|
||||
const f = this.purchaseForm;
|
||||
for (const [
|
||||
gl,
|
||||
amount
|
||||
] of [
|
||||
[
|
||||
STAMP_DUTY_GL,
|
||||
f.stampDuty
|
||||
],
|
||||
[
|
||||
BROKERAGE_GL,
|
||||
f.brokerage
|
||||
],
|
||||
[
|
||||
OTHER_CHARGES_GL,
|
||||
f.otherCharges
|
||||
]
|
||||
] as const) {
|
||||
if (amount && amount > 0) {
|
||||
lines.push({ side: 'Dr', glCode: gl.glCode, glName: gl.glName, amount });
|
||||
}
|
||||
}
|
||||
lines.push({ side: 'Cr', glCode: crGl, glName: this.glNameOf(crGl), amount: total });
|
||||
return lines;
|
||||
}
|
||||
|
||||
savePurchase(): void {
|
||||
const f = this.purchaseForm;
|
||||
const missing: string[] = [];
|
||||
if (!f.scriptCode) missing.push('Script Code');
|
||||
if (!f.partyCode) missing.push('Party Code');
|
||||
if (!f.dealDate) missing.push('Deal Date');
|
||||
if (!f.dealTime) missing.push('Deal Time');
|
||||
if (this.isMutualFund) {
|
||||
if (!f.considerAmt) missing.push('Consider Amt');
|
||||
if (!f.nav) missing.push('NAV');
|
||||
} else {
|
||||
if (!f.faceValue) missing.push('Face Value');
|
||||
if (!f.purchaseRate) missing.push('Purchase Rate');
|
||||
if (!f.lastIntDt) missing.push('Last Interest Date');
|
||||
}
|
||||
if (!f.category) missing.push('Category');
|
||||
if (!f.crToAc) missing.push('CR. To A/c');
|
||||
if (missing.length) {
|
||||
this.toast(`Please fill: ${missing.join(', ')}.`);
|
||||
if (!f.certNo || !this.purchaseBaseAmount || !f.partyCode) {
|
||||
this.toast('Please fill Cert No, Face Value / Consider Amt and Party Code.');
|
||||
return;
|
||||
}
|
||||
const script = this.purchaseScript;
|
||||
const party = this.partyOptions.find((p) => p.partyCode === f.partyCode);
|
||||
const crGlAccountId = this.glIdByCode.get(f.crToAc);
|
||||
if (!script?.id || !party?.id) {
|
||||
this.toast('Script and Party must be saved in Investment Masters first.');
|
||||
return;
|
||||
}
|
||||
if (!crGlAccountId) {
|
||||
this.toast(`GL ${f.crToAc} was not found in the chart of accounts.`);
|
||||
return;
|
||||
}
|
||||
const body = {
|
||||
bondType: f.bondType,
|
||||
scriptId: script.id,
|
||||
partyId: party.id,
|
||||
dealDate: f.dealDate,
|
||||
dealTime: f.dealTime || '',
|
||||
settlementType: f.settlementType,
|
||||
...(this.isMutualFund
|
||||
? { considerAmt: f.considerAmt, nav: f.nav }
|
||||
: { faceValue: f.faceValue, purchaseRate: f.purchaseRate, lastIntDate: f.lastIntDt }),
|
||||
stampDuty: f.stampDuty ?? null,
|
||||
brokerage: f.brokerage ?? null,
|
||||
otherCharges: f.otherCharges ?? null,
|
||||
category: f.category,
|
||||
crGlAccountId,
|
||||
subType: f.subType || '',
|
||||
otherDetails: this.purchaseOtherDetails(),
|
||||
dateFormat: 'dd-MM-yyyy',
|
||||
locale: 'en'
|
||||
};
|
||||
this.investmentService.createPurchase(body).subscribe({
|
||||
next: (res) => {
|
||||
this.toast(
|
||||
`Deal ${res.resourceIdentifier} saved — pending settlement. Settle it from Holdings on or after the settlement date.`
|
||||
);
|
||||
this.activeTab = 'holdings';
|
||||
this.loadPurchases();
|
||||
},
|
||||
error: (err) => this.toast(apiErrorMessage(err))
|
||||
});
|
||||
}
|
||||
|
||||
/** The optional "More Details" fields, kept with the deal as they were entered. */
|
||||
private purchaseOtherDetails(): Record<string, string | number> {
|
||||
const f = this.purchaseForm;
|
||||
const fields: Record<string, string | number | null> = {
|
||||
tradeNo: f.tradeNo,
|
||||
orderNo: f.orderNo,
|
||||
const holding: InvestmentHolding = {
|
||||
certNo: f.certNo,
|
||||
instrumentType: f.bondType,
|
||||
scriptCode: f.scriptCode || f.isin || f.productName,
|
||||
scriptName: this.isMutualFund
|
||||
? f.productName
|
||||
: this.scriptOptions.find((s) => s.scriptCode === f.scriptCode)?.scriptName || f.scriptCode || f.isin,
|
||||
party: f.partyCode,
|
||||
subType: f.subType,
|
||||
faceValue: this.purchaseBaseAmount,
|
||||
purchaseRate: this.isMutualFund ? f.nav || 0 : f.purchaseRate || 100,
|
||||
units: this.purchaseUnits,
|
||||
purchaseDate: f.issueDate,
|
||||
maturityDate: this.purchaseMaturityDate || f.issueDate,
|
||||
interestRate: f.intRate || 0,
|
||||
interestFreq: this.isMutualFund ? 'CUMULATIVE' : f.intType,
|
||||
glCode:
|
||||
'31' +
|
||||
(f.bondType === 'GOVT_SECURITY'
|
||||
? '0020'
|
||||
: f.bondType === 'NON_SLR'
|
||||
? '0030'
|
||||
: f.bondType === 'BOND'
|
||||
? '0040'
|
||||
: '0050'),
|
||||
glName: `INVESTMENT IN ${INSTRUMENT_LABELS[f.bondType].toUpperCase()}`,
|
||||
crToAc: f.crToAc,
|
||||
brokerCode: f.brokerName,
|
||||
recommAuthority: f.recommAuthority,
|
||||
sanctionAuthority: f.sanctionAuthority,
|
||||
meetDate: f.meetDt,
|
||||
resoNo: f.resoNo,
|
||||
dealType: f.dealType,
|
||||
market: f.market,
|
||||
markCblo: f.markCblo,
|
||||
paymentMode: f.paymentMode,
|
||||
deliveryMode: f.deliveryMode,
|
||||
lien: f.lien,
|
||||
lienAmount: f.lienAmount,
|
||||
lienReason: f.lienReason,
|
||||
bondRating: f.bondRating,
|
||||
corpBond: f.corpBond,
|
||||
sglWithBank: f.sglWithBank,
|
||||
tbillGlAc: f.tbillGlAc,
|
||||
intType: f.intType,
|
||||
intDate: f.intDate,
|
||||
folioNo: f.folioNo,
|
||||
callOption: f.callOption,
|
||||
descInv: f.descInv,
|
||||
fromDist: f.fromDist,
|
||||
toDist: f.toDist,
|
||||
amortizeAmt: f.amortizeAmt,
|
||||
registerAddress: f.registerAdd,
|
||||
registerCity: f.regiCity,
|
||||
registerPin: f.regiPin,
|
||||
remarks: f.remarks,
|
||||
description: f.description,
|
||||
tradeAmt: f.tradeAmt,
|
||||
holdingDays: f.holdingDays,
|
||||
stampDutyAc: f.stampDutyAc
|
||||
status: 'ACTIVE'
|
||||
};
|
||||
const out: Record<string, string | number> = {};
|
||||
for (const [
|
||||
k,
|
||||
v
|
||||
] of Object.entries(fields)) {
|
||||
if (v !== null && v !== undefined && v !== '') {
|
||||
out[k] = v;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
this.holdings = [
|
||||
holding,
|
||||
...this.holdings
|
||||
];
|
||||
this.txns = [
|
||||
{
|
||||
certNo: holding.certNo,
|
||||
instrumentType: f.bondType,
|
||||
txnType: 'PURCHASE',
|
||||
voucherNo: `INV/PUR/${f.dealNo}`,
|
||||
txnDate: f.dealDate,
|
||||
amount: this.purchaseSettlementAmount,
|
||||
particulars: `Purchase Deal ${f.dealNo} - ${holding.scriptName} - ${holding.party}${f.category ? ' [' + f.category + ']' : ''}`
|
||||
},
|
||||
...this.txns
|
||||
];
|
||||
this.toast(`${INSTRUMENT_LABELS[f.bondType]} Certificate ${holding.certNo} saved successfully.`);
|
||||
this.purchaseForm = this.blankPurchaseForm();
|
||||
this.activeTab = 'holdings';
|
||||
}
|
||||
|
||||
cancelPurchase(): void {
|
||||
@@ -928,10 +576,9 @@ export class BondInvestmentComponent implements OnInit {
|
||||
|
||||
/** Legacy "Retrieve" button — loads an existing deal back into the form by Cert No. */
|
||||
retrievePurchase(): void {
|
||||
const certNo = this.retrieveCertNo.trim();
|
||||
const h = this.holdings.find((x) => x.certNo === certNo);
|
||||
const h = this.holdings.find((x) => x.certNo === this.purchaseForm.certNo.trim());
|
||||
if (!h) {
|
||||
this.toast(`Cert No ${certNo || '(blank)'} not found.`);
|
||||
this.toast(`Cert No ${this.purchaseForm.certNo} not found.`);
|
||||
return;
|
||||
}
|
||||
this.purchaseForm = {
|
||||
@@ -940,8 +587,7 @@ export class BondInvestmentComponent implements OnInit {
|
||||
certNo: h.certNo,
|
||||
scriptCode: h.scriptCode,
|
||||
isin: this.scriptOptions.find((s) => s.scriptCode === h.scriptCode)?.isin || '',
|
||||
dealNo: h.dealNo ?? '',
|
||||
partyCode: h.partyCode ?? '',
|
||||
partyCode: h.party,
|
||||
subType: h.subType,
|
||||
faceValue: h.faceValue,
|
||||
considerAmt: h.faceValue,
|
||||
@@ -953,44 +599,22 @@ export class BondInvestmentComponent implements OnInit {
|
||||
intType: h.interestFreq,
|
||||
brokerName: h.brokerCode,
|
||||
crToAc: h.crToAc,
|
||||
productName: h.scriptName,
|
||||
category: h.category ?? ''
|
||||
productName: h.scriptName
|
||||
};
|
||||
this.bondType = h.instrumentType as BondType;
|
||||
this.toast(`Deal for Cert No ${h.certNo} retrieved.`);
|
||||
}
|
||||
|
||||
/** Posts a pending deal to GL dated its settlement date; under maker-checker it waits in the Checker Inbox. */
|
||||
settleDeal(h: InvestmentHolding): void {
|
||||
if (!h.id) {
|
||||
return;
|
||||
}
|
||||
this.investmentService.settlePurchase(h.id).subscribe({
|
||||
next: (res) => {
|
||||
this.toast(
|
||||
res.rollbackTransaction
|
||||
? `Settlement of deal ${h.dealNo} sent for approval (Checker Inbox).`
|
||||
: `Deal ${h.dealNo} settled and posted to GL (transaction ${res.transactionId}).`
|
||||
);
|
||||
this.loadPurchases();
|
||||
},
|
||||
error: (err) => this.toast(apiErrorMessage(err))
|
||||
});
|
||||
}
|
||||
|
||||
dropPurchase(): void {
|
||||
const h = this.holdings.find((x) => x.certNo === this.purchaseForm.certNo);
|
||||
if (!h?.id) {
|
||||
this.toast('Retrieve a saved deal first, then Drop.');
|
||||
const certNo = this.purchaseForm.certNo;
|
||||
if (!this.holdings.some((h) => h.certNo === certNo)) {
|
||||
this.toast('Nothing to drop — this deal is not yet saved.');
|
||||
return;
|
||||
}
|
||||
this.investmentService.deletePurchase(h.id).subscribe({
|
||||
next: () => {
|
||||
this.toast(`Deal ${h.dealNo} (Cert No ${h.certNo}) dropped.`);
|
||||
this.loadPurchases();
|
||||
},
|
||||
error: (err) => this.toast(apiErrorMessage(err))
|
||||
});
|
||||
this.holdings = this.holdings.filter((h) => h.certNo !== certNo);
|
||||
this.txns = this.txns.filter((t) => t.certNo !== certNo);
|
||||
this.purchaseForm = this.blankPurchaseForm();
|
||||
this.toast(`Cert No ${certNo} dropped.`);
|
||||
}
|
||||
|
||||
exitPurchase(): void {
|
||||
@@ -1034,113 +658,80 @@ export class BondInvestmentComponent implements OnInit {
|
||||
}
|
||||
|
||||
// -------------------- Interest calculation --------------------
|
||||
/** Saved holdings for the Deal No dropdown, narrowed by Type and Script. */
|
||||
get intDealOptions(): InvestmentHolding[] {
|
||||
return this.holdings.filter(
|
||||
(h) =>
|
||||
h.id != null &&
|
||||
h.status === 'ACTIVE' &&
|
||||
(!this.intType || h.instrumentType === this.intType) &&
|
||||
(!this.intScript || h.scriptCode === this.intScript)
|
||||
/** Holdings the Interest Calculation "Process" run would cover, given the filters. A
|
||||
* Non-Performing holding is always excluded — same accrual-basis rule as the Investment
|
||||
* Interest module (it's still collectible on cash basis via Interest Receive there). */
|
||||
get intCalcTargets(): InvestmentHolding[] {
|
||||
const base = this.holdings.filter((h) => h.status === 'ACTIVE' && canAccrueInterest(h));
|
||||
if (this.intCalcAll) {
|
||||
return base;
|
||||
}
|
||||
return base.filter((h) => {
|
||||
if (this.intCalcType && h.instrumentType !== this.intCalcType) return false;
|
||||
if (this.intCalcScript && h.scriptCode !== this.intCalcScript) return false;
|
||||
if (this.intCalcDealNo && h.certNo !== this.intCalcDealNo.trim()) return false;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
get intCalcExcludedNpi(): InvestmentHolding[] {
|
||||
return this.holdings.filter((h) => h.status === 'ACTIVE' && !canAccrueInterest(h));
|
||||
}
|
||||
|
||||
/** Re-suggests the Interest Income GL when the Type filter changes — still overridable. */
|
||||
onIntCalcTypeChange(): void {
|
||||
if (this.intCalcType) {
|
||||
this.intCalcGlCode = INTEREST_INCOME_GL_BY_TYPE[this.intCalcType];
|
||||
}
|
||||
}
|
||||
|
||||
glName(glCode: string): string {
|
||||
return this.interestIncomeGlOptions.find((g) => g.glCode === glCode)?.glName ?? glCode;
|
||||
}
|
||||
|
||||
/** Interest accrued strictly within [intCalcFromDate, intCalcToDate] — a period-based
|
||||
* Interest Calculation & Post run, same basis as the Investment Interest module. */
|
||||
interestAccrued(h: InvestmentHolding): number {
|
||||
return accruedInterestBetween(h, this.intCalcFromDate || h.purchaseDate, this.intCalcToDate || this.asOnDate);
|
||||
}
|
||||
|
||||
processInterest(): void {
|
||||
const targets = this.intCalcTargets.filter((h) => this.interestAccrued(h) > 0);
|
||||
if (targets.length === 0) {
|
||||
this.toast('No holdings have interest due to be posted for this period.');
|
||||
return;
|
||||
}
|
||||
const toDate = this.intCalcToDate || this.asOnDate;
|
||||
const fromDate = this.intCalcFromDate || toDate;
|
||||
const glCode = this.intCalcGlCode;
|
||||
const glName = this.glName(glCode);
|
||||
const newTxns: InvestmentTxn[] = targets.map((h, i) => {
|
||||
const amt = this.interestAccrued(h);
|
||||
h.interestPosted = (h.interestPosted ?? 0) + amt;
|
||||
h.interestPostedTillDate = toDate;
|
||||
return {
|
||||
certNo: h.certNo,
|
||||
instrumentType: h.instrumentType,
|
||||
txnType: 'INTEREST',
|
||||
voucherNo: `INV/INT/${h.certNo}-${this.txns.length + i + 1}`,
|
||||
txnDate: toDate,
|
||||
amount: amt,
|
||||
particulars: `Interest calculated (accrual) for period ${fromDate} to ${toDate} - ${h.scriptName}`,
|
||||
glCode,
|
||||
glName
|
||||
};
|
||||
});
|
||||
this.txns = [
|
||||
...newTxns,
|
||||
...this.txns
|
||||
];
|
||||
this.intCalcFromDate = toDate;
|
||||
const total = newTxns.reduce((s, t) => s + t.amount, 0);
|
||||
this.toast(
|
||||
`Interest processed for ${targets.length} holding(s) to ${glCode} - ${glName}. Total ₹${total.toLocaleString('en-IN')}.`
|
||||
);
|
||||
}
|
||||
|
||||
get intScriptOptions(): typeof SCRIPT_MASTER {
|
||||
return this.scriptOptions.filter((s) => !this.intType || s.instrumentType === this.intType);
|
||||
}
|
||||
|
||||
onIntFilterChange(): void {
|
||||
if (this.intScript && !this.intScriptOptions.some((s) => s.scriptCode === this.intScript)) {
|
||||
this.intScript = '';
|
||||
}
|
||||
if (this.intPurchaseId != null && !this.intDealOptions.some((h) => h.id === this.intPurchaseId)) {
|
||||
this.intPurchaseId = null;
|
||||
}
|
||||
this.intSchedule = null;
|
||||
}
|
||||
|
||||
retrieveInterestSchedule(): void {
|
||||
if (this.intPurchaseId == null) {
|
||||
this.toast('Select a Deal No first.');
|
||||
return;
|
||||
}
|
||||
this.intLoading = true;
|
||||
this.investmentService.getInterestSchedule(this.intPurchaseId, this.intAsOnDate || undefined).subscribe({
|
||||
next: (schedule) => {
|
||||
this.intSchedule = schedule;
|
||||
this.intBankGlCode = schedule.bankGlCode;
|
||||
this.intLoading = false;
|
||||
},
|
||||
error: (err) => {
|
||||
this.intSchedule = null;
|
||||
this.intLoading = false;
|
||||
this.toast(apiErrorMessage(err));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadDueInterest(): void {
|
||||
this.investmentService.getDueInterest().subscribe({
|
||||
next: (tasks) => (this.intDueTasks = tasks),
|
||||
error: () => (this.intDueTasks = [])
|
||||
});
|
||||
}
|
||||
|
||||
/** Opens a due task's holding in the schedule below. */
|
||||
openDueTask(t: InvestmentInterestDueDto): void {
|
||||
this.intType = '';
|
||||
this.intScript = '';
|
||||
this.intPurchaseId = t.purchaseId;
|
||||
this.retrieveInterestSchedule();
|
||||
}
|
||||
|
||||
/** Lines shown: up to 31 December of next year, plus anything already posted — unless the full schedule is asked for. */
|
||||
get intVisibleRows(): InvestmentInterestRowDto[] {
|
||||
const rows = this.intSchedule?.rows ?? [];
|
||||
if (this.intShowFullSchedule) {
|
||||
return rows;
|
||||
}
|
||||
const upTo = new Date(new Date().getFullYear() + 1, 11, 31);
|
||||
return rows.filter((r) => r.posted || parseDDMMYYYY(r.intDate) <= upTo);
|
||||
}
|
||||
|
||||
/** Posts one interest line with its JV voucher (passed as it is raised), then refreshes the schedule and tasks. */
|
||||
generateVoucher(r: InvestmentInterestRowDto): void {
|
||||
const sc = this.intSchedule;
|
||||
if (!sc || this.intPosting) {
|
||||
return;
|
||||
}
|
||||
const bankGlAccountId =
|
||||
r.type === 'COUPON' ? (this.glIdByCode.get(this.intBankGlCode) ?? sc.bankGlAccountId) : undefined;
|
||||
const body = {
|
||||
lineType: r.type,
|
||||
intDate: r.intDate,
|
||||
...(bankGlAccountId ? { bankGlAccountId } : {}),
|
||||
dateFormat: 'dd-MM-yyyy',
|
||||
locale: 'en'
|
||||
};
|
||||
this.intPosting = true;
|
||||
this.investmentService.postInterest(sc.purchaseId, body).subscribe({
|
||||
next: (res) => {
|
||||
this.intPosting = false;
|
||||
this.toast(
|
||||
`${r.type === 'COUPON' ? 'Coupon' : 'Provision'} of ${r.intDate} posted — voucher ${res.resourceIdentifier ?? ''}.`
|
||||
);
|
||||
this.retrieveInterestSchedule();
|
||||
this.loadDueInterest();
|
||||
},
|
||||
error: (err) => {
|
||||
this.intPosting = false;
|
||||
this.toast(apiErrorMessage(err));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Total of the lines falling due up to the as-on date. */
|
||||
get intDueTotal(): number {
|
||||
return (this.intSchedule?.rows ?? []).filter((r) => r.due).reduce((sum, r) => sum + r.amount, 0);
|
||||
}
|
||||
|
||||
// -------------------- Sell / Redeem Entry --------------------
|
||||
/** Locates the original purchase by Deal No / Cert No or ISIN and fills the sell form. */
|
||||
searchPurchaseForSell(): void {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
export type InstrumentType = 'FD' | 'GOVT_SECURITY' | 'NON_SLR' | 'BOND' | 'MUTUAL_FUND' | 'SHARE';
|
||||
export type HoldingStatus = 'PENDING_SETTLEMENT' | 'ACTIVE' | 'MATURED' | 'SOLD' | 'WRITTEN_OFF';
|
||||
export type HoldingStatus = 'ACTIVE' | 'MATURED' | 'SOLD' | 'WRITTEN_OFF';
|
||||
export type InterestFreq = 'MONTHLY' | 'QUARTERLY' | 'HALF_YEARLY' | 'YEARLY' | 'CUMULATIVE';
|
||||
export type TxnType =
|
||||
| 'PURCHASE'
|
||||
@@ -123,20 +123,6 @@ 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;
|
||||
/** Journal entry transaction posted when the deal was settled. */
|
||||
glTransactionId?: string;
|
||||
}
|
||||
|
||||
export interface InvestmentTxn {
|
||||
@@ -262,80 +248,6 @@ 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()}`;
|
||||
}
|
||||
@@ -1492,331 +1404,99 @@ 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' };
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
/** 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,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100704'
|
||||
},
|
||||
{ scriptCode: 'FD-CUM', scriptName: 'Cumulative Fixed Deposit', instrumentType: 'FD', isin: '', faceValuePerUnit: 1 },
|
||||
{
|
||||
scriptCode: 'FD-MIP',
|
||||
scriptName: 'Monthly Interest Payout FD',
|
||||
instrumentType: 'FD',
|
||||
isin: '',
|
||||
faceValuePerUnit: 1,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100704'
|
||||
faceValuePerUnit: 1
|
||||
},
|
||||
{
|
||||
scriptCode: 'IN0020230012',
|
||||
scriptName: '7.26% GOI 2033',
|
||||
instrumentType: 'GOVT_SECURITY',
|
||||
isin: 'IN0020230012',
|
||||
faceValuePerUnit: 100,
|
||||
slrType: 'GOI',
|
||||
glCode: '100701',
|
||||
couponRate: 7.26,
|
||||
issueDate: '15-01-2023',
|
||||
maturityDate: '15-01-2033'
|
||||
faceValuePerUnit: 100
|
||||
},
|
||||
{
|
||||
scriptCode: 'IN0020220089',
|
||||
scriptName: '7.10% GOI 2029',
|
||||
instrumentType: 'GOVT_SECURITY',
|
||||
isin: 'IN0020220089',
|
||||
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'
|
||||
faceValuePerUnit: 100
|
||||
},
|
||||
{
|
||||
scriptCode: 'TBILL-364D',
|
||||
scriptName: '364 Days Treasury Bill',
|
||||
instrumentType: 'GOVT_SECURITY',
|
||||
isin: '',
|
||||
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'
|
||||
faceValuePerUnit: 100
|
||||
},
|
||||
{
|
||||
scriptCode: 'REC-7.5-2031',
|
||||
scriptName: 'REC Ltd Bond 7.50% 2031',
|
||||
instrumentType: 'NON_SLR',
|
||||
isin: 'INE020B08JN0',
|
||||
faceValuePerUnit: 100,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100703',
|
||||
couponRate: 7.5,
|
||||
issueDate: '11-08-2021',
|
||||
maturityDate: '11-08-2031',
|
||||
companyName: 'REC Limited',
|
||||
city: 'New Delhi'
|
||||
faceValuePerUnit: 100
|
||||
},
|
||||
{
|
||||
scriptCode: 'NABARD-7.35-2030',
|
||||
scriptName: 'NABARD Bond 7.35% 2030',
|
||||
instrumentType: 'NON_SLR',
|
||||
isin: 'INE261F09EU1',
|
||||
faceValuePerUnit: 100,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100703',
|
||||
couponRate: 7.35,
|
||||
issueDate: '20-09-2020',
|
||||
maturityDate: '20-09-2030',
|
||||
companyName: 'NABARD',
|
||||
city: 'Mumbai'
|
||||
faceValuePerUnit: 100
|
||||
},
|
||||
{
|
||||
scriptCode: 'LTF-8.1-2028',
|
||||
scriptName: 'L&T Finance NCD 8.10% 2028',
|
||||
instrumentType: 'BOND',
|
||||
isin: 'INE027E07BR5',
|
||||
faceValuePerUnit: 100,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100703',
|
||||
couponRate: 8.1,
|
||||
companyName: 'L&T Finance Ltd',
|
||||
city: 'Mumbai'
|
||||
faceValuePerUnit: 100
|
||||
},
|
||||
{
|
||||
scriptCode: 'BAF-7.95-2027',
|
||||
scriptName: 'Bajaj Finance NCD 7.95% 2027',
|
||||
instrumentType: 'BOND',
|
||||
isin: 'INE296A07SP0',
|
||||
faceValuePerUnit: 100,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100703',
|
||||
couponRate: 7.95,
|
||||
companyName: 'Bajaj Finance Ltd',
|
||||
city: 'Pune'
|
||||
faceValuePerUnit: 100
|
||||
},
|
||||
{
|
||||
scriptCode: 'SBI-OVN',
|
||||
scriptName: 'SBI Overnight Fund',
|
||||
instrumentType: 'MUTUAL_FUND',
|
||||
isin: 'INF200KA1Q40',
|
||||
faceValuePerUnit: 1000,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100705',
|
||||
companyName: 'SBI Mutual Fund',
|
||||
city: 'Mumbai'
|
||||
faceValuePerUnit: 1000
|
||||
},
|
||||
{
|
||||
scriptCode: 'HDFC-LIQ',
|
||||
scriptName: 'HDFC Liquid Fund',
|
||||
instrumentType: 'MUTUAL_FUND',
|
||||
isin: 'INF179KA1WR9',
|
||||
faceValuePerUnit: 1000,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100705',
|
||||
companyName: 'HDFC Mutual Fund',
|
||||
city: 'Mumbai'
|
||||
faceValuePerUnit: 1000
|
||||
},
|
||||
{
|
||||
scriptCode: 'SBIN',
|
||||
scriptName: 'State Bank of India',
|
||||
instrumentType: 'SHARE',
|
||||
isin: 'INE062A01020',
|
||||
faceValuePerUnit: 1,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100706'
|
||||
faceValuePerUnit: 1
|
||||
},
|
||||
{
|
||||
scriptCode: 'HDFCBANK',
|
||||
scriptName: 'HDFC Bank Ltd',
|
||||
instrumentType: 'SHARE',
|
||||
isin: 'INE040A01034',
|
||||
faceValuePerUnit: 1,
|
||||
slrType: 'NON_SLR',
|
||||
glCode: '100706'
|
||||
faceValuePerUnit: 1
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1881,150 +1561,23 @@ 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;
|
||||
// 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;
|
||||
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';
|
||||
panNo: string;
|
||||
}
|
||||
|
||||
/** 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',
|
||||
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'
|
||||
}
|
||||
{ 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' }
|
||||
];
|
||||
|
||||
export interface SubTypeMaster {
|
||||
@@ -2172,15 +1725,13 @@ 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 | null;
|
||||
openRate: number;
|
||||
closeRate: number;
|
||||
highRate: number | null;
|
||||
lowRate: number | null;
|
||||
highRate: number;
|
||||
lowRate: number;
|
||||
}
|
||||
|
||||
export const DAILY_SCRIPT_RATES: DailyScriptRate[] = [
|
||||
|
||||
@@ -106,112 +106,38 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- PARTY MASTER (layout follows the bank's existing CBS Bank / Party Master) -->
|
||||
<!-- PARTY MASTER -->
|
||||
@if (activeTab === 'party') {
|
||||
<div class="pg-card">
|
||||
<div class="pos-section-label">Bank / Party Master — Entry</div>
|
||||
<div class="inv-form-grid">
|
||||
<label class="inv-form-field">
|
||||
<span>* Bond Type</span>
|
||||
<select [(ngModel)]="partyForm.bondType">
|
||||
<option [ngValue]="undefined">-- Select --</option>
|
||||
@for (t of instrumentTypes; track t) {
|
||||
<option [value]="t">{{ t }}</option>
|
||||
}
|
||||
</select>
|
||||
</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 investmentGlOptions; track g.id) {
|
||||
<option [ngValue]="g.id">{{ g.glCode }} — {{ g.name }}</option>
|
||||
}
|
||||
</select>
|
||||
</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="pos-section-label">Add Bank / Party</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"
|
||||
><span>Party Name *</span><input type="text" [(ngModel)]="newParty.partyName"
|
||||
/></label>
|
||||
<label class="inv-form-field">
|
||||
<span>Party Type *</span>
|
||||
<select [(ngModel)]="newParty.partyType">
|
||||
<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>
|
||||
</select>
|
||||
</label>
|
||||
<label class="inv-form-field"><span>PAN No</span><input type="text" [(ngModel)]="newParty.panNo" /></label>
|
||||
</div>
|
||||
<div class="inv-form-actions">
|
||||
<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>
|
||||
<button type="button" class="pg-btn pg-btn--primary" (click)="addParty()">Save</button>
|
||||
</div>
|
||||
<table class="pg-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Party Code</th>
|
||||
<th>Bond Type</th>
|
||||
<th>Party Name</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>
|
||||
<th>Type</th>
|
||||
<th>PAN No</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -220,14 +146,9 @@
|
||||
<td>
|
||||
<span class="pg-chip">{{ p.partyCode }}</span>
|
||||
</td>
|
||||
<td>{{ p.bondType || '—' }}</td>
|
||||
<td>{{ p.partyName }}</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>
|
||||
<td>{{ p.partyType }}</td>
|
||||
<td>{{ p.panNo }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -235,118 +156,42 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- SCRIPT MASTER (layout follows the bank's existing CBS Script Master) -->
|
||||
<!-- SCRIPT MASTER -->
|
||||
@if (activeTab === 'script') {
|
||||
<div class="pg-card">
|
||||
<div class="pos-section-label">Script Master — Entry</div>
|
||||
<div class="pos-section-label">Add Script</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>* Bond Type</span>
|
||||
<select [(ngModel)]="scriptForm.instrumentType" [disabled]="!!scriptForm.scriptCode">
|
||||
<span>Instrument Type *</span>
|
||||
<select [(ngModel)]="newScript.instrumentType">
|
||||
<option [ngValue]="undefined">-- Select --</option>
|
||||
@for (t of instrumentTypes; track t) {
|
||||
<option [value]="t">{{ t }}</option>
|
||||
}
|
||||
</select>
|
||||
</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>ISIN</span><input type="text" [(ngModel)]="newScript.isin" /></label>
|
||||
<label class="inv-form-field"
|
||||
><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 investmentGlOptions; 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>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>
|
||||
<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"
|
||||
><span>Face Value / Unit</span><input type="number" [(ngModel)]="newScript.faceValuePerUnit"
|
||||
/></label>
|
||||
</div>
|
||||
<div class="inv-form-actions">
|
||||
<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>
|
||||
<button type="button" class="pg-btn pg-btn--primary" (click)="addScript()">Save</button>
|
||||
</div>
|
||||
<table class="pg-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Script Code</th>
|
||||
<th>Bond Type</th>
|
||||
<th>SLR</th>
|
||||
<th>Script Desc</th>
|
||||
<th>GL A/c</th>
|
||||
<th>Script Name</th>
|
||||
<th>Instrument</th>
|
||||
<th>ISIN</th>
|
||||
<th class="num">Int Rate %</th>
|
||||
<th>Issue Date</th>
|
||||
<th>Maturity</th>
|
||||
<th class="num">Face Value/Unit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -355,14 +200,10 @@
|
||||
<td>
|
||||
<span class="pg-chip">{{ s.scriptCode }}</span>
|
||||
</td>
|
||||
<td>{{ s.instrumentType }}</td>
|
||||
<td>{{ s.slrType || '—' }}</td>
|
||||
<td>{{ s.scriptName }}</td>
|
||||
<td>{{ s.glCode || '—' }}</td>
|
||||
<td>{{ s.instrumentType }}</td>
|
||||
<td>{{ s.isin || '—' }}</td>
|
||||
<td class="num">{{ s.couponRate ?? '—' }}</td>
|
||||
<td>{{ s.issueDate || '—' }}</td>
|
||||
<td>{{ s.maturityDate || '—' }}</td>
|
||||
<td class="num">{{ s.faceValuePerUnit }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -545,11 +386,10 @@
|
||||
<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.id ?? r.rateDate + r.scriptCode) {
|
||||
@for (r of dailyScriptRates; track r.rateDate + r.scriptCode) {
|
||||
<tr>
|
||||
<td>{{ r.rateDate }}</td>
|
||||
<td>
|
||||
@@ -560,13 +400,6 @@
|
||||
<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,17 +6,20 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { Component } 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,
|
||||
@@ -28,14 +31,9 @@ import {
|
||||
ScriptMarketDetail,
|
||||
DailyScriptRate,
|
||||
LienReason,
|
||||
InstrumentType,
|
||||
BANK_TYPE_OPTIONS,
|
||||
SLR_TYPE_OPTIONS,
|
||||
INVESTMENT_GL_LOOKUP,
|
||||
periodBetween
|
||||
InstrumentType
|
||||
} from '../investment-data';
|
||||
import { exportWorkbook, ExportSheetSpec } from '../investment-export';
|
||||
import { InvestmentGlAccount, InvestmentService, apiErrorMessage, toDailyScriptRate } from '../investment.service';
|
||||
|
||||
type MasterTab =
|
||||
| 'party'
|
||||
@@ -67,19 +65,18 @@ type MasterTab =
|
||||
DateDdmmyyyyPickerComponent
|
||||
]
|
||||
})
|
||||
export class InvestmentMastersComponent implements OnInit {
|
||||
export class InvestmentMastersComponent {
|
||||
activeTab: MasterTab = 'party';
|
||||
|
||||
scripts: ScriptMaster[] = [];
|
||||
scripts: ScriptMaster[] = [...SCRIPT_MASTER];
|
||||
brokers: BrokerMaster[] = [...BROKER_MASTER];
|
||||
parties: PartyMaster[] = [];
|
||||
parties: PartyMaster[] = [...PARTY_MASTER];
|
||||
subTypes: SubTypeMaster[] = [...SUBTYPE_MASTER];
|
||||
controlParams: ControlParameter[] = [...CONTROL_PARAMETERS];
|
||||
mfProducts: MutualFundProductMaster[] = [...MUTUAL_FUND_PRODUCTS];
|
||||
sglBanks: SglBankMaster[] = [...SGL_BANK_MASTER];
|
||||
marketDetails: ScriptMarketDetail[] = [...SCRIPT_MARKET_DETAIL];
|
||||
/** Loaded from the backend (Daily Script Master) in ngOnInit. */
|
||||
dailyScriptRates: DailyScriptRate[] = [];
|
||||
dailyScriptRates: DailyScriptRate[] = [...DAILY_SCRIPT_RATES];
|
||||
lienReasons: LienReason[] = [...LIEN_REASON_MASTER];
|
||||
|
||||
readonly instrumentTypes: InstrumentType[] = [
|
||||
@@ -109,19 +106,8 @@ export class InvestmentMastersComponent implements OnInit {
|
||||
toastVisible = false;
|
||||
private toastTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
|
||||
// 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;
|
||||
/** Enabled ASSET detail GLs from the chart of accounts. */
|
||||
investmentGlOptions: InvestmentGlAccount[] = [];
|
||||
newParty: Partial<PartyMaster> = {};
|
||||
newScript: Partial<ScriptMaster> = {};
|
||||
newSubType: Partial<SubTypeMaster> = {};
|
||||
newBroker: Partial<BrokerMaster> = {};
|
||||
newControlParam: Partial<ControlParameter> = {};
|
||||
@@ -130,217 +116,43 @@ export class InvestmentMastersComponent implements OnInit {
|
||||
newSglBank: Partial<SglBankMaster> = {};
|
||||
newDailyRate: Partial<DailyScriptRate> = {};
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadDailyRates();
|
||||
this.investmentService.getAssetGlAccounts().subscribe({
|
||||
next: (gls) => (this.investmentGlOptions = gls),
|
||||
error: (err) => this.toast(`Could not load GL accounts: ${apiErrorMessage(err)}`)
|
||||
});
|
||||
this.reloadMasters();
|
||||
}
|
||||
|
||||
setTab(tab: MasterTab): void {
|
||||
this.activeTab = tab;
|
||||
}
|
||||
|
||||
/** 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)}`)
|
||||
});
|
||||
}
|
||||
|
||||
glName(glCode?: string): string {
|
||||
return (
|
||||
this.investmentGlOptions.find((g) => g.glCode === glCode)?.name ??
|
||||
INVESTMENT_GL_LOOKUP.find((g) => g.glCode === glCode)?.glName ??
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------- 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.');
|
||||
addParty(): void {
|
||||
if (!this.newParty.partyName || !this.newParty.partyType) {
|
||||
this.toast('Enter Party Name and Type.');
|
||||
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),
|
||||
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));
|
||||
}
|
||||
});
|
||||
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.');
|
||||
}
|
||||
|
||||
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.`);
|
||||
addScript(): void {
|
||||
if (!this.newScript.scriptName || !this.newScript.instrumentType) {
|
||||
this.toast('Enter Script Name and Instrument Type.');
|
||||
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 ?? '');
|
||||
}
|
||||
|
||||
/** 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)) {
|
||||
this.toast('Enter ISIN, Int Rate and Issue Date for this security.');
|
||||
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 ?? '',
|
||||
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 = '';
|
||||
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.');
|
||||
}
|
||||
|
||||
addSubType(): void {
|
||||
@@ -436,56 +248,24 @@ export class InvestmentMastersComponent implements OnInit {
|
||||
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 {
|
||||
const r = this.newDailyRate;
|
||||
if (!r.scriptCode || !r.rateDate || r.closeRate == null) {
|
||||
if (!this.newDailyRate.scriptCode || !this.newDailyRate.rateDate || this.newDailyRate.closeRate == null) {
|
||||
this.toast('Enter Rate Date, Script Code and Close Rate.');
|
||||
return;
|
||||
}
|
||||
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.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))
|
||||
});
|
||||
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
|
||||
];
|
||||
this.newDailyRate = {};
|
||||
this.toast('Daily script rate added.');
|
||||
}
|
||||
|
||||
// -------------------- Export to Excel --------------------
|
||||
@@ -499,121 +279,46 @@ export class InvestmentMastersComponent implements OnInit {
|
||||
return one(
|
||||
[
|
||||
'Party Code',
|
||||
'Bond Type',
|
||||
'Party Name',
|
||||
'Address',
|
||||
'City',
|
||||
'Pincode',
|
||||
'Phone',
|
||||
'Fax',
|
||||
'Bank Type',
|
||||
'GL A/c No',
|
||||
'RBI Code',
|
||||
'Limit',
|
||||
'LEI No',
|
||||
'Counterparty Bank',
|
||||
'Branch',
|
||||
'Account No',
|
||||
'IFSC',
|
||||
'Status'
|
||||
'Type',
|
||||
'PAN No'
|
||||
],
|
||||
[
|
||||
12,
|
||||
14,
|
||||
30,
|
||||
36,
|
||||
14,
|
||||
10,
|
||||
14,
|
||||
14,
|
||||
24,
|
||||
12,
|
||||
12,
|
||||
14,
|
||||
22,
|
||||
24,
|
||||
20,
|
||||
18,
|
||||
14,
|
||||
10
|
||||
16,
|
||||
14
|
||||
],
|
||||
this.parties.map((p) => [
|
||||
p.partyCode,
|
||||
p.bondType ?? '',
|
||||
p.partyName,
|
||||
[
|
||||
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'
|
||||
p.partyType,
|
||||
p.panNo
|
||||
])
|
||||
);
|
||||
case 'script':
|
||||
return one(
|
||||
[
|
||||
'Script Code',
|
||||
'Bond Type',
|
||||
'SLR',
|
||||
'Script Desc',
|
||||
'GL A/c No',
|
||||
'Script Name',
|
||||
'Instrument',
|
||||
'ISIN',
|
||||
'Int Rate %',
|
||||
'Issue Date',
|
||||
'Maturity Date',
|
||||
'Period (Y/M/D)',
|
||||
'Face Value/Unit',
|
||||
'Company Name',
|
||||
'Corp Code'
|
||||
'Face Value/Unit'
|
||||
],
|
||||
[
|
||||
14,
|
||||
16,
|
||||
12,
|
||||
30,
|
||||
12,
|
||||
16,
|
||||
10,
|
||||
14,
|
||||
14,
|
||||
14,
|
||||
14,
|
||||
24,
|
||||
12
|
||||
16,
|
||||
16
|
||||
],
|
||||
this.scripts.map((s) => {
|
||||
const p = periodBetween(s.issueDate, s.maturityDate);
|
||||
return [
|
||||
s.scriptCode,
|
||||
s.instrumentType,
|
||||
s.slrType ?? '',
|
||||
s.scriptName,
|
||||
s.glCode ?? '',
|
||||
s.isin,
|
||||
s.couponRate ?? null,
|
||||
s.issueDate ?? '',
|
||||
s.maturityDate ?? '',
|
||||
s.issueDate && s.maturityDate ? `${p.years}/${p.months}/${p.days}` : '',
|
||||
s.faceValuePerUnit,
|
||||
s.companyName ?? '',
|
||||
s.corpCode ?? ''
|
||||
];
|
||||
})
|
||||
this.scripts.map((s) => [
|
||||
s.scriptCode,
|
||||
s.scriptName,
|
||||
s.instrumentType,
|
||||
s.isin,
|
||||
s.faceValuePerUnit
|
||||
])
|
||||
);
|
||||
case 'subtype':
|
||||
return one(
|
||||
|
||||
@@ -1,448 +0,0 @@
|
||||
/**
|
||||
* 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 { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
||||
import { Observable, forkJoin } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import {
|
||||
DailyScriptRate,
|
||||
HoldingStatus,
|
||||
InstrumentType,
|
||||
InvestmentHolding,
|
||||
PARTY_MASTER,
|
||||
PartyMaster,
|
||||
SCRIPT_MASTER,
|
||||
ScriptMaster,
|
||||
SlrType
|
||||
} from './investment-data';
|
||||
|
||||
/** Investment party as returned by /investment/parties. */
|
||||
export interface InvestmentPartyDto {
|
||||
id: number;
|
||||
partyCode: string;
|
||||
bondType: InstrumentType;
|
||||
partyName: string;
|
||||
address1?: string;
|
||||
address2?: string;
|
||||
address3?: string;
|
||||
city?: string;
|
||||
pincode?: string;
|
||||
phone?: string;
|
||||
fax?: string;
|
||||
bankType?: string;
|
||||
glAccountId: number;
|
||||
glCode: string;
|
||||
glName: string;
|
||||
rbiCode?: string;
|
||||
limit?: number;
|
||||
leiNo?: string;
|
||||
cpBankName?: string;
|
||||
cpBranchName?: string;
|
||||
cpAccountNo?: string;
|
||||
cpIfsc?: string;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
/** Investment script as returned by /investment/scripts (dates are DD-MM-YYYY). */
|
||||
export interface InvestmentScriptDto {
|
||||
id: number;
|
||||
scriptCode: string;
|
||||
bondType: InstrumentType;
|
||||
slrType?: SlrType;
|
||||
scriptDesc: string;
|
||||
glAccountId: number;
|
||||
glCode: string;
|
||||
glName: string;
|
||||
isin?: string;
|
||||
faceValuePerUnit: number;
|
||||
intRate?: number;
|
||||
issueDate?: string;
|
||||
maturityDate?: string;
|
||||
companyName?: string;
|
||||
address1?: string;
|
||||
address2?: string;
|
||||
address3?: string;
|
||||
city?: string;
|
||||
pincode?: string;
|
||||
phone?: string;
|
||||
fax?: string;
|
||||
corpCode?: string;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
/** Purchase entry (holding) as returned by /investment/purchases (dates are DD-MM-YYYY). */
|
||||
export interface InvestmentPurchaseDto {
|
||||
id: number;
|
||||
dealNo: string;
|
||||
certNo: string;
|
||||
bondType: InstrumentType;
|
||||
scriptId: number;
|
||||
scriptCode: string;
|
||||
scriptDesc: string;
|
||||
isin?: string;
|
||||
partyId: number;
|
||||
partyCode: string;
|
||||
partyName: string;
|
||||
dealDate: string;
|
||||
dealTime?: string;
|
||||
settlementType: string;
|
||||
settlementDate: string;
|
||||
faceValue: number;
|
||||
purchaseRate: number;
|
||||
units: number;
|
||||
balanceUnits: number;
|
||||
brokerage?: number;
|
||||
stampDuty?: number;
|
||||
otherCharges?: number;
|
||||
bookValue: number;
|
||||
premiumDiscount?: number;
|
||||
intRate?: number;
|
||||
issueDate?: string;
|
||||
maturityDate?: string;
|
||||
lastIntDate?: string;
|
||||
accruedDays?: number;
|
||||
accruedInterest?: number;
|
||||
settlementAmount: number;
|
||||
ytm?: number;
|
||||
category: string;
|
||||
subType?: string;
|
||||
investmentGlAccountId: number;
|
||||
investmentGlCode: string;
|
||||
investmentGlName: string;
|
||||
crGlAccountId: number;
|
||||
crGlCode: string;
|
||||
crGlName: string;
|
||||
otherDetails?: string;
|
||||
status: string;
|
||||
glTransactionId?: string;
|
||||
settledOnDate?: string;
|
||||
}
|
||||
|
||||
export interface InvestmentGlAccount {
|
||||
id: number;
|
||||
glCode: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backend calls for the Investment masters (Bank / Party Master and Script Master). Results are also copied into the
|
||||
* shared PARTY_MASTER / SCRIPT_MASTER lists so screens that still read those lists (Purchase Entry) offer the saved
|
||||
* masters.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class InvestmentService {
|
||||
private http = inject(HttpClient);
|
||||
|
||||
// -------------------- Bank / Party Master --------------------
|
||||
getParties(): Observable<InvestmentPartyDto[]> {
|
||||
return this.http.get<InvestmentPartyDto[]>('/investment/parties');
|
||||
}
|
||||
|
||||
createParty(body: object): Observable<{ resourceId: number; resourceIdentifier: string }> {
|
||||
return this.http.post<{ resourceId: number; resourceIdentifier: string }>('/investment/parties', body);
|
||||
}
|
||||
|
||||
updateParty(id: number, body: object): Observable<{ resourceId: number; resourceIdentifier: string }> {
|
||||
return this.http.put<{ resourceId: number; resourceIdentifier: string }>(`/investment/parties/${id}`, body);
|
||||
}
|
||||
|
||||
deleteParty(id: number): Observable<unknown> {
|
||||
return this.http.delete(`/investment/parties/${id}`);
|
||||
}
|
||||
|
||||
// -------------------- Script Master --------------------
|
||||
getScripts(): Observable<InvestmentScriptDto[]> {
|
||||
return this.http.get<InvestmentScriptDto[]>('/investment/scripts');
|
||||
}
|
||||
|
||||
createScript(body: object): Observable<{ resourceId: number; resourceIdentifier: string }> {
|
||||
return this.http.post<{ resourceId: number; resourceIdentifier: string }>('/investment/scripts', body);
|
||||
}
|
||||
|
||||
updateScript(id: number, body: object): Observable<{ resourceId: number; resourceIdentifier: string }> {
|
||||
return this.http.put<{ resourceId: number; resourceIdentifier: string }>(`/investment/scripts/${id}`, body);
|
||||
}
|
||||
|
||||
// -------------------- Purchase Entry --------------------
|
||||
getPurchases(): Observable<InvestmentPurchaseDto[]> {
|
||||
return this.http.get<InvestmentPurchaseDto[]>('/investment/purchases');
|
||||
}
|
||||
|
||||
/** Coupon and 31 Mar / 30 Sep provision lines of a holding up to maturity (calculated, not posted). */
|
||||
/** Interest lines of all holdings that are due now or within the next few days. */
|
||||
getDueInterest(): Observable<InvestmentInterestDueDto[]> {
|
||||
return this.http.get<InvestmentInterestDueDto[]>('/investment/interest-postings/due');
|
||||
}
|
||||
|
||||
/** Posts one interest line (coupon / provision) with its JV voucher; the voucher number comes back as resourceIdentifier. */
|
||||
postInterest(purchaseId: number, body: object): Observable<{ resourceIdentifier?: string; transactionId?: string }> {
|
||||
return this.http.post<{ resourceIdentifier?: string; transactionId?: string }>(
|
||||
`/investment/purchases/${purchaseId}/interest-postings`,
|
||||
body
|
||||
);
|
||||
}
|
||||
|
||||
getInterestSchedule(purchaseId: number, asOnDate?: string): Observable<InvestmentInterestScheduleDto> {
|
||||
const params = asOnDate ? `?asOnDate=${encodeURIComponent(asOnDate)}` : '';
|
||||
return this.http.get<InvestmentInterestScheduleDto>(
|
||||
`/investment/purchases/${purchaseId}/interest-schedule${params}`
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------- Daily Script Master --------------------
|
||||
getDailyRates(scriptId?: number): Observable<InvestmentDailyRateDto[]> {
|
||||
const params = scriptId ? `?scriptId=${scriptId}` : '';
|
||||
return this.http.get<InvestmentDailyRateDto[]>(`/investment/daily-rates${params}`);
|
||||
}
|
||||
|
||||
/** Newest Daily Script Master rate of a script on or before a date; null when none has been entered. */
|
||||
getLatestDailyRate(scriptId: number, onDate: string): Observable<InvestmentDailyRateDto | null> {
|
||||
return this.http.get<InvestmentDailyRateDto | null>(
|
||||
`/investment/daily-rates/latest?scriptId=${scriptId}&onDate=${encodeURIComponent(onDate)}`
|
||||
);
|
||||
}
|
||||
|
||||
createDailyRate(body: object): Observable<{ resourceId: number }> {
|
||||
return this.http.post<{ resourceId: number }>('/investment/daily-rates', body);
|
||||
}
|
||||
|
||||
deleteDailyRate(rateId: number): Observable<unknown> {
|
||||
return this.http.delete(`/investment/daily-rates/${rateId}`);
|
||||
}
|
||||
|
||||
/** Settles a deal: posts it to GL dated its settlement date. Under maker-checker the response only says it awaits approval. */
|
||||
settlePurchase(purchaseId: number): Observable<{ transactionId?: string; rollbackTransaction?: boolean }> {
|
||||
return this.http.post<{ transactionId?: string; rollbackTransaction?: boolean }>(
|
||||
`/investment/purchases/${purchaseId}/settle`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
createPurchase(body: object): Observable<{ resourceId: number; resourceIdentifier: string }> {
|
||||
return this.http.post<{ resourceId: number; resourceIdentifier: string }>('/investment/purchases', body);
|
||||
}
|
||||
|
||||
deletePurchase(id: number): Observable<unknown> {
|
||||
return this.http.delete(`/investment/purchases/${id}`);
|
||||
}
|
||||
|
||||
// -------------------- GL accounts --------------------
|
||||
/** Enabled ASSET detail GLs — the only kind an investment party / script can be booked to. */
|
||||
getAssetGlAccounts(): Observable<InvestmentGlAccount[]> {
|
||||
return this.http
|
||||
.get<
|
||||
Array<{ id: number; glCode: string; name: string; disabled: boolean }>
|
||||
>('/glaccounts', { params: { type: '1', usage: '1', disabled: 'false' } })
|
||||
.pipe(
|
||||
map((list) =>
|
||||
list
|
||||
.map((g) => ({ id: g.id, glCode: g.glCode, name: g.name }))
|
||||
.sort((a, b) => a.glCode.localeCompare(b.glCode))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/** Loads both masters from the backend and refreshes the shared lists other screens read. */
|
||||
syncSharedMasters(): Observable<{ parties: PartyMaster[]; scripts: ScriptMaster[] }> {
|
||||
return forkJoin({ parties: this.getParties(), scripts: this.getScripts() }).pipe(
|
||||
map(({ parties, scripts }) => ({ parties: parties.map(toPartyMaster), scripts: scripts.map(toScriptMaster) })),
|
||||
tap(({ parties, scripts }) => {
|
||||
PARTY_MASTER.splice(0, PARTY_MASTER.length, ...parties);
|
||||
SCRIPT_MASTER.splice(0, SCRIPT_MASTER.length, ...scripts);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function toPartyMaster(p: InvestmentPartyDto): PartyMaster {
|
||||
return {
|
||||
id: p.id,
|
||||
partyCode: p.partyCode,
|
||||
partyName: p.partyName,
|
||||
partyType: 'BANK',
|
||||
bondType: p.bondType,
|
||||
address1: p.address1,
|
||||
address2: p.address2,
|
||||
address3: p.address3,
|
||||
city: p.city,
|
||||
pincode: p.pincode,
|
||||
phone: p.phone,
|
||||
fax: p.fax,
|
||||
bankType: p.bankType,
|
||||
glAccountId: p.glAccountId,
|
||||
glCode: p.glCode,
|
||||
glName: p.glName,
|
||||
rbiCode: p.rbiCode,
|
||||
limit: p.limit ?? null,
|
||||
leiNo: p.leiNo,
|
||||
cpBankName: p.cpBankName,
|
||||
cpBranchName: p.cpBranchName,
|
||||
cpAccountNo: p.cpAccountNo,
|
||||
cpIfsc: p.cpIfsc,
|
||||
status: p.active ? 'ACTIVE' : 'INACTIVE'
|
||||
};
|
||||
}
|
||||
|
||||
export function toScriptMaster(s: InvestmentScriptDto): ScriptMaster {
|
||||
return {
|
||||
id: s.id,
|
||||
scriptCode: s.scriptCode,
|
||||
scriptName: s.scriptDesc,
|
||||
instrumentType: s.bondType,
|
||||
isin: s.isin ?? '',
|
||||
faceValuePerUnit: s.faceValuePerUnit,
|
||||
slrType: s.slrType,
|
||||
glAccountId: s.glAccountId,
|
||||
glCode: s.glCode,
|
||||
glName: s.glName,
|
||||
couponRate: s.intRate,
|
||||
issueDate: s.issueDate,
|
||||
maturityDate: s.maturityDate,
|
||||
companyName: s.companyName,
|
||||
address1: s.address1,
|
||||
address2: s.address2,
|
||||
address3: s.address3,
|
||||
city: s.city,
|
||||
pincode: s.pincode,
|
||||
phone: s.phone,
|
||||
fax: s.fax,
|
||||
corpCode: s.corpCode,
|
||||
active: s.active
|
||||
};
|
||||
}
|
||||
|
||||
/** A saved purchase as a row of the Holdings register. */
|
||||
export function toHolding(p: InvestmentPurchaseDto): InvestmentHolding {
|
||||
return {
|
||||
id: p.id,
|
||||
dealNo: p.dealNo,
|
||||
certNo: p.certNo,
|
||||
instrumentType: p.bondType,
|
||||
scriptCode: p.scriptCode,
|
||||
scriptName: p.scriptDesc,
|
||||
party: p.partyName,
|
||||
partyCode: p.partyCode,
|
||||
subType: p.subType ?? '',
|
||||
faceValue: p.faceValue,
|
||||
purchaseRate: p.purchaseRate,
|
||||
units: p.balanceUnits,
|
||||
purchaseDate: p.settlementDate,
|
||||
maturityDate: p.maturityDate || p.dealDate,
|
||||
interestRate: p.intRate ?? 0,
|
||||
interestFreq: p.bondType === 'MUTUAL_FUND' ? 'CUMULATIVE' : 'HALF_YEARLY',
|
||||
glCode: p.investmentGlCode,
|
||||
glName: p.investmentGlName,
|
||||
crToAc: p.crGlCode,
|
||||
brokerCode: '',
|
||||
status: p.status as HoldingStatus,
|
||||
settlementDate: p.settlementDate,
|
||||
glTransactionId: p.glTransactionId,
|
||||
category: p.category,
|
||||
bookValue: p.bookValue,
|
||||
settlementAmount: p.settlementAmount
|
||||
};
|
||||
}
|
||||
|
||||
/** One line of a holding's interest schedule (see InvestmentInterestScheduleData in the backend). */
|
||||
export interface InvestmentInterestRowDto {
|
||||
type: 'COUPON' | 'PROVISION';
|
||||
intDate: string;
|
||||
fromDate: string;
|
||||
toDate: string;
|
||||
days: number;
|
||||
grossInterest: number;
|
||||
alreadyBooked: number;
|
||||
amount: number;
|
||||
due: boolean;
|
||||
/** Posted to GL: its JV voucher and GL transaction. */
|
||||
posted: boolean;
|
||||
voucherNo?: string;
|
||||
glTransactionId?: string;
|
||||
postedOnDate?: string;
|
||||
/** The next line to post and its date has come. */
|
||||
postable: boolean;
|
||||
/** Unposted and due within the reminder window (or past). */
|
||||
dueSoon: boolean;
|
||||
}
|
||||
|
||||
/** A holding's next interest line that is due (or due within the reminder window) — a task to post. */
|
||||
export interface InvestmentInterestDueDto {
|
||||
purchaseId: number;
|
||||
dealNo: string;
|
||||
certNo: string;
|
||||
scriptCode: string;
|
||||
scriptDesc: string;
|
||||
lineType: 'COUPON' | 'PROVISION';
|
||||
intDate: string;
|
||||
grossInterest: number;
|
||||
amount: number;
|
||||
postable: boolean;
|
||||
overdue: boolean;
|
||||
}
|
||||
|
||||
export interface InvestmentInterestScheduleDto {
|
||||
purchaseId: number;
|
||||
dealNo: string;
|
||||
certNo: string;
|
||||
scriptCode: string;
|
||||
scriptDesc: string;
|
||||
faceValue: number;
|
||||
unitValue: number;
|
||||
balanceUnits: number;
|
||||
purchaseRate: number;
|
||||
bookValue: number;
|
||||
intRate: number;
|
||||
dealDate: string;
|
||||
lastIntDate: string;
|
||||
maturityDate: string;
|
||||
purchasedAccruedInterest: number;
|
||||
couponPerHalfYear: number;
|
||||
asOnDate: string;
|
||||
interestGlCode: string;
|
||||
interestGlName: string;
|
||||
bankGlAccountId: number;
|
||||
bankGlCode: string;
|
||||
bankGlName: string;
|
||||
status: string;
|
||||
rows: InvestmentInterestRowDto[];
|
||||
}
|
||||
|
||||
/** A Daily Script Master row (see InvestmentDailyRateData in the backend). */
|
||||
export interface InvestmentDailyRateDto {
|
||||
id: number;
|
||||
scriptId: number;
|
||||
scriptCode: string;
|
||||
scriptDesc: string;
|
||||
bondType: string;
|
||||
rateDate: string;
|
||||
openRate: number | null;
|
||||
highRate: number | null;
|
||||
lowRate: number | null;
|
||||
closeRate: number;
|
||||
}
|
||||
|
||||
export function toDailyScriptRate(d: InvestmentDailyRateDto): DailyScriptRate {
|
||||
return {
|
||||
id: d.id,
|
||||
rateDate: d.rateDate,
|
||||
scriptCode: d.scriptCode,
|
||||
scriptName: d.scriptDesc,
|
||||
openRate: d.openRate,
|
||||
closeRate: d.closeRate,
|
||||
highRate: d.highRate,
|
||||
lowRate: d.lowRate
|
||||
};
|
||||
}
|
||||
|
||||
/** The first validation / domain-rule message from a Fineract error response, for a toast. */
|
||||
export function apiErrorMessage(err: unknown): string {
|
||||
const e = err as HttpErrorResponse;
|
||||
const body = e?.error;
|
||||
return body?.errors?.[0]?.defaultUserMessage || body?.defaultUserMessage || e?.message || 'Request failed.';
|
||||
}
|
||||
@@ -65,6 +65,7 @@ export class PlatformMenuAccessComponent {
|
||||
{ code: 'MENU_DEPOSITS', label: 'Deposits', icon: 'piggy-bank' },
|
||||
{ code: 'MENU_ADVANCES', label: 'Advances', icon: 'hand-holding-usd' },
|
||||
{ code: 'MENU_LOAN_ORIGINATION', label: 'Loan Origination', icon: 'clipboard-check' },
|
||||
{ code: 'MENU_CREDIT_BUREAU', label: 'Credit Bureau', icon: 'id-card' },
|
||||
{ code: 'MENU_SHARE', label: 'Share', icon: 'coins' },
|
||||
{ code: 'MENU_NPA', label: 'NPA', icon: 'exclamation-triangle' },
|
||||
{ code: 'MENU_GENERAL_LEDGER', label: 'General Ledger', icon: 'book-open' },
|
||||
|
||||
@@ -11,10 +11,12 @@ import { Injectable, inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot } from '@angular/router';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { catchError, map, switchMap } from 'rxjs/operators';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from '../savings.service';
|
||||
import { VoucherCorrectionService } from '../../cashier/voucher-correction.service';
|
||||
|
||||
/**
|
||||
* Savings Account data resolver.
|
||||
@@ -22,14 +24,29 @@ import { SavingsService } from '../savings.service';
|
||||
@Injectable()
|
||||
export class SavingsAccountViewResolver {
|
||||
private savingsService = inject(SavingsService);
|
||||
private voucherCorrectionService = inject(VoucherCorrectionService);
|
||||
|
||||
/**
|
||||
* Returns the Savings Account data.
|
||||
* Returns the Savings Account data, without the deposits a completed voucher correction took off this account:
|
||||
* the passbook and the transaction list read their rows from here, and a deposit that was posted to the wrong
|
||||
* account and moved should not appear on it at all.
|
||||
* @param {ActivatedRouteSnapshot} route Route Snapshot
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const savingAccountId = route.paramMap.get('savingAccountId');
|
||||
return this.savingsService.getSavingsAccountData(savingAccountId);
|
||||
return this.savingsService.getSavingsAccountData(savingAccountId).pipe(
|
||||
switchMap((account: any) =>
|
||||
this.voucherCorrectionService.voidedTransactions(Number(savingAccountId)).pipe(
|
||||
catchError(() => of([] as number[])),
|
||||
map((voided: number[]) => {
|
||||
if (voided.length && Array.isArray(account?.transactions)) {
|
||||
account.transactions = account.transactions.filter((txn: any) => !voided.includes(txn.id));
|
||||
}
|
||||
return account;
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +144,24 @@
|
||||
<fa-icon icon="money-bill-wave" class="ac-tab__ic"></fa-icon>
|
||||
<span>Withdrawal Requests</span>
|
||||
</a>
|
||||
<a
|
||||
class="ac-tab"
|
||||
routerLink="./cash-transfers"
|
||||
routerLinkActive="ac-tab--active"
|
||||
*mifosxHasPermission="'ALL_FUNCTIONS_READ'"
|
||||
>
|
||||
<fa-icon icon="exchange" class="ac-tab__ic"></fa-icon>
|
||||
<span>Cash Transfers</span>
|
||||
</a>
|
||||
<a
|
||||
class="ac-tab"
|
||||
routerLink="./voucher-corrections"
|
||||
routerLinkActive="ac-tab--active"
|
||||
*mifosxHasPermission="'ALL_FUNCTIONS_READ'"
|
||||
>
|
||||
<fa-icon icon="undo" class="ac-tab__ic"></fa-icon>
|
||||
<span>Voucher Corrections</span>
|
||||
</a>
|
||||
<a
|
||||
class="ac-tab"
|
||||
routerLink="./share-withdrawal-requests"
|
||||
|
||||
@@ -16,7 +16,7 @@ $green: #10b981;
|
||||
$amber: #f59e0b;
|
||||
|
||||
.ac-container {
|
||||
padding: 20px 24px;
|
||||
padding: 12px 20px;
|
||||
max-width: 1440px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
@@ -25,40 +25,40 @@ $amber: #f59e0b;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: 10px;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
&__left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12px;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, $blue 0%, $purple 100%);
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
font-size: 14px;
|
||||
box-shadow: 0 2px 8px rgb(29 78 216 / 25%);
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: $navy;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
margin-top: 2px;
|
||||
font-size: 12.5px;
|
||||
margin-top: 1px;
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
@@ -68,26 +68,26 @@ $amber: #f59e0b;
|
||||
hides most of them behind prev/next pagination arrows. Wrapping keeps every tab visible and one
|
||||
click away instead of a scroll-and-hunt. */
|
||||
.ac-tabs {
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 14px;
|
||||
padding: 6px;
|
||||
border-radius: 10px;
|
||||
padding: 4px;
|
||||
box-shadow: 0 1px 3px rgb(15 23 42 / 4%);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.ac-tab {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
height: 38px;
|
||||
padding: 0 18px;
|
||||
border-radius: 10px;
|
||||
gap: 6px;
|
||||
height: 28px;
|
||||
padding: 0 11px;
|
||||
border-radius: 8px;
|
||||
font-family: Inter, 'DM Sans', Roboto, sans-serif;
|
||||
font-size: 13px;
|
||||
font-size: 11.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.01em;
|
||||
color: #64748b;
|
||||
@@ -99,7 +99,7 @@ $amber: #f59e0b;
|
||||
cursor: pointer;
|
||||
|
||||
&__ic {
|
||||
font-size: 13px;
|
||||
font-size: 11px;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ $amber: #f59e0b;
|
||||
|
||||
@media (width <= 768px) {
|
||||
.ac-tab {
|
||||
padding: 0 14px;
|
||||
font-size: 12px;
|
||||
padding: 0 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +194,22 @@ const routes: Routes = [
|
||||
component: ShareWithdrawalRequestsComponent,
|
||||
data: { title: 'Share Withdrawal Requests' }
|
||||
},
|
||||
{
|
||||
path: 'cash-transfers',
|
||||
loadComponent: () =>
|
||||
import('../cashier/cash-transfer-approvals/cash-transfer-approvals.component').then(
|
||||
(m) => m.CashTransferApprovalsComponent
|
||||
),
|
||||
data: { title: 'Cash Transfers' }
|
||||
},
|
||||
{
|
||||
path: 'voucher-corrections',
|
||||
loadComponent: () =>
|
||||
import('../cashier/voucher-correction-approvals/voucher-correction-approvals.component').then(
|
||||
(m) => m.VoucherCorrectionApprovalsComponent
|
||||
),
|
||||
data: { title: 'Voucher Corrections' }
|
||||
},
|
||||
{
|
||||
path: 'dividend-requests',
|
||||
component: DividendRequestsComponent,
|
||||
|
||||
@@ -45,15 +45,17 @@
|
||||
"hasMask": false,
|
||||
"ao": 0,
|
||||
"ks": { "a": { "a": 0, "k": [
|
||||
-17.052704811096184,
|
||||
-15.0467209815979
|
||||
0,
|
||||
0,
|
||||
0
|
||||
], "ix": 1 }, "s": { "a": 0, "k": [
|
||||
362.228,
|
||||
362.228,
|
||||
394,
|
||||
394,
|
||||
100
|
||||
], "ix": 6 }, "sk": { "a": 0, "k": 0 }, "p": { "a": 0, "k": [
|
||||
188.2303284168625,
|
||||
195.49656352277756
|
||||
250,
|
||||
250,
|
||||
0
|
||||
], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 10 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100, "ix": 11 } },
|
||||
"shapes": [
|
||||
{
|
||||
@@ -341,16 +343,16 @@
|
||||
"g": { "p": 3, "k": { "a": 0, "k": [
|
||||
0,
|
||||
1,
|
||||
0.4470588235294118,
|
||||
0,
|
||||
0.6,
|
||||
0.2,
|
||||
0.485,
|
||||
0.9725490196078431,
|
||||
0.2235294117647059,
|
||||
0.5019607843137255,
|
||||
1,
|
||||
0.9411764705882353,
|
||||
0,
|
||||
1
|
||||
0.6,
|
||||
0.2,
|
||||
1,
|
||||
1,
|
||||
0.6,
|
||||
0.2
|
||||
], "ix": 8 } },
|
||||
"t": 1,
|
||||
"a": { "a": 0, "k": 0 },
|
||||
@@ -363,7 +365,7 @@
|
||||
"lj": 1,
|
||||
"ml": 4,
|
||||
"o": { "a": 0, "k": 100, "ix": 9 },
|
||||
"w": { "a": 0, "k": 2, "ix": 10 }
|
||||
"w": { "a": 0, "k": 2.5, "ix": 10 }
|
||||
},
|
||||
{
|
||||
"ty": "fl",
|
||||
@@ -402,8 +404,8 @@
|
||||
"o": {
|
||||
"a": 1,
|
||||
"k": [
|
||||
{ "o": { "x": 0.167, "y": 0.167 }, "i": { "x": 0.833, "y": 0.833 }, "s": [0], "t": 0 },
|
||||
{ "s": [360], "t": 90.0000036657751 }
|
||||
{ "o": { "x": 0.167, "y": 0.167 }, "i": { "x": 0.833, "y": 0.833 }, "s": [28], "t": 0 },
|
||||
{ "s": [388], "t": 90.0000036657751 }
|
||||
],
|
||||
"ix": 3
|
||||
},
|
||||
@@ -437,7 +439,7 @@
|
||||
250,
|
||||
250,
|
||||
0
|
||||
], "ix": 2 }, "r": { "a": 0, "k": 60, "ix": 10 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100, "ix": 11 } },
|
||||
], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 10 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100, "ix": 11 } },
|
||||
"shapes": [
|
||||
{
|
||||
"ty": "gr",
|
||||
@@ -723,16 +725,16 @@
|
||||
], "ix": 5 },
|
||||
"g": { "p": 3, "k": { "a": 0, "k": [
|
||||
0,
|
||||
0,
|
||||
0.7764705882352941,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0.485,
|
||||
0.24705882352941178,
|
||||
0.38823529411764707,
|
||||
1,
|
||||
1,
|
||||
0.49411764705882355,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
], "ix": 8 } },
|
||||
"t": 1,
|
||||
@@ -746,7 +748,7 @@
|
||||
"lj": 1,
|
||||
"ml": 4,
|
||||
"o": { "a": 0, "k": 100, "ix": 9 },
|
||||
"w": { "a": 0, "k": 0.5, "ix": 10 }
|
||||
"w": { "a": 0, "k": 2.5, "ix": 10 }
|
||||
},
|
||||
{
|
||||
"ty": "fl",
|
||||
@@ -813,14 +815,14 @@
|
||||
0,
|
||||
0
|
||||
], "ix": 1 }, "s": { "a": 0, "k": [
|
||||
362.228,
|
||||
362.228,
|
||||
330,
|
||||
330,
|
||||
100
|
||||
], "ix": 6 }, "sk": { "a": 0, "k": 0 }, "p": { "a": 0, "k": [
|
||||
250,
|
||||
250,
|
||||
0
|
||||
], "ix": 2 }, "r": { "a": 0, "k": 30, "ix": 10 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100, "ix": 11 } },
|
||||
], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 10 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100, "ix": 11 } },
|
||||
"shapes": [
|
||||
{
|
||||
"ty": "gr",
|
||||
@@ -1106,17 +1108,17 @@
|
||||
], "ix": 5 },
|
||||
"g": { "p": 3, "k": { "a": 0, "k": [
|
||||
0,
|
||||
1,
|
||||
0.8235294117647058,
|
||||
0,
|
||||
0.0784,
|
||||
0.7059,
|
||||
0.2118,
|
||||
0.485,
|
||||
0.5019607843137255,
|
||||
0.8117647058823529,
|
||||
0.5019607843137255,
|
||||
0.0784,
|
||||
0.7059,
|
||||
0.2118,
|
||||
1,
|
||||
0,
|
||||
0.8,
|
||||
1
|
||||
0.0784,
|
||||
0.7059,
|
||||
0.2118
|
||||
], "ix": 8 } },
|
||||
"t": 1,
|
||||
"a": { "a": 0, "k": 0 },
|
||||
@@ -1129,7 +1131,7 @@
|
||||
"lj": 1,
|
||||
"ml": 4,
|
||||
"o": { "a": 0, "k": 100, "ix": 9 },
|
||||
"w": { "a": 0, "k": 0.5, "ix": 10 }
|
||||
"w": { "a": 0, "k": 2.5, "ix": 10 }
|
||||
},
|
||||
{
|
||||
"ty": "fl",
|
||||
@@ -1168,8 +1170,8 @@
|
||||
"o": {
|
||||
"a": 1,
|
||||
"k": [
|
||||
{ "o": { "x": 0.167, "y": 0.167 }, "i": { "x": 0.833, "y": 0.833 }, "s": [0], "t": 0 },
|
||||
{ "s": [360], "t": 90.0000036657751 }
|
||||
{ "o": { "x": 0.167, "y": 0.167 }, "i": { "x": 0.833, "y": 0.833 }, "s": [-28], "t": 0 },
|
||||
{ "s": [332], "t": 90.0000036657751 }
|
||||
],
|
||||
"ix": 3
|
||||
},
|
||||
|
||||
+6
-6
@@ -325,10 +325,10 @@
|
||||
};
|
||||
document.head.appendChild(script);
|
||||
|
||||
// Progress simulation stages (Guaranteed ~2 seconds duration on refresh)
|
||||
// Progress simulation stages (Guaranteed ~4 seconds duration on refresh: 2% every 90ms reaches 90% in about 4s)
|
||||
var interval = setInterval(function () {
|
||||
if (progress < 90) {
|
||||
progress += 5;
|
||||
progress += 2;
|
||||
} else if (angularReady && progress < 100) {
|
||||
progress += 5;
|
||||
}
|
||||
@@ -351,7 +351,7 @@
|
||||
}
|
||||
}, 90);
|
||||
|
||||
// Enforce minimum hold time (2000ms = 2 seconds) so refresh always shows the animation
|
||||
// Enforce minimum hold time (4000ms = 4 seconds) so refresh always shows the animation
|
||||
setTimeout(function () {
|
||||
minTimePassed = true;
|
||||
if (angularReady) {
|
||||
@@ -359,7 +359,7 @@
|
||||
if (bar) bar.style.width = '100%';
|
||||
dismissSplash();
|
||||
}
|
||||
}, 2000);
|
||||
}, 4000);
|
||||
|
||||
function dismissSplash() {
|
||||
if (dismissed) return;
|
||||
@@ -387,12 +387,12 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Safety fallback (Max 7s in case of backend network failure)
|
||||
// Safety fallback (Max 9s in case of backend network failure)
|
||||
setTimeout(function () {
|
||||
angularReady = true;
|
||||
minTimePassed = true;
|
||||
dismissSplash();
|
||||
}, 7000);
|
||||
}, 9000);
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user