2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +00:00
books/reports/ProfitAndLoss/viewConfig.js

64 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-02-16 06:19:16 +00:00
import frappe, { t } from 'frappe';
2021-12-21 09:21:13 +00:00
import getCommonExportActions from '../commonExporter';
2018-10-25 20:57:34 +00:00
const title = 'Profit and Loss';
export default {
2018-10-25 20:57:34 +00:00
title: title,
method: 'profit-and-loss',
treeView: true,
2018-10-25 20:57:34 +00:00
filterFields: [
{
fieldtype: 'Date',
fieldname: 'fromDate',
size: 'small',
placeholder: 'From Date',
2022-02-16 06:19:16 +00:00
label: t`From Date`,
required: 1,
default: async () => {
return (await frappe.getSingle('AccountingSettings')).fiscalYearStart;
},
},
{
fieldtype: 'Date',
fieldname: 'toDate',
size: 'small',
placeholder: 'To Date',
2022-02-16 06:19:16 +00:00
label: t`To Date`,
required: 1,
default: async () => {
return (await frappe.getSingle('AccountingSettings')).fiscalYearEnd;
},
},
{
fieldtype: 'Select',
size: 'small',
options: ['Monthly', 'Quarterly', 'Half Yearly', 'Yearly'],
default: 'Monthly',
2022-02-16 06:19:16 +00:00
label: t`Periodicity`,
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'),
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;
const columnDefs = currencyColumns.map((name) => ({
2018-10-25 20:57:34 +00:00
label: name,
fieldname: name,
fieldtype: 'Currency',
width: 1,
2018-10-25 20:57:34 +00:00
}));
columns.push(...columnDefs);
}
return columns;
},
2018-10-25 20:57:34 +00:00
};