private void Update_bank_balance( ActualBankOutFile actual_bank_out_file, ISpreadsheet spreadsheet, IInputOutput input_output) { input_output.Output_line("Writing bank balance to spreadsheet..."); IList <ActualBankRecord> potential_balance_rows = actual_bank_out_file.Get_potential_balance_rows().ToList(); if (!potential_balance_rows.Any()) { input_output.Output_line(""); input_output.Get_generic_input(ReconConsts.CantFindBalanceRow); } else { ActualBankRecord balance_row = Choose_balance_row(potential_balance_rows, input_output); string balance_description = String.Format( ReconConsts.BankBalanceDescription, ReconConsts.Bank_descriptor, balance_row.Description, balance_row.Main_amount().To_csv_string(true), balance_row.Date.ToString(@"dd\/MM\/yyyy")); spreadsheet.Update_balance_on_totals_sheet( Codes.Bank_bal, balance_row.Balance, balance_description, balance_column: ReconConsts.BankBalanceAmountColumn, text_column: ReconConsts.BankBalanceTextColumn, code_column: ReconConsts.BankBalanceCodeColumn, input_output: input_output); } }
public void Merge_bespoke_data_with_pending_file( IInputOutput input_output, ISpreadsheet spreadsheet, ICSVFile <CredCard2InOutRecord> pending_file, BudgetingMonths budgeting_months, DataLoadingInformation <CredCard2Record, CredCard2InOutRecord> data_loading_info) { var most_recent_cred_card_direct_debit = spreadsheet.Get_most_recent_row_containing_text <BankRecord>( MainSheetNames.Bank_out, ReconConsts.Cred_card2_dd_description, new List <int> { ReconConsts.DescriptionColumn, ReconConsts.DdDescriptionColumn }); var statement_date = new DateTime(); var next_date = most_recent_cred_card_direct_debit.Date.AddMonths(1); var input = input_output.Get_input(string.Format( ReconConsts.AskForCredCardDirectDebit, ReconConsts.Cred_card2_name, next_date.ToShortDateString())); double new_balance = 0; while (input != "0") { if (double.TryParse(input, out new_balance)) { new_balance = new_balance * -1; pending_file.Records.Add(new CredCard2InOutRecord { Date = next_date, Description = ReconConsts.Cred_card2_regular_pymt_description, Unreconciled_amount = new_balance }); } statement_date = next_date.AddMonths(-1); next_date = next_date.Date.AddMonths(1); input = input_output.Get_input(string.Format( ReconConsts.AskForCredCardDirectDebit, ReconConsts.Cred_card2_name, next_date.ToShortDateString())); } if (!new_balance.Double_equals(0)) { spreadsheet.Update_balance_on_totals_sheet( Codes.Cred_card2_bal, new_balance, string.Format( ReconConsts.CredCardBalanceDescription, ReconConsts.Cred_card2_name, $"{statement_date.ToString("MMM")} {statement_date.Year}"), balance_column: 5, text_column: 6, code_column: 4, input_output: input_output); } }