From b6761475b3ba29b75a0a71cb36cb41664de6600b Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 8 Dec 2012 22:55:36 +0000 Subject: [PATCH] Deploying some more work before nightfall --- .../v5/Ledgers/Json-ProfitLossData.aspx.cs | 36 ++++++++++++++++--- .../Pages/v5/Ledgers/ProfitLossStatement.aspx | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs index 2e43e63e..d3253ebc 100644 --- a/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs @@ -9,6 +9,7 @@ using Activizr.Logic.Financial; using Activizr.Logic.Pirates; using Activizr.Logic.Security; using Activizr.Logic.Structure; +using System.Globalization; public partial class Pages_v5_Ledgers_Json_ProfitLossData : System.Web.UI.Page { @@ -29,6 +30,29 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : System.Web.UI.Page Authority authority = currentUser.GetAuthority(); Organization currentOrganization = Organization.FromIdentity(currentOrganizationId); + // Get culture + + string cultureString = "en-US"; + HttpCookie cookie = Request.Cookies["PreferredCulture"]; + + if (cookie != null) + { + cultureString = cookie.Value; + } + + _renderCulture = new CultureInfo(cultureString); + + // Get current year + + _year = DateTime.Today.Year; + + string yearParameter = Request.QueryString["Year"]; + + if (!string.IsNullOrEmpty(yearParameter)) + { + _year = Int32.Parse(yearParameter); // will throw if non-numeric - don't matter for app + } + // Get accounts FinancialAccounts accounts = FinancialAccounts.ForOrganization(currentOrganization, FinancialAccountType.Result); @@ -70,6 +94,8 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : System.Web.UI.Page } + private CultureInfo _renderCulture; + private string RecurseTreeMap (Dictionary> treeMap, int renderNodeId) { List elements = new List(); @@ -99,14 +125,14 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : System.Web.UI.Page } else { - element += string.Format(",\"lastYear\":\"{0:N0}\"", (double)singleLookups[0][account.Identity] / -100.0); + element += string.Format(_renderCulture, ",\"lastYear\":\"{0:N0}\"", (double)singleLookups[0][account.Identity] / -100.0); for (int quarter = 1; quarter <= 4; quarter++) { - element += string.Format(",\"q{0}\":\"{1:N0}\"", quarter, singleLookups[quarter][account.Identity]); + element += string.Format(_renderCulture, ",\"q{0}\":\"{1:N0}\"", quarter, singleLookups[quarter][account.Identity] / -100.0); } - element += string.Format(",\"ytd\":\"{0:N0}\"", (double)singleLookups[5][account.Identity] / -100.0); + element += string.Format(_renderCulture, ",\"ytd\":\"{0:N0}\"", (double)singleLookups[5][account.Identity] / -100.0); } elements.Add("{" + element + "}"); @@ -120,9 +146,9 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : System.Web.UI.Page { if (treeValue != 0 && singleValue == 0) { - return string.Format("\"Σ {1:N0} \"", accountId, treeValue / -100.00); + return string.Format(_renderCulture, "\"Σ {1:N0} \"", accountId, treeValue / -100.00); } - return string.Format("\"Σ {1:N0}{2:N0}\"", accountId, treeValue / -100.0, singleValue / -100.0); + return string.Format(_renderCulture, "\"Σ {1:N0}{2:N0}\"", accountId, treeValue / -100.0, singleValue / -100.0); } diff --git a/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx b/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx index 2bcf39fd..2e179f5d 100644 --- a/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx +++ b/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx @@ -38,7 +38,7 @@ idField="id" treeField="name"> - Account + Account Last Year Q1 Q2