Ejemplo n.º 1
0
static void
test_bool_fcn (QofBook *book, const char *message,
               void (*set) (GncEmployee *, gboolean),
               gboolean (*get) (const GncEmployee *))
{
    GncEmployee *employee = gncEmployeeCreate (book);
    gboolean num = get_random_boolean ();

    do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
    gncEmployeeBeginEdit (employee);
    set (employee, FALSE);
    set (employee, TRUE);
    set (employee, num);
    /* Employee record should be dirty */
    do_test (gncEmployeeIsDirty (employee), "test dirty later");
    gncEmployeeCommitEdit (employee);
    /* Employee record should be not dirty */
    /* Skip, because will always fail without a backend.
     * It's not possible to load a backend in the engine code
     * without having circular dependencies.
     */
    // do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
    do_test (get (employee) == num, message);
    gncEmployeeSetActive (employee, FALSE);
    count++;
}
Ejemplo n.º 2
0
void gncOwnerCommitEdit (GncOwner *owner)
{
    if (!owner) return;
    switch (owner->type)
    {
    case GNC_OWNER_NONE :
    case GNC_OWNER_UNDEFINED :
        break;
    case GNC_OWNER_CUSTOMER :
    {
        gncCustomerCommitEdit(owner->owner.customer);
        break;
    }
    case GNC_OWNER_JOB :
    {
        gncJobCommitEdit(owner->owner.job);
        break;
    }
    case GNC_OWNER_VENDOR :
    {
        gncVendorCommitEdit(owner->owner.vendor);
        break;
    }
    case GNC_OWNER_EMPLOYEE :
    {
        gncEmployeeCommitEdit(owner->owner.employee);
        break;
    }
    }
}
Ejemplo n.º 3
0
void gncEmployeeSetAcl (GncEmployee *employee, const char *acl)
{
    if (!employee) return;
    if (!acl) return;
    SET_STR(employee, employee->acl, acl);
    mark_employee (employee);
    gncEmployeeCommitEdit (employee);
}
Ejemplo n.º 4
0
void gncEmployeeSetLanguage (GncEmployee *employee, const char *language)
{
    if (!employee) return;
    if (!language) return;
    SET_STR(employee, employee->language, language);
    mark_employee (employee);
    gncEmployeeCommitEdit (employee);
}
Ejemplo n.º 5
0
void gncEmployeeSetUsername (GncEmployee *employee, const char *username)
{
    if (!employee) return;
    if (!username) return;
    SET_STR(employee, employee->username, username);
    mark_employee (employee);
    gncEmployeeCommitEdit (employee);
}
Ejemplo n.º 6
0
void gncEmployeeSetID (GncEmployee *employee, const char *id)
{
    if (!employee) return;
    if (!id) return;
    SET_STR(employee, employee->id, id);
    mark_employee (employee);
    gncEmployeeCommitEdit (employee);
}
Ejemplo n.º 7
0
static void gnc_ui_to_employee (EmployeeWindow *ew, GncEmployee *employee)
{
    GncAddress *addr;

    addr = gncEmployeeGetAddr (employee);

    gnc_suspend_gui_refresh ();

    gncEmployeeBeginEdit (employee);

    if (ew->dialog_type == NEW_EMPLOYEE)
        qof_event_gen(QOF_INSTANCE(employee), QOF_EVENT_ADD, NULL);

    gncEmployeeSetID (employee, gtk_editable_get_chars
                      (GTK_EDITABLE (ew->id_entry), 0, -1));
    gncEmployeeSetUsername (employee, gtk_editable_get_chars
                            (GTK_EDITABLE (ew->username_entry), 0, -1));

    gncAddressSetName (addr, gtk_editable_get_chars
                       (GTK_EDITABLE (ew->name_entry), 0, -1));
    gncAddressSetAddr1 (addr, gtk_editable_get_chars
                        (GTK_EDITABLE (ew->addr1_entry), 0, -1));
    gncAddressSetAddr2 (addr, gtk_editable_get_chars
                        (GTK_EDITABLE (ew->addr2_entry), 0, -1));
    gncAddressSetAddr3 (addr, gtk_editable_get_chars
                        (GTK_EDITABLE (ew->addr3_entry), 0, -1));
    gncAddressSetAddr4 (addr, gtk_editable_get_chars
                        (GTK_EDITABLE (ew->addr4_entry), 0, -1));
    gncAddressSetPhone (addr, gtk_editable_get_chars
                        (GTK_EDITABLE (ew->phone_entry), 0, -1));
    gncAddressSetFax (addr, gtk_editable_get_chars
                      (GTK_EDITABLE (ew->fax_entry), 0, -1));
    gncAddressSetEmail (addr, gtk_editable_get_chars
                        (GTK_EDITABLE (ew->email_entry), 0, -1));

    gncEmployeeSetActive (employee, gtk_toggle_button_get_active
                          (GTK_TOGGLE_BUTTON (ew->active_check)));
    gncEmployeeSetLanguage (employee, gtk_editable_get_chars
                            (GTK_EDITABLE (ew->language_entry), 0, -1));

    /* Parse and set the workday and rate amounts */
    gncEmployeeSetWorkday (employee, gnc_amount_edit_get_amount
                           (GNC_AMOUNT_EDIT (ew->workday_amount)));
    gncEmployeeSetRate (employee, gnc_amount_edit_get_amount
                        (GNC_AMOUNT_EDIT (ew->rate_amount)));
    gncEmployeeSetCurrency (employee, gnc_currency_edit_get_currency
                            (GNC_CURRENCY_EDIT (ew->currency_edit)));

    /* Fill in the CCard Acct */
    gncEmployeeSetCCard (employee,
                         (gtk_toggle_button_get_active
                          (GTK_TOGGLE_BUTTON (ew->ccard_acct_check)) ?
                          gnc_account_sel_get_account
                          (GNC_ACCOUNT_SEL (ew->ccard_acct_sel)) : NULL));

    gncEmployeeCommitEdit (employee);
    gnc_resume_gui_refresh ();
}
Ejemplo n.º 8
0
void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate)
{
    if (!employee) return;
    if (gnc_numeric_equal (rate, employee->rate)) return;
    gncEmployeeBeginEdit (employee);
    employee->rate = rate;
    mark_employee (employee);
    gncEmployeeCommitEdit (employee);
}
Ejemplo n.º 9
0
void gncEmployeeSetWorkday (GncEmployee *employee, gnc_numeric workday)
{
    if (!employee) return;
    if (gnc_numeric_equal (workday, employee->workday)) return;
    gncEmployeeBeginEdit (employee);
    employee->workday = workday;
    mark_employee (employee);
    gncEmployeeCommitEdit (employee);
}
Ejemplo n.º 10
0
void gncEmployeeSetCCard (GncEmployee *employee, Account* ccard_acc)
{
    if (!employee) return;
    if (ccard_acc == employee->ccard_acc) return;
    gncEmployeeBeginEdit (employee);
    employee->ccard_acc = ccard_acc;
    mark_employee (employee);
    gncEmployeeCommitEdit (employee);
}
Ejemplo n.º 11
0
void gncEmployeeSetActive (GncEmployee *employee, gboolean active)
{
    if (!employee) return;
    if (active == employee->active) return;
    gncEmployeeBeginEdit (employee);
    employee->active = active;
    mark_employee (employee);
    gncEmployeeCommitEdit (employee);
}
Ejemplo n.º 12
0
void gncEmployeeSetCurrency (GncEmployee *employee, gnc_commodity *currency)
{
    if (!employee || !currency) return;
    if (employee->currency &&
            gnc_commodity_equal (employee->currency, currency))
        return;
    gncEmployeeBeginEdit (employee);
    employee->currency = currency;
    mark_employee (employee);
    gncEmployeeCommitEdit (employee);
}
Ejemplo n.º 13
0
static void
test_numeric_fcn (QofBook *book, const char *message,
                  void (*set) (GncEmployee *, gnc_numeric),
                  gnc_numeric (*get)(const GncEmployee *))
{
    GncEmployee *employee = gncEmployeeCreate (book);
    gnc_numeric num = gnc_numeric_create (17, 1);

    do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
    gncEmployeeBeginEdit (employee);
    set (employee, num);
    do_test (gncEmployeeIsDirty (employee), "test dirty later");
    gncEmployeeCommitEdit (employee);
    do_test (gncEmployeeIsDirty (employee), "test dirty after commit");
    do_test (gnc_numeric_equal (get (employee), num), message);
    gncEmployeeSetActive (employee, FALSE);
    count++;
}
Ejemplo n.º 14
0
static void
test_gint_fcn (QofBook *book, const char *message,
               void (*set) (GncEmployee *, gint),
               gint (*get) (GncEmployee *))
{
    GncEmployee *employee = gncEmployeeCreate (book);
    gint num = 17;

    do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
    gncEmployeeBeginEdit (employee);
    set (employee, num);
    do_test (gncEmployeeIsDirty (employee), "test dirty later");
    gncEmployeeCommitEdit (employee);
    do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
    do_test (get (employee) == num, message);
    gncEmployeeSetActive (employee, FALSE);
    count++;
}
Ejemplo n.º 15
0
static void
test_string_fcn (QofBook *book, const char *message,
                 void (*set) (GncEmployee *, const char *str),
                 const char * (*get)(const GncEmployee *))
{
    GncEmployee *employee = gncEmployeeCreate (book);
    char const *str = get_random_string ();

    do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
    gncEmployeeBeginEdit (employee);
    set (employee, str);
    do_test (gncEmployeeIsDirty (employee), "test dirty later");
    gncEmployeeCommitEdit (employee);
    do_test (gncEmployeeIsDirty (employee), "test dirty after commit");
    do_test (safe_strcmp (get (employee), str) == 0, message);
    gncEmployeeSetActive (employee, FALSE);
    count++;
}
Ejemplo n.º 16
0
static void
test_bool_fcn (QofBook *book, const char *message,
               void (*set) (GncEmployee *, gboolean),
               gboolean (*get) (const GncEmployee *))
{
    GncEmployee *employee = gncEmployeeCreate (book);
    gboolean num = get_random_boolean ();

    do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
    gncEmployeeBeginEdit (employee);
    set (employee, FALSE);
    set (employee, TRUE);
    set (employee, num);
    do_test (gncEmployeeIsDirty (employee), "test dirty later");
    gncEmployeeCommitEdit (employee);
    do_test (gncEmployeeIsDirty (employee), "test dirty after commit");
    do_test (get (employee) == num, message);
    gncEmployeeSetActive (employee, FALSE);
    count++;
}
Ejemplo n.º 17
0
static GncEmployee*
dom_tree_to_employee (xmlNodePtr node, QofBook *book)
{
    struct employee_pdata employee_pdata;
    gboolean successful;

    employee_pdata.employee = gncEmployeeCreate(book);
    employee_pdata.book = book;
    gncEmployeeBeginEdit (employee_pdata.employee);

    successful = dom_tree_generic_parse (node, employee_handlers_v2,
                                         &employee_pdata);
    if (successful)
        gncEmployeeCommitEdit (employee_pdata.employee);
    else
    {
        PERR ("failed to parse employee tree");
        gncEmployeeDestroy (employee_pdata.employee);
        employee_pdata.employee = NULL;
    }

    return employee_pdata.employee;
}
Ejemplo n.º 18
0
/**
 * Listens for MODIFY events from addresses.   If the address belongs to an employee,
 * mark the employee as dirty.
 *
 * @param entity Entity for the event
 * @param event_type Event type
 * @param user_data User data registered with the handler
 * @param event_data Event data passed with the event.
 */
static void
listen_for_address_events(QofInstance *entity, QofEventId event_type,
                          gpointer user_data, gpointer event_data)
{
    GncEmployee* empl;

    if ((event_type & QOF_EVENT_MODIFY) == 0)
    {
        return;
    }
    if (!GNC_IS_ADDRESS(entity))
    {
        return;
    }
    if (!GNC_IS_EMPLOYEE(event_data))
    {
        return;
    }
    empl = GNC_EMPLOYEE(event_data);
    gncEmployeeBeginEdit(empl);
    mark_employee(empl);
    gncEmployeeCommitEdit(empl);
}
Ejemplo n.º 19
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);
}
Ejemplo n.º 20
0
void gncEmployeeDestroy (GncEmployee *employee)
{
    if (!employee) return;
    qof_instance_set_destroying(employee, TRUE);
    gncEmployeeCommitEdit(employee);
}