private void AddNewBankBalance()
 {
     BankBalances.Add(new BankBalanceViewModel(null, SelectedBankAccount, BankBalance));
     SelectedBankAccount = null;
     BankBalance         = 0;
     RaisePropertyChanged(() => HasRequiredBalances);
 }
        private void OnRemoveBankBalanceCommandExecuted(BankBalanceViewModel bankBalance)
        {
            if (bankBalance == null)
            {
                return;
            }

            BankBalances.Remove(bankBalance);
            RaisePropertyChanged(() => BankBalanceTotal);
            RaisePropertyChanged(() => AdjustedBankBalanceTotal);
            RaisePropertyChanged(() => HasRequiredBalances);
        }
        private void OnShellDialogResponseReceived(ShellDialogResponseMessage message)
        {
            if (!message.IsItForMe(this.dialogCorrelationId))
            {
                return;
            }

            try
            {
                if (message.Response == ShellDialogButton.Help)
                {
                    this.messageBox.Show(
                        "Use your actual pay day as the date, this signifies the closing of the previous month, and opening a new month on your pay day showing available funds in each ledger for the new month. The date used will also be used to select transactions from the statement to calculate the ledger balance. The date is set from the current date range filter (on the dashboard page), using the day after the end date. Transactions will be found by searching one month prior to the given date, excluding the given date. The transactions are used to show how the current ledger balance is calculated. The bank balance is the balance as at the date given, after your pay has been credited.");
                    return;
                }
                if (message.Response == ShellDialogButton.Cancel)
                {
                    Canceled = true;
                }
                else
                {
                    if (BankBalances.None())
                    {
                        if (CanExecuteAddBankBalanceCommand())
                        {
                            // User may have entered some data to add a new bank balance to the collection, but not clicked the add button, instead they just clicked save.
                            OnAddBankBalanceCommandExecuted();
                        }
                        else
                        {
                            throw new InvalidOperationException("Failed to add any bank balances to Ledger Book reconciliation.");
                        }
                    }
                }

                EventHandler <EditBankBalancesEventArgs> handler = Complete;
                handler?.Invoke(this, new EditBankBalancesEventArgs {
                    Canceled = Canceled
                });
            }
            finally
            {
                Reset();
            }
        }