From d652ee800ddef558316090d808e56f686f7197a3 Mon Sep 17 00:00:00 2001 From: Piyush Singhania Date: Sun, 12 Dec 2021 15:30:50 +0530 Subject: [PATCH] Refactored filter fields --- reports/GoodsAndServiceTax/BaseViewConfig.js | 3 +++ reports/GoodsAndServiceTax/GSTR1View.js | 13 +------------ reports/GoodsAndServiceTax/GSTR2View.js | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/reports/GoodsAndServiceTax/BaseViewConfig.js b/reports/GoodsAndServiceTax/BaseViewConfig.js index fb167fb2..4c5f7515 100644 --- a/reports/GoodsAndServiceTax/BaseViewConfig.js +++ b/reports/GoodsAndServiceTax/BaseViewConfig.js @@ -1,5 +1,6 @@ import ExportWizard from '../../src/components/ExportWizard'; import { generateGstr1Json } from '../../accounting/gst'; +import { DateTime } from 'luxon'; export default { filterFields: [ @@ -30,6 +31,7 @@ export default { size: 'small', placeholder: 'From Date', fieldname: 'fromDate', + default: DateTime.local().minus({ months: 3 }).toISODate(), }, { fieldtype: 'Date', @@ -37,6 +39,7 @@ export default { size: 'small', placeholder: 'To Date', fieldname: 'toDate', + default: DateTime.local().toISODate(), }, ], linkFields: [ diff --git a/reports/GoodsAndServiceTax/GSTR1View.js b/reports/GoodsAndServiceTax/GSTR1View.js index 4ed68b21..d3c87c50 100644 --- a/reports/GoodsAndServiceTax/GSTR1View.js +++ b/reports/GoodsAndServiceTax/GSTR1View.js @@ -2,21 +2,10 @@ const title = 'GSTR 1'; import baseConfig from './BaseViewConfig'; import { DateTime } from 'luxon'; -const filterFields = baseConfig.filterFields; -filterFields.forEach((field) => { - if (field.fieldname === 'toDate') { - field.default = DateTime.local().toISODate(); - } - else if(field.fieldname === 'fromDate') { - field.default = DateTime.local().minus({months: 3}).toISODate(); - } -}); - - export default { title: title, method: 'gstr-1', - filterFields, + filterFields: baseConfig.filterFields, linkFields: baseConfig.linkFields, getColumns: baseConfig.getColumns, }; diff --git a/reports/GoodsAndServiceTax/GSTR2View.js b/reports/GoodsAndServiceTax/GSTR2View.js index 615583b3..7b66a217 100644 --- a/reports/GoodsAndServiceTax/GSTR2View.js +++ b/reports/GoodsAndServiceTax/GSTR2View.js @@ -6,5 +6,5 @@ export default { method: 'gstr-2', filterFields: baseConfig.filterFields, linkFields: baseConfig.linkFields, - getColumns: baseConfig.getColumns + getColumns: baseConfig.getColumns, };