diff --git a/Logic/Financial/YearlyReport.cs b/Logic/Financial/YearlyReport.cs index 4fd960f0..71701d27 100644 --- a/Logic/Financial/YearlyReport.cs +++ b/Logic/Financial/YearlyReport.cs @@ -53,7 +53,8 @@ namespace Activizr.Logic.Financial FinancialAccounts orderedList = new FinancialAccounts(); // This list is guaranteed to have parents before children report.PopulateOrderedList(orderedList, 0); // recursively add nodes parents-first - report.PopulateLookups(orderedList); // populate the lookup tables for results per account + report.PopulateLookups(orderedList); // populate the lookup tables for results per account + report.PopulateTotals(); report.ReportLines = new List(); report.RecurseAddLines(report.ReportLines, 0); @@ -62,6 +63,27 @@ namespace Activizr.Logic.Financial } + private void PopulateTotals() + { + this.Totals = new YearlyReportNode(); + + this.Totals.PreviousYear = PopulateOneTotal(_singleLookups[0]); + this.Totals.ThisYear = PopulateOneTotal(_singleLookups[5]); + + for (int quarter = 0; quarter < 4; quarter++) + { + this.Totals.Quarters[quarter] = PopulateOneTotal(_singleLookups[quarter + 1]); + } + } + + private Int64 PopulateOneTotal (Dictionary lookup) + { + Int64[] allValues = lookup.Values.ToArray(); + + return allValues.Sum(); + } + + private void RecurseAddLines (List list, int renderNodeId) { foreach (FinancialAccount account in _treeMap[renderNodeId]) @@ -194,6 +216,7 @@ namespace Activizr.Logic.Financial public List ReportLines; + public YearlyReportNode Totals; public Organization Organization; public int Year; } diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx index 03598054..faffdf14 100644 --- a/Site5/App_GlobalResources/Pages.Ledgers.resx +++ b/Site5/App_GlobalResources/Pages.Ledgers.resx @@ -145,6 +145,10 @@ Q4 + + Results + Footer on P&L statement + YTD Year To Date diff --git a/Site5/App_GlobalResources/Pages.Ledgers.sv-SE.resx b/Site5/App_GlobalResources/Pages.Ledgers.sv-SE.resx index 00d22d63..2e1311b8 100644 --- a/Site5/App_GlobalResources/Pages.Ledgers.sv-SE.resx +++ b/Site5/App_GlobalResources/Pages.Ledgers.sv-SE.resx @@ -59,46 +59,46 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - - + + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -145,6 +145,9 @@ Q4 + + Resultat + Idag Year To Date @@ -168,32 +171,4 @@ Spara budgetar Text on submit button - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs index 594b39cf..78db837f 100644 --- a/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs @@ -57,12 +57,29 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : System.Web.UI.Page Response.ContentType = "application/json"; - Response.Output.WriteLine(RecurseReport(report.ReportLines)); + Response.Output.WriteLine("{\"rows\": " + RecurseReport(report.ReportLines) + ", \"footer\": [" + WriteFooter(report.Totals) + "]}"); Response.End(); } + private string WriteFooter (YearlyReportNode totals) + { + string result = string.Format("\"name\":\"{0}\"", Resources.Pages.Ledgers.ProfitLossStatement_Results); + + result += string.Format(_renderCulture, ",\"lastYear\":\"{0:N0}\"", (double)totals.PreviousYear / -100.0); + + for (int quarter = 1; quarter <= 4; quarter++) + { + result += string.Format(_renderCulture, ",\"q{0}\":\"{1:N0}\"", quarter, totals.Quarters[quarter-1] / -100.0); + } + + result += string.Format(_renderCulture, ",\"ytd\":\"{0:N0}\"", (double)totals.ThisYear / -100.0); + + return "{" + result + "}"; + } + + private int _year = 2012; private CultureInfo _renderCulture; diff --git a/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx b/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx index d121f5de..c7a8a0af 100644 --- a/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx +++ b/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx @@ -77,11 +77,11 @@ -

 

+

 Loading

@@ -91,7 +91,7 @@ - +
— — ——