diff --git a/src/pages/PrintView/PrintView.vue b/src/pages/PrintView/PrintView.vue index 4f514a17..3689f651 100644 --- a/src/pages/PrintView/PrintView.vue +++ b/src/pages/PrintView/PrintView.vue @@ -39,8 +39,12 @@ :template="printProps.template" :values="printProps.values" :scale="scale" - :width="templateDoc?.width" - :height="templateDoc?.height" + :width=" + templateName?.startsWith('POS') + ? fyo.singles.PrintSettings?.posPrintWidth + : templateDoc?.width + " + :height="templateName.startsWith('POS') ? 22 : templateDoc?.height" /> diff --git a/src/pages/TemplateBuilder/TemplateBuilder.vue b/src/pages/TemplateBuilder/TemplateBuilder.vue index 8db29cee..77b4bcb3 100644 --- a/src/pages/TemplateBuilder/TemplateBuilder.vue +++ b/src/pages/TemplateBuilder/TemplateBuilder.vue @@ -55,8 +55,8 @@ :scale="scale" :height="doc.name.startsWith('POS') ? 20 : doc.height" :width=" - doc.name.startsWith('POS') && - fyo.singles.PrintSettings.posPrintWidth + doc.name?.startsWith('POS') && + fyo.singles.PrintSettings?.posPrintWidth ? fyo.singles.PrintSettings.posPrintWidth : doc.width " diff --git a/src/utils/printTemplates.ts b/src/utils/printTemplates.ts index 8400027e..120550e4 100644 --- a/src/utils/printTemplates.ts +++ b/src/utils/printTemplates.ts @@ -13,6 +13,7 @@ import { showExportInFolder, } from './ui'; import { Money } from 'pesa'; +import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; export type PrintTemplateHint = { [key: string]: string | PrintTemplateHint | PrintTemplateHint[]; @@ -40,6 +41,18 @@ export async function getPrintTemplatePropValues( const values: PrintValues = { doc: {}, print: {} }; values.doc = await getPrintTemplateDocValues(doc); + const totalTax = await (doc as Invoice)?.getTotalTax(); + const paymentId = await (doc as SalesInvoice).getPaymentIds(); + + const paymentDoc = await fyo.doc.getDoc(ModelNameEnum.Payment, paymentId[0]); + + (values.doc as PrintTemplateData).paymentMethod = paymentDoc.paymentMethod; + + (values.doc as PrintTemplateData).subTotal = doc.fyo.format( + (doc.grandTotal as Money).sub(totalTax), + ModelNameEnum.Currency + ); + const printSettings = await fyo.doc.getDoc(ModelNameEnum.PrintSettings); const printValues = await getPrintTemplateDocValues( printSettings,