2018-04-18 09:02:05 +00:00
|
|
|
const frappe = require('frappejs');
|
|
|
|
const { getData } = require('../financialStatements');
|
|
|
|
|
|
|
|
class ProfitAndLoss {
|
2018-04-19 14:31:35 +00:00
|
|
|
async run({ fromDate, toDate, periodicity }) {
|
2018-04-18 09:02:05 +00:00
|
|
|
|
|
|
|
let income = await getData({
|
|
|
|
rootType: 'Income',
|
2018-04-19 14:31:35 +00:00
|
|
|
balanceMustBe: 'Credit',
|
|
|
|
fromDate,
|
|
|
|
toDate,
|
|
|
|
periodicity
|
2018-04-18 09:02:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
let expense = await getData({
|
|
|
|
rootType: 'Expense',
|
2018-04-19 14:31:35 +00:00
|
|
|
balanceMustBe: 'Debit',
|
|
|
|
fromDate,
|
|
|
|
toDate,
|
|
|
|
periodicity
|
2018-04-18 09:02:05 +00:00
|
|
|
});
|
|
|
|
|
2018-04-19 14:31:35 +00:00
|
|
|
return { income, expense };
|
2018-04-18 09:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function execute(params) {
|
|
|
|
return new ProfitAndLoss().run(params);
|
|
|
|
}
|