Пример #1
0
        public void Start()
        {
            _input_output.Output_line("");
            _input_output.Output_options(new List <string>
            {
                ReconConsts.Load_pending_csvs,
                "2. Do actual reconciliation."
            });

            string input = _input_output.Get_generic_input(ReconConsts.PendingOrReconciliate);

            switch (input)
            {
            case "1":
            {
                var file_loader = new FileLoader(_input_output, new Clock());
                file_loader.Create_pending_csvs();
            }
            break;

            case "2":
            {
                Reconciliate();
            }
            break;
            }
        }
        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);
            }
        }
        private ActualBankRecord Choose_balance_row(IList <ActualBankRecord> potential_balance_rows, IInputOutput input_output)
        {
            var result = potential_balance_rows.First();

            if (potential_balance_rows.Count > 1)
            {
                input_output.Output_line("");
                input_output.Output_line(String.Format(ReconConsts.MultipleBalanceRows, result.To_string()));

                for (int index = 0; index < potential_balance_rows.Count; index++)
                {
                    input_output.Output_line($"{index + 1}. {potential_balance_rows[index].To_string()}");
                }

                string input = input_output.Get_generic_input(ReconConsts.MultipleBalanceRows);

                int new_index = 0;
                if (int.TryParse(input, out new_index))
                {
                    result = potential_balance_rows[new_index - 1];
                }
            }

            return(result);
        }
Пример #4
0
        public void Start()
        {
            _input_output.Output_line("");
            _input_output.Output_options(new List <string>
            {
                ReconConsts.Load_pending_csvs,
                "2. Do actual reconciliation."
            });

            string input = _input_output.Get_generic_input(ReconConsts.PendingOrReconciliate);

            switch (input)
            {
            case "1":
            {
                ISpreadsheetRepoFactory spreadsheet_factory = new FakeSpreadsheetRepoFactory();
                var path        = new PathSetter(_input_output, spreadsheet_factory).Set_path();
                var file_loader = new FileLoader(_input_output);
                file_loader.Create_pending_csvs(path);
            }
            break;

            case "2":
            {
                Do_actual_reconciliation();
            }
            break;
            }
        }
Пример #5
0
        private DateTime Decide_date(DateTime date, string day_name, string context_description, string start_or_end)
        {
            _input_output.Output_line($"1. {date.ToShortDateString()}");
            _input_output.Output_line($"2. {date.AddDays(7).ToShortDateString()}");
            var choice = _input_output.Get_input($"Which {day_name} do you want to {start_or_end} with for {context_description}? Enter 1 or 2:");

            if (choice == "2")
            {
                date = date.AddDays(7);
            }

            return(date);
        }
        public ISpreadsheetRepoFactory Decide_on_debug()
        {
            _input_output.Output_line("");
            _input_output.Output_options(new List <string>
            {
                $"1. Debug Mode A: Copy live sheet to debug version in [live location]/{ReconConsts.Backup_sub_folder}, and work on it from there.",
                $"2. Debug Mode B: Copy sheet from {ReconConsts.Source_debug_spreadsheet_path} to [live location]/{ReconConsts.Backup_sub_folder}, and work on it from there.",
                "3. Debug Mode C: Use fake spreadsheet repo (like you would get in .Net Core).",
                "4. Work in REAL mode"
            });

            string input = _input_output.Get_generic_input(ReconConsts.DebugOrReal);

            WorkingMode             working_mode        = WorkingMode.DebugA;
            ISpreadsheetRepoFactory spreadsheet_factory = new FakeSpreadsheetRepoFactory();;

            switch (input)
            {
            case "1": { working_mode = WorkingMode.DebugA; spreadsheet_factory = Debug_mode_a(); } break;

            case "2": { working_mode = WorkingMode.DebugB; spreadsheet_factory = Debug_mode_b(); } break;

            case "3": { working_mode = WorkingMode.DebugC; spreadsheet_factory = Debug_mode_c(); } break;

            case "4": { working_mode = WorkingMode.Real; spreadsheet_factory = Real_mode(); } break;
            }

            new Communicator(_input_output).Show_instructions(working_mode);

            return(spreadsheet_factory);
        }
        public void Debug_preliminary_stuff <TThirdPartyType, TOwnedType>(IReconciliator <TThirdPartyType, TOwnedType> reconciliator)
            where TThirdPartyType : ICSVRecord, new()
            where TOwnedType : ICSVRecord, new()
        {
            List <ConsoleLine> all_expense_transactions_from_actual_bank_in = Get_all_expense_transactions_from_actual_bank_in(reconciliator);

            _input_output.Output_line("***********");
            _input_output.Output_line("All Expense Transactions From ActualBank In:");
            _input_output.Output_all_lines(all_expense_transactions_from_actual_bank_in);

            List <ConsoleLine> all_expense_transactions_from_expected_in = Get_all_wages_rows_and_expense_transactions_from_expected_in(reconciliator);

            _input_output.Output_line("***********");
            _input_output.Output_line("All Expense Transactions From Expected In:");
            _input_output.Output_all_lines(all_expense_transactions_from_expected_in);

            reconciliator.Refresh_files();

            _input_output.Get_input(ReconConsts.EnterAnyKeyToContinue);
        }
        public void Merge_bespoke_data_with_pending_file(
            IInputOutput input_output,
            ISpreadsheet spreadsheet,
            ICSVFile <BankRecord> pending_file,
            BudgetingMonths budgeting_months,
            DataLoadingInformation <ActualBankRecord, BankRecord> data_loading_info)
        {
            input_output.Output_line(ReconConsts.Loading_expenses);
            _expected_income_csv_file.Load(false);

            spreadsheet.Add_unreconciled_rows_to_csv_file <ExpectedIncomeRecord>(MainSheetNames.Expected_in, _expected_income_file.File);
            _expected_income_csv_file.Populate_source_records_from_records();
            _expected_income_file.Filter_for_employer_expenses_and_bank_transactions_only();

            _expected_income_file.Copy_to_pending_file(pending_file);
            _expected_income_csv_file.Populate_records_from_original_file_load();
        }
Пример #9
0
        public void Update_balance_on_totals_sheet(
            string balance_code,
            double new_balance,
            string new_text,
            int balance_column,
            int text_column,
            int code_column,
            IInputOutput input_output)
        {
            input_output.Output_line($"Updating {MainSheetNames.Totals} with {balance_code} {new_balance} '{new_text}'.");

            _spreadsheet_io.Update_amount_and_text(
                MainSheetNames.Totals,
                balance_code,
                new_balance,
                new_text,
                balance_column,
                text_column,
                code_column);
        }
Пример #10
0
        public FilePaths Set_path_and_file_names()
        {
            _input_output.Output_line("Mathematical dude! Let's do some reconciliating. Type Exit at any time to leave (although to be honest I'm not sure that actually works...)");

            bool using_defaults = Set_all_file_details();

            if (!using_defaults)
            {
                Set_path();
                Set_third_party_file_name();
                Set_owned_file_name();
            }

            return(new FilePaths
            {
                Matcher = _matcher,
                Main_path = _path,
                Third_party_file_name = _third_party_file_name,
                Owned_file_name = _owned_file_name
            });
        }
        private void Recursively_show_auto_matches_and_get_choices()
        {
            List <ConsoleLine> auto_matches = Reconciliator.Get_auto_matches_for_console();

            if (auto_matches.Count > 0)
            {
                Show_auto_matches(auto_matches);
                Act_on_choices_for_auto_matching();
            }
            else
            {
                _input_output.Output_line("Couldn't find any automatic matches for you, sorry.");
                _input_output.Output_line("");
            }
        }
        public void Show_instructions(WorkingMode working_mode)
        {
            _input_output.Output_line("Here's how it works:");
            _input_output.Output_line("                                      ****");
            _input_output.Output_line(ReconConsts.Instructions_line_01);
            _input_output.Output_line("                                      ****");
            _input_output.Output_line(ReconConsts.Instructions_line_02);
            _input_output.Output_line(ReconConsts.Instructions_line_03);
            _input_output.Output_line(ReconConsts.Instructions_line_04);
            _input_output.Output_line("                                      ****");
            _input_output.Output_line(ReconConsts.Instructions_line_05);
            _input_output.Output_line(ReconConsts.Instructions_line_06);
            _input_output.Output_line(ReconConsts.Instructions_line_07);
            _input_output.Output_line(ReconConsts.Instructions_line_08);
            _input_output.Output_line(ReconConsts.Instructions_line_09);
            _input_output.Output_line("                                      ****");
            _input_output.Output_line(ReconConsts.Instructions_line_10);
            _input_output.Output_line(ReconConsts.Instructions_line_11);
            _input_output.Output_line("");

            switch (working_mode)
            {
            case WorkingMode.DebugA: Show_debug_a_data_message(); break;

            case WorkingMode.DebugB: Show_debug_b_data_message(); break;

            case WorkingMode.DebugC: Show_debug_c_data_message(); break;

            case WorkingMode.Real: Show_real_data_message(); break;
            }
        }
 public void Create_pending_csvs(string path)
 {
     try
     {
         var pending_csv_file_creator = new PendingCsvFileCreator(path);
         pending_csv_file_creator.Create_and_populate_all_csvs();
     }
     catch (Exception e)
     {
         _input_output.Output_line(e.Message);
     }
 }
Пример #14
0
 public void Create_pending_csvs()
 {
     try
     {
         ISpreadsheetRepoFactory spreadsheet_factory = new FakeSpreadsheetRepoFactory();
         var path = new PathSetter(_input_output, spreadsheet_factory).Set_path();
         var pending_csv_file_creator = new PendingCsvFileCreator(path);
         pending_csv_file_creator.Create_and_populate_all_csvs();
     }
     catch (Exception e)
     {
         _input_output.Output_line(e.Message);
     }
 }