Lots of work on Account Plan; Mono test required

This commit is contained in:
Rick Falkvinge
2014-09-26 10:57:33 +02:00
parent 5176e66782
commit 7f9469bbfa
16 changed files with 278 additions and 23 deletions
+39 -3
View File
@@ -148,7 +148,31 @@ namespace Swarmops.Logic.Financial
public FinancialAccount Parent
{
get { return FromIdentity(this.ParentFinancialAccountId); }
get
{
return FromIdentity(this.ParentFinancialAccountId);
}
set
{
// We do not change the parent lightly. It cannot be changed if this account has transactions
// in closedledger space.
try
{
int yearClosed = this.Organization.Parameters.FiscalBooksClosedUntilYear;
if (this.OpenedYear >= yearClosed)
{
throw new InvalidOperationException("Can't reparent an account with transactions in closedledger space");
}
}
catch (ArgumentException)
{
// This is ok. OpenedYear can throw an ArgumentException if there aren't any transactions yet.
}
base.ParentFinancialAccountId = value.Identity;
SwarmDb.GetDatabaseForWriting().SetFinancialAccountParent(this.Identity, value.Identity);
}
}
@@ -171,7 +195,7 @@ namespace Swarmops.Logic.Financial
{
// HACK HACK HACK HACK HACK for our pilots; this will be softcoded later TODO
if (this.OrganizationId != 1 || this.Organization.Name != "Piratpartiet SE")
if (this.OrganizationId != 1 || !PilotInstallationIds.IsPilot(PilotInstallationIds.PiratePartySE))
{
return null;
}
@@ -194,7 +218,19 @@ namespace Swarmops.Logic.Financial
get { return base.Name; }
set
{
// TODO: OPENEDYEAR TEST
try
{
int yearClosed = this.Organization.Parameters.FiscalBooksClosedUntilYear;
if (this.OpenedYear >= yearClosed)
{
throw new InvalidOperationException("Can't rename an account with transactions in closedledger space");
}
}
catch (ArgumentException)
{
// This is ok and can be thrown if OpenedYear throws because there are no transactions yet.
}
SwarmDb.GetDatabaseForWriting().SetFinancialAccountName(this.Identity, value);
base.Name = value;
}
+2 -2
View File
@@ -56,8 +56,8 @@ namespace Swarmops.Logic.Support
static public void UpgradeSchemata()
{
int currentDbVersion = Int32.Parse(SwarmDb.GetDatabaseForReading().GetKeyValue("DbVersion"));
int expectedDbVersion = SwarmDb.DbVersion;
int currentDbVersion = SwarmDb.DbVersion;
int expectedDbVersion = SwarmDb.DbVersionExpected;
string sql;
bool upgraded = false;