From 7bb9d775f1f68443455d92208482c43b939d44e2 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 15 Sep 2020 22:45:43 +0000 Subject: [PATCH] --- server/AyaNova/biz/PrimeData.cs | 5 +++-- .../EXAMPLE modify data before rendering.ayrt | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE modify data before rendering.ayrt diff --git a/server/AyaNova/biz/PrimeData.cs b/server/AyaNova/biz/PrimeData.cs index 34ffad49..ba937a1e 100644 --- a/server/AyaNova/biz/PrimeData.cs +++ b/server/AyaNova/biz/PrimeData.cs @@ -124,7 +124,7 @@ namespace AyaNova.Biz public static async Task PrimeReportTemplates() { //Read in each stock translation from a text file and then create them in the DB - var ReportFilesPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource","rpt","stock-report-templates"); + var ReportFilesPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource", "rpt", "stock-report-templates"); if (!Directory.Exists(ReportFilesPath)) { throw new System.Exception($"E1012: \"stock-report-templates\" folder not found where expected: \"{ReportFilesPath}\", installation damaged?"); @@ -138,7 +138,8 @@ namespace AyaNova.Biz System.IO.DirectoryInfo di = new DirectoryInfo(ReportFilesPath); foreach (FileInfo file in di.EnumerateFiles()) { - await r.ImportAsync(JObject.Parse(await File.ReadAllTextAsync(file.FullName))); + if (file.Extension.ToLowerInvariant() == "ayrt") + await r.ImportAsync(JObject.Parse(await File.ReadAllTextAsync(file.FullName))); } } } diff --git a/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE modify data before rendering.ayrt b/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE modify data before rendering.ayrt new file mode 100644 index 00000000..d2bd65a9 --- /dev/null +++ b/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE modify data before rendering.ayrt @@ -0,0 +1 @@ +{"Name":"EXAMPLE modify data before rendering","Active":true,"Notes":"","Roles":124927,"ObjectType":2,"Template":"\n\n\n\t{{#each ayReportData}}\n\tName: {{ Name }}, DollarAmount: {{ ayCurrency DollarAmount }}, RunningTotal: {{ ayCurrency MyRunningTotal }}
\n\t{{/each}}\n\n\t

Total dollar amount: {{ ayCurrency MyTotalDollarAmount }}\n\n\n","Style":"","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\n //Declare a temporary variable to hold the running total\n let TotalDollarAmount = 0;\n\n //Iterate through all the records in the reportData\n //adding the dollar amount of each item to the TotalDollarAmount variable\n for (MyItem of reportData.ayReportData) {\n\n //make sure it has a value before attempting to add it to the running total\n if (MyItem.DollarAmount != null) {\n TotalDollarAmount += MyItem.DollarAmount;\n }\n\n //add a new key to each record in the reportData object named \"MyRunningTotal\" with the running total so far\n MyItem.MyRunningTotal=TotalDollarAmount;\n }\n\n //Add the TotalDollarAmount variable to the reportData so it can be \n //accessed in the report template\n reportData.MyTotalDollarAmount=TotalDollarAmount;\n\n return reportData;\n}","JsHelpers":"","RenderType":0} \ No newline at end of file