<commit_before>//=======================================================================
// Copyright <NAME> 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include <unordered_map>

#include "overview.hpp"
#include "console.hpp"
#include "accounts.hpp"
#include "expenses.hpp"
#include "budget_exception.hpp"

using namespace budget;

void budget::handle_overview(const std::vector<std::string>& args){
    if(args.size() == 1){
        month_overview();
    } else {
        auto& subcommand = args[1];

        if(subcommand == "month"){
            month_overview();
        } else if(subcommand == "year"){
            year_overview();
        } else {
            throw budget_exception("Invalid subcommand \"" + subcommand + "\"");
        }
    }
}

void budget::month_overview(){
    load_accounts();
    load_expenses();

    std::cout << "Overview of the month" << std::endl << std::endl;

    std::vector<std::string> columns;
    std::unordered_map<std::string, std::size_t> indexes;
    std::vector<std::vector<std::string>> contents;
    std::vector<money> totals;

    for(auto& account : all_accounts()){
        indexes[account.name] = columns.size();
        columns.push_back(account.name);
        totals.push_back({});
    }

    std::vector<std::size_t> current(columns.size(), 0);

    for(auto& expense : all_expenses()){
        std::size_t index = indexes[expense.account];
        std::size_t& row = current[index];

        if(contents.size() <= row){
            contents.emplace_back(columns.size() * 3, "");
        }

        contents[row][index * 3] = to_string(expense.expense_date);
        contents[row][index * 3 + 1] = expense.name;
        contents[row][index * 3 + 2] = to_string(expense.amount);

        totals[index] += expense.amount;

        ++row;
    }
<commit_msg>Display only the day as we are in the overview of the current month<commit_after>//=======================================================================
// Copyright <NAME> 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include <unordered_map>

#include "overview.hpp"
#include "console.hpp"
#include "accounts.hpp"
#include "expenses.hpp"
#include "budget_exception.hpp"

using namespace budget;

void budget::handle_overview(const std::vector<std::string>& args){
    if(args.size() == 1){
        month_overview();
    } else {
        auto& subcommand = args[1];

        if(subcommand == "month"){
            month_overview();
        } else if(subcommand == "year"){
            year_overview();
        } else {
            throw budget_exception("Invalid subcommand \"" + subcommand + "\"");
        }
    }
}

void budget::month_overview(){
    load_accounts();
    load_expenses();

    std::cout << "Overview of the month" << std::endl << std::endl;

    std::vector<std::string> columns;
    std::unordered_map<std::string, std::size_t> indexes;
    std::vector<std::vector<std::string>> contents;
    std::vector<money> totals;

    for(auto& account : all_accounts()){
        indexes[account.name] = columns.size();
        columns.push_back(account.name);
        totals.push_back({});
    }

    std::vector<std::size_t> current(columns.size(), 0);

    for(auto& expense : all_expenses()){
        std::size_t index = indexes[expense.account];
        std::size_t& row = current[index];

        if(contents.size() <= row){
            contents.emplace_back(columns.size() * 3, "");
        }

        contents[row][index * 3] = to_string(expense.expense_date.day());
        contents[row][index * 3 + 1] = expense.name;
        contents[row][index * 3 + 2] = to_string(expense.amount);

        totals[index] += expense.amount;

        ++row;
    }

{'fraction_non_alphanumeric': 0.22000983284169126, 'fraction_numerical': 0.009341199606686333, 'mean_word_length': 3.251828631138976, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '183057', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1193, 'n_words': 243}