From d3d5d56f09c8f15dd452df52f7b0a8543106c51e Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Tue, 13 Jun 2023 13:37:39 +0530 Subject: [PATCH] feat: report to pdf --- fyo/index.ts | 3 + .../baseModels/PrintSettings/PrintSettings.ts | 9 + reports/index.ts | 5 +- src/pages/PrintView/ReportPrintView.vue | 310 ++++++++++++++++++ src/pages/Report.vue | 17 +- src/pages/TemplateBuilder/ScaledContainer.vue | 6 +- src/pages/TemplateBuilder/SetPrintSize.vue | 157 +-------- src/router.ts | 7 + src/utils/misc.ts | 14 +- src/utils/ui.ts | 159 +++++++++ 10 files changed, 520 insertions(+), 167 deletions(-) create mode 100644 src/pages/PrintView/ReportPrintView.vue diff --git a/fyo/index.ts b/fyo/index.ts index 2194904f..fa862558 100644 --- a/fyo/index.ts +++ b/fyo/index.ts @@ -19,6 +19,8 @@ import * as errors from './utils/errors'; import { format } from './utils/format'; import { t, T } from './utils/translation'; import { ErrorLog } from './utils/types'; +import type { reports } from 'reports/index'; +import type { Report } from 'reports/Report'; export class Fyo { t = t; @@ -234,6 +236,7 @@ export class Fyo { deviceId: '', openCount: -1, appFlags: {} as Record, + reports: {} as Record, }; } diff --git a/models/baseModels/PrintSettings/PrintSettings.ts b/models/baseModels/PrintSettings/PrintSettings.ts index bb0da046..b369bd1a 100644 --- a/models/baseModels/PrintSettings/PrintSettings.ts +++ b/models/baseModels/PrintSettings/PrintSettings.ts @@ -1,6 +1,15 @@ +import { Attachment } from 'fyo/core/types'; import { Doc } from 'fyo/model/doc'; import { HiddenMap } from 'fyo/model/types'; export class PrintSettings extends Doc { + logo?: Attachment; + email?: string; + phone?: string; + address?: string; + companyName?: string; + color?: string; + font?: string; + displayLogo?: boolean; override hidden: HiddenMap = {}; } diff --git a/reports/index.ts b/reports/index.ts index 89beb6b9..77fcbe59 100644 --- a/reports/index.ts +++ b/reports/index.ts @@ -2,11 +2,10 @@ import { BalanceSheet } from './BalanceSheet/BalanceSheet'; import { GeneralLedger } from './GeneralLedger/GeneralLedger'; import { GSTR1 } from './GoodsAndServiceTax/GSTR1'; import { GSTR2 } from './GoodsAndServiceTax/GSTR2'; -import { StockLedger } from './inventory/StockLedger'; -import { StockBalance } from './inventory/StockBalance'; import { ProfitAndLoss } from './ProfitAndLoss/ProfitAndLoss'; -import { Report } from './Report'; import { TrialBalance } from './TrialBalance/TrialBalance'; +import { StockBalance } from './inventory/StockBalance'; +import { StockLedger } from './inventory/StockLedger'; export const reports = { GeneralLedger, diff --git a/src/pages/PrintView/ReportPrintView.vue b/src/pages/PrintView/ReportPrintView.vue new file mode 100644 index 00000000..a1c2284d --- /dev/null +++ b/src/pages/PrintView/ReportPrintView.vue @@ -0,0 +1,310 @@ + + + diff --git a/src/pages/Report.vue b/src/pages/Report.vue index 2f85023e..0206ff32 100644 --- a/src/pages/Report.vue +++ b/src/pages/Report.vue @@ -11,7 +11,12 @@ > {{ group.group }} - @@ -43,6 +48,7 @@ import { computed } from '@vue/reactivity'; import { t } from 'fyo'; import { reports } from 'reports'; +import getGSTRExportActions from 'reports/GoodsAndServiceTax/gstExporter'; import { Report } from 'reports/Report'; import Button from 'src/components/Button.vue'; import FormControl from 'src/components/Controls/FormControl.vue'; @@ -50,9 +56,10 @@ import DropdownWithActions from 'src/components/DropdownWithActions.vue'; import PageHeader from 'src/components/PageHeader.vue'; import ListReport from 'src/components/Report/ListReport.vue'; import { fyo } from 'src/initFyo'; -import { docsPathMap } from 'src/utils/misc'; +import { docsPathMap, getReport } from 'src/utils/misc'; import { docsPathRef } from 'src/utils/refs'; import { ActionGroup } from 'src/utils/types'; +import { routeTo } from 'src/utils/ui'; import { PropType, defineComponent } from 'vue'; export default defineComponent({ @@ -133,12 +140,10 @@ export default defineComponent({ }, }, methods: { + routeTo, async setReportData() { - const Report = reports[this.reportClassName]; - if (this.report === null) { - this.report = new Report(fyo); - await this.report.initialize(); + this.report = await getReport(this.reportClassName); } if (!this.report.reportData.length) { diff --git a/src/pages/TemplateBuilder/ScaledContainer.vue b/src/pages/TemplateBuilder/ScaledContainer.vue index 049337ec..78267c01 100644 --- a/src/pages/TemplateBuilder/ScaledContainer.vue +++ b/src/pages/TemplateBuilder/ScaledContainer.vue @@ -1,6 +1,9 @@