2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +00:00
books/reports/BalanceSheet/BalanceSheet.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.1 KiB
JavaScript
Raw Normal View History

import { unique } from 'fyo/utils';
import { getData } from '../FinancialStatements/FinancialStatements';
class BalanceSheet {
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 };
}
}
export default BalanceSheet;