From b0f0c58d2fb356ebad948b1cd79c95f3140dfc74 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 26 Sep 2017 13:58:10 +0200 Subject: [PATCH] Fixed invoiceable-outbound list (and spelling) --- .../OrganizationFinancialAccounts.cs | 42 ++++++++++++++----- Site/Automation/Json-BudgetsTree.aspx.cs | 21 +++++----- .../v5/Financial/ComboBudgets.ascx.cs | 2 + .../v5/Financial/CreateInboundInvoice.aspx | 2 +- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/Logic/Financial/OrganizationFinancialAccounts.cs b/Logic/Financial/OrganizationFinancialAccounts.cs index 83ad9506..9025cc27 100644 --- a/Logic/Financial/OrganizationFinancialAccounts.cs +++ b/Logic/Financial/OrganizationFinancialAccounts.cs @@ -269,15 +269,41 @@ namespace Swarmops.Logic.Financial int yearlyResultId = CostsYearlyResult.Identity; FinancialAccounts costAccounts = - FinancialAccounts.ForOrganization (Organization.FromIdentity (this._organizationId), + FinancialAccounts.ForOrganization(Organization.FromIdentity(this._organizationId), FinancialAccountType.Cost); foreach (FinancialAccount account in costAccounts) { if (account.Identity != yearlyResultId && account.Expensable) - // really should be redundant, but still... + // really should be redundant, but still... { - result.Add (account); + result.Add(account); + } + } + + return result; + } + } + + public FinancialAccounts InvoiceableBudgetsInbound + { + // TODO: This needs to return a tree, not a flat list. + get + { + FinancialAccounts result = new FinancialAccounts(); + + int yearlyResultId = CostsYearlyResult.Identity; + + FinancialAccounts costAccounts = + FinancialAccounts.ForOrganization(Organization.FromIdentity(this._organizationId), + FinancialAccountType.Cost); + + foreach (FinancialAccount account in costAccounts) + { + if (account.Identity != yearlyResultId) + // really should be redundant, but still... + { + result.Add(account); } } @@ -294,17 +320,13 @@ namespace Swarmops.Logic.Financial int yearlyResultId = CostsYearlyResult.Identity; - FinancialAccounts costAccounts = + FinancialAccounts revenueAccounts = FinancialAccounts.ForOrganization (Organization.FromIdentity (this._organizationId), FinancialAccountType.Income); - foreach (FinancialAccount account in costAccounts) + foreach (FinancialAccount account in revenueAccounts) { - if (account.Identity != yearlyResultId && account.Expensable) - // really should be redundant, but still... - { - result.Add (account); - } + result.Add (account); } return result; diff --git a/Site/Automation/Json-BudgetsTree.aspx.cs b/Site/Automation/Json-BudgetsTree.aspx.cs index a0cdcef2..ee2f95cb 100644 --- a/Site/Automation/Json-BudgetsTree.aspx.cs +++ b/Site/Automation/Json-BudgetsTree.aspx.cs @@ -13,23 +13,24 @@ namespace Swarmops.Frontend.Automation Response.ContentType = "application/json"; // What type of budgets do we want? - // Allowed values are "Expensable", "InvoicableOut", or "InvoiceableIn". Default is "Expensable". + // Allowed values are "Expensable", "InvoiceableOut", or "InvoiceableIn". Default is "Expensable". string accountTypeString = Request.QueryString["AccountType"]; AccountTypes accountType = AccountTypes.Unknown; switch (accountTypeString.ToLowerInvariant()) { - case "invoicableout": - accountType = AccountTypes.InvoicablesOut; + case "invoiceableout": + accountType = AccountTypes.InvoiceablesOut; break; - case "invoicablein": - accountType = AccountTypes.InvoicablesIn; + case "invoiceablein": + accountType = AccountTypes.InvoiceablesIn; break; case "expensable": - default: accountType = AccountTypes.Expensables; break; + default: + throw new ArgumentException("Unrecognized account category"); } // Is this stuff in cache already? @@ -56,11 +57,11 @@ namespace Swarmops.Frontend.Automation switch (accountType) { - case AccountTypes.InvoicablesOut: + case AccountTypes.InvoiceablesOut: accounts = CurrentOrganization.FinancialAccounts.InvoiceableBudgetsOutbound; break; case AccountTypes.Expensables: - case AccountTypes.InvoicablesIn: + case AccountTypes.InvoiceablesIn: accounts = CurrentOrganization.FinancialAccounts.ExpensableBudgets; break; default: @@ -122,8 +123,8 @@ namespace Swarmops.Frontend.Automation private enum AccountTypes { Unknown = 0, - InvoicablesOut, - InvoicablesIn, + InvoiceablesOut, + InvoiceablesIn, Expensables } } diff --git a/Site/Controls/v5/Financial/ComboBudgets.ascx.cs b/Site/Controls/v5/Financial/ComboBudgets.ascx.cs index 0418449f..3c861a65 100644 --- a/Site/Controls/v5/Financial/ComboBudgets.ascx.cs +++ b/Site/Controls/v5/Financial/ComboBudgets.ascx.cs @@ -34,6 +34,8 @@ namespace Swarmops.Controls.Financial return "/Automation/Json-BudgetsTree.aspx?AccountType=Expensable"; case AccountListType.InvoiceableOut: return "/Automation/Json-BudgetsTree.aspx?AccountType=InvoiceableOut"; + case AccountListType.InvoiceableIn: + return "/Automation/Json-BudgetsTree.aspx?AccountType=InvoiceableIn"; case AccountListType.All: return "/Automation/Json-FinancialAccountsTree.aspx?AccountType=All"; } diff --git a/Site/Pages/v5/Financial/CreateInboundInvoice.aspx b/Site/Pages/v5/Financial/CreateInboundInvoice.aspx index fbd78f6a..9066cba3 100644 --- a/Site/Pages/v5/Financial/CreateInboundInvoice.aspx +++ b/Site/Pages/v5/Financial/CreateInboundInvoice.aspx @@ -150,7 +150,7 @@
- + ">