Modified render styles to improve printability

This commit is contained in:
Patrick Fic
2020-09-10 15:55:25 -07:00
parent a0bb07abfd
commit 984c001bd8
15 changed files with 187 additions and 92 deletions

View File

@@ -8,12 +8,25 @@ require("dotenv").config({
});
var _ = require("lodash");
const Handlebars = require("handlebars");
const phone = require("phone");
var Dinero = require("dinero.js");
Dinero.defaultCurrency = "CAD";
Dinero.globalLocale = "en-CA";
//Usage: {{moment appointments_by_pk.start format="dddd, DD MMMM YYYY"}}
Handlebars.registerHelper("round", function (context, block) {
if (context && context.hash) {
block = _.cloneDeep(context);
context = undefined;
}
try {
return context.toFixed(2);
} catch {
return context;
}
});
Handlebars.registerHelper("dinerof", function (context, block) {
if (context && context.hash) {
block = _.cloneDeep(context);
@@ -26,6 +39,77 @@ Handlebars.registerHelper("dinerof", function (context, block) {
return "";
});
Handlebars.registerHelper("phonef", function (context, block) {
if (context && context.hash) {
block = _.cloneDeep(context);
context = undefined;
}
var ph = phone(context)[0];
if (context) {
return ph;
}
return "";
});
Handlebars.registerHelper("partType", function (context, block) {
if (!context) return "";
switch (context.toUpperCase()) {
case "PAA":
return "Aftermarket";
case "PAE":
return "Existing";
case "PAN":
return "OEM";
case "PAO":
return "Other";
case "PAS":
return "Sublet";
case "PASL":
return "Sublet";
case "PAL":
return "LKQ";
case "PAM":
return "Remanufactured";
case "PAC":
return "Chrome";
case "PAP":
return "OEM Partial";
case "PAR":
return "Record";
default:
return context;
}
});
Handlebars.registerHelper("lbrType", function (context, block) {
if (!context) return "";
switch (context.toUpperCase()) {
case "LAA":
return "Aluminum";
case "LAB":
return "Body";
case "LAD":
return "Diagnostic";
case "LAF":
return "Frame";
case "LAG":
return "Glass";
case "LAM":
return "Mechanical";
case "LAR":
return "Refinish";
case "LAS":
return "Structural";
case "LAU":
return "Detail";
default:
return context;
}
});
Handlebars.registerHelper("objectKeys", function (obj, block) {
var accum = "";
@@ -41,7 +125,10 @@ Handlebars.registerHelper("dinero", function (context, block) {
block = _.cloneDeep(context);
context = undefined;
}
var amount = Dinero({ amount: Math.round((context || 0) * 100) });
var amount = Dinero({
amount: Math.round((context || 0) * 100),
currency: "CAD",
});
return amount.toFormat();
});
@@ -50,6 +137,9 @@ Handlebars.registerHelper("moment", function (context, block) {
block = _.cloneDeep(context);
context = undefined;
}
if (!!!context) return "";
var date = moment(context);
if (block.hash.timezone) {