2022-04-19 05:59:36 +00:00
|
|
|
import frappe, { t } from 'fyo';
|
2021-12-21 09:21:13 +00:00
|
|
|
import getCommonExportActions from '../commonExporter';
|
2019-11-19 19:14:15 +00:00
|
|
|
|
2022-03-30 10:57:45 +00:00
|
|
|
const title = t`Profit and Loss`;
|
2021-11-04 10:31:26 +00:00
|
|
|
|
2022-03-30 10:57:45 +00:00
|
|
|
const periodicityMap = {
|
|
|
|
Monthly: t`Monthly`,
|
|
|
|
Quarterly: t`Quarterly`,
|
|
|
|
'Half Yearly': t`Half Yearly`,
|
|
|
|
Yearly: t`Yearly`,
|
|
|
|
};
|
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',
|
2022-03-30 10:57:45 +00:00
|
|
|
placeholder: t`From Date`,
|
2022-02-16 06:19:16 +00:00
|
|
|
label: t`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',
|
2022-03-30 10:57:45 +00:00
|
|
|
placeholder: t`To Date`,
|
2022-02-16 06:19:16 +00:00
|
|
|
label: t`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',
|
2022-03-30 10:57:45 +00:00
|
|
|
options: Object.keys(periodicityMap),
|
|
|
|
map: periodicityMap,
|
2019-11-19 19:14:15 +00:00
|
|
|
default: 'Monthly',
|
2022-02-16 06:19:16 +00:00
|
|
|
label: t`Periodicity`,
|
2022-03-30 10:57:45 +00:00
|
|
|
placeholder: t`Select Period...`,
|
2021-12-16 11:15:31 +00:00
|
|
|
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 = [
|
2022-02-16 06:19:16 +00:00
|
|
|
{ label: t`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',
|
2022-01-20 20:57:29 +00:00
|
|
|
width: 1,
|
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
|
|
|
};
|