Files
cbsnexora/src/app/accounting/accounting.component.ts
T
niteshandClaude Sonnet 5 7b77166b19 fix: tenant-config fixes, cashier/share/savings UI bugs, and menu-access hardcoding
- Add Balance Sheet report and disabled-features accounting config
- Point menu-access tenant header and env.js/environment.ts tenant identifier
  at env config instead of hardcoded 'default'/'lincpay' literals
- Surface the real backend error (not a generic "no reference id") when an
  OTP send fails in contact-otp-block
- Fix branch-day "₹null" display bug (null vs undefined) and add a guard
  blocking a branch's first-ever day open before cash denomination migration
- Dynamically size the denomination count input and block re-opening an
  already-open business day from Migrate Cash Denomination
- Lock the denomination-managed cash GL row in Migrate Opening Balances
  (read-only, with a link back to Migrate Cash Denomination)
- Remove duplicate Cancel/Submit action bars on the Share Product and
  Savings Account creation preview steps; align Previous into the same row
- Hide "Apply Collection" on a share account once its advance collection
  is already settled (further purchases go through Apply Additional Shares)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-13 15:19:21 +05:30

217 lines
8.0 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/.
*/
/** Angular Imports */
import { AfterViewInit, Component, ElementRef, TemplateRef, ViewChild, inject } from '@angular/core';
import { Router, RouterLink } from '@angular/router';
/** Custom Services */
import { ConfigurationWizardService } from '../configuration-wizard/configuration-wizard.service';
import { PopoverService } from '../configuration-wizard/popover/popover.service';
import { MatNavList, MatListItem } from '@angular/material/list';
import { MatIcon } from '@angular/material/icon';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { MatLine } from '@angular/material/grid-list';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
import { DISABLED_ACCOUNTING_FEATURES } from './disabled-features';
/**
* Accounting component.
*/
@Component({
selector: 'mifosx-accounting',
templateUrl: './accounting.component.html',
styleUrls: ['./accounting.component.scss'],
imports: [
...STANDALONE_SHARED_IMPORTS,
MatNavList,
MatListItem,
MatIcon,
FaIconComponent,
MatLine
]
})
export class AccountingComponent implements AfterViewInit {
private router = inject(Router);
private configurationWizardService = inject(ConfigurationWizardService);
private popoverService = inject(PopoverService);
/* Reference of Chart of Accounts */
@ViewChild('chartofAccounts') chartofAccounts: ElementRef<any>;
/* Template for popover on Chart of Accounts */
@ViewChild('templateChartofAccounts') templateChartofAccounts: TemplateRef<any>;
/* Reference of Accounts Linked */
@ViewChild('accountsLinked') accountsLinked: ElementRef<any>;
/* Template for popover on Accounts Linked */
@ViewChild('templateAccountsLinked') templateAccountsLinked: TemplateRef<any>;
/* Reference of Migrate Opening Balances */
@ViewChild('migrateOpeningBalances') migrateOpeningBalances: ElementRef<any>;
/* Template for popover on Migrate Opening Balances */
@ViewChild('templateMigrateOpeningBalances') templateMigrateOpeningBalances: TemplateRef<any>;
/* Reference of Closing Entries */
@ViewChild('closingEntries') closingEntries: ElementRef<any>;
/* Template for popover on Closing Entries */
@ViewChild('templateClosingEntries') templateClosingEntries: TemplateRef<any>;
/* Reference of Create Journal Entries */
@ViewChild('createJournalEntries') createJournalEntries: ElementRef<any>;
/* Template for popover on Create Journal Entries */
@ViewChild('templateCreateJournalEntries') templateCreateJournalEntries: TemplateRef<any>;
// Initialize an array of 10 boolean values, all set to false
arrowBooleans: boolean[] = new Array(10).fill(false);
/** Which accounting tiles are switched off for this installation — see disabled-features.ts. */
disabledFeatures = DISABLED_ACCOUNTING_FEATURES;
/**
* Popover function
* @param template TemplateRef<any>.
* @param target HTMLElement | ElementRef<any>.
* @param position String.
* @param backdrop Boolean.
* @param arrowNumber - The index of the boolean value to toggle.
*/
showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
}
/**
* To show popover.
*/
ngAfterViewInit() {
if (this.configurationWizardService.showChartofAccounts) {
setTimeout(() => {
this.showPopover(this.templateChartofAccounts, this.chartofAccounts.nativeElement, 'bottom', true);
});
}
if (this.configurationWizardService.showAccountsLinked) {
setTimeout(() => {
this.showPopover(this.templateAccountsLinked, this.accountsLinked.nativeElement, 'bottom', true);
});
}
if (this.configurationWizardService.showMigrateOpeningBalances) {
setTimeout(() => {
this.showPopover(
this.templateMigrateOpeningBalances,
this.migrateOpeningBalances.nativeElement,
'bottom',
true
);
});
}
// Closing Entries and Create Journal Entries can be switched off (see disabled-features.ts), in
// which case their tiles never render and these refs stay undefined — the wizard simply has no
// step to point at, rather than throwing on a missing element.
if (this.configurationWizardService.showClosingEntries && this.closingEntries) {
setTimeout(() => {
this.showPopover(this.templateClosingEntries, this.closingEntries.nativeElement, 'bottom', true);
});
}
if (this.configurationWizardService.showCreateJournalEntries && this.createJournalEntries) {
setTimeout(() => {
this.showPopover(this.templateCreateJournalEntries, this.createJournalEntries.nativeElement, 'bottom', true);
});
}
}
/**
* Next Step (Charts of Accounts Page) Configuration Wizard.
*/
nextStepChartofAccounts() {
this.configurationWizardService.showChartofAccounts = false;
this.configurationWizardService.showChartofAccountsPage = true;
this.router.navigate(['/accounting/chart-of-accounts']);
}
/**
* Previous Step (Scheduler Jobs Page) Configuration Wizard.
*/
previousStepChartofAccounts() {
this.configurationWizardService.showChartofAccounts = false;
this.configurationWizardService.showSchedulerJobsList = true;
this.router.navigate(['/system/scheduler-jobs']);
}
/**
* Next Step (Accounts Linked Page) Configuration Wizard.
*/
nextStepAccountsLinked() {
this.configurationWizardService.showAccountsLinked = false;
this.configurationWizardService.showAccountsLinkedPage = true;
this.router.navigate(['/accounting/financial-activity-mappings']);
}
/**
* Previous Step (Create Chart of Accounts Page) Configuration Wizard.
*/
previousStepAccountsLinked() {
this.configurationWizardService.showAccountsLinked = false;
this.configurationWizardService.showChartofAccountsForm = true;
this.router.navigate(['/accounting/chart-of-accounts/gl-accounts/create']);
}
/**
* Next Step (Migrate Opening Balances) Configuration Wizard.
*/
nextStepMigrateOpeningBalances() {
this.router.navigate(['/accounting/migrate-opening-balances']);
}
/**
* Previous Step (Accounts Linked Page) Configuration Wizard.
*/
previousStepMigrateOpeningBalances() {
this.configurationWizardService.showMigrateOpeningBalances = false;
this.configurationWizardService.showAccountsLinkedList = true;
this.router.navigate(['accounting/financial-activity-mappings']);
}
/**
* Next Step (Closing Entries Page) Configuration Wizard.
*/
nextStepClosingEntries() {
this.configurationWizardService.showClosingEntries = false;
this.configurationWizardService.showClosingEntriesPage = true;
this.router.navigate(['/accounting/closing-entries']);
}
/**
* Previous Step (Migrate Opening Balances Page) Configuration Wizard.
*/
previousStepClosingEntries() {
this.configurationWizardService.showClosingEntries = false;
this.configurationWizardService.showMigrateOpeningBalances = true;
this.router.navigate(['/accounting/migrate-opening-balances']);
}
/**
* Next Step (Create Journal Entries Page) Configuration Wizard.
*/
nextStepCreateJournalEntries() {
this.router.navigate(['/accounting/journal-entries/create']);
}
/**
* Previous Step (Closing Entries Page) Configuration Wizard.
*/
previousStepCreateJournalEntries() {
this.configurationWizardService.showCreateJournalEntries = false;
this.configurationWizardService.showClosingEntriesList = true;
this.router.navigate(['/accounting/closing-entries']);
}
arrowBooleansToggle(arrowNumber: number) {
// Toggle the boolean value at the given index
this.arrowBooleans[arrowNumber] = !this.arrowBooleans[arrowNumber];
}
}