Beispiel #1
0
void  mmReportCategoryExpenses::RefreshData()
{
    data_.clear();
    valueList_.clear();
    valueListTotals_.clear();
    std::map<int, std::map<int, std::map<int, double> > > categoryStats;
    Model_Category::instance().getCategoryStats(categoryStats
        , date_range_
        , ignoreFutureDate_
        , false
        , with_date_);

    for (const auto& entry : categoryStats)
    {
        wxString categName = "";
        Model_Category::Data *category = Model_Category::instance().get(entry.first);
        if (category) categName = category->CATEGNAME;

        double categ_total = entry.second.at(-1).at(0);
        for (const auto &subentry : entry.second)
        {
            double subcateg_total = subentry.second.at(0);
            if ((type_ == GOES && subcateg_total > 0.0) || (type_ == COME && subcateg_total < 0.0) || (type_ == NONE && subcateg_total != 0.0))
                valueList_.push_back({ Model_Category::full_name(entry.first, subentry.first), subcateg_total });
            categ_total += subcateg_total;
        }
        if ((type_ == GOES && categ_total > 0.0) || (type_ == COME && categ_total < 0.0) || (type_ == NONE && categ_total != 0.0))
            valueListTotals_.push_back({ categName, categ_total });
    }

    data_holder line;
    int groupID = 1;
    for (const auto& category : Model_Category::instance().all(Model_Category::COL_CATEGNAME))
    {
        const wxString& sCategName = category.CATEGNAME;
        double amt = categoryStats[category.CATEGID][-1][0];
        if (type_ == GOES && amt < 0.0) amt = 0;
        if (type_ == COME && amt > 0.0) amt = 0;
        if (amt != 0.0)
            data_.push_back({ sCategName, amt, groupID });

        auto subcategories = Model_Category::sub_category(category);
        std::stable_sort(subcategories.begin(), subcategories.end(), SorterBySUBCATEGNAME());
        for (const auto& sub_category : subcategories)
        {
            wxString sFullCategName = Model_Category::full_name(category.CATEGID, sub_category.SUBCATEGID);
            amt = categoryStats[category.CATEGID][sub_category.SUBCATEGID][0];
            if (type_ == GOES && amt < 0.0) amt = 0;
            if (type_ == COME && amt > 0.0) amt = 0;
            if (amt != 0.0)
                data_.push_back({ sFullCategName, amt, groupID });
        }
        groupID++;
    }
}
Beispiel #2
0
void  mmReportCategoryExpenses::RefreshData()
{
    data_.clear();
    wxString color;
    std::map<int, std::map<int, std::map<int, double> > > categoryStats;
    Model_Category::instance().getCategoryStats(categoryStats
        , const_cast<mmDateRange*>(m_date_range)
        , Option::instance().IgnoreFutureTransactions()
        , false
        , m_date_range->is_with_date());

    data_holder line;
    int i = 0;
    mmHTMLBuilder hb;
    int groupID = 1;
    for (const auto& category : Model_Category::instance().all(Model_Category::COL_CATEGNAME))
    {
        const wxString& sCategName = category.CATEGNAME;
        double amt = categoryStats[category.CATEGID][-1][0];
        if (type_ == COME && amt < 0.0) amt = 0;
        if (type_ == GOES && amt > 0.0) amt = 0;
        if (amt != 0.0)
            data_.push_back({ hb.getColor(i++), sCategName, amt, groupID });

        auto subcategories = Model_Category::sub_category(category);
        std::stable_sort(subcategories.begin(), subcategories.end(), SorterBySUBCATEGNAME());
        for (const auto& sub_category : subcategories)
        {
            wxString sFullCategName = Model_Category::full_name(category.CATEGID, sub_category.SUBCATEGID);
            amt = categoryStats[category.CATEGID][sub_category.SUBCATEGID][0];
            if (type_ == COME && amt < 0.0) amt = 0;
            if (type_ == GOES && amt > 0.0) amt = 0;
            if (amt != 0.0)
                data_.push_back({ hb.getColor(i++), sFullCategName, amt, groupID });
        }
        groupID++;
    }
}