int Model_Splittransaction::update(const Data_Set& rows, int transactionID)
{

    Data_Set split = instance().find(TRANSID(transactionID));
    for (const auto& split_item : split)
    {
        instance().remove(split_item.SPLITTRANSID);
    }

    if (!rows.empty())
    {
        Data_Set split_items;
        for (const auto &item : rows)
        {
            Data *split_item = instance().create();
            split_item->TRANSID = transactionID;
            split_item->SPLITTRANSAMOUNT = item.SPLITTRANSAMOUNT;
            split_item->CATEGID = item.CATEGID;
            split_item->SUBCATEGID = item.SUBCATEGID;
            split_items.push_back(*split_item);
        }
        instance().save(split_items);
    }
    return rows.size();
}
void Model_Shareinfo::RemoveShareEntry(const int checking_id)
{
    Data_Set list = ShareList(checking_id);
    if (!list.empty())
    {
        Model_Shareinfo::instance().remove(list.at(0).SHAREINFOID);
    }
}
Model_Category::Data* Model_Category::get(const wxString& name)
{
    Data* category = this->get_one(CATEGNAME(name));
    if (category) return category;

    Data_Set items = this->find(CATEGNAME(name));
    if (!items.empty()) category = this->get(items[0].CATEGID, this->db_);
    return category;
}
Model_CurrencyHistory::Data* Model_CurrencyHistory::get(const int& currencyID, const wxDate& date)
{
    Data* hist = this->get_one(CURRENCYID(currencyID), DB_Table_CURRENCYHISTORY_V1::CURRDATE(date.FormatISODate()));
    if (hist) return hist;

    Data_Set items = this->find(CURRENCYID(currencyID), DB_Table_CURRENCYHISTORY_V1::CURRDATE(date.FormatISODate()));
    if (!items.empty()) hist = this->get(items[0].id(), this->db_);
    return hist;
}
Model_Report::Data* Model_Report::get(const wxString& name)
{
    Data* report = this->get_one(REPORTNAME(name));
    if (report) return report;

    Data_Set items = this->find(REPORTNAME(name));
    if (!items.empty()) report = this->get(items[0].id(), this->db_);
    return report;
}
Model_Shareinfo::Data* Model_Shareinfo::ShareEntry(const int checking_id)
{
    Data_Set list = Model_Shareinfo::ShareList(checking_id);
    if (!list.empty())
    {
        return Model_Shareinfo::instance().get(list.at(0).SHAREINFOID);
    }
    return NULL;
}
示例#7
0
Model_Payee::Data* Model_Payee::get(const wxString& name)
{
    Data* payee = this->get_one(PAYEENAME(name));
    if (payee) return payee;

    Data_Set items = this->find(PAYEENAME(name));
    if (!items.empty()) payee = this->get(items[0].PAYEEID, this->db_);
    return payee;
}
/** Return the Data record instance for the given subcategory name and category ID */
Model_Subcategory::Data* Model_Subcategory::get(const wxString& name, int category_id)
{
    //FIXME: return wrong value
    Data* category = this->get_one(SUBCATEGNAME(name), CATEGID(category_id));
    if (category) return category;

    Data_Set items = this->find(SUBCATEGNAME(name), CATEGID(category_id));
    if (!items.empty()) category = this->get(items[0].SUBCATEGID, this->db_);
    return category;
}
wxString Model_Setting::GetStringSetting(const wxString& key, const wxString& default_value)
{
    Data* setting = this->get_one(SETTINGNAME(key));
    if (!setting) // not cached
    {
        Data_Set items = this->find(SETTINGNAME(key));
        if (!items.empty()) return items[0].SETTINGVALUE;
    }
    else
    {
        return setting->SETTINGVALUE;
    }
    return default_value;
}
示例#10
0
wxString Model_Infotable::GetStringInfo(const wxString& key, const wxString& default_value)
{
    Data* info = this->get_one(INFONAME(key));
    if (info)
        return info->INFOVALUE;
    else // not cached
    {
        Data_Set items = this->find(INFONAME(key));
        if (!items.empty())
            return items[0].INFOVALUE;
    }

    return default_value;
}
示例#11
0
void Model_Setting::Set(const wxString& key, const wxString& value)
{
    Data* setting = this->get_one(SETTINGNAME(key));
    if (!setting) // not cached
    {
        Data_Set items = this->find(SETTINGNAME(key));
        if (!items.empty()) setting = this->get(items[0].SETTINGID, this->db_);
    }
    if (setting)
    {
        setting->SETTINGVALUE = value;
        setting->save(this->db_);
    }
    else
    {
        setting = this->create();
        setting->SETTINGNAME = key;
        setting->SETTINGVALUE = value;
        setting->save(this->db_);
    }
}
示例#12
0
void Model_Infotable::Set(const wxString& key, const wxString& value)
{
    Data* info = this->get_one(INFONAME(key));
    if (!info) // not cached
    {
        Data_Set items = this->find(INFONAME(key));
        if (!items.empty()) info = this->get(items[0].INFOID);
    }
    if (info)
    {
        info->INFOVALUE= value;
        info->save(this->db_);
    }
    else
    {
        info = this->create();
        info->INFONAME = key;
        info->INFOVALUE = value;
        info->save(this->db_);
    }
}