1 line
11 KiB
Plaintext
1 line
11 KiB
Plaintext
{"Name":"PM Parts Summary ","Active":true,"Notes":"Custom Prepare to obtain translations, group by the woitempart, derived amounts and running totals","Roles":49258,"AType":21,"IncludeWoItemDescendants":false,"Template":"<html>\n<body>\n <div>\n <table>\n <thead>\n <tr>\n <th colspan=\"24\" class=\"reporttitle\">{{ayT 'PreventiveMaintenance'}} {{ayT 'WorkOrderItemParts'}} {{ayT 'PartCost'}} {{ayT 'NetValue'}}</th>\n </tr>\n <tr>\n <td colspan=\"24\"> </td>\n </tr>\n <tr>\n <th colspan=\"3\" class=\"leftlean\">{{ayT 'Part'}}</th>\n <th colspan=\"2\">{{ayT 'PreventiveMaintenance'}}</th>\n <th colspan=\"2\">{{ayT 'PMNextServiceDate'}}</th>\n <th colspan=\"3\">{{ayT 'WorkOrderItemPartQuantity'}}</th>\n <th colspan=\"2\">{{ayT 'PartCost'}} Per</th>\n <th colspan=\"2\">{{ayT 'PartRetail'}} Per</th>\n <th colspan=\"1\"> </th>\n <th colspan=\"3\">{{ayT 'PartCost'}} {{ayT 'NetValue'}}</th>\n <th colspan=\"3\">{{ayT 'PartRetail'}} {{ayT 'NetValue'}}</th>\n <th colspan=\"3\">Difference</th> \n </tr>\n <tr>\n <td colspan=\"24\"> </td>\n </tr>\n </thead>\n <tbody>\n {{#each ayReportData}}\n <tr>\n <td colspan=\"24\" class=\"leftlean\">{{group}}</td>\n </tr>\n {{#each items}}\n <tr>\n <td colspan=\"3\"> </td>\n <td colspan=\"2\">{{Serial}}</td>\n <td colspan=\"2\">{{ayDate NextServiceDate}}</td>\n <td colspan=\"1\" class=\"rightlean\">{{Quantity}}</td>\n <td colspan=\"2\" class=\"leftlean\">{{UnitOfMeasureViz}}</td>\n <td colspan=\"2\">{{ayCurrency Cost}}</td>\n <td colspan=\"2\">{{ayCurrency PriceViz}}</td>\n <td colspan=\"1\"> </td> \n {{#if NetCost }}<td colspan=\"3\">{{ayCurrency NetCost}}</td> {{else}}<td colspan=\"3\">{{Quantity}}</td>{{/if}}\n {{#if NetViz }}<td colspan=\"3\">{{ayCurrency NetViz}}</td> {{else}}<td colspan=\"3\">{{Quantity}}</td>{{/if}}\n {{#if NetDiff }}<td colspan=\"3\">{{ayCurrency NetDiff}}</td> {{else}}<td colspan=\"3\">{{Quantity}}</td>{{/if}} \n </tr>\n {{/each}}\n <tr>\n <th colspan=\"24\"> </th>\n </tr>\n <tr>\n <th colspan=\"15\" class=\"rightlean\">{{ayT 'Total'}} for part {{group}}</th>\n <td colspan=\"3\">{{ayCurrency GroupPartsNetCost}}</td>\n <td colspan=\"3\">{{ayCurrency GroupPartsNetViz}}</td>\n <td colspan=\"3\">{{ayCurrency GroupPartsDiff}}</td>\n </tr>\n <tr>\n <th colspan=\"24\"> </th>\n </tr>\n {{/each}}\n </tbody>\n </table>\n\n <table>\n <!-- tfoot in its own table so it ONLY shows on last page of report -->\n <tfoot>\n <tr>\n <th colspan=\"24\"> </th>\n </tr>\n <tr> \n <th colspan=\"15\" class=\"rightlean\">{{ayT 'Total'}} for all {{ayT 'WorkOrderItemParts'}} in this report</th>\n <th colspan=\"3\">All Net Cost</th>\n <th colspan=\"3\">All Net Charge</th>\n <th colspan=\"3\">All Diff</th>\n </tr>\n <tr>\n <!-- note no #each encompasses here - the data below is from this report template's Prepare -->\n <td colspan=\"15\"> </td>\n {{#if AllWOPartsNetCost}} <td colspan=\"3\" class=\"centerlean\">{{ ayCurrency AllWOPartsNetCost}}</td> {{else}} <td colspan=\"3\" class=\"centerlean\">$0.00</td> {{/if}}\n {{#if AllWOPartsNetViz}} <td colspan=\"3\" class=\"centerlean\">{{ ayCurrency AllWOPartsNetViz}}</td> {{else}} <td colspan=\"3\" class=\"centerlean\">$0.00</td> {{/if}} \n {{#if AllWOPartsDiff}} <td colspan=\"3\" class=\"centerlean\" >{{ayCurrency AllWOPartsDiff}}</td> {{else}} <td colspan=\"3\" class=\"centerlean\">$0.00</td> {{/if}}\n \n </tr>\n </tfoot>\n </table>\n</body>\n</html>","Style":".singlePage\n{\npage-break-after: always;\n\n}\nbody {\n font-family: 'Helvetica', 'Helvetica Neue', Arial, sans-serif; \n}\n\n.reporttitle { \n margin-bottom: 20pt; \n font-weight: bold; \n font-size: 14pt; \n color: #9e9e9e;\n text-align: left;\n} \n\ntable { \n border-collapse: collapse;\n white-space: pre-wrap;\n width: 100%; \n table-layout: fixed; /* the # of columns set in the first row of the thead will be fixed and applied throughout table and rows */\n }\n\nth {\n height: 20px;\n font-size: 10pt; \n color: #9e9e9e;\n text-align: center;\n}\n\ntbody td {\n padding: 2px;\n word-wrap: break-word;\n font-size: 9pt;\n text-align: center;\n}\n\ntbody tr:nth-child(even) {\n background-color: #f8f8f8; /* MUST checkmark Print background in PDF Options for this to show */\n}\n\n\n.rightlean {\n text-align: right;\n}\n.leftlean {\n text-align: left;\n}\n.centerlean {\n text-align: center;\n}\n\n\n.fontgreen {\n color: green;\n}\n.fontblue {\n color: blue;\n}\n.fontred {\n color:red;\n font-weight: bold;\n}\n.fontpurple {\n color: purple;\n}\n","JsPrerender":"async function ayPrepareData(reportData){ \n //this function (if present) is called with the report data \n //before the report is rendered\n //modify data as required here and return it to change the data before the report renders\n //see the help documentation for details\n\n\tawait ayGetTranslations([\"WorkOrderItemParts\", \"Part\", \"PMNextServiceDate\", \"WorkOrderItemPartQuantity\", \"PreventiveMaintenance\", \"NetValue\", \"PartCost\", \"PartRetail\", \"Total\" ]);\n\n\t//below is the code to group by the part - the PartNameViz\n\tlet ret = [];\n //iterate pms -> items -> pm item parts\n reportData.ayReportData.forEach(pm => {\n pm.Items.forEach(pmitem => {\n pmitem.Parts.forEach(part => {\n //new shape of data required for report \n let record = {\n Serial: pm.Serial,\n\t\t\t\t\tNextServiceDate: pm.NextServiceDate,\n\t\t\t\t\tNetViz: part.NetViz,\n\t\t\t\t\tPriceOverride: part.PriceOverride,\n\t\t\t\t\tListPrice: part.ListPrice,\n UnitOfMeasureViz: part.UnitOfMeasureViz,\n PriceViz: part.PriceViz,\n Cost: part.Cost,\n SuggestedQuantity: part.SuggestedQuantity,\n Quantity: part.Quantity,\n PartWarehouseViz: part.PartWarehouseViz,\n UpcViz: part.UpcViz,\n Serials: part.Serials,\n PartDescriptionViz: part.PartDescriptionViz ?? \"\",\n };\n\n //Find or create group and insert this record \n let groupObject = ret.find(z => z.group == (part.PartNameViz + \" \" + record.PartDescriptionViz) );\n if (groupObject != undefined) {\n //there is already a matching group in the return array so just push this record into it\n groupObject.items.push(record);\n //update the count for this group's items\n groupObject.count++;\n } else {\n //No group yet, so start a new one in the ret array and push this record into it\n ret.push({ group: (part.PartNameViz + \" \" + record.PartDescriptionViz), items: [record], count: 1 });\n \n }\n\n })\n })\n });\n\n //replace the ayReportData with our new shaped format of data\n reportData.ayReportData = ret;\n\n \n//need to now edit below to get running totals of THE DATA returned above - can't reference items as not in the returned data\n\n\n\n\n//********************//NOTE if you customize this report template and do NOT need a function or key identified below, remove to increase report performance\n\n\n//below declares a key on the entire wo to hold all Part Net, costs, profit (nets - costs), from all pms so it exists and a key to hold all Part Net Costs\nreportData.AllWOPartsNetViz = 0;\nreportData.AllWOPartsNetCost = 0;\nreportData.AllWOPartsDiff = 0;\n\n\nfor (EachGroup of reportData.ayReportData) \n\t{\n\n\n\t//below declares a key on the entire group to hold all Part Net, costs, profit/loss (nets - costs), for this group (this group is a single Part that has one or more wo item parts records)\n\tEachGroup.GroupPartsNetViz = 0;\n\tEachGroup.GroupPartsNetCost = 0;\n\tEachGroup.GroupPartsDiff = 0; \n\t\n\n\t//below is to Iterate through each woitempart record for this part - groupitem is a woitempart record\n\tfor (groupitem of EachGroup.items)\n\t\t{\n\t\t\t\t\t\n\t\t\tgroupitem.ThisItemPartNetViz = 0; //declare a key on the Item to hold all of this item's parts nets and set it initially to 0 \n\t\t\tgroupitem.ThisItemPartNetCost = 0; //declare a key on the Item to hold all of this item's parts costs and set it initially to 0 \n\t\t\tgroupitem.ThisItemPartDiff = 0; //declare a key on the Item to hold all of this item's part profit/loss (nets - costs) and set it initially to 0 \n\t\t\t\n\n\t\t\t//make sure it has a value before attempting to add it to the running total\n \tif (groupitem.Quantity != 0) \n \t \t{\n\t\t\t\t\t\tEachGroup.GroupPartsNetViz += groupitem.NetViz;\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\treportData.AllWOPartsNetViz += groupitem.NetViz;\t\n\n\n\t\t\t\t\t\tgroupitem.NetCost = (groupitem.Cost * groupitem.Quantity);\t\t\t\t\t\t\n\t\t\t\t\t\tEachGroup.GroupPartsNetCost += groupitem.NetCost;\n\t\t\t\t\t\treportData.AllWOPartsNetCost += groupitem.NetCost;\n\n\n\t\t\t\t\t\tif (groupitem.NetViz != 0) \n\t\t\t\t\t\t{\n\t\t\t\t\t\tgroupitem.NetDiff = (groupitem.NetViz - groupitem.NetCost)\n\t\t\t\t\t\tEachGroup.GroupPartsDiff += groupitem.NetDiff; //\n\t\t\t\t\t\treportData.AllWOPartsDiff += groupitem.NetDiff; //\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\n\n \t \t\t}\t\t\t\t//NOTE if you customize this report template and do NOT need a key above, remove it to increase report performance\t\n\t\t\t\n\n\t\t\t\n\t\t}\n\n }\n\n return reportData; \n}","JsHelpers":"//Register custom Handlebars helpers here to use in your report script\n//https://handlebarsjs.com/guide/#custom-helpers\nHandlebars.registerHelper('loud', function (aString) {\n return aString.toUpperCase()\n})","RenderType":0,"HeaderTemplate":"<span> </span>","FooterTemplate":"<span style=\"font-size:6pt; width: 96%;text-align:left; \"> Printed date: PDFDate</span>\n<span style=\"font-size:6pt;width: 96%; text-align: right; \">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span> </span>","DisplayHeaderFooter":true,"PaperFormat":10,"Landscape":true,"MarginOptionsBottom":"15mm","MarginOptionsLeft":"20mm","MarginOptionsRight":"20mm","MarginOptionsTop":"10mm","PageRanges":null,"PreferCSSPageSize":false,"PrintBackground":true,"Scale":1.00000} |