diff --git a/reports/GoodsAndServiceTax/GSTR1View.js b/reports/GoodsAndServiceTax/GSTR1View.js index d35482fc..4ed68b21 100644 --- a/reports/GoodsAndServiceTax/GSTR1View.js +++ b/reports/GoodsAndServiceTax/GSTR1View.js @@ -1,10 +1,22 @@ 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: baseConfig.filterFields, + filterFields, linkFields: baseConfig.linkFields, - getColumns: baseConfig.getColumns + getColumns: baseConfig.getColumns, }; diff --git a/src/pages/Report.vue b/src/pages/Report.vue index ac9b0cd9..22fe68a8 100644 --- a/src/pages/Report.vue +++ b/src/pages/Report.vue @@ -102,6 +102,8 @@ import Row from '@/components/Row'; import WithScroll from '@/components/WithScroll'; import FormControl from '@/components/Controls/FormControl'; import reportViewConfig from '@/../reports/view'; +import { ipcRenderer } from 'electron'; +import { IPC_ACTIONS } from '@/messages'; export default { name: 'Report', @@ -271,9 +273,29 @@ export default { this.loading ? 'text-gray-100' : 'text-gray-900', ]; }, - downloadAsJson() { + async downloadAsJson() { + const savePath = await this.getSavePath(); console.log('download complete'); }, + async getSavePath() { + const options = { + title: this._('Select folder'), + defaultPath: `${this.reportName}.json`, + }; + + let { filePath } = await ipcRenderer.invoke( + IPC_ACTIONS.GET_SAVE_FILEPATH, + options + ); + + if (filePath) { + if (!filePath.endsWith('.json')) { + filePath = filePath + '.json'; + } + } + + return filePath; + }, }, computed: { columns() {