From a1dd7ae0ce566d5c81f86d1c66bdeacaec96a12a Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 9 Dec 2012 11:58:20 +0000 Subject: [PATCH] Committing more work on P&L --- Basic/Enums/ObjectOptionalDataType.cs | 2 +- Logic/Structure/Organization.cs | 40 +++++++++++++++++- Logic/Structure/OrganizationParameters.cs | 10 +++++ .../PageIcons/iconshock-coins-cross-40px.png | Bin 0 -> 4085 bytes Site5/Pages/v5/Finance/EconomyNotEnabled.aspx | 13 ++++++ .../v5/Finance/EconomyNotEnabled.aspx.cs | 16 +++++++ .../v5/Finance/RequestCashAdvance.aspx.cs | 6 +++ Site5/Pages/v5/Ledgers/CloseLedgers.aspx.cs | 2 +- .../v5/Ledgers/Json-ProfitLossData.aspx.cs | 15 +++++++ .../Pages/v5/Ledgers/ProfitLossStatement.aspx | 35 ++++++++------- .../v5/Ledgers/ProfitLossStatement.aspx.cs | 20 +++++++++ 11 files changed, 140 insertions(+), 19 deletions(-) create mode 100644 Site5/Images/PageIcons/iconshock-coins-cross-40px.png create mode 100644 Site5/Pages/v5/Finance/EconomyNotEnabled.aspx create mode 100644 Site5/Pages/v5/Finance/EconomyNotEnabled.aspx.cs diff --git a/Basic/Enums/ObjectOptionalDataType.cs b/Basic/Enums/ObjectOptionalDataType.cs index 98c2df46..9c6f3c23 100644 --- a/Basic/Enums/ObjectOptionalDataType.cs +++ b/Basic/Enums/ObjectOptionalDataType.cs @@ -196,7 +196,7 @@ namespace Activizr.Basic.Enums /// /// First bookkeeping year of org in Activizr (can set inbound balances for this year only) /// - OrgFirstBookkeepingYear + OrgFirstFiscalYear } diff --git a/Logic/Structure/Organization.cs b/Logic/Structure/Organization.cs index dff16a60..65884439 100644 --- a/Logic/Structure/Organization.cs +++ b/Logic/Structure/Organization.cs @@ -151,6 +151,40 @@ namespace Activizr.Logic.Structure get { return OptionalData.GetOptionalDataBool(ObjectOptionalDataType.OrgEconomyEnabled); } } + public int FirstFiscalYear + { + get + { + if (!IsEconomyEnabled) + { + throw new InvalidOperationException("Cannot request first fiscal year; organization is not economy-enabled"); + } + + int year = Parameters.FirstFiscalYear; + + if (year < 2000) + { + if (this.Identity == 1 && this.Name.StartsWith("Piratpartiet")) + { + OptionalData.SetOptionalDataInt(ObjectOptionalDataType.OrgFirstFiscalYear, 2009); + year = 2009; + } + else if (this.Identity == 2 && this.Name.StartsWith("Europirate Acad")) + { + OptionalData.SetOptionalDataInt(ObjectOptionalDataType.OrgFirstFiscalYear, 2012); + year = 2012; + } + else if (this.Identity == 1 && this.Name.StartsWith("Sandbox")) + { + OptionalData.SetOptionalDataInt(ObjectOptionalDataType.OrgFirstFiscalYear, 2012); + year = 2012; + } + } + + return year; + } + } + public Currency Currency { get @@ -209,8 +243,6 @@ namespace Activizr.Logic.Structure FinancialAccount.Create(this.Identity, "Bank Fees", FinancialAccountType.Cost, 0); FinancialAccounts[OrganizationFinancialAccountType.CostsInfrastructure] = FinancialAccount.Create(this.Identity, "ICT and Infrastructure", FinancialAccountType.Cost, 0); - FinancialAccounts[OrganizationFinancialAccountType.CostsLocalDonationTransfers] = - FinancialAccount.Create(this.Identity, "Local donations (virtual balancing)", FinancialAccountType.Cost, 0); FinancialAccounts[OrganizationFinancialAccountType.CostsYearlyResult] = FinancialAccount.Create(this.Identity, "Yearly result", FinancialAccountType.Cost, 0); FinancialAccounts[OrganizationFinancialAccountType.DebtsCapital] = @@ -258,6 +290,10 @@ namespace Activizr.Logic.Structure OptionalData.SetOptionalDataString(ObjectOptionalDataType.OrgCurrency, currency.Code); + // Set current year to first fiscal year + + this.OptionalData.SetOptionalDataInt(ObjectOptionalDataType.OrgFirstFiscalYear, DateTime.Today.Year); + // Finally, flag the org as enabled this.OptionalData.SetOptionalDataBool(ObjectOptionalDataType.OrgEconomyEnabled, true); diff --git a/Logic/Structure/OrganizationParameters.cs b/Logic/Structure/OrganizationParameters.cs index ff495626..a58359a0 100644 --- a/Logic/Structure/OrganizationParameters.cs +++ b/Logic/Structure/OrganizationParameters.cs @@ -33,6 +33,16 @@ namespace Activizr.Logic.Structure } + public int FirstFiscalYear + { + get + { + int year = data.GetOptionalDataInt(ObjectOptionalDataType.OrgFirstFiscalYear); + return year; + } + } + + public int FiscalBooksClosedUntilYear { get diff --git a/Site5/Images/PageIcons/iconshock-coins-cross-40px.png b/Site5/Images/PageIcons/iconshock-coins-cross-40px.png new file mode 100644 index 0000000000000000000000000000000000000000..a2d19f3a18a4a554933a0921eec1808a6beb9eaa GIT binary patch literal 4085 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyz@ z7YrSLwk0|M01tIZL_t(o!>yQkkX+Su#((!My-jyd&!!p8jJAu%Nj?PFc4v;SKT_swKjOXM^80VS zX)Is6WpcK7d1J1jBOce$v=JpCU4|8#eT&wtxG zy8vH(crEKb^%@$ychPamnS^{*}_>3xu+EBhq~+;}V3q5<}#ONlAY6c|xZ^N-v>B70Pvkq$xxq zrBtZ73s)`D9tX}pTi^h+o(&tDLL;%IZ|%+K@dZKwL=|xMBbWg>jtUDXrARlnjiC#dOj8FvouE;rUWXt=NC}RBm0jvHF#mi1zI#fYl?ayS#zLXo zst89>079VZuh7tS6Pcc`kzRB!dinxf*F)%yq;iXC&Pb+b3QWz0NC}ZtL?LJbl}WMs z``e~(K5Hp1<%h%Kv&c3*&Q8ca`&5e7AaP%>AM zl&TR?1VIF84N^tw3>vz#l%b<4QPqSICxlcvLLy%4+e+C zQ%}6azOz;b0iONl@+aqY6|OU4Ch69-w088O8v^tk0+5l1YtK@ieS_JlVItop8#5Uk z4S8Z;jkdJnn#&;O2zEWsU;g2htM<3d%U+vI8EXXLyeRaQ?|D=Cx%$DAr)p27lJelp zTo~T}aPhYTJleBSRKHXl4^^o%7OzrwJPb|6JvEYg|2C}aB<x*bm0cJ%#XiSOR} zw{yq8aaW2jZm<7lfY1KTqK?iB``+~2fvgNQp=61fIVe^_YED2TBX++KB9*|@6}38a z&C|H>oCK?T;*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t}Eelnzqv~~Jy^gXhj9iXjXb3Eeplb2b%{S5gfs3OD|KT4$@UG70 z?mK$^TGK+|2RflYNg~xiEYX2Rf*=6L1tm3737rLPG0t6_WI>z3tH&K8rRZr!rP|WM z$X&tZ*KSike|opr&_0jIw#ltuPs^rF1k=+56BC?X&>_8U9bI4kGMTHc!hY^K^m3Vo zgNKy5_FAoCS>5jf_|fYU_cY|%lbW1CX-$MOMLs`Gp*V*S5msGLsVRJ4GFkALn03iz z1YNBLt}7WUNT(rVJkYrCkItW%4I0jCZl+fQ?s-X;%ump}AkMrdgJYu(LsJ1lDolgvZ$Ewhwm-gO>#bu$!?`Ou=Mz{K zK|YVx(n1iA69xhLqD2^~6xloOAd-?$N`k>brf;|bVcVEM(Y96Vhd-Ms&dlU-9H&Mkj6{dP3pM>|uPH6UhL`1Sg` z0UEkE6oeYe86unQq#?7I>FEjPinF+$&;Hj!k_kx01-Z1whBX-sP4QnZTP$xEc)mKW zA`c;i3WGq{2M$ntPThY$Q=UhuR3cL-(0h+}+i+@Wxwj-SFa`JuEF0 zL@bx1e9JA=YBjnt8J695AJNH^n0xoqvUoAmot@zO^bQUZJA4?|G*$oBkBDP4Q^UW} zo`@&Fa{4K5JJ-sQoe67 z{TKijxbaQEHf#TQ;UwQt|PTl@R_CyoDuUGiI9p;#<- zx|j>`)i4b058rs>1La-28tgsKkbL2JWsZyr-LfENqUO)1+S{upKCoU?I@)<_-@a$| z@85s-p+koTIa?OlZ*$N#Y}l}T&6+ja7A;wF%fha%cvB*QE+ww-Q?zZSN+l*ICXSDf njeX_t;ln>292~5?{qg?*Fa{g$={}W;00000NkvXXu0mjfXdv7Q literal 0 HcmV?d00001 diff --git a/Site5/Pages/v5/Finance/EconomyNotEnabled.aspx b/Site5/Pages/v5/Finance/EconomyNotEnabled.aspx new file mode 100644 index 00000000..6484f34b --- /dev/null +++ b/Site5/Pages/v5/Finance/EconomyNotEnabled.aspx @@ -0,0 +1,13 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="EconomyNotEnabled.aspx.cs" Inherits="Pages_v5_Finance_EconomyNotEnabled" %> + + + + +

Economy isn't enabled for this organization

+ + Fail symbolEconomy has not been enabled for this organization. Therefore, financial functions are not available. Contact an organization administrator to enable financial functions. +
+
+ + + diff --git a/Site5/Pages/v5/Finance/EconomyNotEnabled.aspx.cs b/Site5/Pages/v5/Finance/EconomyNotEnabled.aspx.cs new file mode 100644 index 00000000..0aa10150 --- /dev/null +++ b/Site5/Pages/v5/Finance/EconomyNotEnabled.aspx.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class Pages_v5_Finance_EconomyNotEnabled : PageV5Base +{ + protected void Page_Load(object sender, EventArgs e) + { + this.PageTitle = "Economy Not Enabled"; + this.PageIcon = "iconshock-coins-cross"; + this.InfoBoxLiteral = "Please contact an organization administrator for assistance."; + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Finance/RequestCashAdvance.aspx.cs b/Site5/Pages/v5/Finance/RequestCashAdvance.aspx.cs index 092ea4d5..d048d79d 100644 --- a/Site5/Pages/v5/Finance/RequestCashAdvance.aspx.cs +++ b/Site5/Pages/v5/Finance/RequestCashAdvance.aspx.cs @@ -11,6 +11,12 @@ public partial class Pages_v5_Finance_RequestCashAdvance : PageV5Base { protected void Page_Load(object sender, EventArgs e) { + if (!this.CurrentOrganization.IsEconomyEnabled) + { + Response.Redirect("/Pages/v5/Finance/EconomyNotEnabled.aspx", true); + return; + } + this.PageTitle = Resources.Pages.Finance.RequestCashAdvance_PageTitle; this.PageIcon = "iconshock-walletmoney"; this.InfoBoxLiteral = Resources.Pages.Finance.RequestCashAdvance_Info; diff --git a/Site5/Pages/v5/Ledgers/CloseLedgers.aspx.cs b/Site5/Pages/v5/Ledgers/CloseLedgers.aspx.cs index f9813164..5ceca6c5 100644 --- a/Site5/Pages/v5/Ledgers/CloseLedgers.aspx.cs +++ b/Site5/Pages/v5/Ledgers/CloseLedgers.aspx.cs @@ -44,7 +44,7 @@ public partial class Pages_v5_Ledgers_CloseLedgers : PageV5Base // First, roll over virtual balances. - if (true) // if this.CurrentOrganization.Parameters.VirtualBankingEnabled + if (false) // if this.CurrentOrganization.Parameters.VirtualBankingEnabled { FinancialAccount rootAccount = FinancialAccount.FromIdentity(29); // HACK: Hardcoded account; should be _organization.FinancialAccount.CostsVirtualBankingRoot FinancialAccount tempAccount = FinancialAccount.FromIdentity(98); // HACK: Hardcoded account; should be _organization.FinancialAccount.AssetsVirtualRollover diff --git a/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs index d3253ebc..bf029f7e 100644 --- a/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs @@ -57,6 +57,21 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : System.Web.UI.Page FinancialAccounts accounts = FinancialAccounts.ForOrganization(currentOrganization, FinancialAccountType.Result); + // Remove unwanted accounts + + FinancialAccount resultsAccount = currentOrganization.FinancialAccounts.CostsYearlyResult; + + foreach (FinancialAccount account in accounts) + { + // For now, just remove the "results" account. TODO: Remove inactive accounts, too. + + if (account.Identity == resultsAccount.Identity) + { + accounts.Remove(account); + break; + } + } + // Build tree (there should be a template for this) Dictionary> treeMap = new Dictionary>(); diff --git a/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx b/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx index 2e179f5d..e228d9d7 100644 --- a/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx +++ b/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx @@ -10,27 +10,32 @@ $(document).ready(function () { $('#tableProfitLoss').treegrid( - { - onBeforeExpand: function (foo) { - $('span.profitlossdata-collapsed-' + foo.id).fadeOut('fast', function () { - $('span.profitlossdata-expanded-' + foo.id).fadeIn('slow'); - }); - }, - - onBeforeCollapse: function (foo) { - $('span.profitlossdata-expanded-' + foo.id).fadeOut('fast', function() { - $('span.profitlossdata-collapsed-' + foo.id).fadeIn('slow'); - }); - } - }); + { + onBeforeExpand: function (foo) { + $('span.profitlossdata-collapsed-' + foo.id).fadeOut('fast', function () { + $('span.profitlossdata-expanded-' + foo.id).fadeIn('slow'); + }); + }, + + onBeforeCollapse: function (foo) { + $('span.profitlossdata-expanded-' + foo.id).fadeOut('fast', function () { + $('span.profitlossdata-collapsed-' + foo.id).fadeIn('slow'); + }); + } + }); + + $('#<%=DropYears.ClientID %>').change(function() { + var selectedYear = $('#<%=DropYears.ClientID %>').val(); + + alert (selectedYear); + }); }); -
-

P&L for Piratpartiet For Year

+

P&L for Piratpartiet For Year

= firstFiscalYear) + { + this.DropYears.Items.Add(year.ToString(CultureInfo.InvariantCulture)); + year--; + } + + } } } \ No newline at end of file