2022-04-19 05:59:36 +00:00
|
|
|
import { unique } from 'fyo/utils';
|
2021-11-04 10:31:26 +00:00
|
|
|
import { getData } from '../FinancialStatements/FinancialStatements';
|
2018-04-24 07:58:57 +00:00
|
|
|
|
|
|
|
class BalanceSheet {
|
2022-01-20 20:57:29 +00:00
|
|
|
async run({ fromDate, toDate, periodicity }) {
|
|
|
|
let asset = await getData({
|
|
|
|
rootType: 'Asset',
|
|
|
|
balanceMustBe: 'Debit',
|
|
|
|
fromDate,
|
|
|
|
toDate,
|
|
|
|
periodicity,
|
|
|
|
accumulateValues: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
let liability = await getData({
|
|
|
|
rootType: 'Liability',
|
|
|
|
balanceMustBe: 'Credit',
|
|
|
|
fromDate,
|
|
|
|
toDate,
|
|
|
|
periodicity,
|
|
|
|
accumulateValues: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
let equity = await getData({
|
|
|
|
rootType: 'Equity',
|
|
|
|
balanceMustBe: 'Credit',
|
|
|
|
fromDate,
|
|
|
|
toDate,
|
|
|
|
periodicity,
|
|
|
|
accumulateValues: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const rows = [
|
|
|
|
...asset.accounts,
|
|
|
|
asset.totalRow,
|
|
|
|
[],
|
|
|
|
...liability.accounts,
|
|
|
|
liability.totalRow,
|
|
|
|
[],
|
|
|
|
...equity.accounts,
|
|
|
|
equity.totalRow,
|
|
|
|
[],
|
|
|
|
];
|
|
|
|
|
|
|
|
const columns = unique([
|
|
|
|
...asset.periodList,
|
|
|
|
...liability.periodList,
|
|
|
|
...equity.periodList,
|
|
|
|
]);
|
|
|
|
|
|
|
|
return { rows, columns };
|
|
|
|
}
|
2018-04-24 07:58:57 +00:00
|
|
|
}
|
|
|
|
|
2021-11-04 10:31:26 +00:00
|
|
|
export default BalanceSheet;
|