34 #include <glib/gi18n.h> 36 #include <aqbanking/banking.h> 38 #include <gnc-aqbanking-templates.h> 40 #include "dialog-transfer.h" 48 G_GNUC_UNUSED
static QofLogModule log_module =
G_LOG_DOMAIN;
50 static void txn_created_cb(Transaction *trans, gpointer user_data);
52 #if (AQBANKING_VERSION_INT >= 60400) 54 save_templates(GtkWidget *parent,
Account *gnc_acc, GList *templates,
57 g_return_if_fail(gnc_acc);
58 if (dont_ask || gnc_verify_dialog (
59 GTK_WINDOW (parent), FALSE,
"%s",
60 _(
"You have changed the list of online transfer templates, " 61 "but you cancelled the transfer dialog. " 62 "Do you nevertheless want to store the changes?")))
70 txn_created_cb(Transaction *trans, gpointer user_data)
72 Transaction **trans_loc = user_data;
75 g_return_if_fail(trans_loc);
81 GncABTransType trans_type)
84 GNC_AB_ACCOUNT_SPEC *ab_acc;
85 GList *templates = NULL;
86 GncABTransDialog *td = NULL;
87 gboolean successful = FALSE;
88 gboolean aborted = FALSE;
90 g_return_if_fail(parent && gnc_acc);
96 g_warning(
"gnc_ab_maketrans: Couldn't get AqBanking API");
103 g_warning(
"gnc_ab_gettrans: No AqBanking account found");
104 gnc_error_dialog (GTK_WINDOW (parent), _(
"No valid online banking account assigned."));
108 #if (AQBANKING_VERSION_INT >= 60400) 109 if (trans_type == SEPA_INTERNAL_TRANSFER)
112 templates = gnc_ab_trans_templ_list_new_from_ref_accounts (ab_acc);
113 if (templates == NULL)
115 g_warning (
"gnc_ab_gettrans: No reference accounts found");
116 gnc_error_dialog (GTK_WINDOW (parent), _(
"No reference accounts found."));
125 gnc_account_get_book(gnc_acc));
131 trans_type, templates);
137 GncGWENGui *gui = NULL;
139 const AB_TRANSACTION *ab_trans;
140 GNC_AB_JOB *job = NULL;
141 GNC_AB_JOB_LIST2 *job_list = NULL;
142 XferDialog *xfer_dialog = NULL;
146 Transaction *gnc_trans = NULL;
147 AB_IMEXPORTER_CONTEXT *context = NULL;
148 GNC_AB_JOB_STATUS job_status;
149 GncABImExContextImport *ieci = NULL;
155 #if (AQBANKING_VERSION_INT >= 60400) 157 templates = gnc_ab_trans_dialog_get_templ(td, &changed);
158 if (trans_type != SEPA_INTERNAL_TRANSFER && changed)
161 save_templates(parent, gnc_acc, templates,
162 (result == GNC_RESPONSE_NOW));
164 g_list_free(templates);
168 if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
177 if (!job || AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_GetCommand(job))==NULL)
179 if (!gnc_verify_dialog (
180 GTK_WINDOW (parent), FALSE,
"%s",
181 _(
"The backend found an error during the preparation " 182 "of the job. It is not possible to execute this job.\n" 184 "Most probable the bank does not support your chosen " 185 "job or your Online Banking account does not have the permission " 186 "to execute this job. More error messages might be " 187 "visible on your console log.\n" 189 "Do you want to enter the job again?")))
193 job_list = AB_Transaction_List2_new();
194 AB_Transaction_List2_PushBack(job_list, job);
200 case SINGLE_DEBITNOTE:
201 gnc_xfer_dialog_set_title(
202 xfer_dialog, _(
"Online Banking Direct Debit Note"));
203 gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
205 case SINGLE_INTERNAL_TRANSFER:
206 gnc_xfer_dialog_set_title(
207 xfer_dialog, _(
"Online Banking Bank-Internal Transfer"));
208 gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
211 gnc_xfer_dialog_set_title(
212 xfer_dialog, _(
"Online Banking European (SEPA) Transfer"));
213 gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
215 #if (AQBANKING_VERSION_INT >= 60400) 216 case SEPA_INTERNAL_TRANSFER:
217 gnc_xfer_dialog_set_title (
218 xfer_dialog, _(
"Online Banking European (SEPA) Internal Transfer"));
219 gnc_xfer_dialog_lock_from_account_tree (xfer_dialog);
223 gnc_xfer_dialog_set_title(
224 xfer_dialog, _(
"Online Banking European (SEPA) Debit Note"));
225 gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
227 case SINGLE_TRANSFER:
229 gnc_xfer_dialog_set_title(
230 xfer_dialog, _(
"Online Banking Transaction"));
231 gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
233 gnc_xfer_dialog_set_to_show_button_active(xfer_dialog, TRUE);
236 AB_Value_GetValueAsDouble(AB_Transaction_GetValue(ab_trans)),
239 gnc_xfer_dialog_set_amount(xfer_dialog, amount);
240 gnc_xfer_dialog_set_amount_sensitive(xfer_dialog, FALSE);
241 gnc_xfer_dialog_set_date_sensitive(xfer_dialog, FALSE);
245 gnc_xfer_dialog_set_description(xfer_dialog, description);
249 gnc_xfer_dialog_set_memo(xfer_dialog, memo);
252 gnc_xfer_dialog_set_txn_cb(xfer_dialog, txn_created_cb, &gnc_trans);
255 successful = gnc_xfer_dialog_run_until_done(xfer_dialog);
258 if (!successful || !gnc_trans)
264 if (result == GNC_RESPONSE_NOW)
267 context = AB_ImExporterContext_new();
272 g_warning(
"gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
278 AB_Banking_SendCommands(api, job_list, context);
284 job_status = AB_Transaction_GetStatus(job);
285 if (job_status != AB_Transaction_StatusAccepted
286 && job_status != AB_Transaction_StatusPending)
289 if (!gnc_verify_dialog (
290 GTK_WINDOW (parent), FALSE,
"%s",
291 _(
"An error occurred while executing the job. Please check " 292 "the log window for the exact error message.\n" 294 "Do you want to enter the job again?")))
314 if (gnc_trans && !successful)
324 AB_ImExporterContext_free(context);
327 AB_Transaction_List2_free(job_list);
332 AB_Transaction_free(job);
342 while (!successful && !aborted);
gnc_numeric double_to_gnc_numeric(double in, gint64 denom, gint how)
Convert a floating-point number to a gnc_numeric.
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
GncABTransDialog * gnc_ab_trans_dialog_new(GtkWidget *parent, GNC_AB_ACCOUNT_SPEC *ab_acc, gint commodity_scu, GncABTransType trans_type, GList *templates)
Create a new AqBanking transfer dialog.
GNC_AB_JOB * gnc_ab_trans_dialog_get_job(const GncABTransDialog *td)
Receive the Aqbanking job filled by the dialog.
gchar * gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans)
Create the appropriate memo field for a GnuCash Split by the information given in the AB_TRANSACTION ...
GncGWENGui * gnc_GWEN_Gui_get(GtkWidget *parent)
When called for the first time, create a unique GncGWENGui object featuring a GWEN_GUI with all neces...
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
gchar * gnc_ab_description_to_gnc(const AB_TRANSACTION *ab_trans, gboolean is_ofx)
Create the appropriate description field for a GnuCash Transaction by the information given in the AB...
Dialog for AqBanking transaction data.
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Currently a no-op.
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
void gnc_ab_set_book_template_list(QofBook *b, GList *template_list)
Set the GList of kvp_frames of template transactions in the Book b to template_list.
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
GncABImExContextImport * gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns, AB_BANKING *api, GtkWidget *parent)
Import balances and transactions found in a AB_IMEXPORTER_CONTEXT into GnuCash.
void gnc_ab_trans_dialog_free(GncABTransDialog *td)
Free a Aqbanking transfer dialog.
GList * gnc_ab_trans_templ_list_new_from_book(QofBook *b)
Obtain the list of QofTemplates saved in a Book.
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
GNC_AB_ACCOUNT_SPEC * gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
Get the corresponding AqBanking account to the GnuCash account gnc_acc.
const AB_TRANSACTION * gnc_ab_trans_dialog_get_ab_trans(const GncABTransDialog *td)
Receive the Aqbanking Transaction filled by the dialog.
GtkWidget * gnc_ab_trans_dialog_get_parent(const GncABTransDialog *td)
Retrieve the widget used as parent.
GUI callbacks for AqBanking.
API for Transactions and Splits (journal entries)
gint gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td)
Run the Aqbanking transfer dialog until correct values where entered or the user cancelled the dialog...
AqBanking utility functions.
void gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc, GncABTransType trans_type)
Create SEPA transfers.