/** * 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, inject } from '@angular/core'; 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 * only renders, so one loading state lives in the row's own click handler rather than being * 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; createdBy: string | null; createdAt: string | null; totalDebit: number; totalCredit: number; balanced: boolean; lines: { lineNo: number; entryType: 'DR' | 'CR'; partyName: string | null; accountNo: string | null; amount: number; description: string | null; }[]; /** GL entries a native platform command posted for the same underlying event, outside this * voucher entirely — a share redemption's Dr Share Capital / Cr Share Sundry pair, posted at * manager approval, before this voucher's own Dr Sundry / Cr Cash at Vault settlement leg even * exists. Empty for every voucher that already is the whole transaction on its own. */ relatedLines: { stage: string; entryType: 'DR' | 'CR'; partyName: string | null; accountNo: string | null; amount: number; description: string | null; }[]; }; } /** The full slip behind a summarised register row — every debit and credit line a voucher is * made of, not just the first side of each that a table row has room for. */ @Component({ selector: 'mifosx-voucher-detail-dialog', standalone: true, imports: [ CommonModule, MatDialogModule, MatButtonModule, MatIconModule, VoucherStatusComponent ], template: `
{{ detail.voucherType || 'Voucher' }} · {{ detail.branchName || 'Head Office' }}
| Side | Party | Account No. | Amount |
|---|---|---|---|
| {{ line.entryType === 'DR' ? 'Debit' : 'Credit' }} | {{ line.partyName || '—' }} | {{ line.accountNo || '—' }} | ₹{{ line.amount | number: '1.2-2' }} |
| {{ line.description }} | |||
| This voucher's individual lines were not recorded. | |||
| Total | ₹{{ detail.totalDebit | number: '1.2-2' }} / ₹{{ detail.totalCredit | number: '1.2-2' }} | ||