Esempio n. 1
0
static void
qof_instance_coll_copy(QofInstance *original, gpointer user_data)
{
    QofInstanceCopyData *qecd;
    QofBook *book;
    QofInstance *inst;
    const GncGUID *g;

    g_return_if_fail(original != NULL);
    g_return_if_fail(user_data != NULL);
    qecd = (QofInstanceCopyData*)user_data;
    book = qof_session_get_book(qecd->new_session);
    if (!qof_object_compliance(original->e_type, TRUE))
    {
        return;
    }
    inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
    qecd->to = inst;
    qecd->from = original;
    g = qof_instance_get_guid(original);
    qof_instance_set_guid(qecd->to, g);
    qof_begin_edit(inst);
    g_slist_foreach(qecd->param_list, qof_instance_foreach_copy, qecd);
    qof_commit_edit(inst);
}
Esempio n. 2
0
void gncEntryCommitEdit (GncEntry *entry)
{
    /* GnuCash 2.6.3 and earlier didn't handle entry kvp's... */
    if (!kvp_frame_is_empty (entry->inst.kvp_data))
        gnc_features_set_used (qof_instance_get_book (QOF_INSTANCE (entry)), GNC_FEATURE_KVP_EXTRA_DATA);

    if (!qof_commit_edit (QOF_INSTANCE(entry))) return;
    qof_commit_edit_part2 (&entry->inst, gncEntryOnError,
                           gncEntryOnDone, entry_free);
}
Esempio n. 3
0
void gncAddressCommitEdit (GncAddress *addr)
{
    /* GnuCash 2.6.3 and earlier didn't handle address kvp's... */
    if (!kvp_frame_is_empty (addr->inst.kvp_data))
        gnc_features_set_used (qof_instance_get_book (QOF_INSTANCE (addr)), GNC_FEATURE_KVP_EXTRA_DATA);

    if (!qof_commit_edit (QOF_INSTANCE(addr))) return;
    qof_commit_edit_part2 (&addr->inst, gncAddressOnError,
                           gncAddressOnDone, address_free);
}
Esempio n. 4
0
void gncTaxTableCommitEdit (GncTaxTable *table)
{
    /* GnuCash 2.6.3 and earlier didn't handle taxtable kvp's... */
    if (!kvp_frame_is_empty (table->inst.kvp_data))
        gnc_features_set_used (qof_instance_get_book (QOF_INSTANCE (table)), GNC_FEATURE_KVP_EXTRA_DATA);

    if (!qof_commit_edit (QOF_INSTANCE(table))) return;
    qof_commit_edit_part2 (&table->inst, gncTaxTableOnError,
                           gncTaxTableOnDone, table_free);
}
Esempio n. 5
0
static void
qofJobSetOwner (GncJob *job, QofInstance *ent)
{
    if (!job || !ent)
    {
        return;
    }
    qof_begin_edit(job);
    qofOwnerSetEntity(&job->owner, ent);
    mark_job (job);
    qof_commit_edit(job);
}
Esempio n. 6
0
static void
gnc_payment_dialog_remember_account (PaymentWindow *pw, Account *acc)
{
     QofInstance *owner = qofOwnerGetOwner (&pw->owner);
    const GncGUID *guid;

    if (!acc) return;

    guid = xaccAccountGetGUID(acc);
    qof_begin_edit (owner);
    qof_instance_set (owner,
		      "payment-last-account", guid,
		      NULL);
    qof_commit_edit (owner);
}
Esempio n. 7
0
static void
qof_instance_list_foreach(gpointer data, gpointer user_data)
{
    QofInstanceCopyData *qecd;
    QofInstance *original;
    QofInstance *inst;
    QofBook *book;
    const GncGUID *g;

    g_return_if_fail(data != NULL);
    original = QOF_INSTANCE(data);
    g_return_if_fail(user_data != NULL);
    qecd = (QofInstanceCopyData*)user_data;
    if (qof_instance_guid_match(qecd->new_session, original))
    {
        return;
    }
    qecd->from = original;
    if (!qof_object_compliance(original->e_type, FALSE))
    {
        qecd->error = TRUE;
        return;
    }
    book = qof_session_get_book(qecd->new_session);
    inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
    if (!inst)
    {
        PERR (" failed to create new entity type=%s.", original->e_type);
        qecd->error = TRUE;
        return;
    }
    qecd->to = inst;
    g = qof_instance_get_guid(original);
    qof_instance_set_guid(qecd->to, g);
    if (qecd->param_list != NULL)
    {
        g_slist_free(qecd->param_list);
        qecd->param_list = NULL;
    }
    qof_class_param_foreach(original->e_type, qof_instance_param_cb, qecd);
    qof_begin_edit(inst);
    g_slist_foreach(qecd->param_list, qof_instance_foreach_copy, qecd);
    qof_commit_edit(inst);
}
Esempio n. 8
0
gboolean
qof_instance_copy_to_session(QofSession* new_session, QofInstance* original)
{
    QofInstanceCopyData qecd;
    QofInstance *inst;
    QofBook *book;

    if (!new_session || !original)
    {
        return FALSE;
    }
    if (qof_instance_guid_match(new_session, original))
    {
        return FALSE;
    }
    if (!qof_object_compliance(original->e_type, TRUE))
    {
        return FALSE;
    }
    qof_event_suspend();
    qecd.param_list = NULL;
    book = qof_session_get_book(new_session);
    qecd.new_session = new_session;
    qof_book_set_partial(book);
    inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
    qecd.to = inst;
    qecd.from = original;
    qof_instance_set_guid(qecd.to, qof_instance_get_guid(original));
    qof_begin_edit(inst);
    qof_class_param_foreach(original->e_type, qof_instance_param_cb, &qecd);
    qof_commit_edit(inst);
    if (g_slist_length(qecd.param_list) == 0)
    {
        return FALSE;
    }
    g_slist_foreach(qecd.param_list, qof_instance_foreach_copy, &qecd);
    g_slist_free(qecd.param_list);
    qof_event_resume();
    return TRUE;
}
Esempio n. 9
0
void gncEntryCommitEdit (GncEntry *entry)
{
    if (!qof_commit_edit (QOF_INSTANCE(entry))) return;
    qof_commit_edit_part2 (&entry->inst, gncEntryOnError,
                           gncEntryOnDone, entry_free);
}
Esempio n. 10
0
void
qof_book_commit_edit(QofBook *book)
{
    if (!qof_commit_edit (QOF_INSTANCE(book))) return;
    qof_commit_edit_part2 (&book->inst, commit_err, noop, noop/*lot_free*/);
}
Esempio n. 11
0
File: gncJob.c Progetto: 573/gnucash
void gncJobCommitEdit (GncJob *job)
{
    if (!qof_commit_edit (QOF_INSTANCE(job))) return;
    qof_commit_edit_part2 (&job->inst, gncJobOnError,
                           gncJobOnDone, job_free);
}
Esempio n. 12
0
void gncEmployeeCommitEdit (GncEmployee *employee)
{
    if (!qof_commit_edit (QOF_INSTANCE(employee))) return;
    qof_commit_edit_part2 (&employee->inst, gncEmployeeOnError,
                           gncEmployeeOnDone, emp_free);
}
Esempio n. 13
0
void gncBillTermCommitEdit (GncBillTerm *term)
{
    if (!qof_commit_edit (QOF_INSTANCE(term))) return;
    qof_commit_edit_part2 (&term->inst, gncBillTermOnError,
                           on_done, bill_free);
}
Esempio n. 14
0
void
gnc_sx_commit_edit (SchedXaction *sx)
{
    if (!qof_commit_edit (QOF_INSTANCE(sx))) return;
    qof_commit_edit_part2 (&sx->inst, commit_err, commit_done, sx_free);
}