diff --git a/models/baseModels/PrintSettings/PrintSettings.ts b/models/baseModels/PrintSettings/PrintSettings.ts index e2cae51f..bdbad09c 100644 --- a/models/baseModels/PrintSettings/PrintSettings.ts +++ b/models/baseModels/PrintSettings/PrintSettings.ts @@ -11,6 +11,7 @@ export class PrintSettings extends Doc { color?: string; font?: string; displayLogo?: boolean; + displayTime?: boolean; amountInWords?: boolean; override hidden: HiddenMap = {}; } diff --git a/schemas/app/PrintSettings.json b/schemas/app/PrintSettings.json index d7eed41d..359a4ec0 100644 --- a/schemas/app/PrintSettings.json +++ b/schemas/app/PrintSettings.json @@ -120,6 +120,12 @@ "label": "Display Amount In Words", "fieldtype": "Check", "section": "Customizations" + }, + { + "fieldname": "displayTime", + "label": "Display Time In Invoice", + "fieldtype": "Check", + "section": "Customizations" } ] } diff --git a/src/utils/printTemplates.ts b/src/utils/printTemplates.ts index 960dca81..8400027e 100644 --- a/src/utils/printTemplates.ts +++ b/src/utils/printTemplates.ts @@ -69,9 +69,30 @@ export async function getPrintTemplatePropValues( (doc.grandTotal as Money).float ); + (values.doc as PrintTemplateData).date = getDate(doc.date as string); + + if (printSettings.displayTime) { + (values.doc as PrintTemplateData).time = getTime(doc.date as string); + } + return values; } +function getDate(dateString: string): string { + const date = new Date(dateString); + date.setMonth(date.getMonth() - 1); + + return `${date.toLocaleString('default', { + month: 'short', + })} ${date.getDate()}, ${date.getFullYear()}`; +} + +function getTime(dateString: string): string { + const date = new Date(dateString); + + return date.toTimeString().split(' ')[0]; +} + export function getPrintTemplatePropHints(schemaName: string, fyo: Fyo) { const hints: PrintTemplateHint = {}; const schema = fyo.schemaMap[schemaName]!; diff --git a/templates/Basic.template.html b/templates/Basic.template.html index 1ac7a80f..9bd8c3f8 100644 --- a/templates/Basic.template.html +++ b/templates/Basic.template.html @@ -31,7 +31,11 @@

{{ doc.name }}

-

{{ doc.date }}

+ +
+

{{ doc.date }}

+

{{ doc?.time }}

+
diff --git a/templates/Business.template.html b/templates/Business.template.html index 41480bea..11e111fc 100644 --- a/templates/Business.template.html +++ b/templates/Business.template.html @@ -31,7 +31,11 @@

{{ doc.name }}

-

{{ doc.date }}

+ +
+

{{ doc.date }}

+

{{doc?.time }}

+
diff --git a/templates/Minimal.template.html b/templates/Minimal.template.html index 697c0577..81ce3b36 100644 --- a/templates/Minimal.template.html +++ b/templates/Minimal.template.html @@ -13,7 +13,11 @@

{{ print.companyName }}

-

{{ doc.date }}

+ +
+

{{ doc.date }}

+

{{ doc?.time }}

+