Files
cbsnexora/src/app/deposits/dds-accounts/dds-account-view/dds-transaction-view-dialog/dds-transaction-view-dialog.component.ts
T
niteshandClaude Sonnet 5.5 306af59099 feat(dds): savings-style DDS account view, batch processing redesign, slab master in Products
- DDS account view: Transactions and Passbook tabs laid out like savings, a per-line
  View Transaction popup (general, payment details, accounting and audit, receipt print)
  with actions menu (view, receipt, journal entries)
- DDS batch processing: job tiles with calculate then post pairs, compact agent and party
  ranges, agent-wise preview with a View popup of each agent's accounts, search, and CSV
  export of all details or one agent; previous runs summary; OD interest hidden
- Discard removes the generated preview on the server
- Commission Slab Master moved from Organization to Products, with a how-to card, rates
  and commission at "To", gap warnings to the paisa, loading state and a calculator popup
- Party edit: scheme terms and agent locked on an active account, with a lock badge

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 17:13:33 +05:30

110 lines
3.6 KiB
TypeScript

/**
* Copyright since 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { Component, inject } from '@angular/core';
import { CurrencyPipe, DatePipe } from '@angular/common';
import { Router } from '@angular/router';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MatButton } from '@angular/material/button';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
/** What the account view hands the dialog: the line, its account, and how to name its type. */
export interface DdsTransactionViewData {
transaction: any;
account: any;
typeLabel: string;
/** Opened from the Receipt menu item: print the receipt straight away. */
printOnOpen?: boolean;
}
/**
* One DDS passbook line in full - everything the line was saved with - the way a savings account's
* View Transaction shows one: what it was, when, how much, and who keyed it, with the voucher, its
* own reference and the journal it was booked under. Prints as a receipt.
*/
@Component({
selector: 'mifosx-dds-transaction-view-dialog',
templateUrl: './dds-transaction-view-dialog.component.html',
styleUrls: ['./dds-transaction-view-dialog.component.scss'],
imports: [
...STANDALONE_SHARED_IMPORTS,
CurrencyPipe,
DatePipe,
MatButton,
FaIconComponent
]
})
export class DdsTransactionViewDialogComponent {
private dialogRef = inject(MatDialogRef<DdsTransactionViewDialogComponent>);
private router = inject(Router);
data = inject<DdsTransactionViewData>(MAT_DIALOG_DATA);
get txn(): any {
return this.data.transaction || {};
}
get account(): any {
return this.data.account || {};
}
get isCredit(): boolean {
return this.txn.direction === 'CREDIT';
}
get currency(): string {
return this.account.currencyCode || 'INR';
}
constructor() {
if (this.data.printOnOpen) {
// After the view has drawn, so the receipt has something in it to print.
setTimeout(() => this.printReceipt(), 300);
}
}
viewJournalEntries(): void {
if (!this.txn.journalTransactionId) {
return;
}
this.dialogRef.close();
this.router.navigate([
'/',
'journal-entry',
'view',
this.txn.journalTransactionId
]);
}
/** The receipt block alone, in a window of its own - as the savings receipt prints. */
printReceipt(): void {
const receipt = document.getElementById('dds-txn-receipt');
const popup = window.open('', '_blank', 'width=720,height=800');
if (!receipt || !popup) {
return;
}
popup.document.write(`<html><head><title>${this.txn.refNo || 'DDS'} Receipt</title><style>
body { font-family: Arial, sans-serif; font-size: 12px; color: #111; margin: 24px; }
h2 { margin: 0 0 4px; font-size: 16px; } .muted { color: #555; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
td { padding: 6px 8px; border-bottom: 1px solid #ddd; vertical-align: top; }
td.k { width: 38%; color: #555; } .amount { font-size: 18px; font-weight: 700; }
.sign { margin-top: 48px; display: flex; justify-content: space-between; }
</style></head><body>${receipt.innerHTML}
<div class="sign"><span>Customer</span><span>Authorised Signatory</span></div>
</body></html>`);
popup.document.close();
popup.focus();
popup.print();
}
close(): void {
this.dialogRef.close();
}
}