2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
books/reports/BalanceSheet/BalanceSheet.js
18alantom 1a8a23d2a2 build(electron): bump electron to 15.3.0
- refactor Common Js imports to ES6
2021-11-05 14:31:35 +05:30

52 lines
1.3 KiB
JavaScript

import frappe from 'frappejs';
import { unique } from 'frappejs/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;