diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx index 894e093d..b5782a54 100644 --- a/Site5/App_GlobalResources/Pages.Ledgers.resx +++ b/Site5/App_GlobalResources/Pages.Ledgers.resx @@ -134,7 +134,7 @@ Balance Sheet for {0}, - {0} is the organization name. The year follows immediately. + {0} is the organization name. The year follows immediately, so keep ending comma. Current @@ -566,4 +566,12 @@ Show Inactive Accounts (<span id="SpanInactiveCount">{0:N0}</span>) The {0} is the number of inactive accounts. + + Projected Loss {0} + "Projected" as in "Budgeted". {0} is year. + + + Projected Profit {0} + "Projected" as in "Budgeted". {0} is year. + \ No newline at end of file diff --git a/Site5/Pages/v5/Ledgers/AccountPlan.aspx b/Site5/Pages/v5/Ledgers/AccountPlan.aspx index b8e96639..0e1e74f7 100644 --- a/Site5/Pages/v5/Ledgers/AccountPlan.aspx +++ b/Site5/Pages/v5/Ledgers/AccountPlan.aspx @@ -48,10 +48,18 @@ beginEditAccount(); }); + + if ($('#CheckOptionShowInactive').prop("checked")) + { + $('.RowInactive').show(); + } }, rowStyler: function (rowData) { - console.log(rowData); + if (rowData.rowCssClass != null) + { + return { class: rowData.rowCssClass }; + } if (rowData.inactive == "true") { return { class: 'RowInactive' }; @@ -562,6 +570,11 @@ color: #C0C0C0; display: none; } + .RowProjectedLoss, .RowProjectedProfit + { + font-weight:500; + } + diff --git a/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs b/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs index 3bed1a3f..d50fce14 100644 --- a/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs +++ b/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs @@ -391,14 +391,14 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers account.SetBudgetCents (DateTime.Today.Year, newSingleBudget); // Once we've set the budget, also update the "yearly result" budget. - // This will be the WRONG SIGN for a P&L budget, but much better for display purposes (positive result is a profit, negative a loss). - // Will need to compensate for this in a future budget vs. actuals display. + // The "yearly result" budget isn't shown in the account plan, but is + // abstracted to "projected loss" or "projected gain" pseudobudgets. int thisYear = DateTime.UtcNow.Year; FinancialAccounts allProfitLossAccounts = FinancialAccounts.ForOrganization(authData.CurrentOrganization); Int64 newProfitLossProjection = allProfitLossAccounts.Where(queryAccount => queryAccount.Identity != authData.CurrentOrganization.FinancialAccounts.CostsYearlyResult.Identity).Sum(queryAccount => queryAccount.GetBudgetCents(thisYear)); - authData.CurrentOrganization.FinancialAccounts.CostsYearlyResult.SetBudgetCents(thisYear, newProfitLossProjection); + authData.CurrentOrganization.FinancialAccounts.CostsYearlyResult.SetBudgetCents(thisYear, -newProfitLossProjection); return new ChangeAccountDataResult { diff --git a/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs index bba34f20..20481af1 100644 --- a/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs @@ -19,6 +19,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers private Dictionary _treeBalanceLookup; private Dictionary _treeBudgetLookup; private int _year = 2012; + private int _resultAccountId; protected void Page_Load (object sender, EventArgs e) { @@ -40,6 +41,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers PopulateLookups (FinancialAccounts.ForOrganization (this._authenticationData.CurrentOrganization)); this._hashedAccounts = FinancialAccounts.GetHashedAccounts (this._authenticationData.CurrentOrganization); + this._resultAccountId = this._authenticationData.CurrentOrganization.FinancialAccounts.CostsYearlyResult.Identity; response += GetAccountGroup (FinancialAccountType.Asset, Resources.Global.Financial_Asset) + ","; response += GetAccountGroup (FinancialAccountType.Debt, Resources.Global.Financial_Debt) + ","; @@ -55,6 +57,16 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { string childrenString = GetAccountsRecurse (type, 0); + Int64 projectedResults = _treeBudgetLookup.ContainsKey (_resultAccountId) ? _treeBudgetLookup[_resultAccountId] : 0; + if (type == FinancialAccountType.Income && projectedResults <= 0) // expected profit or zero + { + childrenString += "," + GetProfitLossNode("ProjectedProfit", -projectedResults); + } + else if (type == FinancialAccountType.Cost && projectedResults >= 0) // expected loss or zero + { + childrenString += "," + GetProfitLossNode("ProjectedLoss", projectedResults); + } + string addString = String.Format ( "", @@ -66,6 +78,16 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers ")\",\"state\":\"open\",\"children\":[" + childrenString + "],\"action\":\"" + addString + "\"}"; } + private string GetProfitLossNode(string resource, Int64 amount) + { + string node = '{' + string.Format( + "\"id\":\"{0}\",\"accountName\":\"{1}\",\"rowCssClass\":\"{2}\",\"budget\":\"{3:N0}\"", + "Row" + resource, string.Format (Resources.Pages.Ledgers.ResourceManager.GetString("AccountPlan_" + resource), _year), "Row" + resource, amount / 100.0) + '}'; + + return node; + } + + private string GetAccountsRecurse (FinancialAccountType accountType, int rootNodeId) { List childStrings = new List(); @@ -84,7 +106,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers foreach (FinancialAccount account in this._hashedAccounts[rootNodeId]) { - if (account.Identity == rootNodeId || account.AccountType != accountType) + if (account.Identity == rootNodeId || account.AccountType != accountType || account.Identity == _resultAccountId) { continue; }