/**
* 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 } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { Observable } from 'rxjs';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
import { OssLine, OssReturnBase } from './oss-return.base';
/**
* OSS 1 — Return on Assets and Liabilities (RAL), return code R070.
*
* The bank's balance sheet restated on RBI's line structure, every figure read from the ledger as
* at the quarter end. Liabilities must equal assets; where they do not, the return says so rather
* than hiding the difference, because an imbalance is a real condition of the books that the filer
* has to see before filing.
*/
@Component({
selector: 'mifosx-oss1-live',
templateUrl: './oss-return.component.html',
styleUrls: ['../oss-return.scss'],
imports: [
...STANDALONE_SHARED_IMPORTS,
FaIconComponent,
FormsModule
]
})
export class Oss1LiveComponent extends OssReturnBase implements OnInit {
protected readonly exportStem = 'RBI_OSS1_RAL';
readonly configRoute = '/organization/oss1-gl-config';
readonly configLinkLabel = 'Open OSS 1 GL Configuration';
readonly returnShortName = 'OSS 1';
/**
* Whether the two sides balance — the first thing to check on a balance sheet, and the reason
* the difference is stated rather than absorbed.
*/
get headlineIsBad(): boolean {
return this.data?.balanced === false;
}
get headline(): string {
if (!this.data) {
return '';
}
const liabilities = this.amount(this.data.totalLiabilities);
const assets = this.amount(this.data.totalAssets);
if (!this.headlineIsBad) {
return (
`Total Liabilities ₹${liabilities} · ` +
`Total Assets ₹${assets} · the two sides agree`
);
}
return (
`Total Liabilities ₹${liabilities} · ` +
`Total Assets ₹${assets} · ` +
`OUT OF BALANCE by ₹${this.amount(Math.abs(this.data.imbalance ?? 0))} — ` +
'resolve before filing'
);
}
protected fetch(quarterEndDate: string): Observable {
return this.rbiService.getOss1(quarterEndDate);
}
ngOnInit(): void {
this.load();
}
protected sections(): { title: string; unit: string; lines: OssLine[] }[] {
if (!this.data) {
return [];
}
return [
{ title: 'Liabilities', unit: 'Rs in Thousands', lines: this.data.liabilities ?? [] },
{ title: 'Assets', unit: 'Rs in Thousands', lines: this.data.assets ?? [] }
];
}
protected totals(): { label: string; value: number | null | undefined }[] {
if (!this.data) {
return [];
}
const totals: { label: string; value: number | null | undefined }[] = [
{ label: 'Total Liabilities', value: this.data.totalLiabilities },
{ label: 'Total Assets', value: this.data.totalAssets }
];
// Stated only when the two sides disagree: printing a nil difference on every balanced return
// would train a reviewer to skip the line that matters when it is not nil.
if (this.data.balanced === false) {
totals.push({ label: 'Difference (Assets − Liabilities)', value: this.data.imbalance });
}
return totals;
}
/** True when the two sides of the balance sheet disagree. */
get isImbalanced(): boolean {
return this.data?.balanced === false;
}
}