1 line
12 KiB
Plaintext
1 line
12 KiB
Plaintext
{"Name":"Example Purchase Order Summary single line per PO","Active":true,"Notes":"example of custom Prepare - derived running totals for nets, taxes and totals for EACH PO on single line, and running total for all POs Nets, Taxes, Totals at bottom of report","Roles":49258,"AType":26,"IncludeWoItemDescendants":false,"Template":"<html>\n<body>\n\t<div >\t \n\t\t<table > \n \t\t<thead>\n <tr class=\"heading\">\n <td colspan=\"10\">Header on every page</td>\n </tr>\n <tr class=\"heading\">\n <td colspan=\"10\">One line of Net totals for each PO in body</td>\n </tr>\n <tr class=\"heading\">\n <td colspan=\"10\">Footer of derived Net totals at bottom to display final totals</td>\n </tr>\n <tr>\n <td colspan=\"10\"> </td>\n </tr>\n <tr>\n <td class=\"bodyhead leftlean\">Vendor</td>\n <td class=\"bodyhead centerlean\">PO Status</td>\n <td class=\"bodyhead centerlean\">Ref#</td>\n <td class=\"bodyhead centerlean\">PO#</td>\n <td class=\"bodyhead centerlean\">Expected Date</td>\n <td class=\"bodyhead centerlean\">Ordered Date</td>\n <td class=\"bodyhead rightlean\">PO Net</td>\n <td class=\"bodyhead rightlean\">PO TaxA</td>\n <td class=\"bodyhead rightlean\">PO TaxB</td>\n <td class=\"bodyhead rightlean\">PO Total</td> \n </tr>\n <tr>\n <td colspan=\"10\"> </td>\n </tr>\n \t\t</thead>\n \n <tbody> \n {{#each ayReportData}}<!-- the #each for the Sample Data MUST encompass the section where its gonna show - in this case the tbody, so needs to be placed within -->\n <!-- to get alternating coloured rows when one PO per line, need CSS statements PLUS this # each MUST be placed BEFORE the tr /tr -->\n <tr>\n <td class=\"leftlean\">{{VendorViz}}</td>\n <td class=\"centerlean\">{{StatusViz}}</td>\n <td class=\"centerlean\">{{ReferenceNumber}}</td>\n <td class=\"centerlean\">{{Serial}}</td>\n <td class=\"centerlean\">{{ayDate ExpectedReceiveDate}}</td>\n <td class=\"centerlean\">{{ayDate OrderedDate}}</td>\n <td class=\"rightlean\">{{ayCurrency ThisPONet}}</td> \n {{#if ThisPOTaxA}}<td class=\"rightlean\" >{{ayCurrency ThisPOTaxA}}</td>{{else}} <td class=\"rightlean\">$0.00</td>{{/if}} \n {{#if ThisPOTaxB}}<td class=\"rightlean\" >{{ayCurrency ThisPOTaxB}}</td>{{else}} <td class=\"rightlean\">$0.00</td>{{/if}}\n <td class=\"rightlean\">{{ayCurrency ThisPOTotalofLines}}</td> \n </tr>\n \t {{/each}}\n </tbody>\n </table>\n\n <table> <!-- this displays footer ONLY on bottom of last page along with CSS commented out -->\n <tfoot>\n <tr> <!-- note no #each here - the data below is from Prepare's reportData.xxxx as in reportData.AllPOTaxBRunning -->\n <td colspan=\"6\"></td>\n <td class=\"bodyhead rightlean\"\">All Net</td>\n <td class=\"bodyhead rightlean\">All TaxA</td>\n <td class=\"bodyhead rightlean\">All TaxB</td>\n <td class=\"bodyhead rightlean\">All Total</td> \n </tr>\n <tr> <!-- note no #each here - the data below is from Prepare's reportData.xxxx as in reportData.AllPOTaxBRunning -->\n <td colspan=\"6\"></td>\n <td class=\"rightlean\">{{ ayCurrency AllPONetRunning }}</td>\n {{#if AllPOTaxARunning}}<td class=\"rightlean\">{{ ayCurrency AllPOTaxARunning }}</td>{{else}} <td class=\"rightlean\">$0.00</td>{{/if}} \n {{#if AllPOTaxBRunning}}<td class=\"rightlean\">{{ ayCurrency AllPOTaxBRunning }}</td>{{else}} <td class=\"rightlean\">$0.00</td>{{/if}} \n <td class=\"rightlean\"> {{ ayCurrency AllPOTotal }}</td> \n </tr>\n </tfoot>\n </table>\n \n\t</div>\n</body>\n</html>","Style":".singlePage\n{\npage-break-after: always;\n}\n\ntable { \n font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;\n border-collapse: collapse;\n white-space: pre-wrap;\n width: 100%;\n table-layout: fixed;\n }\n\nthead {\n display: table-header-group; /* so as to print the table-header on all subsequent pages */\n}\n\n.heading {\n border-style: solid;\n border-width: 1pt;\n border-color: #e8e5e5; \n margin: 10pt;\n background-color: #e8e5e5;\n padding: 5pt; \n font-size: 14pt; \n text-align: center;\n} \n\n.bodyhead {\n border-style: solid;\n border-width: 1pt;\n border-color: #e8e5e5; \n margin: 10pt;\n background-color: #e8e5e5;\n font-size: 12pt; \n}\n\n\n.rightlean {\n text-align: right;\n}\n.leftlean {\n text-align: left;\n}\n.centerlean {\n text-align: center;\n}\ntbody tr:nth-child(even) {\n font-size: 10pt;\n background-color: lightgray; /* MUST checkmark Print background in PDF Options for this to show */\n height: 50px;\n} \ntbody tr:nth-child(odd) {\n font-size: 10pt;\n background-color: lightgoldenrodyellow; /* MUST checkmark Print background in PDF Options for this to show */\n height: 50px;\n} \n\n\ntfoot {\n /* display: table-footer-group; uncomment to print the table-footer on all pages, not just last page - */\n page-break-inside: avoid;\n /* position: fixed; uncommenting position: will force footer to bottom BUT then leftlean and rightlean don't work AND tbody overwrites */\n \n bottom: 0;\n width: 100%;\n border-top: 1px solid black; \n}\n\n\n.fontgreen {\n color: green;\n font-size: 16pt;\n}\n.fontblue {\n color: blue;\n}\n.fontred {\n color:red;\n}\n\n","JsPrerender":"async function ayPrepareData(reportData) {\n //Example of both manipulating the reportData before rendering the report (by adding a running total field)\n //and adding a field to the overall data calculating the total dollar amount for all records\n\nlet AllPONet = 0; //Declare a temporary variable to hold the running net total for all POs in this list\n //Iterate through all the records in the reportData adding the dollar amount of each item to the AllPONet variable\n for (EachPO of reportData.ayReportData) \n {\n let ThisPONet = 0; //Declare a temporary variable to hold the running net total for THIS po\n for (Item of EachPO.Items) //Iterate through all the poitems of THIS po adding the dollar amount of each item to the ThisPONet variable\n {\n //make sure it has a value before attempting to add it to the running total\n if (Item.NetTotalViz != null) \n {\n ThisPONet += Item.NetTotalViz;\n }\n Item.PONetRunning=ThisPONet;\n }\n EachPO.ThisPONet=ThisPONet;\n AllPONet += ThisPONet; //Use ThisPONet to display the running Net total for THIS PO\n }\n //Add the AllPONet variable to the reportData so it can be accessed in the report template i.e. a final running total of ALL PO's Net\n reportData.AllPONetRunning=AllPONet;\n \nlet AllPOTaxA = 0; //Declare a temporary variable to hold the running Tax A total for all POs in the list\n //Iterate through all the records in the reportData adding the Tax A dollar amount of each item to the AllPOTaxA variable\n for (EachPO of reportData.ayReportData) \n {\n let ThisPOTaxA = 0; //Declare a temporary variable to hold the running Tax A total for THIS po\n for (Item of EachPO.Items) //Iterate through all the poitems of THIS po adding the dollar amount of each item to the ThisPOTaxA variable\n {\n //make sure it has a value before attempting to add it to the running total\n if (Item.TaxAViz != null) \n {\n ThisPOTaxA += Item.TaxAViz;\n }\n Item.POTaxARunning=ThisPOTaxA;\n }\n EachPO.ThisPOTaxA=ThisPOTaxA;\n AllPOTaxA += ThisPOTaxA; // Use ThisPOTaxA to display the running Tax A total for THIS PO\n }\n //Add the AllPONet variable to the reportData so it can be accessed in the report template i.e. a final running total of ALL PO's Tax A\n reportData.AllPOTaxARunning=AllPOTaxA; \n \nlet AllPOTaxB = 0; //Declare a temporary variable to hold the running Tax B total for all POs in the list\n //Iterate through all the records in the reportData adding the Tax B dollar amount of each item to the AllPOTaxA variable\n for (EachPO of reportData.ayReportData) \n {\n let ThisPOTaxB = 0; //Declare a temporary variable to hold the running Tax B total for THIS po\n for (Item of EachPO.Items) //Iterate through all the poitems of THIS po adding the dollar amount of each item to the ThisPOTaxB variable\n {\n //make sure it has a value before attempting to add it to the running total\n if (Item.TaxBViz != null) \n {\n ThisPOTaxB += Item.TaxBViz;\n }\n Item.POTaxBRunning=ThisPOTaxB;\n }\n EachPO.ThisPOTaxB=ThisPOTaxB;\n AllPOTaxB += ThisPOTaxB; // Use ThisPOTaxB to display the running Tax B total for THIS PO\n }\n //Add the AllPOTaxB variable to the reportData so it can be accessed in the report template i.e. a final running total of ALL PO's Tax B\n reportData.AllPOTaxBRunning=AllPOTaxB; \n\nlet AllPODollarTotalRunning = 0; //Declare a temporary variable to hold the running total of all POs in this list\n//let ThisPOTotal = 0; //if declare this at this stage will NOT get correct EachPO.ThisPOTotalofLines\n for (EachPO of reportData.ayReportData) \n { \n let ThisPOTotal = 0; \n // need to declared let ThisPOTotal = 0; at this stage so then it will reset ThisPOTotal back to 0 before being able to add to EachPO.POsRunningTotalSoFar\n //BUT OH OH - now the entire AllPOTotal is off hmmmmmmmmmm \n for (Item of EachPO.Items)\n {\n //make sure it has a value before attempting to add it to the running total\n if (Item.LineTotalViz != null) \n {\n ThisPOTotal += Item.LineTotalViz;\n }\n Item.ThisPORunningTotal=ThisPOTotal;\n } \n EachPO.ThisPOTotalofLines =ThisPOTotal; \n //add a new key to each record in the reportData object named \"EachPO.POsRunningTotalSoFar\" with the running total so far\n EachPO.POsRunningTotalSoFar=ThisPOTotal; \n\n AllPODollarTotalRunning += ThisPOTotal; \n }\n //set the AllPODollarTotalRunning variable to the reportData so the reportData.AllPOTotal can be accessed in the report template outside of the #each \n //- i.e. in a separate footer that displays once at end of report\n reportData.AllPOTotal=AllPODollarTotalRunning; \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})\n\n","RenderType":0,"HeaderTemplate":"<span style=\"font-size:6pt;width: 94%; text-align:left; \"> (set in report template's PDF Options) Printed date: <span class=\"date\"></span></span>","FooterTemplate":"<span style=\"font-size:6pt;width: 96%; text-align: right; \"> (set in report template's PDF Options showing x of ALL pages printed) Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\">","DisplayHeaderFooter":true,"PaperFormat":10,"Landscape":true,"MarginOptionsBottom":"10mm","MarginOptionsLeft":"10mm","MarginOptionsRight":"10mm","MarginOptionsTop":"10mm","PageRanges":null,"PreferCSSPageSize":false,"PrintBackground":true,"Scale":1.00000} |