mirror of
https://github.com/frappe/books.git
synced 2025-01-09 01:44:15 +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;
|
color?: string;
|
||||||
font?: string;
|
font?: string;
|
||||||
displayLogo?: boolean;
|
displayLogo?: boolean;
|
||||||
|
displayTime?: boolean;
|
||||||
amountInWords?: boolean;
|
amountInWords?: boolean;
|
||||||
override hidden: HiddenMap = {};
|
override hidden: HiddenMap = {};
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,12 @@
|
|||||||
"label": "Display Amount In Words",
|
"label": "Display Amount In Words",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"section": "Customizations"
|
"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
|
(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;
|
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) {
|
export function getPrintTemplatePropHints(schemaName: string, fyo: Fyo) {
|
||||||
const hints: PrintTemplateHint = {};
|
const hints: PrintTemplateHint = {};
|
||||||
const schema = fyo.schemaMap[schemaName]!;
|
const schema = fyo.schemaMap[schemaName]!;
|
||||||
|
@ -31,7 +31,11 @@
|
|||||||
<!-- Invoice Details -->
|
<!-- Invoice Details -->
|
||||||
<section class="w-1/3">
|
<section class="w-1/3">
|
||||||
<h2 class="text-2xl font-semibold">{{ doc.name }}</h2>
|
<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>
|
</section>
|
||||||
|
|
||||||
<!-- Party Details -->
|
<!-- Party Details -->
|
||||||
|
@ -31,7 +31,11 @@
|
|||||||
</h3>
|
</h3>
|
||||||
<div class="w-2/3 text-gray-800">
|
<div class="w-2/3 text-gray-800">
|
||||||
<p class="font-semibold">{{ doc.name }}</p>
|
<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>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -13,7 +13,11 @@
|
|||||||
<p class="font-semibold text-xl" :style="{ color: print.color }">
|
<p class="font-semibold text-xl" :style="{ color: print.color }">
|
||||||
{{ print.companyName }}
|
{{ print.companyName }}
|
||||||
</p>
|
</p>
|
||||||
<p>{{ doc.date }}</p>
|
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<p>{{ doc.date }}</p>
|
||||||
|
<p>{{ doc?.time }}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user