This commit is contained in:
@@ -80,14 +80,21 @@ namespace Activizr.Logic.Financial
|
||||
return FinancialAccountRows.FromArray(basicRows);
|
||||
}
|
||||
|
||||
|
||||
public double GetBudgetSum (int year)
|
||||
[Obsolete("This function uses double-point variables for money. Use GetBudgetSumCents instead.")]
|
||||
public double GetBudgetSum(int year)
|
||||
{
|
||||
return PirateDb.GetDatabase().GetFinancialAccountsBudget(this.Identities, year);
|
||||
}
|
||||
|
||||
|
||||
public Int64 GetDeltaCents (DateTime start, DateTime end)
|
||||
public Int64 GetBudgetSumCents(int year)
|
||||
{
|
||||
// TODO: Add support in database
|
||||
return (Int64) (PirateDb.GetDatabase().GetFinancialAccountsBudget(this.Identities, year) * 100);
|
||||
}
|
||||
|
||||
|
||||
public Int64 GetDeltaCents(DateTime start, DateTime end)
|
||||
{
|
||||
return PirateDb.GetDatabase().GetFinancialAccountBalanceDeltaCents(this.Identities, start, end);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Activizr.Logic.Financial
|
||||
organizationAccounts[OrganizationFinancialAccountType.AssetsOutboundInvoices] = 28;
|
||||
organizationAccounts[OrganizationFinancialAccountType.DebtsCapital] = 96;
|
||||
organizationAccounts[OrganizationFinancialAccountType.AssetsPaypal] = 2;
|
||||
organizationAccounts[OrganizationFinancialAccountType.CostsYearResult] = 97;
|
||||
organizationAccounts[OrganizationFinancialAccountType.CostsYearlyResult] = 97;
|
||||
}
|
||||
|
||||
public OrganizationFinancialAccounts (int organizationId)
|
||||
@@ -121,12 +121,12 @@ namespace Activizr.Logic.Financial
|
||||
organizationAccounts[OrganizationFinancialAccountType.CostsLocalDonationTransfers]); }
|
||||
}
|
||||
|
||||
public FinancialAccount CostsYearResult
|
||||
public FinancialAccount CostsYearlyResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
FinancialAccount.FromIdentity(organizationAccounts[OrganizationFinancialAccountType.CostsYearResult]);
|
||||
FinancialAccount.FromIdentity(organizationAccounts[OrganizationFinancialAccountType.CostsYearlyResult]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +164,6 @@ namespace Activizr.Logic.Financial
|
||||
CostsLocalDonationTransfers,
|
||||
CostsAllocatedFunds,
|
||||
CostsConferences,
|
||||
CostsYearResult // multi-account type
|
||||
CostsYearlyResult // multi-account type
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +63,9 @@ public class PageV5Base : System.Web.UI.Page
|
||||
{
|
||||
// Localization
|
||||
|
||||
// Set default culture (English, United States)
|
||||
// Set default culture (English, United States, but that doesn't work so fake it to GB)
|
||||
|
||||
string preferredCulture = "en-US";
|
||||
string preferredCulture = "en-GB";
|
||||
|
||||
// ----------- SET CULTURE ------------
|
||||
|
||||
@@ -79,7 +79,7 @@ public class PageV5Base : System.Web.UI.Page
|
||||
else
|
||||
{
|
||||
// No, determine from browser
|
||||
string browserPreference = "en-US";
|
||||
string browserPreference = "en-GB";
|
||||
if (Request.UserLanguages != null && Request.UserLanguages.Length > 0)
|
||||
{
|
||||
browserPreference = Request.UserLanguages[0];
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Activizr.Controls.Base
|
||||
|
||||
protected void LinkEnglish_Click(object sender, EventArgs e)
|
||||
{
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
|
||||
FireLanguageChanged();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
// Code that runs on application startup
|
||||
|
||||
// Set supported cultures
|
||||
HttpContext.Current.Application["Cultures"] = new string[] { "sv-SE", "en-US", "de-DE", "de-AT", "fi-FI" };
|
||||
HttpContext.Current.Application["Cultures"] = new string[] { "sv-SE", "en-GB", "de-DE", "de-AT", "fi-FI" };
|
||||
|
||||
HttpContext.Current.Application["UserRoleCache"] = new Dictionary<int, string[]>();
|
||||
}
|
||||
|
||||
@@ -95,9 +95,23 @@ namespace Activizr
|
||||
string cultureString = Thread.CurrentThread.CurrentCulture.ToString();
|
||||
string cultureStringLower = cultureString.ToLowerInvariant();
|
||||
|
||||
if (cultureStringLower == "en-us")
|
||||
{
|
||||
// doesn't work with tooltip styling for some completely inexplicable reason, use en-gb
|
||||
|
||||
cultureString = "en-GB";
|
||||
cultureStringLower = "en-gb";
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureString);
|
||||
|
||||
HttpCookie cookieCulture = new HttpCookie("PreferredCulture");
|
||||
cookieCulture.Value = cultureString;
|
||||
cookieCulture.Expires = DateTime.Now.AddDays(365);
|
||||
Response.Cookies.Add(cookieCulture);
|
||||
}
|
||||
|
||||
string flagName = "uk";
|
||||
|
||||
if (cultureStringLower != "en-us" && cultureString.Length > 3)
|
||||
if (cultureStringLower != "en-gb" && cultureString.Length > 3)
|
||||
{
|
||||
flagName = cultureStringLower.Substring(3);
|
||||
}
|
||||
@@ -107,7 +121,7 @@ namespace Activizr
|
||||
this.LinkLogout.Text = Resources.Pages.Global.CurrentUserInfo_Logout;
|
||||
this.LabelPreferences.Text = Resources.Pages.Global.CurrentUserInfo_Preferences;
|
||||
|
||||
if (cultureStringLower != "en-us" && cultureStringLower != "sv-se" && cultureString.Trim().Length > 0)
|
||||
if (cultureStringLower != "en-gb" && cultureStringLower != "sv-se" && cultureString.Trim().Length > 0)
|
||||
{
|
||||
this.LinkTranslate.Visible = true;
|
||||
}
|
||||
|
||||
@@ -10,13 +10,23 @@
|
||||
<div class="entrylabels" style="margin-right:30px;width:200px">
|
||||
<strong><asp:Label ID="LabelAccountHeader" Text="Account [LOC]" runat="server" /></strong><br/>
|
||||
<asp:Repeater ID="RepeaterAccountNames" runat="server" OnItemDataBound="RepeaterAccountNames_ItemDataBound" ><ItemTemplate><asp:Label ID="LabelAccountName" runat="server" Text="Unset Account Name" /> <em>(<asp:Label ID="LabelAccountType" runat="server" Text="Type [LOC]" />)</em><br /></ItemTemplate></asp:Repeater>
|
||||
<em><asp:Label ID="LabelYearlyResultLabel" runat="server" Text="Yearly Result [LOC]" /></em>
|
||||
</div>
|
||||
|
||||
<div class="entryfields">
|
||||
<strong>Budget, Owner [LOC]</strong><br/>
|
||||
<asp:Repeater ID="RepeaterAccountBudgets" OnItemDataBound="RepeaterAccountBudgets_ItemDataBound" runat="server"><ItemTemplate><asp:HiddenField runat="server" ID="HiddenAccountId" /><asp:TextBox ID="TextBudget" runat="server" Text="Not set" /> <span style="border-bottom: dashed 1px #808080;cursor:pointer"><asp:Label ID="LabelBudgetOwner" runat="server" /></span><telerik:RadToolTip ID="ToolTip" runat="server" AnimationDuration="150" AutoCloseDelay="200000" ShowDelay="0"
|
||||
<asp:Repeater ID="RepeaterAccountBudgets" OnItemDataBound="RepeaterAccountBudgets_ItemDataBound" runat="server"><ItemTemplate><asp:HiddenField runat="server" ID="HiddenAccountId" /><asp:TextBox ID="TextBudget" runat="server" Text="Not set" /> <span style="border-bottom: dashed 1px #808080;cursor:pointer"><asp:Label ID="LabelBudgetOwner" runat="server" /></span><telerik:RadToolTip ID="ToolTip" runat="server" AnimationDuration="150" AutoCloseDelay="200000" ShowDelay="0"
|
||||
EnableShadow="true" HideDelay="1" Width="288px" Height="96px" HideEvent="ManualClose" OffsetX="30" OffsetY="0"
|
||||
RelativeTo="Element" Animation="Slide" Position="TopCenter" ShowCallout="true" TargetControlID="LabelBudgetOwner" RenderInPageRoot="true" ShowEvent="OnClick"
|
||||
Skin="Telerik"><act5:PersonDetailPopup runat="server" ID="PersonDetail" /></telerik:RadToolTip><br/></ItemTemplate></asp:Repeater>
|
||||
<asp:TextBox ID="TextYearlyResult" Text="Yearly Result (fill in programmatically)" runat="server" ReadOnly="true" Enabled="false" /> <br/>
|
||||
<asp:Button ID="ButtonSetBudgets" Text="Set New Budgets [LOC]" OnClick="ButtonSetBudgets_Click" runat="server" />
|
||||
</div>
|
||||
|
||||
<div class="entrylabels" style="margin-left:20px;width:100px;text-align:right">
|
||||
<strong><asp:Label ID="LabelActualsHeader" Text="Actuals [LOC]" runat="server" /></strong><br/>
|
||||
<asp:Repeater ID="RepeaterAccountActuals" runat="server" OnItemDataBound="RepeaterAccountActuals_ItemDataBound"><ItemTemplate><asp:Label ID="LabelAccountActuals" Text="Unset actuals" runat="server" /><br/></ItemTemplate></asp:Repeater>
|
||||
<asp:Label ID="LabelYearlyResultActuals" runat="server" Text="Yearly Result [LOC]" /><br/>
|
||||
</div>
|
||||
|
||||
<div style="clear:both"></div>
|
||||
@@ -24,7 +34,7 @@
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
|
||||
|
||||
<h2 class="blue"><asp:Label ID="LabelSidebarInfo" runat="server" /><span class="arrow"></span></h2>
|
||||
<h2 class="blue"><asp:Label ID="LabelSidebarInfo" runat="server" Text="INFO [Loc]" /><span class="arrow"></span></h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
@@ -32,7 +42,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="blue"><asp:Label ID="LabelSidebarActions" runat="server" /><span class="arrow"></span></h2>
|
||||
<h2 class="blue"><asp:Label ID="LabelSidebarActions" Text="ACTIONS [Loc]" runat="server" /><span class="arrow"></span></h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="content"><!--
|
||||
@@ -47,7 +57,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="orange"><asp:Label ID="LabelSidebarTodo" runat="server" /><span class="arrow"></span></h2>
|
||||
<h2 class="orange"><asp:Label ID="LabelSidebarTodo" Text="TODO [Loc]" runat="server" /><span class="arrow"></span></h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
|
||||
@@ -38,6 +38,11 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base
|
||||
|
||||
this.RepeaterAccountBudgets.DataSource = accounts;
|
||||
this.RepeaterAccountBudgets.DataBind();
|
||||
|
||||
this.RepeaterAccountActuals.DataSource = accounts;
|
||||
this.RepeaterAccountActuals.DataBind();
|
||||
|
||||
UpdateYearlyResult(accounts);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -45,6 +50,26 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base
|
||||
}
|
||||
|
||||
this.DropYears.Style[HtmlTextWriterStyle.FontWeight] = "bold";
|
||||
this.ButtonSetBudgets.Style[HtmlTextWriterStyle.MarginTop] = "4px";
|
||||
this.ButtonSetBudgets.Style[HtmlTextWriterStyle.MarginBottom] = "5px";
|
||||
}
|
||||
|
||||
protected void UpdateYearlyResult(FinancialAccounts rootAccounts)
|
||||
{
|
||||
Int64 budgetSum = 0;
|
||||
Int64 actualSum = 0;
|
||||
|
||||
foreach (FinancialAccount account in rootAccounts)
|
||||
{
|
||||
budgetSum += account.GetTree().GetBudgetSumCents(_year)/100;
|
||||
actualSum -= account.GetTree().GetDeltaCents(new DateTime(_year,1,1), new DateTime(_year+1, 1, 1))/100; // negative: results accounts are sign reversed
|
||||
}
|
||||
|
||||
this.TextYearlyResult.Text = String.Format("{0:N0}", budgetSum);
|
||||
this.TextYearlyResult.Style[HtmlTextWriterStyle.Width] = "80px";
|
||||
this.TextYearlyResult.Style[HtmlTextWriterStyle.TextAlign] = "right";
|
||||
|
||||
this.LabelYearlyResultActuals.Text = String.Format("{0:N0}", actualSum);
|
||||
}
|
||||
|
||||
private int _year;
|
||||
@@ -81,9 +106,9 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base
|
||||
|
||||
FinancialAccount account = (FinancialAccount)item.DataItem;
|
||||
|
||||
TextBox textBudget = (TextBox) e.Item.FindControl("TextBudget");
|
||||
TextBox textBudget = (TextBox) e.Item.FindControl("TextBudget");
|
||||
|
||||
textBudget.Text = String.Format("{0:N0}", account.GetBudgetCents(_year)/100);
|
||||
textBudget.Text = String.Format("{0:N0}", account.GetTree().GetBudgetSumCents(_year)/100);
|
||||
textBudget.Style[HtmlTextWriterStyle.TextAlign] = "right";
|
||||
textBudget.Style[HtmlTextWriterStyle.Width] = "80px";
|
||||
|
||||
@@ -138,14 +163,20 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base
|
||||
{
|
||||
FinancialAccounts accounts = GetRootLevelResultAccounts();
|
||||
|
||||
UpdateYearlyResult(accounts);
|
||||
|
||||
this.RepeaterAccountBudgets.DataSource = accounts;
|
||||
this.RepeaterAccountBudgets.DataBind();
|
||||
|
||||
this.RepeaterAccountActuals.DataSource = accounts;
|
||||
this.RepeaterAccountActuals.DataBind();
|
||||
|
||||
this.RebindTooltips();
|
||||
}
|
||||
|
||||
private FinancialAccounts GetRootLevelResultAccounts()
|
||||
{
|
||||
FinancialAccount yearlyResult = _currentOrganization.FinancialAccounts.CostsYearlyResult;
|
||||
FinancialAccounts allAccounts = FinancialAccounts.ForOrganization(_currentOrganization, FinancialAccountType.Result);
|
||||
|
||||
// Select root accounts
|
||||
@@ -154,7 +185,7 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base
|
||||
|
||||
foreach (FinancialAccount account in allAccounts)
|
||||
{
|
||||
if (account.ParentFinancialAccountId == 0)
|
||||
if (account.ParentFinancialAccountId == 0 && account.Identity != yearlyResult.Identity)
|
||||
{
|
||||
accounts.Add(account);
|
||||
}
|
||||
@@ -179,4 +210,28 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base
|
||||
personDetail.Account = account;
|
||||
}
|
||||
}
|
||||
|
||||
protected void RepeaterAccountActuals_ItemDataBound(object sender, RepeaterItemEventArgs e)
|
||||
{
|
||||
RepeaterItem item = e.Item;
|
||||
|
||||
if (item.DataItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FinancialAccount account = (FinancialAccount)item.DataItem;
|
||||
|
||||
Label labelActuals = (Label) e.Item.FindControl("LabelAccountActuals");
|
||||
|
||||
Int64 actuals = account.GetTree().GetDeltaCents(new DateTime(_year, 1, 1), new DateTime(_year + 1, 1, 1))/
|
||||
100;
|
||||
|
||||
labelActuals.Text = String.Format("{0:N0}", -actuals); // negative as results accounts are sign reversed
|
||||
}
|
||||
|
||||
protected void ButtonSetBudgets_Click(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public partial class Tests_TestBookkeepingIntegrity : PageV5Base
|
||||
FinancialAccountType.Result);
|
||||
|
||||
FinancialAccount ownCapital = _currentOrganization.FinancialAccounts.DebtsCapital;
|
||||
FinancialAccount resultAsNoted = _currentOrganization.FinancialAccounts.CostsYearResult;
|
||||
FinancialAccount resultAsNoted = _currentOrganization.FinancialAccounts.CostsYearlyResult;
|
||||
|
||||
FinancialAccounts balancesWithoutCapital =
|
||||
FinancialAccounts.ForOrganization(_currentOrganization, FinancialAccountType.Balance);
|
||||
@@ -46,7 +46,7 @@ public partial class Tests_TestBookkeepingIntegrity : PageV5Base
|
||||
|
||||
FinancialAccounts resultAccountsWithoutNotedResult = FinancialAccounts.ForOrganization(_currentOrganization,
|
||||
FinancialAccountType.Result);
|
||||
resultAccountsWithoutNotedResult.Remove(_currentOrganization.FinancialAccounts.CostsYearResult);
|
||||
resultAccountsWithoutNotedResult.Remove(_currentOrganization.FinancialAccounts.CostsYearlyResult);
|
||||
|
||||
Currency currency = _currentOrganization.DefaultCountry.Currency;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user