Exemplo n.º 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;
            }
        }
        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);
        }
        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);
        }
        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);
            }
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
0
        private bool Set_all_file_details()
        {
            bool success = true;

            _input_output.Output_line("");
            _input_output.Output_line("Would you like to enter your own file details, or use defaults?");
            _input_output.Output_options(new List <string>
            {
                "1. Enter my own file details",
                ReconConsts.File_details_02,
                ReconConsts.File_details_03,
                ReconConsts.File_details_04,
                ReconConsts.File_details_05,
            });

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

            success = Set_file_details_according_to_user_input(input);

            return(success);
        }
        private void Proceed_after_showing_matching_results()
        {
            _input_output.Output_options(new List <string>
            {
                "1. Go again! (this means you can match any item, regardless of amount)",
                "2. Write csv and finish.",
            });

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

            switch (input)
            {
            case "1": Go_again(); break;

            case "2": Finish(); break;
            }
        }