34 #include <glib/gi18n.h>
36 #include <aqbanking/banking.h>
39 #include "dialog-transfer.h"
50 static void save_templates(GtkWidget *parent,
Account *gnc_acc, GList *templates,
52 static void txn_created_cb(
Transaction *trans, gpointer user_data);
55 save_templates(GtkWidget *parent,
Account *gnc_acc, GList *templates,
58 g_return_if_fail(gnc_acc);
59 if (dont_ask || gnc_verify_dialog(
61 _(
"You have changed the list of online transfer templates, "
62 "but you cancelled the transfer dialog. "
63 "Do you nevertheless want to store the changes?")))
71 txn_created_cb(
Transaction *trans, gpointer user_data)
76 g_return_if_fail(trans_loc);
82 GncABTransType trans_type)
85 gboolean online = FALSE;
87 GList *templates = NULL;
89 gboolean successful = FALSE;
90 gboolean aborted = FALSE;
92 g_return_if_fail(parent && gnc_acc);
98 g_warning(
"gnc_ab_maketrans: Couldn't get AqBanking API");
101 if (AB_Banking_OnlineInit(api
102 #ifdef AQBANKING_VERSION_4_EXACTLY
107 g_warning(
"gnc_ab_maketrans: Couldn't initialize AqBanking API");
116 g_warning(
"gnc_ab_gettrans: No AqBanking account found");
117 gnc_error_dialog(parent, _(
"No valid online banking account assigned."));
128 trans_type, templates);
134 GncGWENGui *gui = NULL;
137 const AB_TRANSACTION *ab_trans;
139 AB_JOB_LIST2 *job_list = NULL;
145 AB_IMEXPORTER_CONTEXT *context = NULL;
146 AB_JOB_STATUS job_status;
153 g_warning(
"gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
164 save_templates(parent, gnc_acc, templates,
165 (result == GNC_RESPONSE_NOW));
166 g_list_free(templates);
169 if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
178 if (!job || AB_Job_CheckAvailability(job
179 #ifndef AQBANKING_VERSION_5_PLUS
184 if (!gnc_verify_dialog(
186 _(
"The backend found an error during the preparation "
187 "of the job. It is not possible to execute this job. \n"
189 "Most probable the bank does not support your chosen "
190 "job or your Online Banking account does not have the permission "
191 "to execute this job. More error messages might be "
192 "visible on your console log.\n"
194 "Do you want to enter the job again?")))
198 job_list = AB_Job_List2_new();
199 AB_Job_List2_PushBack(job_list, job);
206 case SINGLE_DEBITNOTE:
207 gnc_xfer_dialog_set_title(
208 xfer_dialog, _(
"Online Banking Direct Debit Note"));
209 gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
211 case SINGLE_INTERNAL_TRANSFER:
212 gnc_xfer_dialog_set_title(
213 xfer_dialog, _(
"Online Banking Bank-Internal Transfer"));
214 gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
217 gnc_xfer_dialog_set_title(
218 xfer_dialog, _(
"Online Banking European (SEPA) Transfer"));
219 gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
222 gnc_xfer_dialog_set_title(
223 xfer_dialog, _(
"Online Banking European (SEPA) Debit Note"));
224 gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
226 case SINGLE_TRANSFER:
228 gnc_xfer_dialog_set_title(
229 xfer_dialog, _(
"Online Banking Transaction"));
230 gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
232 gnc_xfer_dialog_set_to_show_button_active(xfer_dialog, TRUE);
235 AB_Value_GetValueAsDouble(AB_Transaction_GetValue(ab_trans)),
238 gnc_xfer_dialog_set_amount(xfer_dialog, amount);
239 gnc_xfer_dialog_set_amount_sensitive(xfer_dialog, FALSE);
240 gnc_xfer_dialog_set_date_sensitive(xfer_dialog, FALSE);
243 gnc_xfer_dialog_set_description(xfer_dialog, description);
247 gnc_xfer_dialog_set_memo(xfer_dialog, memo);
250 gnc_xfer_dialog_set_txn_cb(xfer_dialog, txn_created_cb, &gnc_trans);
253 successful = gnc_xfer_dialog_run_until_done(xfer_dialog);
256 if (!successful || !gnc_trans)
262 if (result == GNC_RESPONSE_NOW)
265 context = AB_ImExporterContext_new();
270 g_warning(
"gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
276 AB_Banking_ExecuteJobs(api, job_list, context
277 #ifndef AQBANKING_VERSION_5_PLUS
287 job_status = AB_Job_GetStatus(job);
288 if (job_status != AB_Job_StatusFinished
289 && job_status != AB_Job_StatusPending)
292 if (!gnc_verify_dialog(
294 _(
"An error occurred while executing the job. Please check "
295 "the log window for the exact error message.\n"
297 "Do you want to enter the job again?")))
317 if (gnc_trans && !successful)
327 AB_ImExporterContext_free(context);
330 AB_Job_List2_free(job_list);
345 while (!successful && !aborted);
351 #ifdef AQBANKING_VERSION_4_EXACTLY
352 AB_Banking_OnlineFini(api, 0);
354 AB_Banking_OnlineFini(api);
GncABTransDialog * gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc, gint commodity_scu, GncABTransType trans_type, GList *templates)
Templates for AqBanking transactions.
gnc_numeric double_to_gnc_numeric(double n, gint64 denom, gint how)
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
int xaccAccountGetCommoditySCU(const Account *acc)
gchar * gnc_ab_description_to_gnc(const AB_TRANSACTION *ab_trans)
gchar * gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans)
AB_JOB * gnc_ab_trans_dialog_get_job(const GncABTransDialog *td)
GncGWENGui * gnc_GWEN_Gui_get(GtkWidget *parent)
void xaccTransDestroy(Transaction *trans)
GList * gnc_ab_trans_templ_list_to_kvp_list(GList *k)
Dialog for AqBanking transaction data.
void gnc_GWEN_Gui_release(GncGWENGui *gui)
GList * gnc_ab_trans_dialog_get_templ(const GncABTransDialog *td, gboolean *changed)
AB_BANKING * gnc_AB_BANKING_new(void)
void xaccTransCommitEdit(Transaction *trans)
void xaccTransBeginEdit(Transaction *trans)
void gnc_ab_set_book_template_list(QofBook *b, GList *template_list)
gint gnc_AB_BANKING_fini(AB_BANKING *api)
AB_ACCOUNT * gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
GncABImExContextImport * gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns, AB_BANKING *api, GtkWidget *parent)
void gnc_ab_trans_dialog_free(GncABTransDialog *td)
const AB_TRANSACTION * gnc_ab_trans_dialog_get_ab_trans(const GncABTransDialog *td)
GList * gnc_ab_trans_templ_list_new_from_kvp_list(GList *v)
GtkWidget * gnc_ab_trans_dialog_get_parent(const GncABTransDialog *td)
GUI callbacks for AqBanking.
GList * gnc_ab_get_book_template_list(QofBook *b)
API for Transactions and Splits (journal entries)
gint gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td)
AqBanking utility functions.
const gchar * QofLogModule
void gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc, GncABTransType trans_type)