コード例 #1
0
xmlNodePtr
gnc_owner_to_dom_tree (const char* tag, const GncOwner* owner)
{
    xmlNodePtr ret;
    const char* type_str;

    switch (gncOwnerGetType (owner))
    {
    case GNC_OWNER_CUSTOMER:
        type_str = GNC_ID_CUSTOMER;
        break;
    case GNC_OWNER_JOB:
        type_str = GNC_ID_JOB;
        break;
    case GNC_OWNER_VENDOR:
        type_str = GNC_ID_VENDOR;
        break;
    case GNC_OWNER_EMPLOYEE:
        type_str = GNC_ID_EMPLOYEE;
        break;
    default:
        PWARN ("Invalid owner type: %d", gncOwnerGetType (owner));
        return NULL;
    }

    ret = xmlNewNode (NULL, BAD_CAST tag);
    xmlSetProp (ret, BAD_CAST "version", BAD_CAST owner_version_string);

    xmlAddChild (ret, text_to_dom_tree (owner_type_string, type_str));
    xmlAddChild (ret, guid_to_dom_tree (owner_id_string,
                                        gncOwnerGetGUID (owner)));

    return ret;
}
コード例 #2
0
ファイル: gncOwner.c プロジェクト: Justinadanielson/gnucash
GncGUID gncOwnerRetGUID (GncOwner *owner)
{
    const GncGUID *guid = gncOwnerGetGUID (owner);
    if (guid)
        return *guid;
    return *guid_null ();
}
コード例 #3
0
ファイル: gncOwner.c プロジェクト: Justinadanielson/gnucash
void gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot)
{
     if (!owner || !lot)
        return;

    gnc_lot_begin_edit (lot);

    qof_instance_set (QOF_INSTANCE (lot),
		      "owner-type", (gint64)gncOwnerGetType (owner),
		      "owner-guid", gncOwnerGetGUID (owner),
		      NULL);
    gnc_lot_commit_edit (lot);
}
コード例 #4
0
ファイル: dialog-job.c プロジェクト: mikikomat/gnucash
GNCSearchWindow *
gnc_job_search (GncJob *start, GncOwner *owner, QofBook *book)
{
    QofQuery *q, *q2 = NULL;
    QofIdType type = GNC_JOB_MODULE_NAME;
    struct _job_select_window *sw;
    static GList *params = NULL;
    static GList *columns = NULL;
    static GNCSearchCallbackButton buttons[] =
    {
        { N_("View/Edit Job"), edit_job_cb, NULL, TRUE},
        { N_("View Invoices"), invoice_job_cb, NULL, TRUE},
        { N_("Process Payment"), payment_job_cb, NULL, FALSE},
        { NULL },
    };

    g_return_val_if_fail (book, NULL);

    /* Build parameter list in reverse order */
    if (params == NULL)
    {
        params = gnc_search_param_prepend (params, _("Owner's Name"), NULL, type,
                                           JOB_OWNER, OWNER_NAME, NULL);
        params = gnc_search_param_prepend (params, _("Only Active?"), NULL, type,
                                           JOB_ACTIVE, NULL);
        params = gnc_search_param_prepend (params, _("Billing ID"), NULL, type,
                                           JOB_REFERENCE, NULL);
        params = gnc_search_param_prepend (params, _("Job Number"), NULL, type,
                                           JOB_ID, NULL);
        params = gnc_search_param_prepend (params, _("Job Name"), NULL, type,
                                           JOB_NAME, NULL);
    }

    /* Build the column list in reverse order */
    if (columns == NULL)
    {
        columns = gnc_search_param_prepend (columns, _("Billing ID"), NULL, type,
                                            JOB_REFERENCE, NULL);
        columns = gnc_search_param_prepend (columns, _("Company"), NULL, type,
                                            JOB_OWNER, OWNER_NAME, NULL);
        columns = gnc_search_param_prepend (columns, _("Job Name"), NULL, type,
                                            JOB_NAME, NULL);
        columns = gnc_search_param_prepend (columns, _("ID #"), NULL, type,
                                            JOB_ID, NULL);
    }

    /* Build the queries */
    q = qof_query_create_for (type);
    qof_query_set_book (q, book);

    /* If we have a start job but, for some reason, not an owner -- grab
     * the owner from the starting job.
     */
    if ((!owner || !gncOwnerGetGUID (owner)) && start)
        owner = gncJobGetOwner (start);

    /* If owner is supplied, limit all searches to invoices who's owner
     * is the supplied owner!  Show all invoices by this owner.
     */
    if (owner && gncOwnerGetGUID (owner))
    {
        qof_query_add_guid_match (q, g_slist_prepend
                                  (g_slist_prepend (NULL, QOF_PARAM_GUID),
                                   JOB_OWNER),
                                  gncOwnerGetGUID (owner), QOF_QUERY_AND);

        q2 = qof_query_copy (q);
    }

#if 0
    if (start)
    {
        if (q2 == NULL)
            q2 = qof_query_copy (q);

        qof_query_add_guid_match (q2, g_slist_prepend (NULL, QOF_PARAM_GUID),
                                  gncJobGetGUID (start), QOF_QUERY_AND);
    }
#endif

    /* launch select dialog and return the result */
    sw = g_new0 (struct _job_select_window, 1);

    if (owner)
    {
        gncOwnerCopy (owner, &(sw->owner_def));
        sw->owner = &(sw->owner_def);
    }
    sw->book = book;
    sw->q = q;

    return gnc_search_dialog_create (type, _("Find Job"),
                                     params, columns, q, q2, buttons, NULL,
                                     new_job_cb, sw, free_userdata_cb,
                                     GCONF_SECTION_SEARCH, NULL);
}
コード例 #5
0
ファイル: gncOwner.c プロジェクト: Justinadanielson/gnucash
const GncGUID * gncOwnerGetEndGUID (const GncOwner *owner)
{
    if (!owner) return NULL;
    return gncOwnerGetGUID (gncOwnerGetEndOwner (owner));
}
コード例 #6
0
static void
gnc_entry_ledger_set_watches (GncEntryLedger *ledger, GList *entries)
{
    GList *node;
    QofIdType type = NULL;

    gnc_gui_component_clear_watches (ledger->component_id);

    switch (ledger->type)
    {
    case GNCENTRY_ORDER_ENTRY:
    case GNCENTRY_ORDER_VIEWER:
        type = GNC_ORDER_MODULE_NAME;
        break;

    case GNCENTRY_INVOICE_ENTRY:
    case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
        /* Watch the invoice owner to see when items get added via orders */
        gnc_gui_component_watch_entity (ledger->component_id,
                                        gncOwnerGetGUID
                                        (gncInvoiceGetOwner (ledger->invoice)),
                                        QOF_EVENT_MODIFY);
    case GNCENTRY_INVOICE_VIEWER:
    case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
    case GNCENTRY_BILL_ENTRY:
    case GNCENTRY_BILL_VIEWER:
    case GNCENTRY_EXPVOUCHER_ENTRY:
    case GNCENTRY_EXPVOUCHER_VIEWER:
    case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
    case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
    case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
    case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
        type = GNC_INVOICE_MODULE_NAME;
        break;

    default:
        g_warning ("Invalid ledger type");
        break;
    }

    gnc_gui_component_watch_entity_type (ledger->component_id,
                                         type,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);

    /* To make sure the xfer cell is up to date */
    gnc_gui_component_watch_entity_type (ledger->component_id,
                                         GNC_ID_ACCOUNT,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY
                                         | GNC_EVENT_ITEM_CHANGED);

    /* To make sure the taxtable cell is up to date */
    gnc_gui_component_watch_entity_type (ledger->component_id,
                                         GNC_TAXTABLE_MODULE_NAME,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);

    /* For expense vouchers, watch the employee and refresh if it's changed */
    if (ledger->type == GNCENTRY_EXPVOUCHER_ENTRY)
    {
        const GncOwner *owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (ledger->invoice));
        GncEmployee *employee = gncOwnerGetEmployee (owner);

        if (employee)
            gnc_gui_component_watch_entity (ledger->component_id,
                                            gncEmployeeGetGUID (employee),
                                            QOF_EVENT_MODIFY);
    }

    for (node = entries; node; node = node->next)
    {
        GncEntry *entry = node->data;
        gnc_gui_component_watch_entity (ledger->component_id,
                                        gncEntryGetGUID (entry),
                                        QOF_EVENT_MODIFY);
    }
}