mirror of
https://github.com/frappe/books.git
synced 2025-01-08 01:14:39 +00:00
Merge pull request #1062 from AbleKSaju/feat-time-in-templates
feat: option to display time in print templates
This commit is contained in:
commit
8462dc4482
@ -11,6 +11,7 @@ export class PrintSettings extends Doc {
|
||||
color?: string;
|
||||
font?: string;
|
||||
displayLogo?: boolean;
|
||||
displayTime?: boolean;
|
||||
amountInWords?: boolean;
|
||||
override hidden: HiddenMap = {};
|
||||
}
|
||||
|
@ -120,6 +120,12 @@
|
||||
"label": "Display Amount In Words",
|
||||
"fieldtype": "Check",
|
||||
"section": "Customizations"
|
||||
},
|
||||
{
|
||||
"fieldname": "displayTime",
|
||||
"label": "Display Time In Invoice",
|
||||
"fieldtype": "Check",
|
||||
"section": "Customizations"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -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]!;
|
||||
|
@ -31,7 +31,11 @@
|
||||
<!-- Invoice Details -->
|
||||
<section class="w-1/3">
|
||||
<h2 class="text-2xl font-semibold">{{ doc.name }}</h2>
|
||||
<p class="py-2 text-base">{{ doc.date }}</p>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<p class="py-2 text-base">{{ doc.date }}</p>
|
||||
<p class="py-2 text-base">{{ doc?.time }}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Party Details -->
|
||||
|
@ -31,7 +31,11 @@
|
||||
</h3>
|
||||
<div class="w-2/3 text-gray-800">
|
||||
<p class="font-semibold">{{ doc.name }}</p>
|
||||
<p>{{ doc.date }}</p>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<p>{{ doc.date }}</p>
|
||||
<p>{{doc?.time }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
@ -13,7 +13,11 @@
|
||||
<p class="font-semibold text-xl" :style="{ color: print.color }">
|
||||
{{ print.companyName }}
|
||||
</p>
|
||||
<p>{{ doc.date }}</p>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<p>{{ doc.date }}</p>
|
||||
<p>{{ doc?.time }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user