Files
cbsnexora/src/app/investment/share-investment/share-investment.component.html
T

586 lines
21 KiB
HTML

<!--
Copyright since 2025 Mifos Initiative
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<div class="pg">
<header class="pg-head">
<div>
<div class="pg-eyebrow">TREASURY · INVESTMENT · SHARE</div>
<h1 class="pg-title">Share Entry</h1>
<p class="pg-sub">
Shares of the DCCB / State Co-op Bank, co-operative societies in the area of operation, and membership shares
(NPCI, CCIL, SWIFT, Umbrella Organisation, IDPIC) — held as AFS. No other company's shares.
</p>
</div>
@if (activeTab === 'holdings') {
<div class="pg-toolbar">
<button type="button" class="pg-btn pg-btn--ghost" [disabled]="generating" (click)="exportExcel()">
{{ generating ? 'Exporting…' : 'Export to Excel' }}
</button>
</div>
}
</header>
<div class="cctr-tabs">
<button
type="button"
class="pg-btn pg-btn--ghost"
[class.pg-btn--active]="activeTab === 'holdings'"
(click)="setTab('holdings')"
>
Holdings
</button>
<button
type="button"
class="pg-btn pg-btn--ghost"
[class.pg-btn--active]="activeTab === 'purchase'"
(click)="setTab('purchase')"
>
01 Share Purchase Entry
</button>
<button
type="button"
class="pg-btn pg-btn--ghost"
[class.pg-btn--active]="activeTab === 'dividend'"
(click)="setTab('dividend')"
>
02 Share Dividend Entry
</button>
<button
type="button"
class="pg-btn pg-btn--ghost"
[class.pg-btn--active]="activeTab === 'sell'"
(click)="setTab('sell')"
>
03 Share Refund / Retirement
</button>
<button
type="button"
class="pg-btn pg-btn--ghost"
[class.pg-btn--active]="activeTab === 'writeoff'"
(click)="setTab('writeoff')"
>
04 Share Write Off Entry
</button>
</div>
<!-- HOLDINGS -->
@if (activeTab === 'holdings') {
<div class="pg-card">
<div class="pos-section-label">Share Holdings Register</div>
<table class="pg-table">
<thead>
<tr>
<th>Deal / Cert No</th>
<th>Institution</th>
<th>Script</th>
<th class="num">Shares</th>
<th class="num">Face Value</th>
<th class="num">Book Value</th>
<th class="num">Dividends</th>
<th>Purchase Date</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
@for (d of deals; track d.id) {
<tr>
<td>
<span class="pg-chip">{{ d.dealNo }}</span> <small>{{ d.certNo }}</small>
</td>
<td>
{{ d.partyName }}<br /><small
>{{ institutionLabel(dealParty(d)?.institutionType)
}}{{ dealParty(d)?.inLiquidation ? ' · in liquidation' : '' }}</small
>
</td>
<td>{{ d.scriptCode }} {{ d.scriptDesc }}</td>
<td class="num">{{ d.balanceUnits | number: '1.0-0' }}</td>
<td class="num">₹{{ faceHeld(d) | number: '1.2-2' }}</td>
<td class="num">₹{{ carryingValue(d) | number: '1.2-2' }}</td>
<td class="num">₹{{ dividendsReceived(d) | number: '1.2-2' }}</td>
<td>{{ d.settlementDate }}</td>
<td>
<span [class]="statusClass(d.status)">{{ d.status }}</span>
</td>
<td>
@if (d.status === 'PENDING_SETTLEMENT') {
<button
type="button"
class="pg-btn pg-btn--primary"
[disabled]="settlingDealId !== null"
(click)="settleDeal(d)"
>
Settle
</button>
<button
type="button"
class="pg-btn pg-btn--ghost"
[disabled]="settlingDealId !== null"
(click)="dropDeal(d)"
>
Drop
</button>
}
</td>
</tr>
} @empty {
<tr>
<td colspan="10" class="pg-empty">No share holdings yet.</td>
</tr>
}
</tbody>
</table>
</div>
}
<!-- 01 PURCHASE ENTRY -->
@if (activeTab === 'purchase') {
<div class="pg-card">
<div class="pos-section-label">Investment - Share Purchase Entry (AFS)</div>
<div class="inv-form-grid">
<label class="inv-form-field">
<span>* Institution</span>
<select [(ngModel)]="purchaseForm.partyId" (ngModelChange)="refreshLimit()">
<option [ngValue]="null">-- Select --</option>
@for (p of parties; track p.id) {
<option [ngValue]="p.id">{{ p.partyCode }} — {{ p.partyName }}</option>
}
</select>
</label>
@if (purchaseParty; as p) {
<label class="inv-form-field"
><span>Institution Type</span><input type="text" [value]="institutionLabel(p.institutionType)" readonly
/></label>
}
<label class="inv-form-field">
<span>* Share Script</span>
<select [(ngModel)]="purchaseForm.scriptId" (ngModelChange)="onScriptChange()">
<option [ngValue]="null">-- Select --</option>
@for (s of scripts; track s.id) {
<option [ngValue]="s.id">{{ s.scriptCode }} — {{ s.scriptDesc }}</option>
}
</select>
</label>
<label class="inv-form-field"
><span>* Deal Date</span
><mifosx-date-ddmmyyyy
[(ngModel)]="purchaseForm.dealDate"
(ngModelChange)="refreshLimit()"
></mifosx-date-ddmmyyyy
></label>
<label class="inv-form-field">
<span>Settlement</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>* No. of Shares</span
><input type="number" min="1" step="1" [(ngModel)]="purchaseForm.shares" (ngModelChange)="refreshLimit()"
/></label>
<label class="inv-form-field"
><span>Face Value per Share</span
><input
type="text"
[value]="purchaseScript ? '₹' + (purchaseScript.faceValuePerUnit | number: '1.2-2') : ''"
readonly
/></label>
<label class="inv-form-field"
><span>* Price per Share (₹)</span
><input
type="number"
min="0"
step="0.01"
[(ngModel)]="purchaseForm.pricePerShare"
(ngModelChange)="refreshLimit()"
/></label>
<label class="inv-form-field"
><span>Face Value</span><input type="text" [value]="'₹' + (purchaseFaceValue | number: '1.2-2')" readonly
/></label>
<label class="inv-form-field"
><span>Amount Paid</span><input type="text" [value]="'₹' + (purchaseAmount | number: '1.2-2')" readonly
/></label>
<label class="inv-form-field">
<span>* Paid from (Bank GL)</span>
<select [(ngModel)]="purchaseForm.bankGlCode">
@for (b of bankOptions; track b.glCode) {
<option [value]="b.glCode">{{ b.glCode }} — {{ b.glName }}</option>
}
</select>
</label>
<label class="inv-form-field"
><span>Category</span><input type="text" value="AFS (Available For Sale)" readonly
/></label>
</div>
@if (shareLimit; as l) {
<div class="pos-section-label">
RBI Limit — shares of co-operative societies (owned funds as on {{ l.asOnDate }})
</div>
@if (!l.exempt) {
<table class="pg-table">
<thead>
<tr>
<th>Limit</th>
<th class="num">Allowed</th>
<th class="num">Now</th>
<th class="num">After this deal</th>
</tr>
</thead>
<tbody>
<tr>
<td>
All co-operative societies — 2% of owned funds
{{
l.ownedFunds !== null && l.ownedFunds !== undefined
? '₹' + (l.ownedFunds | number: '1.2-2')
: '(not entered)'
}}
</td>
<td class="num">
{{ l.coopLimit !== null && l.coopLimit !== undefined ? '₹' + (l.coopLimit | number: '1.2-2') : '—' }}
</td>
<td class="num">₹{{ l.coopOutstanding | number: '1.2-2' }}</td>
<td class="num">₹{{ l.coopAfter | number: '1.2-2' }}</td>
</tr>
@if (l.partyName) {
<tr>
<td>
{{ l.partyName }} — 5% of subscribed capital
{{
l.subscribedCapital !== null && l.subscribedCapital !== undefined
? '₹' + (l.subscribedCapital | number: '1.2-2')
: '(not entered)'
}}
</td>
<td class="num">
{{
l.institutionLimit !== null && l.institutionLimit !== undefined
? '₹' + (l.institutionLimit | number: '1.2-2')
: '—'
}}
</td>
<td class="num">₹{{ l.institutionOutstanding | number: '1.2-2' }}</td>
<td class="num">₹{{ l.institutionAfter | number: '1.2-2' }}</td>
</tr>
}
</tbody>
</table>
}
<p class="inv-hint" [class.inv-hint--bad]="!l.withinLimits">{{ l.message }}</p>
@if (!l.exempt && (l.ownedFunds === null || l.ownedFunds === undefined)) {
<div class="inv-form-grid">
<label class="inv-form-field"
><span>* Owned Funds as on {{ l.asOnDate }} (₹)</span
><input type="number" min="0" [(ngModel)]="ownedFunds" placeholder="Paid-up share capital + reserves"
/></label>
<label class="inv-form-field"
><span>Total Deposits as on {{ l.asOnDate }} (₹)</span
><input
type="number"
min="0"
[(ngModel)]="totalDeposits"
placeholder="Only if not entered on the FD screen"
/></label>
</div>
<div class="inv-form-actions">
<button type="button" class="pg-btn pg-btn--primary" [disabled]="saving" (click)="saveOwnedFunds()">
Save Owned Funds
</button>
</div>
}
}
@if (shareLimitError) {
<p class="inv-hint inv-hint--bad">{{ shareLimitError }}</p>
}
<div class="pos-section-label">Accounting (posted on Settle, dated the settlement date)</div>
<p class="inv-hint">
Dr 100706 Investment in Shares / Cr {{ purchaseForm.bankGlCode }} ₹{{ purchaseAmount | number: '1.2-2' }}
</p>
<div class="inv-form-actions">
<button type="button" class="pg-btn pg-btn--ghost" (click)="cancelPurchase()">Cancel</button>
<button
type="button"
class="pg-btn pg-btn--primary"
[disabled]="saving || (shareLimit !== null && !shareLimit.withinLimits)"
(click)="savePurchase()"
>
Save
</button>
</div>
</div>
}
<!-- 02 DIVIDEND ENTRY -->
@if (activeTab === 'dividend') {
<div class="pg-card">
<div class="pos-section-label">Investment - Share Dividend Entry (income when received)</div>
<div class="inv-form-grid">
<label class="inv-form-field">
<span>* Holding</span>
<select [(ngModel)]="dividend.purchaseId" (ngModelChange)="onDividendDealChange()">
<option [ngValue]="null">-- Select --</option>
@for (d of dividendDeals; track d.id) {
<option [ngValue]="d.id">
{{ d.dealNo }} — {{ d.partyName }} ({{ d.balanceUnits | number: '1.0-0' }} shares)
</option>
}
</select>
</label>
<label class="inv-form-field"
><span>* Date Received</span><mifosx-date-ddmmyyyy [(ngModel)]="dividend.dividendDate"></mifosx-date-ddmmyyyy
></label>
<label class="inv-form-field"
><span>* Dividend Amount (₹)</span><input type="number" min="0" step="0.01" [(ngModel)]="dividend.amount"
/></label>
<label class="inv-form-field">
<span>* Received in (Bank GL)</span>
<select [(ngModel)]="dividend.bankGlCode">
<option value="">-- Select --</option>
@for (b of bankOptions; track b.glCode) {
<option [value]="b.glCode">{{ b.glCode }} — {{ b.glName }}</option>
}
</select>
</label>
<label class="inv-form-field"
><span>Remarks</span
><input type="text" maxlength="500" [(ngModel)]="dividend.remarks" placeholder="e.g. Dividend for FY 2025-26"
/></label>
</div>
<p class="inv-hint">
Dr {{ dividend.bankGlCode || 'Bank' }} / Cr 400404 Dividend on Investments ₹{{
dividend.amount || 0 | number: '1.2-2'
}}
</p>
<div class="inv-form-actions">
<button type="button" class="pg-btn pg-btn--primary" [disabled]="saving" (click)="saveDividend()">Save</button>
</div>
</div>
}
<!-- 03 REFUND / RETIREMENT -->
@if (activeTab === 'sell') {
<div class="pg-card">
<div class="pos-section-label">Investment - Share Refund / Retirement Entry</div>
<div class="inv-form-grid">
<label class="inv-form-field">
<span>* Holding</span>
<select [(ngModel)]="refund.purchaseId" (ngModelChange)="onRefundDealChange()">
<option [ngValue]="null">-- Select --</option>
@for (d of activeDeals; track d.id) {
<option [ngValue]="d.id">
{{ d.dealNo }} — {{ d.partyName }} ({{ d.balanceUnits | number: '1.0-0' }} shares)
</option>
}
</select>
</label>
<label class="inv-form-field"
><span>* Refund Date</span
><mifosx-date-ddmmyyyy
[(ngModel)]="refund.dealDate"
(ngModelChange)="refreshRefundQuote()"
></mifosx-date-ddmmyyyy
></label>
<label class="inv-form-field"
><span>* Shares Refunded</span
><input type="number" min="1" step="1" [(ngModel)]="refund.units" (ngModelChange)="refreshRefundQuote()"
/></label>
<label class="inv-form-field"
><span>* Price per Share (₹)</span
><input
type="number"
min="0"
step="0.01"
[(ngModel)]="refund.pricePerShare"
(ngModelChange)="refreshRefundQuote()"
/></label>
<label class="inv-form-field">
<span>* Received in (Bank GL)</span>
<select [(ngModel)]="refund.bankGlCode" (ngModelChange)="refreshRefundQuote()">
<option value="">-- Select --</option>
@for (b of bankOptions; track b.glCode) {
<option [value]="b.glCode">{{ b.glCode }} — {{ b.glName }}</option>
}
</select>
</label>
<label class="inv-form-field"
><span>Remarks</span><input type="text" maxlength="500" [(ngModel)]="refund.remarks"
/></label>
</div>
@if (refundQuote; as q) {
<table class="pg-table">
<tbody>
<tr>
<td>Amount received</td>
<td class="num">₹{{ q.consideration | number: '1.2-2' }}</td>
</tr>
<tr>
<td>Book value taken off (Cr 100706)</td>
<td class="num">₹{{ q.bookValueSold | number: '1.2-2' }}</td>
</tr>
<tr>
<td>{{ q.profitLoss >= 0 ? 'Profit (Cr 400405)' : 'Loss (Dr 500605)' }}</td>
<td class="num">₹{{ (q.profitLoss >= 0 ? q.profitLoss : -q.profitLoss) | number: '1.2-2' }}</td>
</tr>
<tr>
<td>Settlement date</td>
<td class="num">{{ q.settlementDate }}</td>
</tr>
</tbody>
</table>
}
@if (refundQuoteError) {
<p class="inv-hint inv-hint--bad">{{ refundQuoteError }}</p>
}
<div class="inv-form-actions">
<button type="button" class="pg-btn pg-btn--primary" [disabled]="saving || !refundQuote" (click)="saveRefund()">
Save
</button>
</div>
<div class="pos-section-label">Pending Refunds (posted on Settle)</div>
<table class="pg-table">
<thead>
<tr>
<th>Deal No</th>
<th>Institution</th>
<th class="num">Shares</th>
<th class="num">Amount</th>
<th class="num">Profit / Loss</th>
<th>Settlement Date</th>
<th></th>
</tr>
</thead>
<tbody>
@for (s of pendingRefunds; track s.id) {
<tr>
<td>
<span class="pg-chip">{{ s.dealNo }}</span>
</td>
<td>{{ s.partyName }}</td>
<td class="num">{{ s.units | number: '1.0-0' }}</td>
<td class="num">₹{{ s.netAmount | number: '1.2-2' }}</td>
<td class="num">
{{ s.profitLoss < 0 ? 'Loss' : 'Profit' }} ₹{{
(s.profitLoss < 0 ? -s.profitLoss : s.profitLoss) | number: '1.2-2'
}}
</td>
<td>{{ s.settlementDate }}</td>
<td>
<button
type="button"
class="pg-btn pg-btn--primary"
[disabled]="busySaleId !== null"
(click)="settleRefund(s)"
>
Settle
</button>
<button
type="button"
class="pg-btn pg-btn--ghost"
[disabled]="busySaleId !== null"
(click)="dropRefund(s)"
>
Drop
</button>
</td>
</tr>
} @empty {
<tr>
<td colspan="7" class="pg-empty">No pending refunds.</td>
</tr>
}
</tbody>
</table>
</div>
}
<!-- 04 WRITE OFF ENTRY -->
@if (activeTab === 'writeoff') {
<div class="pg-card">
<div class="pos-section-label">Investment - Share Write Off Entry</div>
<div class="inv-form-grid">
<label class="inv-form-field">
<span>* Holding</span>
<select [(ngModel)]="writeoffPurchaseId">
<option [ngValue]="null">-- Select --</option>
@for (d of activeDeals; track d.id) {
<option [ngValue]="d.id">{{ d.dealNo }} — {{ d.partyName }}</option>
}
</select>
</label>
@if (writeoffDeal; as d) {
<label class="inv-form-field"
><span>Book Value</span><input type="text" [value]="'₹' + (carryingValue(d) | number: '1.2-2')" readonly
/></label>
}
<label class="inv-form-field"
><span>* Amount to Write Off (₹)</span><input type="number" min="0" step="0.01" [(ngModel)]="writeoffAmount"
/></label>
<label class="inv-form-field"><span>* Reason</span><input type="text" [(ngModel)]="writeoffReason" /></label>
</div>
@if (writeoffDeal) {
<p class="inv-hint">
@if (writeoffInLiquidation) {
The institution is in liquidation: the shares may be written off in full; they stay held at nil until the
liquidator pays.
} @else {
Only part of the book value can be written off; enter a refund to close the holding.
}
Dr 500605 Loss on Investments / Cr 100706 Investment in Shares.
</p>
}
<div class="inv-form-actions">
<button type="button" class="pg-btn pg-btn--primary" [disabled]="saving" (click)="saveWriteoff()">Save</button>
</div>
</div>
}
@if (activeTab !== 'holdings') {
<div class="pg-card">
<div class="pos-section-label">Share Transaction Log</div>
<table class="pg-table">
<thead>
<tr>
<th>Date</th>
<th>Voucher No</th>
<th>Cert No</th>
<th>Type</th>
<th>Particulars</th>
<th class="num">Amount</th>
</tr>
</thead>
<tbody>
@for (t of txns; track $index) {
<tr>
<td>{{ t.txnDate }}</td>
<td>
<span class="pg-chip">{{ t.voucherNo }}</span>
</td>
<td>{{ t.certNo }}</td>
<td>{{ t.txnType }}</td>
<td>{{ t.particulars }}</td>
<td class="num">₹{{ t.amount | number: '1.2-2' }}</td>
</tr>
} @empty {
<tr>
<td colspan="6" class="pg-empty">No share transactions yet.</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
<div class="inv-toast" [class.show]="toastVisible">{{ toastMsg }}</div>