feat: cash-only registers, day book sections and DD amendments
build-run / Run Lint, Build and Deploy (push) Canceled after 0s
Publish Image in Docker Hub / build (push) Canceled after 0s
Playwright E2E Tests / Run Playwright Tests (push) Canceled after 0s
Tests / testRigor (push) Canceled after 0s

This commit is contained in:
2026-09-03 18:26:22 +05:30
parent 6442562df0
commit fbce73fd17
111 changed files with 9076 additions and 3507 deletions
@@ -9,9 +9,11 @@
import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { MatButtonModule } from '@angular/material/button';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { SponsorDDService } from '../sponsor-dd.service';
@@ -26,67 +28,98 @@ import { SponsorDDService } from '../sponsor-dd.service';
MatDialogModule,
MatFormFieldModule,
MatInputModule,
MatSelectModule,
MatButtonModule,
MatSnackBarModule
],
template: `
<h2 mat-dialog-title>GST / GL Settings</h2>
<h2 mat-dialog-title>Sponsor DD GST & GL Mapping Configuration</h2>
<mat-dialog-content>
<p class="hint-text">
GST is charged on the DD issuance commission/charges only, never on the DD face value. The rate below applies to
every DD submitted from now on - it's locked in per-request at submission time, so changing it here never
affects requests already in flight.
Configure the one-time General Ledger (GL) accounts for Demand Draft creation. When a walk-in or bank customer
creates a DD, the system will automatically route the face value, charges, and GST to these mapped accounts.
</p>
<form [formGroup]="form" class="dialog-form" *ngIf="!loading">
<!-- DD Payable GL Account -->
<mat-form-field appearance="outline" class="full-width">
<mat-label>GST Percentage (%)</mat-label>
<input matInput type="number" formControlName="gstPercentage" step="0.01" />
<mat-error *ngIf="form.get('gstPercentage')?.hasError('required')">Required</mat-error>
<mat-error *ngIf="form.get('gstPercentage')?.hasError('min') || form.get('gstPercentage')?.hasError('max')">
Must be between 0 and 100
</mat-error>
<mat-label>Sponsor DD Payable GL Account *</mat-label>
<mat-select formControlName="ddPayableGlAccountId" required placeholder="Select DD Payable Liability GL">
<mat-option *ngFor="let acc of glAccounts" [value]="acc.id"> {{ acc.glCode }} · {{ acc.name }} </mat-option>
</mat-select>
<mat-hint>Credited for the DD Face Value</mat-hint>
<mat-error *ngIf="form.get('ddPayableGlAccountId')?.hasError('required')">Required</mat-error>
</mat-form-field>
<!-- Charges Income GL Account -->
<mat-form-field appearance="outline" class="full-width">
<mat-label>DD Limit Amount</mat-label>
<input matInput type="number" formControlName="ddLimitAmount" step="0.01" />
<mat-hint>
Maximum face value for a single DD, and the maximum combined face value of all DDs issued to the same
beneficiary on the same day. Leave blank for no limit.
</mat-hint>
<mat-error *ngIf="form.get('ddLimitAmount')?.hasError('min')">Cannot be negative</mat-error>
<mat-label>DD Charges / Commission Income GL *</mat-label>
<mat-select formControlName="chargesIncomeGlAccountId" required placeholder="Select Charges Income GL">
<mat-option *ngFor="let acc of glAccounts" [value]="acc.id"> {{ acc.glCode }} · {{ acc.name }} </mat-option>
</mat-select>
<mat-hint>Credited for DD Issuance Charges/Commission</mat-hint>
<mat-error *ngIf="form.get('chargesIncomeGlAccountId')?.hasError('required')">Required</mat-error>
</mat-form-field>
<div class="readonly-accounts">
<div class="account-row">
<span>DD Payable</span><strong>{{ mapping?.ddPayableGlAccountName || '-' }}</strong>
</div>
<div class="account-row">
<span>Cheque Clearing</span><strong>{{ mapping?.chequeClearingGlAccountName || '-' }}</strong>
</div>
<div class="account-row">
<span>Cash</span><strong>{{ mapping?.cashGlAccountName || '-' }}</strong>
</div>
<div class="account-row">
<span>Cash (Pending Approval)</span><strong>{{ mapping?.cashSuspenseGlAccountName || '-' }}</strong>
</div>
<div class="account-row">
<span>Charges Income</span><strong>{{ mapping?.chargesIncomeGlAccountName || '-' }}</strong>
</div>
<div class="account-row">
<span>GST Payable</span><strong>{{ mapping?.gstPayableGlAccountName || '-' }}</strong>
</div>
<!-- GST Payable GL Account -->
<mat-form-field appearance="outline" class="full-width">
<mat-label>GST Payable on Charges GL *</mat-label>
<mat-select formControlName="gstPayableGlAccountId" required placeholder="Select GST Liability GL">
<mat-option *ngFor="let acc of glAccounts" [value]="acc.id"> {{ acc.glCode }} · {{ acc.name }} </mat-option>
</mat-select>
<mat-hint>Credited for GST collected on charges</mat-hint>
<mat-error *ngIf="form.get('gstPayableGlAccountId')?.hasError('required')">Required</mat-error>
</mat-form-field>
<!-- Cash GL Account -->
<mat-form-field appearance="outline" class="full-width">
<mat-label>Cash at Tellers / Vault GL Account *</mat-label>
<mat-select formControlName="cashGlAccountId" required placeholder="Select Cash Asset GL">
<mat-option *ngFor="let acc of glAccounts" [value]="acc.id"> {{ acc.glCode }} · {{ acc.name }} </mat-option>
</mat-select>
<mat-hint>Debited when cash is received from walk-in customer</mat-hint>
<mat-error *ngIf="form.get('cashGlAccountId')?.hasError('required')">Required</mat-error>
</mat-form-field>
<!-- Cheque Clearing GL Account -->
<mat-form-field appearance="outline" class="full-width">
<mat-label>Cheque Clearing Suspense GL Account</mat-label>
<mat-select formControlName="chequeClearingGlAccountId" placeholder="Select Cheque Clearing GL (Optional)">
<mat-option [value]="null">-- None --</mat-option>
<mat-option *ngFor="let acc of glAccounts" [value]="acc.id"> {{ acc.glCode }} · {{ acc.name }} </mat-option>
</mat-select>
<mat-hint>Debited when DD is paid via cheque</mat-hint>
</mat-form-field>
<div class="row-two-fields">
<!-- GST Percentage -->
<mat-form-field appearance="outline" class="half-width">
<mat-label>GST Percentage (%) *</mat-label>
<input matInput type="number" formControlName="gstPercentage" step="0.01" />
<mat-error *ngIf="form.get('gstPercentage')?.hasError('required')">Required</mat-error>
<mat-error *ngIf="form.get('gstPercentage')?.hasError('min') || form.get('gstPercentage')?.hasError('max')">
0 - 100%
</mat-error>
</mat-form-field>
<!-- DD Limit Amount -->
<mat-form-field appearance="outline" class="half-width">
<mat-label>DD Limit Amount (₹)</mat-label>
<input matInput type="number" formControlName="ddLimitAmount" step="0.01" />
<mat-hint>Max limit per draft/day</mat-hint>
<mat-error *ngIf="form.get('ddLimitAmount')?.hasError('min')">Cannot be negative</mat-error>
</mat-form-field>
</div>
<p class="hint-text">
GL account assignments above are set up once by an administrator and shown here read-only.
</p>
</form>
<div *ngIf="loading" class="loading-state">
<p>Loading GL accounts and settings...</p>
</div>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button (click)="onClose()">Close</button>
<button mat-flat-button color="primary" [disabled]="loading || form.invalid || saving" (click)="onSave()">
Save
{{ saving ? 'Saving...' : 'Save Mapping' }}
</button>
</mat-dialog-actions>
`,
@@ -101,25 +134,22 @@ import { SponsorDDService } from '../sponsor-dd.service';
.full-width {
width: 100%;
}
.row-two-fields {
display: flex;
gap: 16px;
}
.half-width {
flex: 1;
}
.hint-text {
color: #64748b;
font-size: 13px;
margin: 0 0 12px 0;
margin: 0 0 16px 0;
line-height: 1.4;
}
.readonly-accounts {
border: 1px solid #e2e8f0;
border-radius: 8px;
padding: 12px 16px;
background: #f8fafc;
}
.account-row {
display: flex;
justify-content: space-between;
font-size: 13px;
padding: 4px 0;
color: #334155;
}
.account-row span {
.loading-state {
padding: 24px;
text-align: center;
color: #64748b;
}
`
@@ -127,6 +157,7 @@ import { SponsorDDService } from '../sponsor-dd.service';
})
export class GlSettingsDialogComponent implements OnInit {
private fb = inject(FormBuilder);
private http = inject(HttpClient);
private sponsorDDService = inject(SponsorDDService);
private dialogRef = inject(MatDialogRef<GlSettingsDialogComponent>);
private snackBar = inject(MatSnackBar);
@@ -135,9 +166,27 @@ export class GlSettingsDialogComponent implements OnInit {
loading = true;
saving = false;
mapping: any = null;
glAccounts: any[] = [];
ngOnInit(): void {
this.form = this.fb.group({
ddPayableGlAccountId: [
null,
[Validators.required]
],
chargesIncomeGlAccountId: [
null,
[Validators.required]
],
gstPayableGlAccountId: [
null,
[Validators.required]
],
cashGlAccountId: [
null,
[Validators.required]
],
chequeClearingGlAccountId: [null],
gstPercentage: [
18,
[
@@ -151,20 +200,42 @@ export class GlSettingsDialogComponent implements OnInit {
[Validators.min(0)]
]
});
this.sponsorDDService.getGlMappings().subscribe({
next: (mappings) => {
this.mapping = mappings && mappings.length ? mappings[0] : null;
if (this.mapping) {
this.form.patchValue({
gstPercentage: this.mapping.gstPercentage ?? 18,
ddLimitAmount: this.mapping.ddLimitAmount ?? null
});
}
this.loading = false;
this.loadGlAccountsAndMapping();
}
loadGlAccountsAndMapping(): void {
this.loading = true;
this.http.get<any[]>('/glaccounts?manualEntriesAllowed=true&disabled=false').subscribe({
next: (accounts) => {
this.glAccounts = accounts || [];
this.sponsorDDService.getGlMappings().subscribe({
next: (mappings) => {
this.mapping = mappings && mappings.length ? mappings[0] : null;
if (this.mapping) {
this.form.patchValue({
ddPayableGlAccountId: this.mapping.ddPayableGlAccountId ?? null,
chargesIncomeGlAccountId: this.mapping.chargesIncomeGlAccountId ?? null,
gstPayableGlAccountId: this.mapping.gstPayableGlAccountId ?? null,
cashGlAccountId: this.mapping.cashGlAccountId ?? null,
chequeClearingGlAccountId: this.mapping.chequeClearingGlAccountId ?? null,
gstPercentage: this.mapping.gstPercentage ?? 18,
ddLimitAmount: this.mapping.ddLimitAmount ?? null
});
}
this.loading = false;
},
error: (err) => {
this.loading = false;
this.snackBar.open('Error loading GL mapping: ' + (err.error?.message || err.message), 'Close', {
duration: 5000
});
}
});
},
error: (err) => {
this.loading = false;
this.snackBar.open('Error loading GL settings: ' + (err.error?.message || err.message), 'Close', {
this.snackBar.open('Error loading GL accounts: ' + (err.error?.message || err.message), 'Close', {
duration: 5000
});
}
@@ -172,29 +243,32 @@ export class GlSettingsDialogComponent implements OnInit {
}
onSave(): void {
if (this.form.invalid || !this.mapping) return;
if (this.form.invalid) return;
this.saving = true;
const val = this.form.value;
this.sponsorDDService
.upsertGlMapping({
sponsorBankId: 0,
ddPayableGlAccountId: this.mapping.ddPayableGlAccountId,
chequeClearingGlAccountId: this.mapping.chequeClearingGlAccountId,
cashGlAccountId: this.mapping.cashGlAccountId,
chargesIncomeGlAccountId: this.mapping.chargesIncomeGlAccountId,
cashSuspenseGlAccountId: this.mapping.cashSuspenseGlAccountId,
gstPercentage: this.form.value.gstPercentage,
gstPayableGlAccountId: this.mapping.gstPayableGlAccountId,
ddLimitAmount: this.form.value.ddLimitAmount
ddPayableGlAccountId: val.ddPayableGlAccountId,
chequeClearingGlAccountId: val.chequeClearingGlAccountId,
cashGlAccountId: val.cashGlAccountId,
chargesIncomeGlAccountId: val.chargesIncomeGlAccountId,
cashSuspenseGlAccountId: this.mapping?.cashSuspenseGlAccountId || val.cashGlAccountId,
gstPercentage: val.gstPercentage,
gstPayableGlAccountId: val.gstPayableGlAccountId,
ddLimitAmount: val.ddLimitAmount
})
.subscribe({
next: () => {
this.snackBar.open('GST percentage updated', 'Close', { duration: 3000 });
this.snackBar.open('Sponsor DD GL Mapping & GST Settings saved successfully!', 'Close', { duration: 3000 });
this.dialogRef.close(true);
},
error: (err) => {
this.saving = false;
this.snackBar.open('Error: ' + (err.error?.message || err.message), 'Close', { duration: 5000 });
this.snackBar.open('Error saving GL settings: ' + (err.error?.message || err.message), 'Close', {
duration: 5000
});
}
});
}