Exemplo n.º 1
0
        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);
            }
        }
        private void Add_most_recent_credit_card_direct_debits(
            IInputOutput input_output,
            ISpreadsheet spreadsheet,
            ICSVFile <BankRecord> pending_file,
            string cred_card_name,
            string direct_debit_description)
        {
            var most_recent_cred_card_direct_debit = spreadsheet.Get_most_recent_row_containing_text <BankRecord>(
                MainSheetNames.Bank_out,
                direct_debit_description,
                new List <int> {
                ReconConsts.DescriptionColumn, ReconConsts.DdDescriptionColumn
            });

            var next_date = most_recent_cred_card_direct_debit.Date.AddMonths(1);
            var input     = input_output.Get_input(string.Format(
                                                       ReconConsts.AskForCredCardDirectDebit,
                                                       cred_card_name,
                                                       next_date.ToShortDateString()));

            while (input != "0")
            {
                double amount;
                if (double.TryParse(input, out amount))
                {
                    pending_file.Records.Add(new BankRecord
                    {
                        Date                = next_date,
                        Description         = direct_debit_description,
                        Type                = "POS",
                        Unreconciled_amount = amount
                    });
                }
                next_date = next_date.Date.AddMonths(1);
                input     = input_output.Get_input(string.Format(
                                                       ReconConsts.AskForCredCardDirectDebit,
                                                       cred_card_name,
                                                       next_date.ToShortDateString()));
            }
        }