From 7283aa52a88933840e041bce306d8e799687bd92 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 24 Feb 2014 11:34:39 +0000 Subject: [PATCH] More work on account plan --- .../Types/Financial/BasicFinancialAccount.cs | 6 +- Database/Database-Financials.cs | 6 +- Site5/App_GlobalResources/Global.resx | 12 +++ Site5/App_GlobalResources/Pages.Ledgers.resx | 4 +- .../Json-FinancialAccountsTree.aspx | 1 + .../Json-FinancialAccountsTree.aspx.cs | 92 ++++++++++++++++++ Site5/Controls/v5/Financial/ComboBudgets.ascx | 2 +- .../v5/Financial/ComboBudgets.ascx.cs | 2 +- Site5/Controls/v5/Swarm/ComboPeople.ascx | 42 ++++++++ Site5/Controls/v5/Swarm/ComboPeople.ascx.cs | 22 +++++ ...boPerson.ascx => ComboPersonObsolete.ascx} | 2 +- ...on.ascx.cs => ComboPersonObsolete.ascx.cs} | 2 +- .../Controls/v5/Swarm/PersonDetailPopup.ascx | 2 +- Site5/Images/Icons/iconshock-warning-24px.png | Bin 0 -> 970 bytes Site5/Pages/v5/Governance/AddMotion.aspx | 2 +- .../v5/Governance/AddMotionAmendment.aspx | 2 +- Site5/Pages/v5/Ledgers/AccountPlan.aspx | 35 ++++++- Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs | 27 ++++- Site5/Style/jquery.switchButton.css | 90 ++++++++--------- Site5/Style/style-v5.css | 16 +++ 20 files changed, 300 insertions(+), 67 deletions(-) create mode 100644 Site5/Automation/Json-FinancialAccountsTree.aspx create mode 100644 Site5/Automation/Json-FinancialAccountsTree.aspx.cs create mode 100644 Site5/Controls/v5/Swarm/ComboPeople.ascx create mode 100644 Site5/Controls/v5/Swarm/ComboPeople.ascx.cs rename Site5/Controls/v5/Swarm/{ComboPerson.ascx => ComboPersonObsolete.ascx} (81%) rename Site5/Controls/v5/Swarm/{ComboPerson.ascx.cs => ComboPersonObsolete.ascx.cs} (95%) create mode 100644 Site5/Images/Icons/iconshock-warning-24px.png diff --git a/Basic/Types/Financial/BasicFinancialAccount.cs b/Basic/Types/Financial/BasicFinancialAccount.cs index ef2b356e..528ce32c 100644 --- a/Basic/Types/Financial/BasicFinancialAccount.cs +++ b/Basic/Types/Financial/BasicFinancialAccount.cs @@ -7,7 +7,7 @@ namespace Swarmops.Basic.Types.Financial { public BasicFinancialAccount (int financialAccountId, string name, FinancialAccountType accountType, int organizationId, int parentFinancialAccountId, int ownerPersonId, - bool open, int openedYear, int closedYear, bool expensable) + bool open, int openedYear, int closedYear, bool expensable, bool administrative) { this.FinancialAccountId = financialAccountId; this.Name = name; @@ -19,10 +19,11 @@ namespace Swarmops.Basic.Types.Financial this.OpenedYear = openedYear; this.ClosedYear = closedYear; this.Expensable = expensable; + this.Administrative = administrative; } public BasicFinancialAccount (BasicFinancialAccount original) : - this(original.Identity, original.Name, original.AccountType, original.OrganizationId, original.ParentFinancialAccountId, original.OwnerPersonId, original.Open, original.OpenedYear, original.ClosedYear, original.Expensable) + this(original.Identity, original.Name, original.AccountType, original.OrganizationId, original.ParentFinancialAccountId, original.OwnerPersonId, original.Open, original.OpenedYear, original.ClosedYear, original.Expensable, original.Administrative) { // Empty copy constructor } @@ -38,6 +39,7 @@ namespace Swarmops.Basic.Types.Financial public int OpenedYear { get; protected set; } public int ClosedYear { get; protected set; } public bool Expensable { get; protected set; } + public bool Administrative { get; protected set; } #region IHasIdentity Members diff --git a/Database/Database-Financials.cs b/Database/Database-Financials.cs index 94d1fb80..5c8e85c5 100644 --- a/Database/Database-Financials.cs +++ b/Database/Database-Financials.cs @@ -15,7 +15,8 @@ namespace Swarmops.Database { private const string financialAccountFieldSequence = " FinancialAccountId,Name,OrganizationId,AccountType,ParentFinancialAccountId," + // 0-4 - " OwnerPersonId,Open,OpenedYear,ClosedYear,Expensable " + // 5-9 + " OwnerPersonId,Open,OpenedYear,ClosedYear,Expensable," + // 5-9 + " Administrative " + // 10 " FROM FinancialAccounts "; public int CreateFinancialAccount(int pOrganizationId, string pName, FinancialAccountType pAccountType, int pParentFinancialAccountId) @@ -690,8 +691,9 @@ namespace Swarmops.Database int openedYear = reader.GetInt32(7); int closedYear = reader.GetInt32(8); bool expensable = reader.GetBoolean(9); + bool administrative = reader.GetBoolean(10); - return new BasicFinancialAccount(accountId, name, accountType, organizationId, parentFinancialAccountId, ownerPersonId, open, openedYear, closedYear, expensable); + return new BasicFinancialAccount(accountId, name, accountType, organizationId, parentFinancialAccountId, ownerPersonId, open, openedYear, closedYear, expensable, administrative); } private BasicFinancialAccountRow ReadFinancialAccountRowFromDataReader (DbDataReader reader) diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx index ce62923e..d2105b7d 100644 --- a/Site5/App_GlobalResources/Global.resx +++ b/Site5/App_GlobalResources/Global.resx @@ -379,4 +379,16 @@ Yes For yes/no options + + Assets + + + Expenses + + + Liabilities + + + Revenue + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx index e4977e29..d6d1f032 100644 --- a/Site5/App_GlobalResources/Pages.Ledgers.resx +++ b/Site5/App_GlobalResources/Pages.Ledgers.resx @@ -140,7 +140,7 @@ Current - Debt + Liabilities BalanceSheet @@ -180,7 +180,7 @@ The {0} is the organization name. The year number follows this string. - Costs + Expenses ProfitLoss diff --git a/Site5/Automation/Json-FinancialAccountsTree.aspx b/Site5/Automation/Json-FinancialAccountsTree.aspx new file mode 100644 index 00000000..284bfe9e --- /dev/null +++ b/Site5/Automation/Json-FinancialAccountsTree.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-FinancialAccountsTree.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Financial.Json_FinancialAccountsTree" %> \ No newline at end of file diff --git a/Site5/Automation/Json-FinancialAccountsTree.aspx.cs b/Site5/Automation/Json-FinancialAccountsTree.aspx.cs new file mode 100644 index 00000000..5d9161ab --- /dev/null +++ b/Site5/Automation/Json-FinancialAccountsTree.aspx.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Swarmops.Basic.Enums; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Swarm; +using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; + +namespace Swarmops.Frontend.Pages.v5.Financial +{ + public partial class Json_FinancialAccountsTree : DataV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + Response.ContentType = "application/json"; + FinancialAccountType accountType = + (FinancialAccountType) (Enum.Parse(typeof (FinancialAccountType), Request.QueryString["AccountType"])); + + string accountsJson = string.Empty; + + int excludeId = -1; + + string excludeIdString = Request.QueryString["ExcludeId"]; + + if (!String.IsNullOrEmpty(excludeIdString)) + { + excludeId = Int32.Parse(excludeIdString); + } + + // Get accounts + + FinancialAccounts accounts = FinancialAccounts.ForOrganization(this.CurrentOrganization, accountType); + + // Build tree (there should be a template for this) + + Dictionary> treeMap = new Dictionary>(); + + foreach (FinancialAccount account in accounts) + { + if (account.Identity == excludeId) + { + continue; + } + + if (!treeMap.ContainsKey(account.ParentIdentity)) + { + treeMap[account.ParentIdentity] = new List(); + } + + treeMap[account.ParentIdentity].Add(account); + } + + accountsJson = RecurseTreeMap(treeMap, 0); + + accountsJson = "[{\"id\":\"0\",\"text\":\"" + + JsonSanitize(Resources.Global.ResourceManager.GetString("Financial_" + accountType.ToString())) + + "\",\"state\":\"open\",\"children\":" + + accountsJson + + "}]"; + + Response.Output.WriteLine(accountsJson); + + Response.End(); + } + + private string RecurseTreeMap(Dictionary> treeMap, int node) + { + List elements = new List(); + + foreach (FinancialAccount account in treeMap[node]) + { + string element = string.Format("\"id\":{0},\"text\":\"{1}\"", account.Identity, + JsonSanitize(account.Name)); + + if (treeMap.ContainsKey(account.Identity)) + { + element += ",\"state\":\"closed\",\"children\":" + RecurseTreeMap(treeMap, account.Identity); + } + + elements.Add("{" + element + "}"); + } + + return "[" + String.Join(",", elements.ToArray()) + "]"; + + } + } +} \ No newline at end of file diff --git a/Site5/Controls/v5/Financial/ComboBudgets.ascx b/Site5/Controls/v5/Financial/ComboBudgets.ascx index 0b1f15e7..b2bea6d9 100644 --- a/Site5/Controls/v5/Financial/ComboBudgets.ascx +++ b/Site5/Controls/v5/Financial/ComboBudgets.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ComboBudgets.ascx.cs" Inherits="Swarmops.Controls.Financial.BudgetCombo" %> +<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ComboBudgets.ascx.cs" Inherits="Swarmops.Controls.Financial.ComboBudgets" %> + + \ No newline at end of file diff --git a/Site5/Controls/v5/Swarm/ComboPeople.ascx.cs b/Site5/Controls/v5/Swarm/ComboPeople.ascx.cs new file mode 100644 index 00000000..b8c36857 --- /dev/null +++ b/Site5/Controls/v5/Swarm/ComboPeople.ascx.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Swarmops.Logic.Swarm; + +namespace Swarmops.Controls.Financial +{ + public partial class ComboPeople : ControlV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + public Person Selected { set; protected get; } + + public bool NobodySelected { set; protected get; } + } +} \ No newline at end of file diff --git a/Site5/Controls/v5/Swarm/ComboPerson.ascx b/Site5/Controls/v5/Swarm/ComboPersonObsolete.ascx similarity index 81% rename from Site5/Controls/v5/Swarm/ComboPerson.ascx rename to Site5/Controls/v5/Swarm/ComboPersonObsolete.ascx index bfffeeff..cbc79aa8 100644 --- a/Site5/Controls/v5/Swarm/ComboPerson.ascx +++ b/Site5/Controls/v5/Swarm/ComboPersonObsolete.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ComboPerson.ascx.cs" Inherits="Swarmops.Controls.Swarm.ComboPerson" %> +<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ComboPersonObsolete.ascx.cs" Inherits="Swarmops.Controls.Swarm.ComboPersonObsolete" %> -<%@ Register Src="~/Controls/v5/Swarm/ComboPerson.ascx" TagName="ComboPerson" TagPrefix="act5" %> +<%@ Register Src="~/Controls/v5/Swarm/ComboPersonObsolete.ascx" TagName="ComboPerson" TagPrefix="act5" %> diff --git a/Site5/Images/Icons/iconshock-warning-24px.png b/Site5/Images/Icons/iconshock-warning-24px.png new file mode 100644 index 0000000000000000000000000000000000000000..0f4f3c2ea9a7c1c8032660930a9ed82ac9349340 GIT binary patch literal 970 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE(}6TtKSPDj(q#+`Oy@jZ978;gU%hrdU)ojVz{mHqXU4978+*G{ zxLUjYO5fv%6`Nds3f9eu;^bVpb&<@huqA<^ii%1B8q@y>|2WYoE%Tto;?VvBjlnJc zqCxt$MJE|EV&0#791vu>bcv@hpUq3zG`G)opH12&e?Bet6KT%1Ex9{q&7aSYcN{P( zc(|Ww-Ib_!r$+m(t%|DegIiJ^MxlsP51Ojv5UK~^|x!tB=`h4Xa$ zPCVucnxky~K3SQox6ztE##-+JpYY8Ux-%+G1uHYT3t2Z=sI3kW3|G*vYx3&+HRx>+OatjTW9hn6Ca zdzb$@+piK|(_PiCBw#ipP1<9DS*`P~16Q9jo_-n_sH2jR()~}S9&Sk7rDMD1)Zvo{FR%XY^EL2Yzi6Y=do7=kLBM@{JZhD#ck{FneXq|8$4I%pJB73^Vf_YsG_^7?vNAE$ zH2^XUylU>wK+%w!pOTqY3DjU -<%@ Register src="~/Controls/v5/Swarm/ComboPerson.ascx" tagname="ComboPerson" tagprefix="act5" %> +<%@ Register src="~/Controls/v5/Swarm/ComboPersonObsolete.ascx" tagname="ComboPerson" tagprefix="act5" %>