Good first results with Account Plan page.

This commit is contained in:
Rick Falkvinge
2014-02-18 02:15:20 +00:00
parent 2f1e2697f1
commit c10a0517e9
18 changed files with 380 additions and 143 deletions
@@ -24,6 +24,14 @@ namespace Swarmops.Basic.Enums
/// </summary>
AssetsPaypal,
/// <summary>
/// Assets held in bitcoin (if any), immediately accessible.
/// </summary>
AssetsBitcoinHot,
/// <summary>
/// Assets held in bitcoin cold storage (if any).
/// </summary>
AssetsBitcoinCold,
/// <summary>
/// Any outstanding cash advances that have been paid out and not cleared against receipts or paid back
/// </summary>
AssetsOutstandingCashAdvances,
@@ -80,6 +88,10 @@ namespace Swarmops.Basic.Enums
/// </summary>
CostsBankFees,
/// <summary>
/// Gains from currency fluctuation (typically bitcoin or altcoins).
/// </summary>
IncomeCurrencyFluctuations,
/// <summary>
/// IT and such - default SMS charges, etc, here
/// </summary>
CostsInfrastructure,
@@ -92,6 +104,10 @@ namespace Swarmops.Basic.Enums
/// </summary>
CostsAllocatedFunds,
/// <summary>
/// Losses from currency fluctuation (typically bitcoin or altcoins).
/// </summary>
CostsCurrencyFluctuations,
/// <summary>
/// When closing books, this is the yearly result (balanced against DebtsEquity)
/// </summary>
CostsYearlyResult, // multi-account type
+6 -7
View File
@@ -103,7 +103,7 @@ namespace Swarmops.Logic.Financial
public static FinancialAccounts GetTree(FinancialAccount rootAccount)
{
Dictionary<int, FinancialAccounts> nodes = GetHashedAccounts();
Dictionary<int, FinancialAccounts> nodes = GetHashedAccounts(rootAccount.Organization);
return GetTree(nodes, rootAccount.Identity, 0);
}
@@ -161,7 +161,7 @@ namespace Swarmops.Logic.Financial
return result;
}
protected static Dictionary<int, FinancialAccounts> GetHashedAccounts()
public static Dictionary<int, FinancialAccounts> GetHashedAccounts(Organization organization)
{
// This generates a Dictionary <int,List<FinancialAccount>>.
//
@@ -173,7 +173,7 @@ namespace Swarmops.Logic.Financial
Dictionary<int, FinancialAccounts> result = new Dictionary<int, FinancialAccounts>();
FinancialAccounts allAccounts = FromArray(SwarmDb.GetDatabaseForReading().GetFinancialAccountsForOrganization(Organization.PPSEid)); // HACK HACK HACK
FinancialAccounts allAccounts = FromArray(SwarmDb.GetDatabaseForReading().GetFinancialAccountsForOrganization(organization.Identity));
// Add the nodes.
@@ -187,12 +187,11 @@ namespace Swarmops.Logic.Financial
// Add the children.
result[0] = new FinancialAccounts(); // for the root-level accounts
foreach (FinancialAccount account in allAccounts)
{
if (account.ParentIdentity != 0)
{
result[account.ParentIdentity].Add(account);
}
result[account.ParentIdentity].Add(account);
}
return result;
+6 -2
View File
@@ -233,8 +233,12 @@ namespace Swarmops.Logic.Structure
FinancialAccount.Create(this.Identity, "Outbound Invoices", FinancialAccountType.Asset, 0);
FinancialAccounts[OrganizationFinancialAccountType.AssetsOutstandingCashAdvances] =
FinancialAccount.Create(this.Identity, "Cash Advances", FinancialAccountType.Asset, 0);
FinancialAccounts[OrganizationFinancialAccountType.AssetsPaypal] =
FinancialAccount.Create(this.Identity, "Paypal Account", FinancialAccountType.Asset, 0);
//FinancialAccounts[OrganizationFinancialAccountType.AssetsPaypal] =
// FinancialAccount.Create(this.Identity, "Paypal Account", FinancialAccountType.Asset, 0);
//FinancialAccounts[OrganizationFinancialAccountType.AssetsBitcoinHot] =
// FinancialAccount.Create(this.Identity, "Bitcoin Holdings (Hot)", FinancialAccountType.Asset, 0);
//FinancialAccounts[OrganizationFinancialAccountType.AssetsBitcoinCold] =
// FinancialAccount.Create(this.Identity, "Bitcoin Cold Storage", FinancialAccountType.Asset, 0);
FinancialAccounts[OrganizationFinancialAccountType.AssetsVat] =
FinancialAccount.Create(this.Identity, "Inbound Value Added Tax", FinancialAccountType.Asset, 0);
FinancialAccounts[OrganizationFinancialAccountType.CostsAllocatedFunds] =
@@ -117,6 +117,15 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AccountPlan_CreateRootAccount" xml:space="preserve">
<value>Create new root account</value>
</data>
<data name="AccountPlan_Info" xml:space="preserve">
<value>This is the overview of the financial accounts in your bookkeeping ledger. You can do some maintenance from here, even if most of the daily operations should be delegated to the budget owners.</value>
</data>
<data name="AccountPlan_PageTitle" xml:space="preserve">
<value>Account Plan</value>
</data>
<data name="BalanceSheet_AccountName" xml:space="preserve">
<value>Account</value>
</data>
Binary file not shown.

After

Width:  |  Height:  |  Size: 812 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

+1 -1
View File
@@ -186,7 +186,7 @@
<telerik:RadMenuItem runat="server" Text="XYZ P&L Statement" Permission="All" UserLevel="3" NavigateUrl="~/Pages/v5/Ledgers/ProfitLossStatement.aspx" ImageUrl="~/Images/PageIcons/iconshock-abacus-16px.png" GlobalResourceKey="Menu5_Ledgers_ProfitLossStatement" />
<telerik:RadMenuItem runat="server" IsSeparator="true" UserLevel="3" />
<telerik:RadMenuItem runat="server" Text="XYZ Audit Ledgers" ImageUrl="~/Images/PageIcons/iconshock-ledger-inspect-16px.png" Permission="EconomyDetail:Read" UserLevel="3" GlobalResourceKey="Menu5_Ledgers_AuditLedgers" />
<telerik:RadMenuItem runat="server" Text="XYZ Account Plan" Permission="Economy:Read" UserLevel="3" GlobalResourceKey="Menu5_Ledgers_AccountPlan" />
<telerik:RadMenuItem runat="server" Text="XYZ Account Plan" ImageUrl="~/Images/PageIcons/iconshock-openbook-16px.png" NavigateUrl="~/Pages/v5/Ledgers/AccountPlan.aspx" Permission="Economy:Read" UserLevel="3" GlobalResourceKey="Menu5_Ledgers_AccountPlan" />
<telerik:RadMenuItem runat="server" Text="XYZ Set Budget" NavigateUrl="~/Pages/v5/Ledgers/SetRootBudgets.aspx" ImageUrl="~/Images/PageIcons/iconshock-moneybag-16px.png" Permission="Financial:Write" UserLevel="3" GlobalResourceKey="Menu5_Ledgers_SetBudgets" />
<telerik:RadMenuItem runat="server" IsSeparator="true" UserLevel="3" />
<telerik:RadMenuItem runat="server" Text="XYZ Upload Bank Files" NavigateUrl="~/Pages/v5/Ledgers/UploadBankFiles.aspx" ImageUrl="~/Images/PageIcons/iconshock-bank-16px.png" Permission="Economy:Write" UserLevel="3" GlobalResourceKey="Menu5_Ledgers_UploadBankFiles" />
+51
View File
@@ -0,0 +1,51 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="AccountPlan.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.AccountPlan" %>
<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<Swarmops5:ExternalScripts ID="ExternalScripts1" Package="easyui" Control="tree" runat="server" />
<script type="text/javascript">
$(document).ready(function () {
$('#tableAccountPlan').treegrid(
{
onLoadSuccess: function () {
$('div.datagrid').css('opacity', 1);
}
});
$('div.datagrid').css('opacity', 0.4);
});
var currentYear = <%=DateTime.Today.Year %>;
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<h2><asp:Label ID="LabelContentHeader" runat="server" /></h2>
<table id="tableAccountPlan" title="" class="easyui-treegrid" style="width:680px;height:600px"
url="Json-AccountPlanData.aspx"
rownumbers="false"
animate="true"
fitColumns="false"
idField="id" treeField="accountName">
<thead>
<tr>
<th field="accountName" width="240"><asp:Literal ID="LiteralHeaderAccountName" runat="server"/>Account Name</th>
<th field="budget" width="160" align="left">Owner</th>
<th field="balance" width="80" align="right">Balance</th>
<th field="budget" width="80" align="right">Budget</th>
<th field="class" width="80" align="center">Flags</th>
<th field="action" width="40" align="center">Edit</th>
</tr>
</thead>
</table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
</asp:Content>
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Swarmops.Frontend.Pages.v5.Ledgers
{
public partial class AccountPlan : PageV5Base
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.CurrentOrganization.IsEconomyEnabled)
{
Response.Redirect("/Pages/v5/Financial/EconomyNotEnabled.aspx", true);
return;
}
this.PageIcon = "iconshock-openbook";
this.PageTitle = Resources.Pages.Ledgers.AccountPlan_PageTitle;
this.InfoBoxLiteral = Resources.Pages.Ledgers.AccountPlan_Info;
}
}
}
+14 -14
View File
@@ -1,4 +1,4 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="BalanceSheet.aspx.cs" Inherits="Pages_v5_Ledgers_BalanceSheet" %>
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="BalanceSheet.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.BalanceSheet" %>
<%@ Register src="~/Controls/v5/UI/ExternalScripts.ascx" tagname="ExternalScripts" tagprefix="Swarmops5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
@@ -86,20 +86,20 @@
animate="true"
fitColumns="true"
idField="id" treeField="name">
<thead>
<tr>
<th field="name" width="178"><asp:Literal ID="LiteralHeaderAccountName" runat="server"/></th>
<th field="lastYear" width="80" align="right"><span class="commonHeader" id="headerStartYear" style="display:none"></span><span class="loadingHeader">&mdash;</span></th>
<th field="q1" width="80" align="right"><span class="commonHeader" id="headerQ1" style="display:none"><asp:Literal ID="LiteralHeaderQ1" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="q2" width="80" align="right"><span class="commonHeader" id="headerQ2" style="display:none"><asp:Literal ID="LiteralHeaderQ2" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="q3" width="80" align="right"><span class="commonHeader" id="headerQ3" style="display:none"><asp:Literal ID="LiteralHeaderQ3" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="q4" width="80" align="right"><span class="commonHeader" id="headerQ4" style="display:none"><asp:Literal ID="LiteralHeaderQ4" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="ytd" width="80" align="right"><span class="previousYearsHeader" id="previousYtd" style="display:none"></span><span class="currentYearHeader" style="display:none"><asp:Literal ID="LiteralHeaderYtd" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
</tr>
</thead>
</table>
<thead>
<tr>
<th field="name" width="178"><asp:Literal ID="LiteralHeaderAccountName" runat="server"/></th>
<th field="lastYear" width="80" align="right"><span class="commonHeader" id="headerStartYear" style="display:none"></span><span class="loadingHeader">&mdash;</span></th>
<th field="q1" width="80" align="right"><span class="commonHeader" id="headerQ1" style="display:none"><asp:Literal ID="LiteralHeaderQ1" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="q2" width="80" align="right"><span class="commonHeader" id="headerQ2" style="display:none"><asp:Literal ID="LiteralHeaderQ2" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="q3" width="80" align="right"><span class="commonHeader" id="headerQ3" style="display:none"><asp:Literal ID="LiteralHeaderQ3" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="q4" width="80" align="right"><span class="commonHeader" id="headerQ4" style="display:none"><asp:Literal ID="LiteralHeaderQ4" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="ytd" width="80" align="right"><span class="previousYearsHeader" id="previousYtd" style="display:none"></span><span class="currentYearHeader" style="display:none"><asp:Literal ID="LiteralHeaderYtd" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
</tr>
</thead>
</table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
<h2 class="blue"><asp:Label ID="LabelSidebarDownload" Text="Download This" runat="server" /><span class="arrow"></span></h2>
+37 -33
View File
@@ -6,45 +6,49 @@ using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
public partial class Pages_v5_Ledgers_BalanceSheet : PageV5Base
namespace Swarmops.Frontend.Pages.v5.Ledgers
{
protected void Page_Load(object sender, EventArgs e)
public partial class BalanceSheet : PageV5Base
{
if (!this.CurrentOrganization.IsEconomyEnabled)
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect("/Pages/v5/Financial/EconomyNotEnabled.aspx", true);
return;
}
this.PageIcon = "iconshock-treasure";
this.PageTitle = Resources.Pages.Ledgers.BalanceSheet_PageTitle;
this.InfoBoxLiteral = Resources.Pages.Ledgers.BalanceSheet_Info;
if (!Page.IsPostBack)
{
int year = DateTime.Today.Year;
int firstFiscalYear = CurrentOrganization.FirstFiscalYear;
while (year >= firstFiscalYear)
if (!this.CurrentOrganization.IsEconomyEnabled)
{
this.DropYears.Items.Add(year.ToString(CultureInfo.InvariantCulture));
year--;
Response.Redirect("/Pages/v5/Financial/EconomyNotEnabled.aspx", true);
return;
}
Localize();
this.PageIcon = "iconshock-treasure";
this.PageTitle = Resources.Pages.Ledgers.BalanceSheet_PageTitle;
this.InfoBoxLiteral = Resources.Pages.Ledgers.BalanceSheet_Info;
if (!Page.IsPostBack)
{
int year = DateTime.Today.Year;
int firstFiscalYear = CurrentOrganization.FirstFiscalYear;
while (year >= firstFiscalYear)
{
this.DropYears.Items.Add(year.ToString(CultureInfo.InvariantCulture));
year--;
}
Localize();
}
}
private void Localize()
{
this.LabelContentHeader.Text = string.Format(Resources.Pages.Ledgers.BalanceSheet_ContentHeader,
CurrentOrganization.Name);
this.LiteralHeaderQ1.Text = Resources.Pages.Ledgers.BalanceSheet_Q1;
this.LiteralHeaderQ2.Text = Resources.Pages.Ledgers.BalanceSheet_Q2;
this.LiteralHeaderQ3.Text = Resources.Pages.Ledgers.BalanceSheet_Q3;
this.LiteralHeaderQ4.Text = Resources.Pages.Ledgers.BalanceSheet_Q4;
this.LiteralHeaderYtd.Text = Resources.Pages.Ledgers.BalanceSheet_Current;
this.LiteralHeaderAccountName.Text = Resources.Pages.Ledgers.BalanceSheet_AccountName;
}
}
private void Localize()
{
this.LabelContentHeader.Text = string.Format(Resources.Pages.Ledgers.BalanceSheet_ContentHeader, CurrentOrganization.Name);
this.LiteralHeaderQ1.Text = Resources.Pages.Ledgers.BalanceSheet_Q1;
this.LiteralHeaderQ2.Text = Resources.Pages.Ledgers.BalanceSheet_Q2;
this.LiteralHeaderQ3.Text = Resources.Pages.Ledgers.BalanceSheet_Q3;
this.LiteralHeaderQ4.Text = Resources.Pages.Ledgers.BalanceSheet_Q4;
this.LiteralHeaderYtd.Text = Resources.Pages.Ledgers.BalanceSheet_Current;
this.LiteralHeaderAccountName.Text = Resources.Pages.Ledgers.BalanceSheet_AccountName;
}
}
@@ -0,0 +1 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-AccountPlanData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.AccountPlanData" %>
@@ -0,0 +1,104 @@
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.Security;
namespace Swarmops.Frontend.Pages.v5.Ledgers
{
public partial class AccountPlanData : DataV5Base
{
protected void Page_Load(object sender, EventArgs e)
{
_authenticationData = GetAuthenticationDataAndCulture();
_year = DateTime.Today.Year;
if (!_authenticationData.CurrentUser.HasAccess(new Access(_authenticationData.CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read)))
{
throw new UnauthorizedAccessException();
}
// TODO: Get and cache account tree and account balances
Response.ContentType = "application/json";
string response = string.Empty;
_hashedAccounts = FinancialAccounts.GetHashedAccounts(_authenticationData.CurrentOrganization);
response += GetAccountGroup(FinancialAccountType.Asset, Resources.Pages.Ledgers.BalanceSheet_Assets) + ",";
response += GetAccountGroup(FinancialAccountType.Debt, Resources.Pages.Ledgers.BalanceSheet_Debt) + ",";
response += GetAccountGroup(FinancialAccountType.Income, Resources.Pages.Ledgers.ProfitLossStatement_Income) + ",";
response += GetAccountGroup(FinancialAccountType.Cost, Resources.Pages.Ledgers.ProfitLossStatement_Costs);
Response.Output.WriteLine("[" + response + "]");
Response.End();
}
private int _year = 2012;
private CultureInfo _renderCulture;
private AuthenticationData _authenticationData;
private Dictionary<int, FinancialAccounts> _hashedAccounts;
private string GetAccountGroup (FinancialAccountType type, string localizedGroupName)
{
string childrenString = GetAccountsRecurse(type, 0);
return "{\"id\":\"" + -((int) type) + "\",\"accountName\":\"" + JsonSanitize(localizedGroupName) +
"\",\"state\":\"open\",\"children\":[" + childrenString + "]}";
}
private string GetAccountsRecurse (FinancialAccountType accountType, int rootNodeId)
{
List<string> childStrings = new List<string>();
if (!_hashedAccounts.ContainsKey(rootNodeId))
{
return string.Empty;
}
if (_hashedAccounts [rootNodeId].Count == 1)
{
// No children
return string.Empty;
}
foreach (FinancialAccount account in _hashedAccounts[rootNodeId])
{
if (account.Identity == rootNodeId || account.AccountType != accountType)
{
continue;
}
string grandChildren = GetAccountsRecurse(accountType, account.Identity);
if (!string.IsNullOrEmpty(grandChildren))
{
grandChildren = ",\"state\":\"closed\",\"children\":[" + grandChildren + "]";
}
childStrings.Add('{' + String.Format("\"id\":\"{0}\",\"accountName\":\"{1}\"", account.Identity, JsonSanitize(account.Name)) + grandChildren + '}');
}
return String.Join(",", childStrings.ToArray());
}
private class DisplayedAccount
{
public string Name;
public int Identity;
};
private class DisplayedAccounts : List<DisplayedAccount>
{
// typedef
};
}
}
@@ -1 +1 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-BalanceSheetData.aspx.cs" Inherits="Pages_v5_Ledgers_Json_BalanceSheetData" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-BalanceSheetData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.BalanceSheetData" %>
@@ -12,117 +12,131 @@ using Swarmops.Logic.Swarm;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
public partial class Pages_v5_Ledgers_Json_BalanceSheetData : DataV5Base
namespace Swarmops.Frontend.Pages.v5.Ledgers
{
protected void Page_Load(object sender, EventArgs e)
public partial class BalanceSheetData : DataV5Base
{
// Get auth data
_authenticationData = GetAuthenticationDataAndCulture();
// Get current year
_year = DateTime.Today.Year;
string yearParameter = Request.QueryString["Year"];
if (!string.IsNullOrEmpty(yearParameter))
protected void Page_Load(object sender, EventArgs e)
{
_year = Int32.Parse(yearParameter); // will throw if non-numeric - don't matter for app
// Get auth data
_authenticationData = GetAuthenticationDataAndCulture();
// Get current year
_year = DateTime.Today.Year;
string yearParameter = Request.QueryString["Year"];
if (!string.IsNullOrEmpty(yearParameter))
{
_year = Int32.Parse(yearParameter); // will throw if non-numeric - don't matter for app
}
YearlyReport report = YearlyReport.Create(_authenticationData.CurrentOrganization, _year,
FinancialAccountType.Balance);
LocalizeRoot(report.ReportLines);
Response.ContentType = "application/json";
Response.Output.WriteLine(RecurseReport(report.ReportLines));
Response.End();
}
YearlyReport report = YearlyReport.Create(_authenticationData.CurrentOrganization, _year, FinancialAccountType.Balance);
LocalizeRoot(report.ReportLines);
Response.ContentType = "application/json";
Response.Output.WriteLine(RecurseReport(report.ReportLines));
Response.End();
}
private AuthenticationData _authenticationData;
private AuthenticationData _authenticationData;
private void LocalizeRoot(List<YearlyReportLine> lines)
{
Dictionary<string, string> localizeMap = new Dictionary<string, string>();
localizeMap["%ASSET_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.BalanceSheet_Assets;
localizeMap["%DEBT_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.BalanceSheet_Debt;
localizeMap["%INCOME_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.ProfitLossStatement_Income;
localizeMap["%COST_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.ProfitLossStatement_Costs;
foreach (YearlyReportLine line in lines)
private void LocalizeRoot(List<YearlyReportLine> lines)
{
if (localizeMap.ContainsKey(line.AccountName))
Dictionary<string, string> localizeMap = new Dictionary<string, string>();
localizeMap["%ASSET_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.BalanceSheet_Assets;
localizeMap["%DEBT_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.BalanceSheet_Debt;
localizeMap["%INCOME_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.ProfitLossStatement_Income;
localizeMap["%COST_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.ProfitLossStatement_Costs;
foreach (YearlyReportLine line in lines)
{
line.AccountName = localizeMap[line.AccountName];
if (localizeMap.ContainsKey(line.AccountName))
{
line.AccountName = localizeMap[line.AccountName];
}
}
}
}
private int _year = 2012;
private CultureInfo _renderCulture;
private int _year = 2012;
private CultureInfo _renderCulture;
private string RecurseReport(List<YearlyReportLine> reportLines)
{
List<string> elements = new List<string>();
foreach (YearlyReportLine line in reportLines)
private string RecurseReport(List<YearlyReportLine> reportLines)
{
string element = string.Format("\"id\":{0},\"name\":\"{1}\"", line.AccountId,
JsonSanitize(line.AccountName));
List<string> elements = new List<string>();
if (line.Children.Count > 0)
foreach (YearlyReportLine line in reportLines)
{
string element = string.Format("\"id\":{0},\"name\":\"{1}\"", line.AccountId,
JsonSanitize(line.AccountName));
element += ",\"lastYear\":" +
JsonDualString(line.AccountId, line.AccountTreeValues.PreviousYear, line.AccountValues.PreviousYear);
for (int quarter = 1; quarter <= 4; quarter++)
if (line.Children.Count > 0)
{
element += string.Format(",\"q{0}\":", quarter) +
JsonDualString(line.AccountId, line.AccountTreeValues.Quarters[quarter - 1], line.AccountValues.Quarters[quarter - 1]);
element += ",\"lastYear\":" +
JsonDualString(line.AccountId, line.AccountTreeValues.PreviousYear,
line.AccountValues.PreviousYear);
for (int quarter = 1; quarter <= 4; quarter++)
{
element += string.Format(",\"q{0}\":", quarter) +
JsonDualString(line.AccountId, line.AccountTreeValues.Quarters[quarter - 1],
line.AccountValues.Quarters[quarter - 1]);
}
element += ",\"ytd\":" +
JsonDualString(line.AccountId, line.AccountTreeValues.ThisYear,
line.AccountValues.ThisYear);
element += ",\"state\":\"closed\",\"children\":" + RecurseReport(line.Children);
}
else
{
element += string.Format(_renderCulture, ",\"lastYear\":\"{0:N0}\"",
(double) line.AccountValues.PreviousYear/100.0);
for (int quarter = 1; quarter <= 4; quarter++)
{
element += string.Format(_renderCulture, ",\"q{0}\":\"{1:N0}\"", quarter,
line.AccountValues.Quarters[quarter - 1]/100.0);
}
element += string.Format(_renderCulture, ",\"ytd\":\"{0:N0}\"",
(double) line.AccountValues.ThisYear/100.0);
}
element += ",\"ytd\":" +
JsonDualString(line.AccountId, line.AccountTreeValues.ThisYear, line.AccountValues.ThisYear);
element += ",\"state\":\"closed\",\"children\":" + RecurseReport(line.Children);
}
else
{
element += string.Format(_renderCulture, ",\"lastYear\":\"{0:N0}\"", (double)line.AccountValues.PreviousYear / 100.0);
for (int quarter = 1; quarter <= 4; quarter++)
{
element += string.Format(_renderCulture, ",\"q{0}\":\"{1:N0}\"", quarter, line.AccountValues.Quarters[quarter - 1] / 100.0);
}
element += string.Format(_renderCulture, ",\"ytd\":\"{0:N0}\"", (double)line.AccountValues.ThisYear / 100.0);
elements.Add("{" + element + "}");
}
elements.Add("{" + element + "}");
return "[" + String.Join(",", elements.ToArray()) + "]";
}
return "[" + String.Join(",", elements.ToArray()) + "]";
}
private string JsonDualString(int accountId, Int64 treeValue, Int64 singleValue)
{
if (treeValue != 0 && singleValue == 0)
private string JsonDualString(int accountId, Int64 treeValue, Int64 singleValue)
{
return string.Format(_renderCulture, "\"<span class=\\\"profitlossdata-collapsed-{0}\\\"><strong>&Sigma;</strong> {1:N0}</span><span class=\\\"profitlossdata-expanded-{0}\\\" style=\\\"display:none\\\">&nbsp;</span>\"", accountId, treeValue / 100.00);
if (treeValue != 0 && singleValue == 0)
{
return string.Format(_renderCulture,
"\"<span class=\\\"profitlossdata-collapsed-{0}\\\"><strong>&Sigma;</strong> {1:N0}</span><span class=\\\"profitlossdata-expanded-{0}\\\" style=\\\"display:none\\\">&nbsp;</span>\"",
accountId, treeValue/100.00);
}
return string.Format(_renderCulture,
"\"<span class=\\\"profitlossdata-collapsed-{0}\\\"><strong>&Sigma;</strong> {1:N0}</span><span class=\\\"profitlossdata-expanded-{0}\\\" style=\\\"display:none\\\">{2:N0}</span>\"",
accountId, treeValue/100.0, singleValue/100.0);
}
return string.Format(_renderCulture, "\"<span class=\\\"profitlossdata-collapsed-{0}\\\"><strong>&Sigma;</strong> {1:N0}</span><span class=\\\"profitlossdata-expanded-{0}\\\" style=\\\"display:none\\\">{2:N0}</span>\"", accountId, treeValue / 100.0, singleValue / 100.0);
}
}
@@ -7,7 +7,7 @@
<script type="text/javascript">
$(document).ready(function () {
$('#OrganizationId').combotree({
$('#DropOrganizations').combotree({
animate: true,
height: 30
});
@@ -20,7 +20,7 @@
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<div class="entryFields">
<span style="margin-left:12px"><asp:Label runat="server" ID="LabelCurrentOrganizationName" /></span>&nbsp;<br/>
<select class="easyui-combotree" url="Json-AccessibleOrganizationsTree.aspx" name="OrganizationId" id="OrganizationId" animate="true" style="width:300px" height="30"></select>
<select class="easyui-combotree" url="Json-AccessibleOrganizationsTree.aspx" name="DropOrganizations" id="DropOrganizations" animate="true" style="width:300px" height="30"></select>
<asp:Button ID="ButtonSwitch" runat="server" CssClass="buttonAccentColor NoInputFocus" OnClick="ButtonSwitch_Click" Text="Switch"/>
</div>
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
@@ -30,7 +32,11 @@ namespace Swarmops.Frontend.Pages.Security
protected void ButtonSwitch_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
int newOrganizationId = Int32.Parse(this.Request.Form["DropOrganizations"]);
// TODO: Re-authorize user's ability to log onto this org
FormsAuthentication.RedirectFromLoginPage(this.CurrentUser.Identity.ToString(CultureInfo.InvariantCulture) + "," + newOrganizationId.ToString(CultureInfo.InvariantCulture), true);
}
}
}
+4 -1
View File
@@ -24,6 +24,9 @@ namespace Swarmops.Pages.Security
return;
}
//Person rick = Person.FromIdentity(1);
//rick.SetPassword("1");
// Unlock Telerik
this.Application["Telerik.Web.UI.Key"] = "Activizr";
@@ -35,7 +38,7 @@ namespace Swarmops.Pages.Security
if ((!Request.IsSecureConnection) || Request.Url.ToString().StartsWith("http://")) // Both are necessary, as some reverse proxies will https-ify an original nonsecure connection
{
if (!Request.Url.ToString().StartsWith("http://dev.activizr.com/") && !Request.Url.ToString().StartsWith("http://localhost:") && !Request.Url.ToString().StartsWith("http://activizr-"))
if (!Request.Url.ToString().StartsWith("http://dev.swarmops.com/") && !Request.Url.ToString().StartsWith("http://localhost:") && !Request.Url.ToString().StartsWith("http://swarmops-"))
{
Response.Redirect(Request.Url.ToString().Replace("http:", "https:"));
}