From 6f10e5ee89cd4ed4c5d3a51c27d2f45531bdeea8 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 24 Nov 2012 20:58:38 +0000 Subject: [PATCH] Bugfix for database replication topology in Organization.EnableEconomy() --- Logic/Structure/Organization.cs | 12 +++++++++--- Site5/Pages/v5/Init/Default.aspx.cs | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Logic/Structure/Organization.cs b/Logic/Structure/Organization.cs index cea6f18f..56995ec6 100644 --- a/Logic/Structure/Organization.cs +++ b/Logic/Structure/Organization.cs @@ -197,12 +197,18 @@ namespace Activizr.Logic.Structure FinancialAccount.Create(this.Identity, "Taxes Due", FinancialAccountType.Debt, 0); FinancialAccounts[OrganizationFinancialAccountType.DebtsVat] = FinancialAccount.Create(this.Identity, "Outbound Value Added Tax", FinancialAccountType.Debt, 0); - FinancialAccounts[OrganizationFinancialAccountType.IncomeGeneral] = + + 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, FinancialAccounts.IncomeGeneral.Identity); + FinancialAccount.Create(this.Identity, "Donations", FinancialAccountType.Income, incomeGeneral.Identity); FinancialAccounts[OrganizationFinancialAccountType.IncomeSales] = - FinancialAccount.Create(this.Identity, "Sales", FinancialAccountType.Income, FinancialAccounts.IncomeGeneral.Identity); + FinancialAccount.Create(this.Identity, "Sales", FinancialAccountType.Income, incomeGeneral.Identity); // Then, create various cost accounts that are probably needed, or that could be used as a starting point diff --git a/Site5/Pages/v5/Init/Default.aspx.cs b/Site5/Pages/v5/Init/Default.aspx.cs index 0cf2fd9f..f453489d 100644 --- a/Site5/Pages/v5/Init/Default.aspx.cs +++ b/Site5/Pages/v5/Init/Default.aspx.cs @@ -529,7 +529,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page rootGeographyId, true, true, 0).EnableEconomy(); - // Create the + // TEMP - delete this later Activizr.Logic.Structure.Organization.Create(0, "Europirate Academy", "Europirate Academy", "Pirate Academy", "pirateacademy.eu", "Academy", rootGeographyId, true,