2021-11-04 10:31:26 +00:00
|
|
|
import frappe from 'frappejs';
|
2021-12-21 09:21:13 +00:00
|
|
|
import getCommonExportActions from '../commonExporter';
|
2019-11-19 19:14:15 +00:00
|
|
|
|
2018-10-25 20:57:34 +00:00
|
|
|
const title = 'Profit and Loss';
|
2021-11-04 10:31:26 +00:00
|
|
|
|
|
|
|
export default {
|
2018-10-25 20:57:34 +00:00
|
|
|
title: title,
|
|
|
|
method: 'profit-and-loss',
|
2019-08-20 08:57:27 +00:00
|
|
|
treeView: true,
|
2018-10-25 20:57:34 +00:00
|
|
|
filterFields: [
|
|
|
|
{
|
2019-08-20 08:57:27 +00:00
|
|
|
fieldtype: 'Date',
|
|
|
|
fieldname: 'fromDate',
|
|
|
|
size: 'small',
|
|
|
|
placeholder: 'From Date',
|
|
|
|
label: 'From Date',
|
2019-11-19 19:14:15 +00:00
|
|
|
required: 1,
|
|
|
|
default: async () => {
|
|
|
|
return (await frappe.getSingle('AccountingSettings')).fiscalYearStart;
|
2021-12-16 11:15:31 +00:00
|
|
|
},
|
2019-08-20 08:57:27 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldtype: 'Date',
|
|
|
|
fieldname: 'toDate',
|
|
|
|
size: 'small',
|
|
|
|
placeholder: 'To Date',
|
|
|
|
label: 'To Date',
|
2019-11-19 19:14:15 +00:00
|
|
|
required: 1,
|
|
|
|
default: async () => {
|
|
|
|
return (await frappe.getSingle('AccountingSettings')).fiscalYearEnd;
|
2021-12-16 11:15:31 +00:00
|
|
|
},
|
2019-08-20 08:57:27 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldtype: 'Select',
|
|
|
|
size: 'small',
|
2021-12-16 11:15:31 +00:00
|
|
|
options: ['Monthly', 'Quarterly', 'Half Yearly', 'Yearly'],
|
2019-11-19 19:14:15 +00:00
|
|
|
default: 'Monthly',
|
2019-08-20 08:57:27 +00:00
|
|
|
label: 'Periodicity',
|
2021-12-16 11:15:31 +00:00
|
|
|
placeholder: 'Select Period...',
|
|
|
|
fieldname: 'periodicity',
|
|
|
|
},
|
2018-10-25 20:57:34 +00:00
|
|
|
],
|
2021-12-21 09:21:13 +00:00
|
|
|
actions: getCommonExportActions('profit-and-loss'),
|
2021-12-29 05:22:31 +00:00
|
|
|
getColumns({ data }) {
|
2018-10-25 20:57:34 +00:00
|
|
|
const columns = [
|
2021-12-16 11:15:31 +00:00
|
|
|
{ label: 'Account', fieldtype: 'Data', fieldname: 'account', width: 2 },
|
2018-10-25 20:57:34 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
if (data && data.columns) {
|
|
|
|
const currencyColumns = data.columns;
|
2021-12-16 11:15:31 +00:00
|
|
|
const columnDefs = currencyColumns.map((name) => ({
|
2018-10-25 20:57:34 +00:00
|
|
|
label: name,
|
|
|
|
fieldname: name,
|
2021-12-16 11:15:31 +00:00
|
|
|
fieldtype: 'Currency',
|
2018-10-25 20:57:34 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
columns.push(...columnDefs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return columns;
|
2021-12-16 11:15:31 +00:00
|
|
|
},
|
2018-10-25 20:57:34 +00:00
|
|
|
};
|