예제 #1
0
파일: gncCustomer.c 프로젝트: 573/gnucash
static void gncCustomerFree (GncCustomer *cust)
{
    if (!cust) return;

    qof_event_gen (&cust->inst, QOF_EVENT_DESTROY, NULL);

    CACHE_REMOVE (cust->id);
    CACHE_REMOVE (cust->name);
    CACHE_REMOVE (cust->notes);
    gncAddressBeginEdit (cust->addr);
    gncAddressDestroy (cust->addr);
    gncAddressBeginEdit (cust->shipaddr);
    gncAddressDestroy (cust->shipaddr);
    g_list_free (cust->jobs);

    if (cust->terms)
        gncBillTermDecRef (cust->terms);
    if (cust->taxtable)
    {
        gncTaxTableDecRef (cust->taxtable);
    }

    /* qof_instance_release (&cust->inst); */
    g_object_unref (cust);
}
예제 #2
0
static void
test_address (void)
{
    QofInstance *ent;
    GncAddress *address;
    QofBook *book = qof_book_new ();

    ent = g_object_new(QOF_TYPE_INSTANCE, "guid", guid_null(), NULL);
    ent->e_type = "asdf";

    /* Test creation/destruction */
    {
        do_test (gncAddressCreate (NULL,  NULL) == NULL, "address create NULL");

        address = gncAddressCreate (book, ent);
        do_test (address != NULL, "address create");

        gncAddressBeginEdit (address);
        gncAddressDestroy (address);
        success ("create/destroy");
    }

    /* Test setting routines */
    {
        address = gncAddressCreate (book, ent);
        test_string_fcn (address, "Name", gncAddressSetName, gncAddressGetName);
        test_string_fcn (address, "Addr1", gncAddressSetAddr1, gncAddressGetAddr1);
        test_string_fcn (address, "Addr2", gncAddressSetAddr2, gncAddressGetAddr2);
        test_string_fcn (address, "Addr3", gncAddressSetAddr3, gncAddressGetAddr3);
        test_string_fcn (address, "Addr4", gncAddressSetAddr4, gncAddressGetAddr4);
        test_string_fcn (address, "Phone", gncAddressSetPhone, gncAddressGetPhone);
        test_string_fcn (address, "Fax", gncAddressSetFax, gncAddressGetFax);
        test_string_fcn (address, "Email", gncAddressSetEmail, gncAddressGetEmail);
    }
}
예제 #3
0
static void gncEmployeeFree (GncEmployee *employee)
{
    if (!employee) return;

    qof_event_gen (&employee->inst, QOF_EVENT_DESTROY, NULL);

    CACHE_REMOVE (employee->id);
    CACHE_REMOVE (employee->username);
    CACHE_REMOVE (employee->language);
    CACHE_REMOVE (employee->acl);
    gncAddressBeginEdit (employee->addr);
    gncAddressDestroy (employee->addr);

    /* qof_instance_release (&employee->inst); */
    g_object_unref (employee);
}
예제 #4
0
void
qofEmployeeSetAddr (GncEmployee *employee, QofInstance *addr_ent)
{
    GncAddress *addr;

    if (!employee || !addr_ent)
    {
        return;
    }
    addr = (GncAddress*)addr_ent;
    if (addr == employee->addr)
    {
        return;
    }
    if (employee->addr != NULL)
    {
        gncAddressBeginEdit(employee->addr);
        gncAddressDestroy(employee->addr);
    }
    gncEmployeeBeginEdit(employee);
    employee->addr = addr;
    gncEmployeeCommitEdit(employee);
}