/** * Copyright since 2025 Mifos Initiative * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Component, OnInit, inject } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule, ReactiveFormsModule, FormBuilder, FormGroup, FormArray, Validators } from '@angular/forms'; import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; export interface CashierIssueDdDialogData { leaflet: any; branchName: string; sponsorBankName: string; faceValue: number; chargesAmount: number; gstPercentage: number; gstAmount: number; totalCashPayable: number; /** * How the draft is being paid for. Cash is a walk-in purchaser the bank may know nothing about, * so their name, address and Aadhaar have to be captured here. An account debit is a member whose * account is already on screen — those fields are not asked for, and must not be sent, because * the identity is the account holder's rather than a walk-in's. */ paymentMethod?: 'CASH' | 'ACCOUNT_DEBIT'; /** The account being debited, shown so the clerk can see what is funding the draft. */ accountNo?: string; /** The account holder, for the same reason. */ accountHolderName?: string; /** * How many drafts this slip raises. Absent or 1 is the ordinary single draft and the dialog is * unchanged; 2 or more turns it into a slip, asking for a face value, charge and beneficiary per * draft and reporting the combined total the account will be debited for. */ ddCount?: number; /** * Whether the funding account is a GL account rather than a member's. Only affects wording: a GL * account has no passbook, so it is not promised one. */ glFunded?: boolean; /** * The leaflets provisionally shown against each line of a slip. * * Only ever indicative. The server allocates the real numbers inside the locked transaction that * submits the slip, so what is shown here is the next-available run at the moment the dialog was * opened — accurate unless another clerk submits first, which is precisely why the numbers cannot * be promised until submit returns them. */ previewDdNumbers?: string[]; } /** One captured draft on a multi-DD slip. */ export interface DdSlipLineResult { beneficiaryName: string; payableAtBranch: string; payableAtCity: string; faceValue: number; chargesAmount: number; } @Component({ selector: 'mifosx-cashier-issue-dd-dialog', standalone: true, imports: [ CommonModule, FormsModule, ReactiveFormsModule, MatDialogModule, MatFormFieldModule, MatInputModule, MatButtonModule, MatIconModule ], template: `
@if (isSlip) { One debit funds all {{ lineCount }} drafts · Enter each draft's beneficiary and amount } @else { Next available DD leaflet auto-selected · {{ isAccountDebit ? 'Enter beneficiary details' : 'Enter purchaser & beneficiary details' }} }