From 3ad7d0ee7f6b12d4f115b37be762fefa5db19684 Mon Sep 17 00:00:00 2001 From: Jasir K Date: Sat, 14 Jun 2025 13:06:17 +0530 Subject: [PATCH] fix: added description in print when enables settings --- models/baseModels/PrintSettings/PrintSettings.ts | 1 + schemas/app/PrintSettings.json | 6 ++++++ src/utils/printTemplates.ts | 11 +++++++++++ templates/Basic.template.html | 4 ++++ templates/Business.template.html | 2 ++ templates/Minimal.template.html | 6 ++++++ 6 files changed, 30 insertions(+) diff --git a/models/baseModels/PrintSettings/PrintSettings.ts b/models/baseModels/PrintSettings/PrintSettings.ts index 95bb7afb..706435ab 100644 --- a/models/baseModels/PrintSettings/PrintSettings.ts +++ b/models/baseModels/PrintSettings/PrintSettings.ts @@ -12,6 +12,7 @@ export class PrintSettings extends Doc { font?: string; displayLogo?: boolean; displayTime?: boolean; + displayDescription?: boolean; posPrintWidth?: number; amountInWords?: boolean; override hidden: HiddenMap = {}; diff --git a/schemas/app/PrintSettings.json b/schemas/app/PrintSettings.json index af429f9d..65382558 100644 --- a/schemas/app/PrintSettings.json +++ b/schemas/app/PrintSettings.json @@ -127,6 +127,12 @@ "fieldtype": "Check", "section": "Customizations" }, + { + "fieldname": "displayDescription", + "label": "Display Description In Invoice", + "fieldtype": "Check", + "section": "Customizations" + }, { "fieldname": "posPrintWidth", "label": "Pos Print Width", diff --git a/src/utils/printTemplates.ts b/src/utils/printTemplates.ts index 849999f1..489992c3 100644 --- a/src/utils/printTemplates.ts +++ b/src/utils/printTemplates.ts @@ -126,6 +126,10 @@ export async function getPrintTemplatePropValues( (values.doc as PrintTemplateData).time = getTime(doc.date as string); } + if (printSettings.displayDescription) { + (values.doc as PrintTemplateData).description = showDescription(doc); + } + return values; } async function getPaymentDetails(doc: Doc, paymentId: string[]) { @@ -310,6 +314,13 @@ function showHSN(doc: Doc): boolean { return items.map((i: Doc) => i.hsnCode).every(Boolean); } +function showDescription(doc: Doc): boolean { + const description = Array.isArray(doc.items) + ? doc.items.map((item: Doc) => item.description).filter(Boolean) + : []; + return description.length > 0; +} + function formattedTotalDiscount(doc: Doc): string { if (!(doc instanceof Invoice)) { return ''; diff --git a/templates/Basic.template.html b/templates/Basic.template.html index 9bd8c3f8..6c5f533b 100644 --- a/templates/Basic.template.html +++ b/templates/Basic.template.html @@ -61,6 +61,7 @@
{{ t`Item` }}
+
{{ t`Description` }}
{{ t`HSN/SAC` }}
@@ -76,6 +77,9 @@ :key="row.name" >
{{ row.item }}
+
+ {{ row.description }} +
{{ row.hsnCode }}
diff --git a/templates/Business.template.html b/templates/Business.template.html index c3fe2a9a..4b52564b 100644 --- a/templates/Business.template.html +++ b/templates/Business.template.html @@ -61,6 +61,7 @@
{{ t`Item` }}
+
{{ t`Description` }}
{{ t`HSN/SAC` }}
{{ t`Quantity` }}
{{ t`Rate` }}
@@ -74,6 +75,7 @@ :key="row.name" >
{{ row.item }}
+
{{ row.description }}
{{ row.hsnCode }}
{{ row.quantity }}
{{ row.rate }}
diff --git a/templates/Minimal.template.html b/templates/Minimal.template.html index 81ce3b36..15e013e5 100644 --- a/templates/Minimal.template.html +++ b/templates/Minimal.template.html @@ -99,6 +99,9 @@ " >
{{ t`Item` }}
+
+ {{ t`Description` }} +
{{ t`HSN/SAC` }}
{{ t`Quantity` }}
{{ t`Rate` }}
@@ -108,6 +111,9 @@
{{ row.item }}
+
+ {{ row.description }} +
{{ row.hsnCode }}
{{ row.quantity }}
{{ row.rate }}