static void gnc_plugin_business_cmd_employee_process_payment (GtkAction *action, GncMainWindowActionData *mw) { GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); gnc_ui_payment_new (GTK_WINDOW (mw->window), priv->last_employee, gnc_get_current_book ()); }
PaymentWindow * gnc_ui_payment_new_with_txn (GncOwner *owner, Transaction *txn) { SplitList *slist; Split *assetaccount_split; Split *postaccount_split; gnc_numeric amount; PaymentWindow *pw; if (!txn) return NULL; // We require the txn to have one split in an Asset account. slist = xaccTransGetSplitList(txn); if (!slist) return NULL; if (countAssetAccounts(slist) == 0) { g_message("No asset splits in txn \"%s\"; cannot use this for assigning a payment.", xaccTransGetDescription(txn)); return NULL; } assetaccount_split = getFirstAssetAccountSplit(slist); postaccount_split = getFirstAPARAccountSplit(slist); // watch out: Might be NULL amount = xaccSplitGetValue(assetaccount_split); pw = gnc_ui_payment_new(owner, qof_instance_get_book(QOF_INSTANCE(txn))); g_assert(assetaccount_split); // we can rely on this because of the countAssetAccounts() check above g_debug("Amount=%s", gnc_numeric_to_string(amount)); // Fill in the values from the given txn pw->pre_existing_txn = txn; gnc_ui_payment_window_set_num(pw, gnc_get_num_action(txn, assetaccount_split)); gnc_ui_payment_window_set_memo(pw, xaccTransGetDescription(txn)); { GDate txn_date = xaccTransGetDatePostedGDate (txn); gnc_ui_payment_window_set_date(pw, &txn_date); } gnc_ui_payment_window_set_amount(pw, amount); gnc_ui_payment_window_set_xferaccount(pw, xaccSplitGetAccount(assetaccount_split)); if (postaccount_split) gnc_ui_payment_window_set_postaccount(pw, xaccSplitGetAccount(postaccount_split)); return pw; }
static void payment_customer_cb (gpointer *cust_p, gpointer user_data) { struct _customer_select_window *sw = user_data; GncOwner owner; GncCustomer *cust; g_return_if_fail (cust_p && user_data); cust = *cust_p; if (!cust) return; gncOwnerInitCustomer (&owner, cust); gnc_ui_payment_new (&owner, sw->book); return; }
static void payment_job_cb (gpointer *job_p, gpointer user_data) { struct _job_select_window *sw = user_data; GncOwner owner; GncJob *job; g_return_if_fail (job_p && user_data); job = *job_p; if (!job) return; gncOwnerInitJob (&owner, job); gnc_ui_payment_new (&owner, sw->book); return; }
static void payment_employee_cb (gpointer *employee_p, gpointer user_data) { struct _employee_select_window *sw = user_data; GncOwner owner; GncEmployee *employee; g_return_if_fail (employee_p && user_data); employee = *employee_p; if (!employee) return; gncOwnerInitEmployee (&owner, employee); gnc_ui_payment_new (&owner, sw->book); return; }