diff --git a/src/Fab.Client/ServiceReferences.ClientConfig b/src/Fab.Client/ServiceReferences.ClientConfig
index 6dc66b8..1d5c4a7 100644
--- a/src/Fab.Client/ServiceReferences.ClientConfig
+++ b/src/Fab.Client/ServiceReferences.ClientConfig
@@ -6,19 +6,19 @@
+ openTimeout="01:01:00"
+ receiveTimeout="01:10:00"
+ sendTimeout="01:01:00"
+ closeTimeout="01:01:00">
+ openTimeout="01:01:00"
+ receiveTimeout="01:10:00"
+ sendTimeout="01:01:00"
+ closeTimeout="01:01:00">
diff --git a/src/Fab.Server/Core/ModelHelper.cs b/src/Fab.Server/Core/ModelHelper.cs
index 8bd1a95..a903d69 100644
--- a/src/Fab.Server/Core/ModelHelper.cs
+++ b/src/Fab.Server/Core/ModelHelper.cs
@@ -102,7 +102,7 @@ private static Account GetSystemAccount(ModelContainer mc, int assetTypeId)
///
/// Account to check.
/// New posting date.
- private static void CheckAccountPeriod(Account account, DateTime date)
+ private static void UpdateAccountPeriodAfterNewPosting(Account account, DateTime date)
{
if (!account.FirstPostingDate.HasValue || account.FirstPostingDate > date)
{
@@ -121,7 +121,7 @@ private static void CheckAccountPeriod(Account account, DateTime date)
/// Entity Framework model container.
/// Account to check.
/// Deleted posting date.
- private static void UpdateAccountPeriod(ModelContainer mc, Account account, DateTime date)
+ private static void UpdateAccountPeriodAfterDeletePosting(ModelContainer mc, Account account, DateTime date)
{
if (account.FirstPostingDate.HasValue && account.FirstPostingDate == date)
{
@@ -305,7 +305,7 @@ internal static void DeleteJournal(ModelContainer mc, int journalId)
// Update cached postings count
posting.Account.PostingsCount--;
- UpdateAccountPeriod(mc, posting.Account, posting.Date);
+ UpdateAccountPeriodAfterDeletePosting(mc, posting.Account, posting.Date);
// Delete original postings
mc.Postings.DeleteObject(posting);
@@ -396,8 +396,8 @@ internal static Journal CreateTransaction(ModelContainer mc, int accountId, Jour
creditAccount.PostingsCount++;
debitAccount.PostingsCount++;
- CheckAccountPeriod(creditAccount, date);
- CheckAccountPeriod(debitAccount, date);
+ UpdateAccountPeriodAfterNewPosting(creditAccount, date);
+ UpdateAccountPeriodAfterNewPosting(debitAccount, date);
return journal;
}
@@ -468,6 +468,12 @@ internal static void UpdateTransaction(ModelContainer mc, int accountId, int tra
cashAccount.Balance += amount;
}
+ // Update account cached "first" and "last" posting dates
+ UpdateAccountPeriodAfterDeletePosting(mc, targetAccount, targetAccountPosting.Date);
+ UpdateAccountPeriodAfterDeletePosting(mc, cashAccount, cashAccountPosting.Date);
+ UpdateAccountPeriodAfterNewPosting(targetAccount, date);
+ UpdateAccountPeriodAfterNewPosting(cashAccount, date);
+
targetAccountPosting.Date = date;
cashAccountPosting.Date = date;
@@ -487,9 +493,6 @@ internal static void UpdateTransaction(ModelContainer mc, int accountId, int tra
journal.Category = category;
}
- CheckAccountPeriod(targetAccount, date);
- CheckAccountPeriod(cashAccount, date);
-
mc.SaveChanges();
}
@@ -555,8 +558,8 @@ internal static Journal CreateTransfer(ModelContainer mc, DateTime date, int fro
targetAccount.PostingsCount++;
sourceAccount.PostingsCount++;
- CheckAccountPeriod(sourceAccount, date);
- CheckAccountPeriod(targetAccount, date);
+ UpdateAccountPeriodAfterNewPosting(sourceAccount, date);
+ UpdateAccountPeriodAfterNewPosting(targetAccount, date);
return journal;
}
@@ -623,15 +626,18 @@ internal static void UpdateTransfer(ModelContainer mc, int transactionId, int fr
sourceAccountPosting.Account = sourceAccount;
targetAccountPosting.Account = targetAccount;
- sourceAccountPosting.Date = date;
- targetAccountPosting.Date = date;
-
journal.Rate = rate;
journal.Quantity = quantity;
journal.Comment = comment;
- CheckAccountPeriod(sourceAccount, date);
- CheckAccountPeriod(targetAccount, date);
+ // Update account cached "first" and "last" posting dates
+ UpdateAccountPeriodAfterDeletePosting(mc, targetAccount, targetAccountPosting.Date);
+ UpdateAccountPeriodAfterDeletePosting(mc, sourceAccount, sourceAccountPosting.Date);
+ UpdateAccountPeriodAfterNewPosting(targetAccount, date);
+ UpdateAccountPeriodAfterNewPosting(sourceAccount, date);
+
+ sourceAccountPosting.Date = date;
+ targetAccountPosting.Date = date;
mc.SaveChanges();
}