Added download of balance sheet, security on switch orgs, loc of new features to sv-SE

This commit is contained in:
Rick Falkvinge
2012-12-12 12:54:18 +00:00
parent 4bcd5694fb
commit dc6bfed9fc
24 changed files with 1216 additions and 252 deletions
@@ -43,7 +43,7 @@ namespace Activizr.Logic.Financial
organizationAccounts[OrganizationFinancialAccountType.DebtsInboundInvoices] = FinancialAccount.FromIdentity(25); //
organizationAccounts[OrganizationFinancialAccountType.DebtsOther] = FinancialAccount.FromIdentity(25); //
organizationAccounts[OrganizationFinancialAccountType.AssetsOutboundInvoices] = FinancialAccount.FromIdentity(28); //
organizationAccounts[OrganizationFinancialAccountType.DebtsCapital] = FinancialAccount.FromIdentity(96); //
organizationAccounts[OrganizationFinancialAccountType.DebtsEquity] = FinancialAccount.FromIdentity(96); //
organizationAccounts[OrganizationFinancialAccountType.AssetsPaypal] = FinancialAccount.FromIdentity(2); //
organizationAccounts[OrganizationFinancialAccountType.CostsYearlyResult] = FinancialAccount.FromIdentity(97); //
organizationAccounts[OrganizationFinancialAccountType.AssetsOutstandingCashAdvances] = FinancialAccount.FromIdentity(156); //
@@ -137,9 +137,9 @@ namespace Activizr.Logic.Financial
get { return this[OrganizationFinancialAccountType.CostsYearlyResult]; }
}
public FinancialAccount DebtsCapital
public FinancialAccount DebtsEquity
{
get { return this[OrganizationFinancialAccountType.DebtsCapital]; }
get { return this[OrganizationFinancialAccountType.DebtsEquity]; }
}
public FinancialAccount DebtsExpenseClaims
@@ -172,11 +172,6 @@ namespace Activizr.Logic.Financial
get { return this[OrganizationFinancialAccountType.DebtsSalary]; }
}
public FinancialAccount IncomeGeneral
{
get { return this[OrganizationFinancialAccountType.IncomeGeneral]; }
}
public FinancialAccount IncomeDonations
{
get { return this[OrganizationFinancialAccountType.IncomeDonations]; }
+62
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Activizr.Basic.Enums;
using Activizr.Basic.Types;
using Activizr.Logic.Structure;
namespace Activizr.Logic.Financial
@@ -51,6 +52,13 @@ namespace Activizr.Logic.Financial
}
if (report._treeMap[0].Count > 3)
{
// regroup list
report.AggregateAccounts();
}
FinancialAccounts orderedList = new FinancialAccounts(); // This list is guaranteed to have parents before children
report.PopulateOrderedList(orderedList, 0); // recursively add nodes parents-first
@@ -67,6 +75,60 @@ namespace Activizr.Logic.Financial
private FinancialAccountType _accountType;
private void AggregateAccounts()
{
const int assetIdentity = 1000000001;
const int debtIdentity = 1000000002;
const int incomeIdentity = 1000000003;
const int costIdentity = 1000000004;
Dictionary<FinancialAccountType, int> remapLookup = new Dictionary<FinancialAccountType, int>();
remapLookup[FinancialAccountType.Asset] = assetIdentity;
remapLookup[FinancialAccountType.Debt] = debtIdentity;
remapLookup[FinancialAccountType.Income] = incomeIdentity;
remapLookup[FinancialAccountType.Cost] = costIdentity;
List<FinancialAccount> newRootLevel = new List<FinancialAccount>();
int equityIdentity = _treeMap[0][0].Organization.FinancialAccounts.DebtsEquity.Identity;
if (_accountType == FinancialAccountType.Balance)
{
newRootLevel.Add(FinancialAccount.FromBasic(new BasicFinancialAccount(assetIdentity, "%ASSET_ACCOUNTGROUP%", FinancialAccountType.Asset, 0, 0, 0)));
newRootLevel.Add(FinancialAccount.FromBasic(new BasicFinancialAccount(debtIdentity, "%DEBT_ACCOUNTGROUP%", FinancialAccountType.Debt, 0, 0, 0)));
}
else if (_accountType == FinancialAccountType.Result)
{
newRootLevel.Add(FinancialAccount.FromBasic(new BasicFinancialAccount(incomeIdentity, "%INCOME_ACCOUNTGROUP%", FinancialAccountType.Income, 0, 0, 0)));
newRootLevel.Add(FinancialAccount.FromBasic(new BasicFinancialAccount(costIdentity, "%COST_ACCOUNTGROUP%", FinancialAccountType.Cost, 0, 0, 0)));
}
else
{
throw new InvalidOperationException("AccountType other than Balance or Result passed to YearlyReport.AggregateAccounts()");
}
foreach (FinancialAccount account in _treeMap[0])
{
if (account.Identity == equityIdentity)
{
newRootLevel.Add(account);
}
else
{
if (!_treeMap.ContainsKey(remapLookup[account.AccountType]))
{
_treeMap[remapLookup[account.AccountType]] = new List<FinancialAccount>();
}
_treeMap[remapLookup[account.AccountType]].Add(account);
}
}
_treeMap[0] = newRootLevel;
}
private void PopulateTotals()
{
this.Totals = new YearlyReportNode();
+21 -12
View File
@@ -245,8 +245,8 @@ namespace Activizr.Logic.Structure
FinancialAccount.Create(this.Identity, "ICT and Infrastructure", FinancialAccountType.Cost, 0);
FinancialAccounts[OrganizationFinancialAccountType.CostsYearlyResult] =
FinancialAccount.Create(this.Identity, "Yearly result", FinancialAccountType.Cost, 0);
FinancialAccounts[OrganizationFinancialAccountType.DebtsCapital] =
FinancialAccount.Create(this.Identity, "Own Capital", FinancialAccountType.Debt, 0);
FinancialAccounts[OrganizationFinancialAccountType.DebtsEquity] =
FinancialAccount.Create(this.Identity, "Equity", FinancialAccountType.Debt, 0);
FinancialAccounts[OrganizationFinancialAccountType.DebtsExpenseClaims] =
FinancialAccount.Create(this.Identity, "Expense Claims", FinancialAccountType.Debt, 0);
FinancialAccounts[OrganizationFinancialAccountType.DebtsInboundInvoices] =
@@ -260,17 +260,10 @@ namespace Activizr.Logic.Structure
FinancialAccounts[OrganizationFinancialAccountType.DebtsVat] =
FinancialAccount.Create(this.Identity, "Outbound Value Added Tax", FinancialAccountType.Debt, 0);
FinancialAccount incomeGeneral =
FinancialAccount.Create(this.Identity, "Income", FinancialAccountType.Income, 0);
// We need to store this in code because of database lag replication issues when creating children -
// we can't use assume that it's available for reading yet.
FinancialAccounts[OrganizationFinancialAccountType.IncomeGeneral] = incomeGeneral;
FinancialAccounts[OrganizationFinancialAccountType.IncomeDonations] =
FinancialAccount.Create(this.Identity, "Donations", FinancialAccountType.Income, incomeGeneral.Identity);
FinancialAccount.Create(this.Identity, "Donations", FinancialAccountType.Income, 0);
FinancialAccounts[OrganizationFinancialAccountType.IncomeSales] =
FinancialAccount.Create(this.Identity, "Sales", FinancialAccountType.Income, incomeGeneral.Identity);
FinancialAccount.Create(this.Identity, "Sales", FinancialAccountType.Income, 0);
// Then, create various cost accounts that are probably needed, or that could be used as a starting point
@@ -632,7 +625,6 @@ namespace Activizr.Logic.Structure
#region class globals
public static readonly int SandboxIdentity = 3;
public static readonly int RootIdentity = 5;
public static readonly int PPSEid = 1;
public static readonly int UPSEid = 2;
@@ -647,6 +639,23 @@ namespace Activizr.Logic.Structure
get { return FromIdentity(SandboxIdentity); }
}
public static int SandboxIdentity
{
get
{
if (Organization.FromIdentity(1).Name.StartsWith("Sandbox"))
{
return 1;
}
else if (Organization.FromIdentity(3).Name.StartsWith("Sandbox"))
{
return 3;
}
throw new InvalidOperationException("Cannot locate Sandbox organization's identity");
}
}
public static Organization Root
{
get { return FromIdentity(RootIdentity); }