コード例 #1
0
int DB_Init_Model::Get_Payee_id(const wxString& name)
{
    int payee_id = -1;
    Model_Payee::Data* entry = Model_Payee::instance().get(name);
    if (entry)
    {
        payee_id = entry->id();
    }
    else ShowMessage("The ID not found for Payee: " + name);

    return payee_id;
}
コード例 #2
0
void Test_Relocate_Payee::setUp()
{
    CpuTimer time("Startup");
    m_base_frame = new TestFrameBase(m_this_instance);
    m_base_frame->Show(true);

    m_test_db.Open(m_test_db_filename);
    m_dbmodel = new DB_Model();
    m_dbmodel->Init_Model_Tables(&m_test_db);
    m_dbmodel->Init_BaseCurrency();


    // Initialise some payees
    Model_Payee::instance().Savepoint();
    {
        Model_Payee::Data* payee = Model_Payee::instance().create();
        payee->PAYEENAME = "Workshop";
        payee->CATEGID = Model_Category::instance().get("Income")->id();
        payee->SUBCATEGID = Model_Subcategory::instance().get("Salary", payee->CATEGID)->id();
        Model_Payee::instance().save(payee);

        Model_Payee::Data* supermarket = Model_Payee::instance().clone(payee);
        supermarket->PAYEENAME = "Supermarket";
        supermarket->CATEGID = Model_Category::instance().get("Food")->id();
        supermarket->SUBCATEGID = Model_Subcategory::instance().get("Groceries", supermarket->CATEGID)->id();
        Model_Payee::instance().save(supermarket);

        payee = Model_Payee::instance().create();
        payee->PAYEENAME = "Aldi";
        Model_Payee::instance().save(payee);

        payee = Model_Payee::instance().create();
        payee->PAYEENAME = "Coles";
        Model_Payee::instance().save(payee);

        payee = Model_Payee::instance().create();
        payee->PAYEENAME = "Woolworths";
        Model_Payee::instance().save(payee);

        // Set up payees inthe other tables.
        Model_Checking::Data* checking_entry = Model_Checking::instance().create();
        checking_entry->PAYEEID = supermarket->id();
        Model_Checking::instance().save(checking_entry);

        Model_Billsdeposits::Data* bill_entry = Model_Billsdeposits::instance().create();
        bill_entry->PAYEEID = supermarket->id();
        Model_Billsdeposits::instance().save(bill_entry);
    }
    Model_Payee::instance().ReleaseSavepoint();
}