private decimal RetrieveOpeningBalance()
{
Engine.Ledger.LedgerBook book = this.ledgerService.LedgerBook;
bool found = false;
IEnumerable<LedgerEntryLine> remainingRecons = book.Reconciliations.SkipWhile(r =>
{
// Find the recon that directly precedes this current one.
if (found) return false; // Found recon line on previous pass, now return.
found = r.Entries.Contains(LedgerEntry);
return true; // Keep skipping...
}).Take(1);
LedgerEntryLine previousLine = remainingRecons.FirstOrDefault();
if (previousLine == null) return 0M;
var previousEntry = previousLine.Entries.FirstOrDefault(l => l.LedgerBucket == LedgerEntry.LedgerBucket);
return previousEntry?.Balance ?? 0M;
}