internal static void Finalise(LedgerBook book, bool unlock = false)
{
if (book.Reconciliations.None()) return;
var ledgers = new Dictionary<BudgetBucket, LedgerBucket>();
foreach (LedgerEntryLine line in book.Reconciliations)
{
if (!unlock)
{
PrivateAccessor.SetProperty(line, "IsNew", false);
}
foreach (LedgerEntry entry in line.Entries)
{
if (!unlock)
{
PrivateAccessor.SetField(entry, "isNew", false);
}
if (entry.LedgerBucket.StoredInAccount == null)
{
entry.LedgerBucket.StoredInAccount = StatementModelTestData.ChequeAccount;
}
if (!ledgers.ContainsKey(entry.LedgerBucket.BudgetBucket))
{
ledgers.Add(entry.LedgerBucket.BudgetBucket, entry.LedgerBucket);
}
}
}
book.Ledgers = ledgers.Values;
}