mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
1a8a23d2a2
- refactor Common Js imports to ES6
52 lines
1.3 KiB
JavaScript
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;
|