diff --git a/Logic/Financial/AnnualReport.cs b/Logic/Financial/AnnualReport.cs index 98fed8b8..00a63b12 100644 --- a/Logic/Financial/AnnualReport.cs +++ b/Logic/Financial/AnnualReport.cs @@ -361,6 +361,7 @@ namespace Swarmops.Logic.Financial public AnnualReportNode AccountValues; public List Children; + public bool DefaultExpand; public AnnualReportLine() { diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs index 3bebc344..c502d1dd 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -19,7 +19,7 @@ namespace Resources.Pages { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option or rebuild the Visual Studio project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "11.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "14.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Ledgers { @@ -339,6 +339,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to Assets XXXX. + /// + internal static string BalanceSheet_Assets { + get { + return ResourceManager.GetString("BalanceSheet_Assets", resourceCulture); + } + } + /// /// Looks up a localized string similar to Balance Sheet for {0},. /// @@ -357,6 +366,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to (change). + /// + internal static string BalanceSheet_Delta { + get { + return ResourceManager.GetString("BalanceSheet_Delta", resourceCulture); + } + } + /// /// Looks up a localized string similar to BalanceSheet. /// @@ -384,6 +402,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to Liabilities XXXX. + /// + internal static string BalanceSheet_Liabilities { + get { + return ResourceManager.GetString("BalanceSheet_Liabilities", resourceCulture); + } + } + /// /// Looks up a localized string similar to Balance Sheet. /// diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index f3dbc1f2..ecafd1fb 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -785,4 +785,16 @@ Unspent TxOut The local translation of a bitcoin UTXO (Unspent Transaction Output). + + Assets XXXX + For the simplified view - XXXX is replaced with year + + + (change) + Change from previous year's close, which is same as from start of this year + + + Liabilities XXXX + For the simplified view - XXXX is replaced with year + \ No newline at end of file diff --git a/Site/Global.asax b/Site/Global.asax index 8febd512..ac510c57 100644 --- a/Site/Global.asax +++ b/Site/Global.asax @@ -70,6 +70,7 @@ "{0}.aspx", // for dev.swarmops.com/Security/Login "/Pages/v5/Public{0}.aspx", // for dev.swarmops.com/Signup (and others under Public) "/Pages/v5/Public{0}", // for dev.swarmops.com/WizardStyle.css (linked from pages in Public) + "/Pages/v5/{0}SheetSimplified.aspx", // for dev.swarmops.com/Ledgers/Balance -- one-page substitution "/Pages/v5{0}.aspx", // for dev.swarmops.com/User/SelectLanguage "/Pages/v5{0}" // for dev.swarmops.com/Ledgers/Json-SomethingData.aspx }; diff --git a/Site/Pages/v5/Ledgers/BalanceSheetSimplified.aspx b/Site/Pages/v5/Ledgers/BalanceSheetSimplified.aspx new file mode 100644 index 00000000..fd533838 --- /dev/null +++ b/Site/Pages/v5/Ledgers/BalanceSheetSimplified.aspx @@ -0,0 +1,112 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Frontend.Pages.Ledgers.BalanceSheetSimplified" CodeFile="BalanceSheetSimplified.aspx.cs" Codebehind="BalanceSheetSimplified.aspx.cs" %> + + + + + + + + +

<%= CurrentOrganization.Currency.DisplayCode %>
 Loading

+ + + + + + + + + + +
————
+
+ + +

+ +
+
+ +
+
+ + +
+ diff --git a/Site/Pages/v5/Ledgers/BalanceSheetSimplified.aspx.cs b/Site/Pages/v5/Ledgers/BalanceSheetSimplified.aspx.cs new file mode 100644 index 00000000..0d820e82 --- /dev/null +++ b/Site/Pages/v5/Ledgers/BalanceSheetSimplified.aspx.cs @@ -0,0 +1,86 @@ +using System; +using System.Globalization; +using Swarmops.Logic.Security; + +namespace Swarmops.Frontend.Pages.Ledgers +{ + /// + /// This is a simplified display for economists. + /// + public partial class BalanceSheetSimplified : PageV5Base + { + protected void Page_Load (object sender, EventArgs e) + { + if (!CurrentOrganization.IsEconomyEnabled) + { + Response.Redirect ("/Financial/EconomyNotEnabled", true); + return; + } + + PageIcon = "iconshock-treasure"; + PageTitle = Resources.Pages.Ledgers.BalanceSheet_PageTitle; + InfoBoxLiteral = Resources.Pages.Ledgers.BalanceSheet_Info; + + // Security: If the org has open ledgers, then anyone may read. Otherwise, Financials.Read. + + if (!String.IsNullOrEmpty (CurrentOrganization.OpenLedgersDomain)) + { + PageAccessRequired = new Access (AccessAspect.Null, AccessType.Read); + } + else + { + PageAccessRequired = new Access (CurrentOrganization, AccessAspect.Financials, AccessType.Read); + } + + + if (!Page.IsPostBack) + { + int year = DateTime.Today.Year; + int firstFiscalYear = CurrentOrganization.FirstFiscalYear; + + while (year >= firstFiscalYear) + { + this.DropYears.Items.Add (year.ToString (CultureInfo.InvariantCulture)); + year--; + } + + Localize(); + } + + RegisterControl (EasyUIControl.DataGrid | EasyUIControl.Tree); + } + + + private void Localize() + { + this.LabelContentHeader.Text = string.Format (Resources.Pages.Ledgers.BalanceSheet_ContentHeader, + CurrentOrganization.Name); + /* + this.LiteralHeaderQ1.Text = Resources.Pages.Ledgers.BalanceSheet_Q1; + this.LiteralHeaderQ2.Text = Resources.Pages.Ledgers.BalanceSheet_Q2; + this.LiteralHeaderQ3.Text = Resources.Pages.Ledgers.BalanceSheet_Q3; + this.LiteralHeaderQ4.Text = Resources.Pages.Ledgers.BalanceSheet_Q4; + this.LiteralHeaderYtd.Text = Resources.Pages.Ledgers.BalanceSheet_Current;*/ + this.LiteralHeaderAccountName.Text = Resources.Pages.Ledgers.BalanceSheet_AccountName; + } + + // Localized strings for direct access from ASPX + + // ReSharper disable InconsistentNaming + public string Localized_Assets + { + get { return JavascriptEscape(Resources.Pages.Ledgers.BalanceSheet_Assets); } + } + + public string Localized_Liabilities + { + get { return JavascriptEscape(Resources.Pages.Ledgers.BalanceSheet_Liabilities); } + } + + public string Localized_DownloadFileName + { + get { return JavascriptEscape(Resources.Pages.Ledgers.BalanceSheet_DownloadFileName); } + } + + } +} \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/BalanceSheetSimplified.aspx.designer.cs b/Site/Pages/v5/Ledgers/BalanceSheetSimplified.aspx.designer.cs new file mode 100644 index 00000000..76724a11 --- /dev/null +++ b/Site/Pages/v5/Ledgers/BalanceSheetSimplified.aspx.designer.cs @@ -0,0 +1,87 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Frontend.Pages.Ledgers { + + + public partial class BalanceSheetSimplified { + + /// + /// LabelContentHeader control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelContentHeader; + + /// + /// DropYears control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList DropYears; + + /// + /// LiteralHeaderAccountName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal LiteralHeaderAccountName; + + /// + /// LiteralAssets control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal LiteralAssets; + + /// + /// LiteralAssetsDelta control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal LiteralAssetsDelta; + + /// + /// LiteralLiabilities control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal LiteralLiabilities; + + /// + /// LiteralLiabilitiesDelta control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal LiteralLiabilitiesDelta; + + /// + /// LabelSidebarDownload control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelSidebarDownload; + } +} diff --git a/Site/Pages/v5/Ledgers/Json-BalanceSheetData.aspx.cs b/Site/Pages/v5/Ledgers/Json-BalanceSheetData.aspx.cs index e6c39c32..d74fdf86 100644 --- a/Site/Pages/v5/Ledgers/Json-BalanceSheetData.aspx.cs +++ b/Site/Pages/v5/Ledgers/Json-BalanceSheetData.aspx.cs @@ -55,6 +55,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers if (localizeMap.ContainsKey (line.AccountName)) { line.AccountName = localizeMap[line.AccountName]; + line.DefaultExpand = true; } } } @@ -87,7 +88,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers line.AccountValues.ThisYear); - element += ",\"state\":\"closed\",\"children\":" + RecurseReport (line.Children); + element += ",\"state\":\"" + (line.DefaultExpand ? "open" : "closed") + "\",\"children\":" + RecurseReport(line.Children); } else { @@ -116,11 +117,11 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers if (treeValue != 0 && singleValue == 0) { return string.Format (CultureInfo.CurrentCulture, - "\"Σ {1:N0} \"", + "\"Σ {1:N0} \"", accountId, treeValue/100.00); } return string.Format (CultureInfo.CurrentCulture, - "\"Σ {1:N0}{2:N0}\"", + "\"Σ {1:N0}{2:N0}\"", accountId, treeValue/100.0, singleValue/100.0); } } diff --git a/Site/Pages/v5/Ledgers/Json-BalanceSheetDataSimplified.aspx b/Site/Pages/v5/Ledgers/Json-BalanceSheetDataSimplified.aspx new file mode 100644 index 00000000..a0d6d5b6 --- /dev/null +++ b/Site/Pages/v5/Ledgers/Json-BalanceSheetDataSimplified.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.BalanceSheetDataSimplified" Codebehind="Json-BalanceSheetDataSimplified.aspx.cs" %> diff --git a/Site/Pages/v5/Ledgers/Json-BalanceSheetDataSimplified.aspx.cs b/Site/Pages/v5/Ledgers/Json-BalanceSheetDataSimplified.aspx.cs new file mode 100644 index 00000000..a81bec49 --- /dev/null +++ b/Site/Pages/v5/Ledgers/Json-BalanceSheetDataSimplified.aspx.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using Swarmops.Common.Enums; +using Swarmops.Logic.Financial; + +namespace Swarmops.Frontend.Pages.v5.Ledgers +{ + public partial class BalanceSheetDataSimplified : DataV5Base + { + private AuthenticationData _authenticationData; + + + private int _year = 2012; + + protected void Page_Load (object sender, EventArgs e) + { + // Get auth data + + this._authenticationData = GetAuthenticationDataAndCulture(); + + // Get current year + + this._year = DateTime.Today.Year; + + string yearParameter = Request.QueryString["Year"]; + + if (!string.IsNullOrEmpty (yearParameter)) + { + this._year = Int32.Parse (yearParameter); // will throw if non-numeric - don't matter for app + } + + AnnualReport report = AnnualReport.Create (this._authenticationData.CurrentOrganization, this._year, + FinancialAccountType.Balance); + LocalizeRoot (report.ReportLines); + + Response.ContentType = "application/json"; + + Response.Output.WriteLine (RecurseReport (report.ReportLines)); + + Response.End(); + } + + private void LocalizeRoot (List lines) + { + Dictionary localizeMap = new Dictionary(); + + localizeMap["%ASSET_ACCOUNTGROUP%"] = Resources.Global.Financial_Asset; + localizeMap["%DEBT_ACCOUNTGROUP%"] = Resources.Global.Financial_Debt; + localizeMap["%INCOME_ACCOUNTGROUP%"] = Resources.Global.Financial_Income; + localizeMap["%COST_ACCOUNTGROUP%"] = Resources.Global.Financial_Cost; + + foreach (AnnualReportLine line in lines) + { + if (localizeMap.ContainsKey (line.AccountName)) + { + line.AccountName = localizeMap[line.AccountName]; + line.DefaultExpand = true; + } + } + } + + + private string RecurseReport (List reportLines) + { + List elements = new List(); + + foreach (AnnualReportLine line in reportLines) + { + string columnCardinal = "assets"; + string columnDelta = "assetdelta"; + int signReverser = 1; + + if (line.AccountType == FinancialAccountType.Debt) + { + columnCardinal = "liabilities"; + columnDelta = "liabilitydelta"; + signReverser = -1; + } + + string element = string.Format ("\"id\":\"{0}\",\"name\":\"{1}\"", line.AccountId, + JsonSanitize (line.AccountName)); + + if (line.Children.Count > 0) + { + element += ",\"" + columnCardinal + "\":" + + JsonDualString (line.AccountId, line.AccountTreeValues.ThisYear * signReverser, + line.AccountValues.ThisYear * signReverser); + + element += ",\"" + columnDelta + "\":" + + JsonDualString (line.AccountId, (line.AccountTreeValues.ThisYear-line.AccountTreeValues.PreviousYear) * signReverser, + (line.AccountValues.ThisYear-line.AccountValues.PreviousYear) * signReverser); + + + element += ",\"state\":\"" + (line.DefaultExpand? "open":"closed") + "\",\"children\":" + RecurseReport (line.Children); + } + else + { + element += string.Format (CultureInfo.CurrentCulture, ",\"" + columnCardinal + "\":\"{0:N2}\"", + (double) line.AccountValues.PreviousYear/100.0*signReverser); + + element += string.Format (CultureInfo.CurrentCulture, ",\"" + columnDelta + "\":\"({0:+#,#;-#,#;0})\"", + (double) line.AccountValues.ThisYear/100.0*signReverser).Replace("-", "−"); + } + + elements.Add ("{" + element + "}"); + } + + return "[" + String.Join (",", elements.ToArray()) + "]"; + } + + + private string JsonDualString (int accountId, Int64 treeValue, Int64 singleValue) + { + if (treeValue != 0 && singleValue == 0) + { + return string.Format (CultureInfo.CurrentCulture, + "\"Σ {1:N0} \"", + accountId, treeValue/100.00); + } + return string.Format (CultureInfo.CurrentCulture, + "\"Σ {1:N0}{2:N0}\"", + accountId, treeValue/100.0, singleValue/100.0); + } + } +} \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/Json-BalanceSheetDataSimplified.aspx.designer.cs b/Site/Pages/v5/Ledgers/Json-BalanceSheetDataSimplified.aspx.designer.cs new file mode 100644 index 00000000..082e8ef2 --- /dev/null +++ b/Site/Pages/v5/Ledgers/Json-BalanceSheetDataSimplified.aspx.designer.cs @@ -0,0 +1,15 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Frontend.Pages.v5.Ledgers { + + + public partial class BalanceSheetDataSimplified { + } +} diff --git a/Site/Pages/v5/Ledgers/Json-BudgetActualData.aspx.cs b/Site/Pages/v5/Ledgers/Json-BudgetActualData.aspx.cs index 2de7be60..443fd7d8 100644 --- a/Site/Pages/v5/Ledgers/Json-BudgetActualData.aspx.cs +++ b/Site/Pages/v5/Ledgers/Json-BudgetActualData.aspx.cs @@ -57,6 +57,7 @@ public partial class Pages_v5_Ledgers_Json_BudgetActualData : DataV5Base if (localizeMap.ContainsKey (line.AccountName)) { line.AccountName = localizeMap[line.AccountName]; + line.DefaultExpand = true; } } } @@ -105,7 +106,7 @@ public partial class Pages_v5_Ledgers_Json_BudgetActualData : DataV5Base - element += ",\"state\":\"closed\",\"children\":" + RecurseReport (line.Children); + element += ",\"state\":\"" + (line.DefaultExpand ? "open" : "closed") + "\",\"children\":" + RecurseReport(line.Children); } else { diff --git a/Site/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs b/Site/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs index 36f1ce1c..f3c814a4 100644 --- a/Site/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs +++ b/Site/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs @@ -54,6 +54,7 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : DataV5Base if (localizeMap.ContainsKey (line.AccountName)) { line.AccountName = localizeMap[line.AccountName]; + line.DefaultExpand = true; } } } @@ -104,7 +105,7 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : DataV5Base JsonDualString (line.AccountId, line.AccountTreeValues.ThisYear, line.AccountValues.ThisYear); - element += ",\"state\":\"closed\",\"children\":" + RecurseReport (line.Children); + element += ",\"state\":\"" + (line.DefaultExpand ? "open" : "closed") + "\",\"children\":" + RecurseReport(line.Children); } else { diff --git a/Site/Site.csproj b/Site/Site.csproj index 4453556f..45afb8c5 100644 --- a/Site/Site.csproj +++ b/Site/Site.csproj @@ -285,6 +285,13 @@ AccountPlan.aspx + + BalanceSheetSimplified.aspx + ASPXCodeBehind + + + BalanceSheetSimplified.aspx + BalanceSheet.aspx ASPXCodeBehind @@ -355,6 +362,13 @@ Json-AccountPlanData.aspx + + Json-BalanceSheetDataSimplified.aspx + ASPXCodeBehind + + + Json-BalanceSheetDataSimplified.aspx + Json-BalanceSheetData.aspx ASPXCodeBehind @@ -1013,6 +1027,7 @@ + @@ -1023,6 +1038,7 @@ +