GnuCash  4.8a-134-g214de30c7+
Files | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
AqBanking

Files

file  assistant-ab-initial.h
 AqBanking setup functionality.
 
file  dialog-ab-trans.h
 Dialog for AqBanking transaction data.
 
file  gnc-ab-getbalance.h
 AqBanking getbalance functions.
 
file  gnc-ab-getbalance.h
 AqBanking getbalance functions.
 
file  gnc-ab-kvp.h
 AqBanking KVP handling.
 
file  gnc-ab-transfer.h
 Dialog for AqBanking transaction data.
 
file  gnc-ab-utils.h
 AqBanking utility functions.
 
file  gnc-flicker-gui.h
 GUI callbacks for Flicker and ChipTAN(optisch)
 
file  gnc-gwen-gui.h
 GUI callbacks for AqBanking.
 
file  gnc-plugin-aqbanking.h
 Plugin registration of the AqBanking module.
 

Data Structures

struct  GncFlickerGui
 
struct  GncPluginAqBanking
 
struct  GncPluginAqBankingClass
 

Macros

#define GNC_RESPONSE_NOW   GTK_RESPONSE_YES
 
#define GNC_RESPONSE_LATER   GTK_RESPONSE_NO
 
#define AQBANKING_VERSION_INT   (10000 * AQBANKING_VERSION_MAJOR + 100 * AQBANKING_VERSION_MINOR + AQBANKING_VERSION_PATCHLEVEL)
 A define that combines the aqbanking version number into one single integer number. More...
 
#define GWENHYWFAR_VERSION_INT   (10000 * GWENHYWFAR_VERSION_MAJOR + 100 * GWENHYWFAR_VERSION_MINOR + GWENHYWFAR_VERSION_PATCHLEVEL)
 A define that combines the gwenhywfar version number into one single integer number. More...
 
#define GNC_AB_ACCOUNT_SPEC   AB_ACCOUNT
 
#define GNC_AB_ACCOUNT_SPEC_LIST   AB_ACCOUNT_LIST2
 
#define GNC_AB_JOB   AB_JOB
 
#define GNC_AB_JOB_LIST2   AB_JOB_LIST2
 
#define GNC_AB_JOB_LIST2_ITERATOR   AB_JOB_LIST2_ITERATOR
 
#define GNC_AB_JOB_STATUS   AB_JOB_STATUS
 
#define GNC_GWEN_DATE   GWEN_TIME
 
#define GNC_PREFS_GROUP_AQBANKING   "dialogs.import.hbci"
 
#define GNC_PREF_FORMAT_SWIFT940   "format-swift-mt940"
 
#define GNC_PREF_FORMAT_SWIFT942   "format-swift-mt942"
 
#define GNC_PREF_FORMAT_DTAUS   "format-dtaus"
 
#define GNC_PREF_USE_TRANSACTION_TXT   "use-ns-transaction-text"
 
#define GNC_PREF_VERBOSE_DEBUG   "verbose-debug"
 
#define AWAIT_BALANCES   1 << 1
 
#define FOUND_BALANCES   1 << 2
 
#define IGNORE_BALANCES   1 << 3
 
#define AWAIT_TRANSACTIONS   1 << 4
 
#define FOUND_TRANSACTIONS   1 << 5
 
#define IGNORE_TRANSACTIONS   1 << 6
 
#define GNC_TYPE_PLUGIN_AQBANKING   (gnc_plugin_aqbanking_get_type())
 
#define GNC_PLUGIN_AQBANKING(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBanking))
 
#define GNC_PLUGIN_AQBANKING_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBankingClass))
 
#define GNC_IS_PLUGIN_AQBANKING(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_AQBANKING))
 
#define GNC_IS_PLUGIN_AQBANKING_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_AQBANKING))
 
#define GNC_PLUGIN_AQBANKING_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBankingClass))
 
#define GNC_PLUGIN_AQBANKING_NAME   "gnc-plugin-aqbanking"
 

Typedefs

typedef typedefG_BEGIN_DECLS struct _GncABTransTempl GncABTransTempl
 A template for an AqBanking transaction.
 
typedef enum _GncABTransType GncABTransType
 
typedef typedefG_BEGIN_DECLS struct _GncGWENGui GncGWENGui
 

Enumerations

enum  _GncABTransType {
  SINGLE_TRANSFER = 0, SINGLE_DEBITNOTE, SINGLE_INTERNAL_TRANSFER, SEPA_TRANSFER,
  SEPA_DEBITNOTE
}
 

Functions

GncABTransTemplgnc_ab_trans_templ_new (void)
 Create a template with unset contents. More...
 
GncABTransTemplgnc_ab_trans_templ_new_full (const gchar *name, const gchar *recp_name, const gchar *recp_account, const gchar *recp_bankcode, gnc_numeric amount, const gchar *purpose, const gchar *purpose_cont)
 Create a template with given contents. More...
 
GList * gnc_ab_trans_templ_list_new_from_book (QofBook *b)
 Obtain the list of QofTemplates saved in a Book. More...
 
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. More...
 
void gnc_ab_trans_templ_free (GncABTransTempl *t)
 Free the memory used by a template. More...
 
void gnc_ab_trans_templ_list_free (GList *l)
 Free the memory used by a list of templates, including the list itself. More...
 
const gchar * gnc_ab_trans_templ_get_name (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_recp_name (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_recp_account (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_recp_bankcode (const GncABTransTempl *t)
 
gnc_numeric gnc_ab_trans_templ_get_amount (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_purpose (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_purpose_cont (const GncABTransTempl *t)
 
void gnc_ab_trans_templ_set_name (GncABTransTempl *t, const gchar *name)
 Set the name of a template. More...
 
void gnc_ab_trans_templ_set_recp_name (GncABTransTempl *t, const gchar *recp_name)
 Replace the Account Number of the recipient stored in a template. More...
 
void gnc_ab_trans_templ_set_recp_account (GncABTransTempl *t, const gchar *recp_account)
 Replace the Account Number of the recipient stored in a template. More...
 
void gnc_ab_trans_templ_set_recp_bankcode (GncABTransTempl *t, const gchar *recp_bankcode)
 Replace the Bank Code of the recipient stored in a template. More...
 
void gnc_ab_trans_templ_set_amount (GncABTransTempl *t, gnc_numeric amount)
 Replace the amount stored in a template. More...
 
void gnc_ab_trans_templ_set_purpose (GncABTransTempl *t, const gchar *purpose)
 Replace the first purpose line stored in a template. More...
 
void gnc_ab_trans_templ_set_purpose_cont (GncABTransTempl *t, const gchar *purpose_cont)
 Replace the second purpose line stored in a template. More...
 
G_BEGIN_DECLS void gnc_ab_initial_assistant (void)
 Create and show an assistant for the aqbanking setup.
 
G_BEGIN_DECLS gboolean gnc_ab_enter_daterange (GtkWidget *parent, const char *heading, time64 *from_date, gboolean *last_retv_date, gboolean *first_possible_date, time64 *to_date, gboolean *to_now)
 Show a dialog to pick a time frame using a sensible set of default options. More...
 
gboolean gnc_ab_trans_isSEPA (GncABTransType t)
 Returns true if the given GncABTransType is an European (SEPA) transaction (transfer or debit note), otherwise false.
 
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. More...
 
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. More...
 
void gnc_ab_trans_dialog_free (GncABTransDialog *td)
 Free a Aqbanking transfer dialog. More...
 
GList * gnc_ab_trans_dialog_get_templ (const GncABTransDialog *td, gboolean *changed)
 Retrieve the current list of transaction templates from the dialog td, unless changed is a specified location and the templates have not been touched by the user. More...
 
GtkWidget * gnc_ab_trans_dialog_get_parent (const GncABTransDialog *td)
 Retrieve the widget used as parent. More...
 
const AB_TRANSACTION * gnc_ab_trans_dialog_get_ab_trans (const GncABTransDialog *td)
 Receive the Aqbanking Transaction filled by the dialog. More...
 
GNC_AB_JOB * gnc_ab_trans_dialog_get_job (const GncABTransDialog *td)
 Receive the Aqbanking job filled by the dialog. More...
 
GNC_AB_JOB * gnc_ab_get_trans_job (GNC_AB_ACCOUNT_SPEC *ab_acc, const AB_TRANSACTION *ab_trans, GncABTransType trans_type)
 Return the AqBanking job associated with the transaction. More...
 
G_BEGIN_DECLS void gnc_ab_getbalance (GtkWidget *parent, Account *gnc_acc)
 Execute a GetBalance job, show the resulting balance and offer to reconcile the GnuCash account. More...
 
G_BEGIN_DECLS void gnc_ab_gettrans (GtkWidget *parent, Account *gnc_acc)
 Execute a GetTransactions job. More...
 
G_BEGIN_DECLS void gnc_ab_maketrans (GtkWidget *parent, Account *gnc_acc, GncABTransType trans_type)
 FIXME. More...
 
void gnc_GWEN_Init (void)
 Initialize the gwenhywfar library by calling GWEN_Init() and setting up gwenhywfar logging.
 
void gnc_GWEN_Fini (void)
 Finalize the gwenhywfar library.
 
AB_BANKING * gnc_AB_BANKING_new (void)
 If there is a cached AB_BANKING object, return it initialized. More...
 
void gnc_AB_BANKING_delete (AB_BANKING *api)
 Delete the AB_BANKING api. More...
 
gint gnc_AB_BANKING_fini (AB_BANKING *api)
 Finish the AB_BANKING api. More...
 
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. More...
 
gchar * gnc_AB_VALUE_to_readable_string (const AB_VALUE *value)
 Print the value of value with two decimal places and value's currency appended, or 0.0 otherwise. More...
 
gchar * gnc_AB_JOB_to_readable_string (const GNC_AB_JOB *job)
 Return the job as string. More...
 
gchar * gnc_AB_JOB_ID_to_string (gulong job_id)
 Return the job_id as string. More...
 
gchar * gnc_ab_get_remote_name (const AB_TRANSACTION *ab_trans)
 Retrieve the merged "remote name" fields from a transaction. More...
 
gchar * gnc_ab_get_purpose (const AB_TRANSACTION *ab_trans, gboolean is_ofx)
 Retrieve the merged purpose fields from a transaction. More...
 
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_TRANSACTION ab_trans. More...
 
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 ab_trans. More...
 
Transaction * gnc_ab_trans_to_gnc (const AB_TRANSACTION *ab_trans, Account *gnc_acc)
 Create an unbalanced and dirty GnuCash transaction with a split to gnc_acc from the information available in the AqBanking transaction ab_trans. More...
 
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. More...
 
guint gnc_ab_ieci_get_found (GncABImExContextImport *ieci)
 Extract awaiting from data. More...
 
GNC_AB_JOB_LIST2 * gnc_ab_ieci_get_job_list (GncABImExContextImport *ieci)
 Extract the job list from data. More...
 
gboolean gnc_ab_ieci_run_matcher (GncABImExContextImport *ieci)
 Run the generic transaction matcher dialog. More...
 
GWEN_DB_NODE * gnc_ab_get_permanent_certs (void)
 get the GWEN_DB_NODE from AqBanking configuration files More...
 
gchar * gnc_ab_create_online_id (const gchar *bankcode, const gchar *accountnumber)
 Creates an online ID from bank code and account number. More...
 
G_BEGIN_DECLS void gnc_file_aqbanking_import (GtkWindow *parent, const gchar *aqbanking_importername, const gchar *aqbanking_formatname, gboolean exec_as_aqbanking_jobs)
 This routine will pop up a standard file selection dialog asking the user to pick a file to import. More...
 
void ini_flicker_gui (const char *pChallenge, GncFlickerGui *gui)
 Initialize the dialog and drawing area. More...
 
void gnc_GWEN_Gui_log_init (void)
 Hook our logging into the gwenhywfar logging framework by creating a minimalistic GWEN_GUI with only a callback for Gwen_Gui_LogHook(). More...
 
GncGWENGui * gnc_GWEN_Gui_get (GtkWidget *parent)
 When called for the first time, create a unique GncGWENGui object featuring a GWEN_GUI with all necessary callbacks, which can serve as a user interface for AqBanking jobs. More...
 
void gnc_GWEN_Gui_release (GncGWENGui *gui)
 Currently a no-op. More...
 
void gnc_GWEN_Gui_shutdown (void)
 Free all memory related to both the full-blown and minimalistic GUI objects.
 
void gnc_GWEN_Gui_set_close_flag (gboolean close_when_finished)
 Set "Close when finished" flag. More...
 
gboolean gnc_GWEN_Gui_get_close_flag (void)
 Get "Close when finished" flag. More...
 
gboolean gnc_GWEN_Gui_show_dialog (void)
 Unhides Online Banking Connection Window (Make log visible) More...
 
void gnc_GWEN_Gui_hide_dialog (void)
 Hides Online Banking Connection Window (Close log window) More...
 
GType gnc_plugin_aqbanking_get_type (void)
 
GncPlugingnc_plugin_aqbanking_new (void)
 
void gnc_plugin_aqbanking_create_plugin (void)
 Create a new GncPluginAqBanking object and register it.
 
void gnc_plugin_aqbanking_set_logwindow_visible (gboolean logwindow_visible)
 Set MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW.
 

Variables

GtkWidget * GncFlickerGui::dialog
 
GtkWidget * GncFlickerGui::input_entry
 
GtkWidget * GncFlickerGui::flicker_challenge
 
GtkWidget * GncFlickerGui::flicker_marker
 
GtkWidget * GncFlickerGui::flicker_hbox
 
GtkAdjustment * GncFlickerGui::adj_barwidth
 
GtkAdjustment * GncFlickerGui::adj_delay
 
GtkSpinButton * GncFlickerGui::spin_barwidth
 
GtkSpinButton * GncFlickerGui::spin_delay
 

Account

const gchar * gnc_ab_get_account_accountid (const Account *a)
 Return accountid string in the Account a. More...
 
void gnc_ab_set_account_accountid (Account *a, const gchar *id)
 Set the accountid string in the Account a to id. More...
 
const gchar * gnc_ab_get_account_bankcode (const Account *a)
 Return the bankcode string in the Account a. More...
 
void gnc_ab_set_account_bankcode (Account *a, const gchar *code)
 Set the bankcode string in the Account a to code. More...
 
guint32 gnc_ab_get_account_uid (const Account *a)
 Return the unique id for the AB_BANKING account in the Account a. More...
 
void gnc_ab_set_account_uid (Account *a, guint32 uid)
 Set the unique id for the AB_BANKING account in the Account a to uid. More...
 
time64 gnc_ab_get_account_trans_retrieval (const Account *a)
 Return the time of last online transaction retrieval for Account a. More...
 
void gnc_ab_set_account_trans_retrieval (Account *a, time64 time)
 Set the time of last online transaction retrieval for Account a. More...
 

Detailed Description

Macro Definition Documentation

◆ AQBANKING_VERSION_INT

#define AQBANKING_VERSION_INT   (10000 * AQBANKING_VERSION_MAJOR + 100 * AQBANKING_VERSION_MINOR + AQBANKING_VERSION_PATCHLEVEL)

A define that combines the aqbanking version number into one single integer number.

Assumption: Both MINOR and PATCHLEVEL numbers are in the interval [0..99].

Definition at line 48 of file gnc-ab-utils.h.

◆ GWENHYWFAR_VERSION_INT

#define GWENHYWFAR_VERSION_INT   (10000 * GWENHYWFAR_VERSION_MAJOR + 100 * GWENHYWFAR_VERSION_MINOR + GWENHYWFAR_VERSION_PATCHLEVEL)

A define that combines the gwenhywfar version number into one single integer number.

Assumption: Both MINOR and PATCHLEVEL numbers are in the interval [0..99].

Definition at line 53 of file gnc-ab-utils.h.

Function Documentation

◆ gnc_AB_BANKING_delete()

void gnc_AB_BANKING_delete ( AB_BANKING *  api)

Delete the AB_BANKING api.

If this is also the one that was cached by gnc_AB_BANKING_new(), then all references are deleted, too.

Parameters
apiAB_BANKING or NULL for the cached AB_BANKING object

Definition at line 228 of file gnc-ab-utils.c.

229 {
230  if (!api)
231  api = gnc_AB_BANKING;
232 
233  if (api)
234  {
235  if (api == gnc_AB_BANKING)
236  {
237  gnc_AB_BANKING = NULL;
238  gnc_AB_BANKING_fini(api);
239  }
240 
241  AB_Banking_free(api);
242  }
243 }
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:247

◆ gnc_AB_BANKING_fini()

gint gnc_AB_BANKING_fini ( AB_BANKING *  api)

Finish the AB_BANKING api.

If this is also the one that was cached by gnc_AB_BANKING_new(), then finish only if the decremented reference count reaches zero. After this call, you may only call gnc_AB_BANKING_new() to get the api again in a properly initialized state.

Parameters
apiAB_BANKING object
Returns
Zero on success

Definition at line 247 of file gnc-ab-utils.c.

248 {
249  if (api == gnc_AB_BANKING)
250  {
251  if (--gnc_AB_BANKING_refcount == 0)
252  {
253  if (gnc_gwengui_extended_by_ABBanking)
254  AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
255  gnc_gwengui_extended_by_ABBanking = NULL;
256  return AB_Banking_Fini(api);
257  }
258  }
259  else
260  {
261  if (gnc_gwengui_extended_by_ABBanking)
262  AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
263  gnc_gwengui_extended_by_ABBanking = NULL;
264  return AB_Banking_Fini(api);
265  }
266  return 0;
267 }

◆ gnc_AB_BANKING_new()

AB_BANKING* gnc_AB_BANKING_new ( void  )

If there is a cached AB_BANKING object, return it initialized.

Otherwise, create a new AB_BANKING, let it load its environment from its default configuration and cache it.

Returns
The AB_BANKING object

Definition at line 158 of file gnc-ab-utils.c.

159 {
160  AB_BANKING *api;
161 
162  if (gnc_AB_BANKING)
163  {
164  /* API cached. */
165  api = gnc_AB_BANKING;
166 
167  /* Init the API again. */
168  if (gnc_AB_BANKING_refcount == 0)
169  g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);
170 
171  }
172  else
173  {
174  api = AB_Banking_new("gnucash", NULL, 0);
175  g_return_val_if_fail(api, NULL);
176 
177 #if AQBANKING_VERSION_INT >= 59925 \
178  || (AQBANKING_VERSION_INT >= 50709 && AQBANKING_VERSION_INT < 59900)
179  /* These two values must be set because newest bank regulation requires
180  the bank servers to require it. The string itself results from our
181  registration with the German bank association at
182  https://www.hbci-zka.de/register/prod_register.htm (where the
183  registration was requested and is managed by cstim). The function call was
184  introduced in aqbanking-5.99.25 and aqbanking-5.7.9. */
185  AB_Banking_RuntimeConfig_SetCharValue(api, "fintsRegistrationKey", "412748A1836CDD07181CE1910");
186  AB_Banking_RuntimeConfig_SetCharValue(api, "fintsApplicationVersionString", PROJECT_VERSION);
187 #endif
188 
189 #ifndef AQBANKING6
190  /* Check for config migration */
191  if (AB_Banking_HasConf4(api) != 0)
192  {
193  if (AB_Banking_HasConf3(api) == 0)
194  {
195  PINFO("gnc_AB_BANKING_new: importing aqbanking3 configuration\n");
196  if (AB_Banking_ImportConf3(api) < 0)
197  {
198  PINFO("gnc_AB_BANKING_new: unable to import aqbanking3 configuration\n");
199  }
200  }
201  else if (AB_Banking_HasConf2(api) == 0)
202  {
203  PINFO("gnc_AB_BANKING_new: importing aqbanking2 configuration\n");
204  if (AB_Banking_ImportConf2(api) < 0)
205  {
206  PINFO("gnc_AB_BANKING_new: unable to import aqbanking2 configuration\n");
207  }
208  }
209  }
210 #endif
211 
212  /* Init the API */
213  g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);
214  gnc_gwengui_extended_by_ABBanking = GWEN_Gui_GetGui();
215  AB_Gui_Extend(gnc_gwengui_extended_by_ABBanking, api);
216 
217  /* Cache it */
218  gnc_AB_BANKING = api;
219  gnc_AB_BANKING_refcount = 0;
220  }
221 
222  gnc_AB_BANKING_refcount++;
223 
224  return api;
225 }
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256

◆ gnc_ab_create_online_id()

gchar* gnc_ab_create_online_id ( const gchar *  bankcode,
const gchar *  accountnumber 
)

Creates an online ID from bank code and account number.

The returned string must be g_free'd by the caller.

Parameters
bankcodeBank code
accountnumberAccount number
Returns
an online ID

Definition at line 336 of file gnc-ab-utils.c.

337 {
338  gchar *online_id;
339 
340  /* The accountnumber may have leading zeros, depending on where them
341  * accountnumber is came from, e.g. the accountnumber of accountinfo
342  * has no leading zeros while the (local)accountnumber of a transaction
343  * has leading zeros.
344  * So remove all leading '0', to get a consistent online_id.
345  */
346  while (accountnumber && *accountnumber == '0')
347  accountnumber++;
348 
349  online_id = g_strconcat(bankcode ? bankcode : "",
350  accountnumber ? accountnumber : "",
351  (gchar*)NULL);
352 
353  return online_id;
354 }

◆ gnc_ab_description_to_gnc()

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_TRANSACTION ab_trans.

The returned string must be g_free'd by the caller.

Parameters
ab_transAqBanking transaction
Returns
A newly allocated string, may be ""

Definition at line 466 of file gnc-ab-utils.c.

467 {
468  /* Description */
469  gchar *description = gnc_ab_get_purpose(ab_trans, is_ofx);
470  gchar *other_name = gnc_ab_get_remote_name(ab_trans);
471  gchar *retval;
472 
473  if (other_name)
474  {
475  if (description && *description)
476  {
477  retval = g_strdup_printf("%s; %s", description, other_name);
478  }
479  else
480  {
481  retval = g_strdup(other_name);
482  }
483  }
484  else
485  {
486  if (description && *description)
487  {
488  retval = g_strdup(description);
489  }
490  else
491  {
492  retval = g_strdup(_("Unspecified"));
493  }
494  }
495  g_free(description);
496  g_free(other_name);
497 
498  return retval;
499 }
gchar * gnc_ab_get_remote_name(const AB_TRANSACTION *ab_trans)
Retrieve the merged "remote name" fields from a transaction.
Definition: gnc-ab-utils.c:388
gchar * gnc_ab_get_purpose(const AB_TRANSACTION *ab_trans, gboolean is_ofx)
Retrieve the merged purpose fields from a transaction.
Definition: gnc-ab-utils.c:417

◆ gnc_ab_enter_daterange()

G_BEGIN_DECLS gboolean gnc_ab_enter_daterange ( GtkWidget *  parent,
const char *  heading,
time64 from_date,
gboolean *  last_retv_date,
gboolean *  first_possible_date,
time64 to_date,
gboolean *  to_now 
)

Show a dialog to pick a time frame using a sensible set of default options.

Parameters
parentWidget to use as parent, may be NULL
headingDescriptive text showed at the top, may be NULL
from_dateLocation to read from the initial and write to the final value of the from date entry
last_retv_dateLocation to read from whether the caller knows the last retrieval date and write to whether the corresponding button has been chosen
first_possible_dateLocation to write to whether the earliest possible date button has been chosen
to_dateLocation to read from the initial and write to the final value of the to date entry
to_nowLocation to write to whether the to now button has been chosen

Definition at line 52 of file dialog-ab-daterange.c.

59 {
60  GtkBuilder *builder;
61  GtkWidget *dialog;
62  GtkWidget *heading_label;
63  GtkWidget *first_button;
64  GtkWidget *last_retrieval_button;
65  GtkWidget *now_button;
66  DaterangeInfo info;
67  gint result;
68 
69  ENTER("");
70 
71  builder = gtk_builder_new();
72  gnc_builder_add_from_file (builder, "dialog-ab.glade", "aqbanking_date_range_dialog");
73 
74  dialog = GTK_WIDGET(gtk_builder_get_object (builder, "aqbanking_date_range_dialog"));
75 
76  /* Connect the signals */
77  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, &info );
78 
79  if (parent)
80  gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
81 
82  heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "date_heading_label"));
83  first_button = GTK_WIDGET(gtk_builder_get_object (builder, "first_button"));
84  last_retrieval_button = GTK_WIDGET(gtk_builder_get_object (builder, "last_retrieval_button"));
85  info.enter_from_button = GTK_WIDGET(gtk_builder_get_object (builder, "enter_from_button"));
86  now_button = GTK_WIDGET(gtk_builder_get_object (builder, "now_button"));
87  info.enter_to_button = GTK_WIDGET(gtk_builder_get_object (builder, "enter_to_button"));
88 
89  info.from_dateedit = gnc_date_edit_new (*from_date, FALSE, FALSE);
90  gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_from_box")),
91  info.from_dateedit);
92  gtk_widget_show(info.from_dateedit);
93 
94  info.to_dateedit = gnc_date_edit_new (*to_date, FALSE, FALSE);
95  gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_to_box")),
96  info.to_dateedit);
97  gtk_widget_show(info.to_dateedit);
98 
99  if (*last_retv_date)
100  {
101  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button),
102  TRUE);
103  }
104  else
105  {
106  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE);
107  gtk_widget_set_sensitive(last_retrieval_button, FALSE);
108  }
109 
110  gtk_widget_set_sensitive(info.from_dateedit, FALSE);
111  gtk_widget_set_sensitive(info.to_dateedit, FALSE);
112 
113  gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
114 
115  if (heading)
116  gtk_label_set_text(GTK_LABEL(heading_label), heading);
117 
118  gtk_widget_show(dialog);
119 
120  result = gtk_dialog_run(GTK_DIALOG(dialog));
121  gtk_widget_hide(dialog);
122 
123  if (result == GTK_RESPONSE_OK)
124  {
125  *from_date = gnc_date_edit_get_date(GNC_DATE_EDIT(info.from_dateedit));
126  *last_retv_date = gtk_toggle_button_get_active(
127  GTK_TOGGLE_BUTTON(last_retrieval_button));
128  *first_possible_date = gtk_toggle_button_get_active(
129  GTK_TOGGLE_BUTTON(first_button));
130  *to_date = gnc_date_edit_get_date (GNC_DATE_EDIT(info.to_dateedit));
131  *to_now = gtk_toggle_button_get_active(
132  GTK_TOGGLE_BUTTON(now_button));
133  }
134 
135  g_object_unref(G_OBJECT(builder));
136 
137  gtk_widget_destroy(dialog);
138 
139  LEAVE("");
140  return result == GTK_RESPONSE_OK;
141 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ gnc_ab_get_ab_account()

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.

Of course this only works after the GnuCash account has been set up for AqBanking use, i.e. the account's hbci data have been set up and populated.

Parameters
apiThe AB_BANKING to get the GNC_AB_ACCOUNT_SPEC from
gnc_accThe GnuCash account to query for GNC_AB_ACCOUNT_SPEC reference data
Returns
The GNC_AB_ACCOUNT_SPEC found or NULL otherwise

Definition at line 270 of file gnc-ab-utils.c.

271 {
272  GNC_AB_ACCOUNT_SPEC *ab_account = NULL;
273  const gchar *bankcode = NULL;
274  const gchar *accountid = NULL;
275  guint32 account_uid = 0;
276 
277  bankcode = gnc_ab_get_account_bankcode(gnc_acc);
278  accountid = gnc_ab_get_account_accountid(gnc_acc);
279  account_uid = gnc_ab_get_account_uid (gnc_acc);
280 
281  if (account_uid > 0)
282  {
283 #ifdef AQBANKING6
284  gint rv;
285 
286  rv = AB_Banking_GetAccountSpecByUniqueId(api, account_uid, &ab_account);
287 
288  if ( (rv<0 || !ab_account) && bankcode && *bankcode &&
289  accountid && *accountid)
290  {
291 /* Finding the account by code and number is suspended in AQBANKING 6 pending
292  * implementation of a replacement for AB_Banking_GetAccountByCodeAndNumber.
293  */
294  PINFO("gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, "
295  "trying bank code\n", account_uid);
296  return NULL;
297  }
298  return ab_account;
299 #else
300  ab_account = AB_Banking_GetAccount(api, account_uid);
301 
302  if (!ab_account && bankcode && *bankcode && accountid && *accountid)
303  {
304  PINFO("gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, "
305  "trying bank code\n", account_uid);
306  ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
307  accountid);
308  }
309  return ab_account;
310 
311  }
312  else if (bankcode && *bankcode && accountid && *accountid)
313  {
314  ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
315  accountid);
316  return ab_account;
317 #endif
318  }
319 
320  return NULL;
321 }
guint32 gnc_ab_get_account_uid(const Account *a)
Return the unique id for the AB_BANKING account in the Account a.
Definition: gnc-ab-kvp.c:79
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256
const gchar * gnc_ab_get_account_bankcode(const Account *a)
Return the bankcode string in the Account a.
Definition: gnc-ab-kvp.c:59
const gchar * gnc_ab_get_account_accountid(const Account *a)
Return accountid string in the Account a.
Definition: gnc-ab-kvp.c:39

◆ gnc_ab_get_account_accountid()

const gchar* gnc_ab_get_account_accountid ( const Account a)

Return accountid string in the Account a.

Parameters
aAccount
Returns
Account ID

Definition at line 39 of file gnc-ab-kvp.c.

40 {
41  gchar *id = NULL;
42  qof_instance_get (QOF_INSTANCE (a),
43  "ab-account-id", &id,
44  NULL);
45  return id;
46 }
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.

◆ gnc_ab_get_account_bankcode()

const gchar* gnc_ab_get_account_bankcode ( const Account a)

Return the bankcode string in the Account a.

Parameters
aAccount
Returns
Bank code

Definition at line 59 of file gnc-ab-kvp.c.

60 {
61  gchar *code = NULL;
62  qof_instance_get (QOF_INSTANCE (a),
63  "ab-bank-code", &code,
64  NULL);
65  return code;
66 }
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.

◆ gnc_ab_get_account_trans_retrieval()

time64 gnc_ab_get_account_trans_retrieval ( const Account a)

Return the time of last online transaction retrieval for Account a.

Parameters
aAccount
Returns
Retrieval time

Definition at line 99 of file gnc-ab-kvp.c.

100 {
101  Time64 *t = NULL;
102  qof_instance_get (QOF_INSTANCE (a),
103  "ab-trans-retrieval", &t,
104  NULL);
105  return t ? t->t : 0;
106 }
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.

◆ gnc_ab_get_account_uid()

guint32 gnc_ab_get_account_uid ( const Account a)

Return the unique id for the AB_BANKING account in the Account a.

Parameters
aAccount
Returns
Unique ID

Definition at line 79 of file gnc-ab-kvp.c.

80 {
81  guint64 uid = 0LL;
82  qof_instance_get (QOF_INSTANCE (a),
83  "ab-account-uid", &uid,
84  NULL);
85  return (guint32)uid;
86 }
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.

◆ gnc_ab_get_permanent_certs()

GWEN_DB_NODE* gnc_ab_get_permanent_certs ( void  )

get the GWEN_DB_NODE from AqBanking configuration files

Returns
a GWEN_DB containing all permanently accepted SSL certificates (hashed).

Definition at line 1322 of file gnc-ab-utils.c.

1323 {
1324  int rv;
1325  GWEN_DB_NODE *perm_certs = NULL;
1326  AB_BANKING *banking = gnc_AB_BANKING_new();
1327 
1328  g_return_val_if_fail(banking, NULL);
1329  rv = AB_Banking_LoadSharedConfig(banking, "certs", &perm_certs);
1330  gnc_AB_BANKING_fini(banking);
1331  g_return_val_if_fail(rv >= 0, NULL);
1332  return perm_certs;
1333 }
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
Definition: gnc-ab-utils.c:158
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:247

◆ gnc_ab_get_purpose()

gchar* gnc_ab_get_purpose ( const AB_TRANSACTION *  ab_trans,
gboolean  is_ofx 
)

Retrieve the merged purpose fields from a transaction.

The returned string must be g_free'd by the caller. If there was no purpose, an empty (but allocated) string is returned.

Parameters
ab_transAqBanking transaction
Returns
A newly allocated string, may be ""

Definition at line 417 of file gnc-ab-utils.c.

418 {
419 #ifdef AQBANKING6
420 # if AQBANKING_VERSION_INT < 59929
421 # error "You are using an old beta version of aqbanking > 5.99.0 but < 5.99.29, please upgrade to the latest 5.99.29 or newer."
422 # endif
423 #else
424  const /* only const in aqbanking < 5.99 */
425 #endif
426  GWEN_STRINGLIST *ab_purpose;
427  const char *ab_transactionText = NULL;
428  gchar *gnc_description = NULL;
429 
430  g_return_val_if_fail(ab_trans, g_strdup(""));
431 
432  if (!is_ofx && gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_USE_TRANSACTION_TXT))
433  {
434  /* According to AqBanking, some of the non-swift lines have a special
435  * meaning. Some banks place valuable text into the transaction text,
436  * hence we put this text in front of the purpose. */
437  ab_transactionText = AB_Transaction_GetTransactionText(ab_trans);
438  if (ab_transactionText)
439  gnc_description = g_strdup(ab_transactionText);
440  }
441 
442  ab_purpose =
443 #ifdef AQBANKING6
444  /* With aqbanking-5.99.29, the identical function as before is now available under this new name. */
445  AB_Transaction_GetPurposeAsStringList
446 #else
447  AB_Transaction_GetPurpose
448 #endif
449  (ab_trans);
450  if (ab_purpose)
451  GWEN_StringList_ForEach(ab_purpose, join_ab_strings_cb,
452  &gnc_description);
453 
454 #ifdef AQBANKING6
455  /* With aqbanking>=5.99, the return value must now be free'd */
456  GWEN_StringList_free(ab_purpose);
457 #endif
458 
459  if (!gnc_description)
460  gnc_description = g_strdup("");
461 
462  return gnc_description;
463 }
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.

◆ gnc_ab_get_remote_name()

gchar* gnc_ab_get_remote_name ( const AB_TRANSACTION *  ab_trans)

Retrieve the merged "remote name" fields from a transaction.

The returned string must be g_free'd by the caller. If there was no "remote name" field, NULL (!) is returned.

Parameters
ab_transAqBanking transaction
Returns
A newly allocated string or NULL otherwise

Definition at line 388 of file gnc-ab-utils.c.

389 {
390 #ifdef AQBANKING6
391  const char* ab_remote_name;
392 #else
393  const GWEN_STRINGLIST *ab_remote_name;
394 #endif
395  gchar *gnc_other_name = NULL;
396 
397  g_return_val_if_fail(ab_trans, NULL);
398 
399  ab_remote_name = AB_Transaction_GetRemoteName(ab_trans);
400  if (ab_remote_name)
401 #ifdef AQBANKING6
402  gnc_other_name = g_strdup(ab_remote_name);
403 #else
404  GWEN_StringList_ForEach(ab_remote_name, join_ab_strings_cb,
405  &gnc_other_name);
406 #endif
407  if (!gnc_other_name || !*gnc_other_name)
408  {
409  g_free(gnc_other_name);
410  gnc_other_name = NULL;
411  }
412 
413  return gnc_other_name;
414 }

◆ gnc_ab_get_trans_job()

GNC_AB_JOB* gnc_ab_get_trans_job ( GNC_AB_ACCOUNT_SPEC *  ab_acc,
const AB_TRANSACTION *  ab_trans,
GncABTransType  trans_type 
)

Return the AqBanking job associated with the transaction.

Parameters
tdTransaction dialog
Returns
An AQBanking job

Definition at line 878 of file dialog-ab-trans.c.

881 {
882  GNC_AB_JOB *job;
883 
884  g_return_val_if_fail(ab_acc && ab_trans, NULL);
885 
886 #ifdef AQBANKING6
887  job = gnc_ab_trans_dialog_get_available_empty_job(ab_acc, trans_type);
888  if (job)
889  {
890  AB_TRANSACTION *new_job;
891 
892  /* merge transactions */
893  new_job=AB_Transaction_dup(ab_trans);
894  AB_Transaction_SetCommand(new_job, AB_Transaction_GetCommand(job));
895  AB_Transaction_SetUniqueAccountId(new_job,
896  AB_Transaction_GetUniqueAccountId(job));
897 
898  AB_Transaction_free(job);
899  return new_job;
900  }
901  return NULL;
902 
903 #else
904  job = gnc_ab_trans_dialog_get_available_empty_job(ab_acc, trans_type);
905  if (job)
906  {
907  AB_Job_SetTransaction(job, ab_trans);
908  }
909  return job;
910 #endif
911 }

◆ gnc_ab_getbalance()

G_BEGIN_DECLS void gnc_ab_getbalance ( GtkWidget *  parent,
Account gnc_acc 
)

Execute a GetBalance job, show the resulting balance and offer to reconcile the GnuCash account.

Parameters
parentWidget to use as parent, may be NULL
gnc_accGnuCash account to fetch balance for

Definition at line 51 of file gnc-ab-getbalance.c.

52 {
53  AB_BANKING *api;
54  gboolean online = FALSE;
55  GNC_AB_ACCOUNT_SPEC *ab_acc;
56  GNC_AB_JOB *job = NULL;
57  GNC_AB_JOB_LIST2 *job_list = NULL;
58  GncGWENGui *gui = NULL;
59  AB_IMEXPORTER_CONTEXT *context = NULL;
60  GncABImExContextImport *ieci = NULL;
61  GNC_AB_JOB_STATUS job_status;
62 
63  g_return_if_fail(parent && gnc_acc);
64 
65  /* Get the API */
66  api = gnc_AB_BANKING_new();
67  if (!api)
68  {
69  g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
70  return;
71  }
72 
73 #ifndef AQBANKING6
74  if (AB_Banking_OnlineInit(api) != 0)
75  {
76  g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
77  goto cleanup;
78  }
79  online = TRUE;
80 #endif
81  /* Get the AqBanking Account */
82  ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
83  if (!ab_acc)
84  {
85  g_warning("gnc_ab_getbalance: No AqBanking account found");
86  gnc_error_dialog (GTK_WINDOW (parent), _("No valid online banking account assigned."));
87  goto cleanup;
88  }
89 
90  /* Get a GetBalance job and enqueue it */
91 #ifdef AQBANKING6
92  if (!AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_CommandGetBalance))
93 #else
94  job = AB_JobGetBalance_new(ab_acc);
95  if (!job || AB_Job_CheckAvailability(job))
96 #endif
97  {
98  g_warning("gnc_ab_getbalance: JobGetBalance not available for this "
99  "account");
100  gnc_error_dialog (GTK_WINDOW (parent), _("Online action \"Get Balance\" not available for this account."));
101  goto cleanup;
102  }
103 #ifdef AQBANKING6
104  job = AB_Transaction_new();
105  AB_Transaction_SetCommand(job, AB_Transaction_CommandGetBalance);
106  AB_Transaction_SetUniqueAccountId(job, AB_AccountSpec_GetUniqueId(ab_acc));
107 
108  job_list = AB_Transaction_List2_new();
109  AB_Transaction_List2_PushBack(job_list, job);
110 #else
111  job_list = AB_Job_List2_new();
112  AB_Job_List2_PushBack(job_list, job);
113 #endif
114  /* Get a GUI object */
115  gui = gnc_GWEN_Gui_get(parent);
116  if (!gui)
117  {
118  g_warning("gnc_ab_getbalance: Couldn't initialize Gwenhywfar GUI");
119  goto cleanup;
120  }
121 
122  /* Create a context to store the results */
123  context = AB_ImExporterContext_new();
124 
125  /* Execute the job */
126 #ifdef AQBANKING6
127  AB_Banking_SendCommands(api, job_list, context);
128 #else
129  AB_Banking_ExecuteJobs(api, job_list, context);
130 #endif
131  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
132  * status always describes better whether the job was actually
133  * transferred to and accepted by the bank. See also
134  * https://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
135  */
136 #ifdef AQBANKING6
137  job_status = AB_Transaction_GetStatus(job);
138  if (job_status != AB_Transaction_StatusEnqueued
139  && job_status != AB_Transaction_StatusPending
140  && job_status != AB_Transaction_StatusAccepted)
141 #else
142  job_status = AB_Job_GetStatus(job);
143  if (job_status != AB_Job_StatusFinished
144  && job_status != AB_Job_StatusPending)
145 #endif
146  {
147  g_warning("gnc_ab_getbalance: Error on executing job: %d", job_status);
148 #ifdef AQBANKING6
149  gnc_error_dialog (GTK_WINDOW (parent),
150  _("Error on executing job.\n\nStatus: %s"),
151  AB_Transaction_Status_toString(job_status));
152 #else
153  gnc_error_dialog (GTK_WINDOW (parent),
154  _("Error on executing job.\n\nStatus: %s - %s"),
155  AB_Job_Status2Char(job_status),
156  AB_Job_GetResultText(job));
157 #endif
158  goto cleanup;
159  }
160 
161  /* Import the results */
162  ieci = gnc_ab_import_context(context, AWAIT_BALANCES, FALSE, NULL, parent);
163 
164 cleanup:
165  if (ieci)
166  g_free(ieci);
167  if (context)
168  AB_ImExporterContext_free(context);
169  if (gui)
171 #ifdef AQBANKING6
172  if (job_list)
173  AB_Transaction_List2_free(job_list);
174  if (job)
175  AB_Transaction_free(job);
176 #else
177  if (job_list)
178  AB_Job_List2_free(job_list);
179  if (job)
180  AB_Job_free(job);
181  if (online)
182  AB_Banking_OnlineFini(api);
183 #endif
184  gnc_AB_BANKING_fini(api);
185 }
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...
Definition: gnc-gwen-gui.c:259
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Currently a no-op.
Definition: gnc-gwen-gui.c:294
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
Definition: gnc-ab-utils.c:158
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:247
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.
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.
Definition: gnc-ab-utils.c:270

◆ gnc_ab_gettrans()

G_BEGIN_DECLS void gnc_ab_gettrans ( GtkWidget *  parent,
Account gnc_acc 
)

Execute a GetTransactions job.

Parameters
parentWidget to use as parent, may be NULL
gnc_accGnuCash account to fetch transactions for

Definition at line 101 of file gnc-ab-gettrans.c.

102 {
103  AB_BANKING *api;
104  gboolean online = FALSE;
105  GNC_AB_ACCOUNT_SPEC *ab_acc;
106  GWEN_TIME *from_date = NULL, *to_date = NULL;
107  time64 until;
108  GNC_AB_JOB *job = NULL;
109  GNC_AB_JOB_LIST2 *job_list = NULL;
110  GncGWENGui *gui = NULL;
111  AB_IMEXPORTER_CONTEXT *context = NULL;
112  GncABImExContextImport *ieci = NULL;
113  GNC_AB_JOB_STATUS job_status;
114 
115  g_return_if_fail(parent && gnc_acc);
116 
117  /* Get the API */
118  api = gnc_AB_BANKING_new();
119  if (!api)
120  {
121  g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
122  return;
123  }
124 #ifndef AQBANKING6
125  if (AB_Banking_OnlineInit(api) != 0)
126  {
127  g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
128  goto cleanup;
129  }
130  online = TRUE;
131 #endif
132  /* Get the AqBanking Account */
133  ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
134  if (!ab_acc)
135  {
136  g_warning("gnc_ab_gettrans: No AqBanking account found");
137  gnc_error_dialog (GTK_WINDOW (parent), _("No valid online banking account assigned."));
138  goto cleanup;
139  }
140 
141  /* Get the start and end dates for the GetTransactions job. */
142  if (!gettrans_dates(parent, gnc_acc, &from_date, &to_date))
143  {
144  DEBUG("gnc_ab_gettrans: gettrans_dates aborted");
145  goto cleanup;
146  }
147  /* Use this as a local storage for the until_time below. */
148  until = GWEN_Time_toTime_t(to_date);
149 
150  /* Get a GetTransactions job and enqueue it */
151 #ifdef AQBANKING6
152  if (!AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_CommandGetTransactions))
153 #else
154  job = AB_JobGetTransactions_new(ab_acc);
155  if (!job || AB_Job_CheckAvailability(job))
156 #endif
157  {
158  g_warning("gnc_ab_gettrans: JobGetTransactions not available for this "
159  "account");
160  gnc_error_dialog (GTK_WINDOW (parent), _("Online action \"Get Transactions\" not available for this account."));
161  goto cleanup;
162  }
163 #ifdef AQBANKING6
164  job = AB_Transaction_new();
165  AB_Transaction_SetCommand(job, AB_Transaction_CommandGetTransactions);
166  AB_Transaction_SetUniqueAccountId(job, AB_AccountSpec_GetUniqueId(ab_acc));
167 
168  if (from_date) /* TODO: this should be simplified */
169  {
170  GWEN_DATE *dt;
171 
172  dt=GWEN_Date_fromLocalTime(GWEN_Time_toTime_t(from_date));
173  AB_Transaction_SetFirstDate(job, dt);
174  GWEN_Date_free(dt);
175  }
176 
177  if (to_date)
178  {
179  GWEN_DATE *dt;
180 
181  dt=GWEN_Date_fromLocalTime(GWEN_Time_toTime_t(to_date));
182  AB_Transaction_SetLastDate(job, dt);
183  GWEN_Date_free(dt);
184  }
185 
186  job_list = AB_Transaction_List2_new();
187  AB_Transaction_List2_PushBack(job_list, job);
188 #else
189  AB_JobGetTransactions_SetFromTime(job, from_date);
190  AB_JobGetTransactions_SetToTime(job, to_date);
191  job_list = AB_Job_List2_new();
192  AB_Job_List2_PushBack(job_list, job);
193 #endif
194  /* Get a GUI object */
195  gui = gnc_GWEN_Gui_get(parent);
196  if (!gui)
197  {
198  g_warning("gnc_ab_gettrans: Couldn't initialize Gwenhywfar GUI");
199  goto cleanup;
200  }
201 
202  /* Create a context to store the results */
203  context = AB_ImExporterContext_new();
204 
205  /* Execute the job */
206 #ifdef AQBANKING6
207  AB_Banking_SendCommands(api, job_list, context);
208 #else
209  AB_Banking_ExecuteJobs(api, job_list, context);
210 #endif
211  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
212  * status always describes better whether the job was actually
213  * transferred to and accepted by the bank. See also
214  * https://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
215  */
216 #ifdef AQBANKING6
217  job_status = AB_Transaction_GetStatus(job);
218  if (job_status != AB_Transaction_StatusAccepted
219  && job_status != AB_Transaction_StatusPending)
220 #else
221  job_status = AB_Job_GetStatus(job);
222  if (job_status != AB_Job_StatusFinished
223  && job_status != AB_Job_StatusPending)
224 #endif
225  {
226  g_warning("gnc_ab_gettrans: Error on executing job");
227 #ifdef AQBANKING6
228  gnc_error_dialog (GTK_WINDOW (parent),
229  _("Error on executing job.\n\nStatus: %s (%d)"),
230  AB_Transaction_Status_toString(job_status),
231  job_status);
232 #else
233  gnc_error_dialog (GTK_WINDOW (parent),
234  _("Error on executing job.\n\nStatus: %s - %s"),
235  AB_Job_Status2Char(job_status),
236  AB_Job_GetResultText(job));
237 #endif
238  goto cleanup;
239  }
240 
241  /* Import the results */
242  ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS, FALSE, NULL,
243  parent);
244  if (!(gnc_ab_ieci_get_found(ieci) & FOUND_TRANSACTIONS))
245  {
246  /* No transaction found */
247  GtkWidget *dialog = gtk_message_dialog_new(
248  GTK_WINDOW(parent),
249  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
250  GTK_MESSAGE_INFO,
251  GTK_BUTTONS_OK,
252  "%s",
253  _("The Online Banking import returned no transactions "
254  "for the selected time period."));
255  gtk_dialog_run(GTK_DIALOG(dialog));
256  gtk_widget_destroy(dialog);
257  }
258 
259  /* Store the date of this retrieval */
260  gnc_ab_set_account_trans_retrieval(gnc_acc, until);
261 
262 cleanup:
263  if (ieci)
264  g_free(ieci);
265  if (context)
266  AB_ImExporterContext_free(context);
267  if (gui)
269  if (job_list)
270 #ifdef AQBANKING6
271  AB_Transaction_List2_free(job_list);
272 #else
273  AB_Job_List2_free(job_list);
274 #endif
275  if (job)
276 #ifdef AQBANKING6
277  AB_Transaction_free(job);
278 #else
279  AB_Job_free(job);
280 #endif
281  if (to_date)
282  GWEN_Time_free(to_date);
283  if (from_date)
284  GWEN_Time_free(from_date);
285 #ifndef AQBANKING6
286  if (online)
287  AB_Banking_OnlineFini(api);
288 #endif
289  gnc_AB_BANKING_fini(api);
290 }
void gnc_ab_set_account_trans_retrieval(Account *a, time64 time)
Set the time of last online transaction retrieval for Account a.
Definition: gnc-ab-kvp.c:109
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:264
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...
Definition: gnc-gwen-gui.c:259
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Currently a no-op.
Definition: gnc-gwen-gui.c:294
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
Definition: gnc-ab-utils.c:158
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:247
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.
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.
Definition: gnc-ab-utils.c:270
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
Definition: gnc-date.h:93
guint gnc_ab_ieci_get_found(GncABImExContextImport *ieci)
Extract awaiting from data.

◆ gnc_ab_ieci_get_found()

guint gnc_ab_ieci_get_found ( GncABImExContextImport *  ieci)

Extract awaiting from data.

Parameters
ieciThe return value of gnc_ab_import_context()
Returns
The initial awaiting bitmask plus IGNORE_* for unexpected and then ignored items, and FOUND_* for non-empty items

Definition at line 1298 of file gnc-ab-utils.c.

1299 {
1300  g_return_val_if_fail(ieci, 0);
1301 
1302  return ieci->awaiting;
1303 }

◆ gnc_ab_ieci_get_job_list()

GNC_AB_JOB_LIST2* gnc_ab_ieci_get_job_list ( GncABImExContextImport *  ieci)

Extract the job list from data.

Parameters
ieciThe return value of gnc_ab_import_context()
Returns
The list of jobs, freeable with AB_Job_List2_FreeAll()

Definition at line 1306 of file gnc-ab-utils.c.

1307 {
1308  g_return_val_if_fail(ieci, NULL);
1309 
1310  return ieci->job_list;
1311 }

◆ gnc_ab_ieci_run_matcher()

gboolean gnc_ab_ieci_run_matcher ( GncABImExContextImport *  ieci)

Run the generic transaction matcher dialog.

Parameters
ieciThe return value of gnc_ab_import_context()
Returns
The return value of gnc_gen_trans_list_run().

Definition at line 1314 of file gnc-ab-utils.c.

1315 {
1316  g_return_val_if_fail(ieci, FALSE);
1317 
1318  return gnc_gen_trans_list_run(ieci->generic_importer);
1319 }
gboolean gnc_gen_trans_list_run(GNCImportMainMatcher *info)
Run this dialog and return only after the user pressed Ok, Cancel, or closed the window.

◆ gnc_ab_import_context()

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.

By using awaiting the caller can specify what the user will expect to receive. By using execute_txns, transactions in context can be used to generate corresponding AqBanking jobs, e.g. after a file import.

Parameters
contextAB_IMEXPORTER_CONTEXT to import
awaitingInformation the caller expects to receive or wants to ignore, bitmask of AWAIT_* or IGNORE_* values
execute_txnsIf awaiting contains AWAIT_TRANSACTIONS, whether to create an aqbanking job for each of the transactions found
apiIf execute_txns is TRUE, the AB_BANKING to get GNC_AB_ACCOUNT_SPECs from
parentWidget to set new dialogs transient for, may be NULL
Returns
A new GncABImExContextImport object which must be freed with g_free(), or NULL otherwise. If execute_txns is TRUE, additionally gnc_ab_ieci_get_job_list() must be called and the result freed with AB_Job_List2_FreeAll()

Definition at line 1204 of file gnc-ab-utils.c.

1207 {
1208  GncABImExContextImport *data = g_new(GncABImExContextImport, 1);
1209 #ifdef AQBANKING6
1210  AB_IMEXPORTER_ACCOUNTINFO_LIST *ab_ail;
1211 #endif
1212  g_return_val_if_fail(context, NULL);
1213  /* Do not await and ignore at the same time */
1214  g_return_val_if_fail(!(awaiting & AWAIT_BALANCES)
1215  || !(awaiting & IGNORE_BALANCES),
1216  NULL);
1217  g_return_val_if_fail(!(awaiting & AWAIT_TRANSACTIONS)
1218  || !(awaiting & IGNORE_TRANSACTIONS),
1219  NULL);
1220  /* execute_txns must be FALSE if txns are not awaited */
1221  g_return_val_if_fail(awaiting & AWAIT_TRANSACTIONS || !execute_txns, NULL);
1222  /* An api is needed for the jobs */
1223  g_return_val_if_fail(!execute_txns || api, NULL);
1224 
1225  data->awaiting = awaiting;
1226  data->txn_found = FALSE;
1227  data->execute_txns = execute_txns;
1228  data->api = api;
1229  data->parent = parent;
1230 #ifdef AQBANKING6
1231  data->job_list = AB_Transaction_List2_new();
1232 #else
1233  data->job_list = AB_Job_List2_new();
1234 #endif
1235  data->tmp_job_list = NULL;
1236  data->generic_importer = NULL;
1237 
1238  g_datalist_init(&data->tmp_job_list);
1239 
1240  /* Import transactions */
1241 #ifdef AQBANKING6
1242  ab_ail = AB_ImExporterContext_GetAccountInfoList(context);
1243  if (ab_ail && AB_ImExporterAccountInfo_List_GetCount(ab_ail))
1244  {
1245  if (!(awaiting & IGNORE_TRANSACTIONS))
1246  AB_ImExporterAccountInfo_List_ForEach(ab_ail, txn_accountinfo_cb,
1247  data);
1248 
1249  /* populate and display the matching window */
1250  if (data->generic_importer)
1251  gnc_gen_trans_list_show_all(data->generic_importer);
1252 
1253  /* Check balances */
1254  if (!(awaiting & IGNORE_BALANCES))
1255  AB_ImExporterAccountInfo_List_ForEach(ab_ail, bal_accountinfo_cb,
1256  data);
1257  }
1258 #else
1259  if (!(awaiting & IGNORE_TRANSACTIONS))
1260  AB_ImExporterContext_AccountInfoForEach(context, txn_accountinfo_cb,
1261  data);
1262 
1263  /* populate and display the matching window */
1264  if (data->generic_importer)
1265  gnc_gen_trans_list_show_all(data->generic_importer);
1266 
1267  /* Check balances */
1268  if (!(awaiting & IGNORE_BALANCES))
1269  AB_ImExporterContext_AccountInfoForEach(context, bal_accountinfo_cb,
1270  data);
1271 #endif
1272 
1273  /* Check bank-messages */
1274  {
1275  AB_MESSAGE * bankmsg = AB_ImExporterContext_GetFirstMessage(context);
1276  while (bankmsg)
1277  {
1278  const char* subject = AB_Message_GetSubject(bankmsg);
1279  const char* text = AB_Message_GetText(bankmsg);
1280  gnc_info_dialog(GTK_WINDOW (data->parent), "%s\n%s %s\n%s",
1281  _("The bank has sent a message in its response."),
1282  _("Subject:"),
1283  subject,
1284  text);
1285 
1286 #ifdef AQBANKING6
1287  bankmsg = AB_Message_List_Next(bankmsg);
1288 #else
1289  bankmsg = AB_ImExporterContext_GetNextMessage(context); // The iterator is incremented within aqbanking
1290 #endif
1291  }
1292  }
1293 
1294  return data;
1295 }
void gnc_gen_trans_list_show_all(GNCImportMainMatcher *info)
Shows widgets.

◆ gnc_AB_JOB_ID_to_string()

gchar* gnc_AB_JOB_ID_to_string ( gulong  job_id)

Return the job_id as string.

Parameters
job_id
Returns
A newly allocated string

Definition at line 881 of file gnc-ab-utils.c.

882 {
883  return g_strdup_printf("job_%lu", job_id);
884 }

◆ gnc_AB_JOB_to_readable_string()

gchar* gnc_AB_JOB_to_readable_string ( const GNC_AB_JOB *  job)

Return the job as string.

Parameters
valueGNC_AB_JOB or NULL
Returns
A newly allocated string

Definition at line 865 of file gnc-ab-utils.c.

866 {
867  if (job)
868  {
869 #ifdef AQBANKING6
870  return gnc_AB_JOB_ID_to_string(AB_Transaction_GetUniqueId(job));
871 #else
872  return gnc_AB_JOB_ID_to_string(AB_Job_GetJobId(job));
873 #endif
874  }
875  else
876  {
877  return gnc_AB_JOB_ID_to_string(0);
878  }
879 }
gchar * gnc_AB_JOB_ID_to_string(gulong job_id)
Return the job_id as string.
Definition: gnc-ab-utils.c:881

◆ gnc_ab_maketrans()

G_BEGIN_DECLS void gnc_ab_maketrans ( GtkWidget *  parent,
Account gnc_acc,
GncABTransType  trans_type 
)

FIXME.

Parameters
parentWidget to use as parent, may be NULL
gnc_accGnuCash account to fetch balance for
trans_typeType of transaction

Definition at line 80 of file gnc-ab-transfer.c.

82 {
83  AB_BANKING *api;
84  gboolean online = FALSE;
85  GNC_AB_ACCOUNT_SPEC *ab_acc;
86  GList *templates = NULL;
87  GncABTransDialog *td = NULL;
88  gboolean successful = FALSE;
89  gboolean aborted = FALSE;
90 
91  g_return_if_fail(parent && gnc_acc);
92 
93  /* Get the API */
94  api = gnc_AB_BANKING_new();
95  if (!api)
96  {
97  g_warning("gnc_ab_maketrans: Couldn't get AqBanking API");
98  return;
99  }
100 #ifndef AQBANKING6
101  if (AB_Banking_OnlineInit(api) != 0)
102  {
103  g_warning("gnc_ab_maketrans: Couldn't initialize AqBanking API");
104  goto cleanup;
105  }
106  online = TRUE;
107 #endif
108  /* Get the AqBanking Account */
109  ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
110  if (!ab_acc)
111  {
112  g_warning("gnc_ab_gettrans: No AqBanking account found");
113  gnc_error_dialog (GTK_WINDOW (parent), _("No valid online banking account assigned."));
114  goto cleanup;
115  }
116 
117  /* Get list of template transactions */
119  gnc_account_get_book(gnc_acc));
120 
121  /* Create new ABTransDialog */
122  td = gnc_ab_trans_dialog_new(parent, ab_acc,
124  trans_type, templates);
125  templates = NULL;
126 
127  /* Repeat until AqBanking action was successful or user pressed cancel */
128  do
129  {
130  GncGWENGui *gui = NULL;
131  gint result;
132  gboolean changed;
133  const AB_TRANSACTION *ab_trans;
134  GNC_AB_JOB *job = NULL;
135  GNC_AB_JOB_LIST2 *job_list = NULL;
136  XferDialog *xfer_dialog = NULL;
137  gnc_numeric amount;
138  gchar *description;
139  gchar *memo;
140  Transaction *gnc_trans = NULL;
141  AB_IMEXPORTER_CONTEXT *context = NULL;
142  GNC_AB_JOB_STATUS job_status;
143  GncABImExContextImport *ieci = NULL;
144 
145 #ifndef AQBANKING6
146  /* Get a GUI object */
147  gui = gnc_GWEN_Gui_get(parent);
148  if (!gui)
149  {
150  g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
151  aborted = TRUE;
152  goto repeat;
153  }
154 #endif
155 
156  /* Let the user enter the values */
158 
159  /* Save the templates */
160  templates = gnc_ab_trans_dialog_get_templ(td, &changed);
161  if (changed)
162  save_templates(parent, gnc_acc, templates,
163  (result == GNC_RESPONSE_NOW));
164  g_list_free(templates);
165  templates = NULL;
166 
167  if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
168  {
169  aborted = TRUE;
170  goto repeat;
171  }
172 
173  /* Get a job and enqueue it */
174  ab_trans = gnc_ab_trans_dialog_get_ab_trans(td);
175  job = gnc_ab_trans_dialog_get_job(td);
176 #ifdef AQBANKING6
177  if (!job || AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_GetCommand(job))==NULL)
178 #else
179  if (!job || AB_Job_CheckAvailability(job))
180 #endif
181  {
182  if (!gnc_verify_dialog (
183  GTK_WINDOW (parent), FALSE, "%s",
184  _("The backend found an error during the preparation "
185  "of the job. It is not possible to execute this job.\n"
186  "\n"
187  "Most probable the bank does not support your chosen "
188  "job or your Online Banking account does not have the permission "
189  "to execute this job. More error messages might be "
190  "visible on your console log.\n"
191  "\n"
192  "Do you want to enter the job again?")))
193  aborted = TRUE;
194  goto repeat;
195  }
196 #ifdef AQBANKING6
197  job_list = AB_Transaction_List2_new();
198  AB_Transaction_List2_PushBack(job_list, job);
199 #else
200  job_list = AB_Job_List2_new();
201  AB_Job_List2_PushBack(job_list, job);
202 #endif
203  /* Setup a Transfer Dialog for the GnuCash transaction */
204  xfer_dialog = gnc_xfer_dialog(gnc_ab_trans_dialog_get_parent(td),
205  gnc_acc);
206  switch (trans_type)
207  {
208  case SINGLE_DEBITNOTE:
209  gnc_xfer_dialog_set_title(
210  xfer_dialog, _("Online Banking Direct Debit Note"));
211  gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
212  break;
213  case SINGLE_INTERNAL_TRANSFER:
214  gnc_xfer_dialog_set_title(
215  xfer_dialog, _("Online Banking Bank-Internal Transfer"));
216  gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
217  break;
218  case SEPA_TRANSFER:
219  gnc_xfer_dialog_set_title(
220  xfer_dialog, _("Online Banking European (SEPA) Transfer"));
221  gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
222  break;
223  case SEPA_DEBITNOTE:
224  gnc_xfer_dialog_set_title(
225  xfer_dialog, _("Online Banking European (SEPA) Debit Note"));
226  gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
227  break;
228  case SINGLE_TRANSFER:
229  default:
230  gnc_xfer_dialog_set_title(
231  xfer_dialog, _("Online Banking Transaction"));
232  gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
233  }
234  gnc_xfer_dialog_set_to_show_button_active(xfer_dialog, TRUE);
235 
236  amount = double_to_gnc_numeric(
237  AB_Value_GetValueAsDouble(AB_Transaction_GetValue(ab_trans)),
240  gnc_xfer_dialog_set_amount(xfer_dialog, amount);
241  gnc_xfer_dialog_set_amount_sensitive(xfer_dialog, FALSE);
242  gnc_xfer_dialog_set_date_sensitive(xfer_dialog, FALSE);
243 
244  /* OFX doesn't do transfers. */
245  description = gnc_ab_description_to_gnc(ab_trans, FALSE);
246  gnc_xfer_dialog_set_description(xfer_dialog, description);
247  g_free(description);
248 
249  memo = gnc_ab_memo_to_gnc(ab_trans);
250  gnc_xfer_dialog_set_memo(xfer_dialog, memo);
251  g_free(memo);
252 
253  gnc_xfer_dialog_set_txn_cb(xfer_dialog, txn_created_cb, &gnc_trans);
254 
255  /* And run it */
256  successful = gnc_xfer_dialog_run_until_done(xfer_dialog);
257 
258  /* On cancel, go back to the AB transaction dialog */
259  if (!successful || !gnc_trans)
260  {
261  successful = FALSE;
262  goto repeat;
263  }
264 
265  if (result == GNC_RESPONSE_NOW)
266  {
267  /* Create a context to store possible results */
268  context = AB_ImExporterContext_new();
269 
270  gui = gnc_GWEN_Gui_get(parent);
271  if (!gui)
272  {
273  g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
274  aborted = TRUE;
275  goto repeat;
276  }
277 
278  /* Finally, execute the job */
279 #ifdef AQBANKING6
280  AB_Banking_SendCommands(api, job_list, context);
281 #else
282  AB_Banking_ExecuteJobs(api, job_list, context);
283 #endif
284  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
285  * status always describes better whether the job was actually
286  * transferred to and accepted by the bank. See also
287  * https://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
288  */
289 #ifdef AQBANKING6
290  job_status = AB_Transaction_GetStatus(job);
291  if (job_status != AB_Transaction_StatusAccepted
292  && job_status != AB_Transaction_StatusPending)
293 #else
294  job_status = AB_Job_GetStatus(job);
295  if (job_status != AB_Job_StatusFinished
296  && job_status != AB_Job_StatusPending)
297 #endif
298  {
299  successful = FALSE;
300  if (!gnc_verify_dialog (
301  GTK_WINDOW (parent), FALSE, "%s",
302  _("An error occurred while executing the job. Please check "
303  "the log window for the exact error message.\n"
304  "\n"
305  "Do you want to enter the job again?")))
306  {
307  aborted = TRUE;
308  }
309  }
310  else
311  {
312  successful = TRUE;
313  }
314 
315  if (successful)
316  {
317  /* Import the results, awaiting nothing */
318  ieci = gnc_ab_import_context(context, 0, FALSE, NULL, parent);
319  }
320  }
321  /* Simply ignore any other case */
322 
323 repeat:
324  /* Clean up */
325  if (gnc_trans && !successful)
326  {
327  xaccTransBeginEdit(gnc_trans);
328  xaccTransDestroy(gnc_trans);
329  xaccTransCommitEdit(gnc_trans);
330  gnc_trans = NULL;
331  }
332  if (ieci)
333  g_free(ieci);
334  if (context)
335  AB_ImExporterContext_free(context);
336  if (job_list)
337  {
338 #ifdef AQBANKING6
339  AB_Transaction_List2_free(job_list);
340 #else
341  AB_Job_List2_free(job_list);
342 #endif
343  job_list = NULL;
344  }
345  if (job)
346  {
347 #ifdef AQBANKING6
348  AB_Transaction_free(job);
349 #else
350  AB_Job_free(job);
351 #endif
352  job = NULL;
353  }
354  if (gui)
355  {
357  gui = NULL;
358  }
359 
360  }
361  while (!successful && !aborted);
362 
363 cleanup:
364  if (td)
366 #ifndef AQBANKING6
367  if (online)
368  AB_Banking_OnlineFini(api);
369 #endif
370  gnc_AB_BANKING_fini(api);
371 }
gnc_numeric double_to_gnc_numeric(double in, gint64 denom, gint how)
Convert a floating-point number to a gnc_numeric.
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
Definition: Account.cpp:2682
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 ...
Definition: gnc-ab-utils.c:502
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
Definition: gnc-numeric.h:166
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...
Definition: gnc-gwen-gui.c:259
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...
Definition: gnc-ab-utils.c:466
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Currently a no-op.
Definition: gnc-gwen-gui.c:294
GList * gnc_ab_trans_dialog_get_templ(const GncABTransDialog *td, gboolean *changed)
Retrieve the current list of transaction templates from the dialog td, unless changed is a specified ...
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
Definition: gnc-ab-utils.c:158
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...
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:247
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.
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.
Definition: gnc-ab-utils.c:270
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.
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...

◆ gnc_ab_memo_to_gnc()

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 ab_trans.

The returned string must be g_free'd by the caller.

Parameters
ab_transAqBanking transaction
Returns
A newly allocated string, may be ""

Definition at line 502 of file gnc-ab-utils.c.

503 {
504  const gchar *ab_remote_accountnumber =
505  AB_Transaction_GetRemoteAccountNumber(ab_trans);
506  const gchar *ab_remote_bankcode =
507  AB_Transaction_GetRemoteBankCode(ab_trans);
508 
509  gchar *ab_other_accountid;
510  gchar *ab_other_bankcode;
511 
512  gboolean have_accountid;
513  gboolean have_bankcode;
514 
515  gchar *retval;
516 
517  // For SEPA transactions, we need to ask for something different here
518  if (!ab_remote_accountnumber)
519  ab_remote_accountnumber = AB_Transaction_GetRemoteIban(ab_trans);
520  if (!ab_remote_bankcode)
521  ab_remote_bankcode = AB_Transaction_GetRemoteBic(ab_trans);
522 
523  ab_other_accountid = g_strdup(ab_remote_accountnumber ? ab_remote_accountnumber : "");
524  ab_other_bankcode = g_strdup(ab_remote_bankcode ? ab_remote_bankcode : "");
525 
526  /* Ensure string is in utf8 */
527  gnc_utf8_strip_invalid(ab_other_accountid);
528  gnc_utf8_strip_invalid(ab_other_bankcode);
529 
530  /* and -then- trim it */
531  g_strstrip(ab_other_accountid);
532  g_strstrip(ab_other_bankcode);
533 
534 
535  have_accountid = ab_other_accountid && *ab_other_accountid;
536  have_bankcode = ab_other_bankcode && *ab_other_bankcode;
537 
538  if ( have_accountid || have_bankcode )
539  {
540  retval = g_strdup_printf("%s %s %s %s",
541  have_accountid ? _("Account") : "",
542  have_accountid ? ab_other_accountid : "",
543  have_bankcode ? _("Bank") : "",
544  have_bankcode ? ab_other_bankcode : ""
545  );
546  g_strstrip(retval);
547  }
548  else
549  {
550  retval = g_strdup("");
551  }
552 
553  g_free(ab_other_accountid);
554  g_free(ab_other_bankcode);
555 
556  return retval;
557 }
void gnc_utf8_strip_invalid(gchar *str)
Strip any non-UTF-8 characters from a string.

◆ gnc_ab_set_account_accountid()

void gnc_ab_set_account_accountid ( Account a,
const gchar *  id 
)

Set the accountid string in the Account a to id.

A copy of the string will be stored. The Account will be marked as "dirty".

Parameters
aAccount
idAccount ID

Definition at line 49 of file gnc-ab-kvp.c.

50 {
52  qof_instance_set (QOF_INSTANCE (a),
53  "ab-account-id", id,
54  NULL);
56 }
void qof_instance_set(QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.cpp:1430
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

◆ gnc_ab_set_account_bankcode()

void gnc_ab_set_account_bankcode ( Account a,
const gchar *  code 
)

Set the bankcode string in the Account a to code.

A copy of the string will be stored. The Account will be marked as "dirty".

Parameters
aAccount
codeBank code

Definition at line 69 of file gnc-ab-kvp.c.

70 {
72  qof_instance_set (QOF_INSTANCE (a),
73  "ab-bank-code", code,
74  NULL);
76 }
void qof_instance_set(QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.cpp:1430
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

◆ gnc_ab_set_account_trans_retrieval()

void gnc_ab_set_account_trans_retrieval ( Account a,
time64  time 
)

Set the time of last online transaction retrieval for Account a.

The account will be marked as "dirty".

Parameters
aAccount
timeRetrieval time

Definition at line 109 of file gnc-ab-kvp.c.

110 {
111  Time64 t = {time};
113  qof_instance_set (QOF_INSTANCE (a),
114  "ab-trans-retrieval", &t,
115  NULL);
117 }
void qof_instance_set(QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.cpp:1430
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

◆ gnc_ab_set_account_uid()

void gnc_ab_set_account_uid ( Account a,
guint32  uid 
)

Set the unique id for the AB_BANKING account in the Account a to uid.

The Account will be marked as "dirty".

Parameters
aAccount
uidUnique ID

Definition at line 89 of file gnc-ab-kvp.c.

90 {
92  qof_instance_set (QOF_INSTANCE (a),
93  "ab-account-uid", (guint64)uid,
94  NULL);
96 }
void qof_instance_set(QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition: Account.cpp:1430
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1471

◆ gnc_ab_set_book_template_list()

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.

No copy of the GList will be stored, the callee becomes the owner and the caller must not free it. The book will be marked "dirty".

Parameters
bBook
template_listTemplate list

Definition at line 183 of file gnc-aqbanking-templates.cpp.

184 {
185  GList *kvp_list = NULL;
186  for (auto node = template_list; node != NULL; node = g_list_next (node))
187  {
188  auto templ = static_cast<_GncABTransTempl*>(node->data);
189  auto value = new KvpValue(templ->make_kvp_frame());
190  kvp_list = g_list_prepend (kvp_list, value);
191  }
192  kvp_list = g_list_reverse (kvp_list);
193  auto value = new KvpValue(g_list_copy_deep(kvp_list, copy_list_value,
194  nullptr));
195  qof_book_begin_edit(b);
196  KvpFrame *toplevel = qof_instance_get_slots (QOF_INSTANCE (b));
197  delete toplevel->set_path({"hbci", "template-list"}, value);
198  qof_instance_set_dirty_flag (QOF_INSTANCE (b), TRUE);
199  qof_book_commit_edit(b);
200 }

◆ gnc_ab_trans_dialog_free()

void gnc_ab_trans_dialog_free ( GncABTransDialog *  td)

Free a Aqbanking transfer dialog.

Parameters
tdTransaction dialog

Definition at line 744 of file dialog-ab-trans.c.

745 {
746  if (!td) return;
747  if (td->ab_trans)
748  AB_Transaction_free(td->ab_trans);
749  if (td->dialog)
750  gtk_widget_destroy(td->dialog);
751  if (td->template_list_store)
752  {
753  gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
754  gnc_ab_trans_dialog_clear_templ_helper, NULL);
755  g_object_unref(td->template_list_store);
756  }
757  g_free(td);
758 }

◆ gnc_ab_trans_dialog_get_ab_trans()

const AB_TRANSACTION* gnc_ab_trans_dialog_get_ab_trans ( const GncABTransDialog *  td)

Receive the Aqbanking Transaction filled by the dialog.

Parameters
tdTransaction dialog
Returns
An Aqbanking transaction

Definition at line 804 of file dialog-ab-trans.c.

805 {
806  g_return_val_if_fail(td, NULL);
807  return td->ab_trans;
808 }

◆ gnc_ab_trans_dialog_get_job()

GNC_AB_JOB* gnc_ab_trans_dialog_get_job ( const GncABTransDialog *  td)

Receive the Aqbanking job filled by the dialog.

Parameters
tdTransaction dialog
Returns
An Aqbanking job

Definition at line 871 of file dialog-ab-trans.c.

872 {
873  g_return_val_if_fail(td, NULL);
874  return gnc_ab_get_trans_job(td->ab_acc, td->ab_trans, td->trans_type);
875 }
GNC_AB_JOB * gnc_ab_get_trans_job(GNC_AB_ACCOUNT_SPEC *ab_acc, const AB_TRANSACTION *ab_trans, GncABTransType trans_type)
Return the AqBanking job associated with the transaction.

◆ gnc_ab_trans_dialog_get_parent()

GtkWidget* gnc_ab_trans_dialog_get_parent ( const GncABTransDialog *  td)

Retrieve the widget used as parent.

Parameters
tdTransaction dialog
Returns
The parent

Definition at line 797 of file dialog-ab-trans.c.

798 {
799  g_return_val_if_fail(td, NULL);
800  return td->parent;
801 }

◆ gnc_ab_trans_dialog_get_templ()

GList* gnc_ab_trans_dialog_get_templ ( const GncABTransDialog *  td,
gboolean *  changed 
)

Retrieve the current list of transaction templates from the dialog td, unless changed is a specified location and the templates have not been touched by the user.

Parameters
tdTransaction dialog
changedLocation to store whether the templates have been changed, may be NULL
Returns
The a newly allocated list of the internal transaction templates. Free this one via g_list_free().

Definition at line 777 of file dialog-ab-trans.c.

778 {
779  GList *list = NULL;
780 
781  g_return_val_if_fail(td, NULL);
782 
783  if (changed)
784  {
785  *changed = td->templ_changed;
786  if (!*changed)
787  return NULL;
788  }
789 
790  gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
791  gnc_ab_trans_dialog_get_templ_helper, &list);
792  list = g_list_reverse(list);
793  return list;
794 }

◆ gnc_ab_trans_dialog_new()

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.

Parameters
parentWidget to use as parent, may be NULL
ab_accAqbanking account
commodity_scucommodity used for the amount
trans_typeType of transaction
templatesA GList of template transactions which will become fully managed by the dialog, so do not free it and retrieve snapshots via gnc_ab_trans_dialog_get_templ()
Returns
A new GncABTransDialog, free with gnc_ab_trans_dialog_free()

Definition at line 260 of file dialog-ab-trans.c.

263 {
264  GncABTransDialog *td;
265  GtkBuilder *builder;
266  const gchar *ab_ownername;
267  const gchar *ab_accountnumber;
268  const gchar *ab_bankname;
269  const gchar *ab_bankcode;
270  G_GNUC_UNUSED GtkWidget *trans_vbox;
271  GtkWidget *heading_label;
272  GtkWidget *recp_name_heading;
273  GtkWidget *recp_account_heading;
274  GtkWidget *recp_bankcode_heading;
275  GtkWidget *amount_hbox, *amount_label;
276  GtkWidget *orig_name_heading;
277  GtkWidget *orig_account_heading;
278  GtkWidget *orig_account_label;
279  G_GNUC_UNUSED GtkWidget *orig_bankname_heading;
280  GtkWidget *orig_bankname_label;
281  GtkWidget *orig_bankcode_heading;
282  GtkWidget *orig_bankcode_label;
283  GtkCellRenderer *renderer;
284  GtkTreeViewColumn *column;
285 
286  g_return_val_if_fail(ab_acc, NULL);
287 
288 #ifdef AQBANKING6
289  ab_ownername = AB_AccountSpec_GetOwnerName(ab_acc);
290  if (!ab_ownername)
291  ab_ownername = "";
292  ab_accountnumber = AB_AccountSpec_GetAccountNumber(ab_acc);
293  ab_bankcode = AB_AccountSpec_GetBankCode(ab_acc);
294  ab_bankname = _("(unknown)");
295 #else
296  ab_ownername = AB_Account_GetOwnerName(ab_acc);
297  if (!ab_ownername)
298  ab_ownername = "";
299  ab_accountnumber = AB_Account_GetAccountNumber(ab_acc);
300  ab_bankcode = AB_Account_GetBankCode(ab_acc);
301  ab_bankname = AB_Account_GetBankName(ab_acc);
302  if (!ab_bankname || !*ab_bankname)
303  ab_bankname = _("(unknown)");
304 #endif
305 
306  td = g_new0(GncABTransDialog, 1);
307  td->parent = parent;
308  td->ab_acc = ab_acc;
309  td->trans_type = trans_type;
310 
311  builder = gtk_builder_new();
312  gnc_builder_add_from_file (builder, "dialog-ab.glade", "aqbanking_transaction_dialog");
313  td->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "aqbanking_transaction_dialog"));
314 
315  if (parent)
316  gtk_window_set_transient_for(GTK_WINDOW(td->dialog), GTK_WINDOW(parent));
317 
318  /* Extract widgets */
319  trans_vbox = GTK_WIDGET(gtk_builder_get_object (builder, "trans_vbox"));
320  heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
321  recp_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_heading"));
322  td->recp_name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_entry"));
323  recp_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_heading"));
324  td->recp_account_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_entry"));
325  recp_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_heading"));
326  td->recp_bankcode_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_entry"));
327  td->recp_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankname_label"));
328  amount_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "amount_hbox"));
329  amount_label = GTK_WIDGET(gtk_builder_get_object (builder, "amount_label"));
330  td->purpose_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_entry"));
331  td->purpose_cont_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont_entry"));
332  td->purpose_cont2_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont2_entry"));
333  td->purpose_cont3_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont3_entry"));
334  td->exec_button = GTK_WIDGET(gtk_builder_get_object(builder, "exec_now_button"));
335  orig_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_heading"));
336  td->orig_name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_label"));
337  orig_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_heading"));
338  orig_account_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_label"));
339  orig_bankname_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_heading"));
340  orig_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_label"));
341  orig_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_heading"));
342  orig_bankcode_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_label"));
343  td->template_gtktreeview =
344  GTK_TREE_VIEW(gtk_builder_get_object (builder, "template_list"));
345 
346  /* Amount edit */
347  td->amount_edit = gnc_amount_edit_new();
348  gtk_box_pack_start(GTK_BOX(amount_hbox), td->amount_edit, TRUE, TRUE, 0);
349  gnc_amount_edit_make_mnemonic_target(GNC_AMOUNT_EDIT(td->amount_edit), amount_label);
350  gnc_amount_edit_set_evaluate_on_enter(GNC_AMOUNT_EDIT(td->amount_edit),
351  TRUE);
352  gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(td->amount_edit),
353  commodity_scu);
354 
355  /* Use "focus-out" signal because "amount-changed" is only sent when ENTER is pressed */
356  g_signal_connect_swapped (gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit)), "focus-out-event",
357  G_CALLBACK(gnc_ab_trans_dialog_verify_values), td);
358 
359  /* Check for what kind of transaction this should be, and change the
360  * labels accordingly */
361  switch (trans_type)
362  {
363  case SINGLE_TRANSFER:
364  case SINGLE_INTERNAL_TRANSFER:
365  /* all labels are already set */
366  break;
367  case SEPA_TRANSFER:
368  gtk_label_set_text(GTK_LABEL (heading_label),
369  /* Translators: Strings from this file are
370  needed only in countries that have one of
371  aqbanking's Online Banking techniques
372  available. This is 'OFX DirectConnect'
373  (U.S. and others), 'HBCI' (Germany),
374  or 'YellowNet' (Switzerland). If none of
375  these techniques are available in your
376  country, you may safely ignore strings
377  from the import-export/hbci
378  subdirectory. */
379  _("Enter a SEPA Online Transfer"));
380  gtk_label_set_text(GTK_LABEL(recp_account_heading),
381  _("Recipient IBAN (International Account Number)"));
382  gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
383  _("Recipient BIC (Bank Code)"));
384 
385  gtk_label_set_text(GTK_LABEL(orig_account_heading),
386  _("Originator IBAN (International Account Number)"));
387  gtk_label_set_text(GTK_LABEL(orig_bankcode_heading),
388  _("Originator BIC (Bank Code)"));
389  break;
390 
391  case SINGLE_DEBITNOTE:
392  /* this case is no longer in use; don't introduce extra strings */
393  break;
394 
395  case SEPA_DEBITNOTE:
396  gtk_label_set_text(GTK_LABEL (heading_label),
397  _("Enter a SEPA Online Direct Debit Note"));
398 
399  gtk_label_set_text(GTK_LABEL(recp_name_heading),
400  _("Debited Account Owner"));
401  gtk_label_set_text(GTK_LABEL(recp_account_heading),
402  _("Debited IBAN (International Account Number)"));
403  gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
404  _("Debited BIC (Bank Code)"));
405 
406  gtk_label_set_text(GTK_LABEL(orig_name_heading),
407  _("Credited Account Owner"));
408  gtk_label_set_text(GTK_LABEL(orig_account_heading),
409  _("Credited IBAN (International Account Number)"));
410  gtk_label_set_text(GTK_LABEL(orig_bankcode_heading),
411  _("Credited BIC (Bank Code)"));
412  break;
413 
414  default:
415  g_critical("gnc_ab_trans_dialog_new: Oops, unknown GncABTransType %d",
416  trans_type);
417  break;
418  }
419 
420  /* Additionally change the labels for the European (SEPA) transactions */
421  if (gnc_ab_trans_isSEPA(trans_type))
422  {
423  // Also, SEPA might have much longer IBAN (up to 34 chars) and BIC (11)
424  gtk_entry_set_max_length(GTK_ENTRY(td->recp_bankcode_entry), 11);
425  gtk_entry_set_max_length(GTK_ENTRY(td->recp_account_entry), 34);
426  }
427 
428  gtk_entry_set_text(GTK_ENTRY(td->orig_name_entry), ab_ownername);
429  gtk_label_set_text(GTK_LABEL(orig_bankname_label), ab_bankname);
430  if (gnc_ab_trans_isSEPA(trans_type))
431  {
432  gtk_widget_set_sensitive(GTK_WIDGET(td->orig_name_entry), TRUE);
433 #if AQBANKING6
434  ab_accountnumber = AB_AccountSpec_GetIban(ab_acc);
435  ab_bankcode = AB_AccountSpec_GetBic(ab_acc);
436 #else
437  ab_accountnumber = AB_Account_GetIBAN(ab_acc);
438  ab_bankcode = AB_Account_GetBIC(ab_acc);
439 #endif
440  gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber);
441  gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode);
442  }
443  else
444  {
445  gtk_widget_set_sensitive(GTK_WIDGET(td->orig_name_entry), FALSE);
446  gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber);
447  gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode);
448  }
449 
450  /* Fill list for choosing a transaction template */
451  td->template_list_store = gtk_list_store_new(TEMPLATE_NUM_COLUMNS,
452  G_TYPE_STRING, G_TYPE_POINTER);
453  g_list_foreach(templates, gnc_ab_trans_dialog_fill_templ_helper, td->template_list_store);
454  gtk_tree_view_set_model(td->template_gtktreeview,
455  GTK_TREE_MODEL(td->template_list_store));
456  td->templ_changed = FALSE;
457  /* Keep a reference to the store */
458 
459  /* Show this list */
460  renderer = gtk_cell_renderer_text_new();
461  column = gtk_tree_view_column_new_with_attributes(
462  "Template Name", renderer, "text", TEMPLATE_NAME, NULL);
463  gtk_tree_view_append_column(td->template_gtktreeview, column);
464 
465  /* Connect the Signals */
466  gtk_builder_connect_signals_full(builder, gnc_builder_connect_full_func, td);
467 
468  g_object_unref(G_OBJECT(builder));
469 
470  /* Disabled OK button until suitable values are filled */
471  gnc_ab_trans_dialog_verify_values(td);
472 
473  return td;
474 }
gboolean gnc_ab_trans_isSEPA(GncABTransType t)
Returns true if the given GncABTransType is an European (SEPA) transaction (transfer or debit note)...

◆ gnc_ab_trans_dialog_run_until_ok()

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.

Parameters
tdTransaction dialog
ab_accAqBanking account
Returns
GTK_RESPONSE_CANCEL or GTK_RESPONSE_DESTROY_EVENT if the user cancelled the dialog and GNC_RESPONSE_NOW otherwise.

Definition at line 654 of file dialog-ab-trans.c.

655 {
656  gint result;
657  GNC_AB_JOB *job;
658  const AB_TRANSACTION_LIMITS *joblimits;
659  guint8 max_purpose_lines;
660 
661  /* Check whether the account supports this job */
662  job = gnc_ab_trans_dialog_get_available_empty_job(td->ab_acc, td->trans_type);
663  if (!job)
664  {
665  g_warning("gnc_ab_trans_dialog_run_until_ok: Oops, job not available");
666  return GTK_RESPONSE_CANCEL;
667  }
668 
669  /* Activate as many purpose entries as available for the job */
670 #ifdef AQBANKING6
671  joblimits = AB_AccountSpec_GetTransactionLimitsForCommand(td->ab_acc, AB_Transaction_GetCommand(job));
672 #else
673  joblimits = AB_Job_GetFieldLimits (job);
674 #endif
675  max_purpose_lines = joblimits ?
676  AB_TransactionLimits_GetMaxLinesPurpose(joblimits) : 2;
677  gtk_widget_set_sensitive(td->purpose_cont_entry, max_purpose_lines > 1);
678  gtk_widget_set_sensitive(td->purpose_cont2_entry, max_purpose_lines > 2);
679  gtk_widget_set_sensitive(td->purpose_cont3_entry, max_purpose_lines > 3);
680  if (joblimits)
681  {
682  gtk_entry_set_max_length(GTK_ENTRY(td->purpose_entry),
683  AB_TransactionLimits_GetMaxLenPurpose(joblimits));
684  gtk_entry_set_max_length(GTK_ENTRY(td->purpose_cont_entry),
685  AB_TransactionLimits_GetMaxLenPurpose(joblimits));
686  gtk_entry_set_max_length(GTK_ENTRY(td->purpose_cont2_entry),
687  AB_TransactionLimits_GetMaxLenPurpose(joblimits));
688  gtk_entry_set_max_length(GTK_ENTRY(td->purpose_cont3_entry),
689  AB_TransactionLimits_GetMaxLenPurpose(joblimits));
690  gtk_entry_set_max_length(GTK_ENTRY(td->recp_name_entry),
691  AB_TransactionLimits_GetMaxLenRemoteName(joblimits));
692  }
693 
694  /* Show the dialog */
695  gtk_widget_show(td->dialog);
696 
697  /* Now run the dialog until it gets closed by a button press */
698  result = gtk_dialog_run (GTK_DIALOG (td->dialog));
699 
700  /* Was cancel pressed or dialog closed?
701  * GNC_RESPONSE_NOW == execute now
702  * GNC_RESPONSE_LATER == scheduled for later execution (unimplemented)
703  * GTK_RESPONSE_CANCEL == cancel
704  * GTK_RESPONSE_DELETE_EVENT == window destroyed */
705  if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
706  {
707  gtk_widget_destroy(td->dialog);
708  td->dialog = NULL;
709  return result;
710  }
711 
712  /* Get the transaction details - have been checked beforehand */
713  td->ab_trans = gnc_ab_trans_dialog_fill_values(td);
714 
715  /* FIXME: If this is a direct debit, set the textkey/ "Textschluessel"/
716  * transactionCode according to some GUI selection here!! */
717  /*if (td->trans_type == SINGLE_DEBITNOTE)
718  AB_TRANSACTION_setTextKey (td->hbci_trans, 05); */
719 
720 
721  /* Hide the dialog */
722  if (td->dialog)
723  gtk_widget_hide(td->dialog);
724 
725  return result;
726 }

◆ gnc_ab_trans_templ_free()

void gnc_ab_trans_templ_free ( GncABTransTempl t)

Free the memory used by a template.

Parameters
tGncABTransTempl to be freed

Definition at line 164 of file gnc-aqbanking-templates.cpp.

165 {
166  delete t;
167 }

◆ gnc_ab_trans_templ_get_amount()

gnc_numeric gnc_ab_trans_templ_get_amount ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Amount

Definition at line 231 of file gnc-aqbanking-templates.cpp.

232 {
233  g_return_val_if_fail(t, gnc_numeric_zero());
234  return t->amount();
235 }

◆ gnc_ab_trans_templ_get_name()

const gchar* gnc_ab_trans_templ_get_name ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Name of the template, an internal string

Definition at line 203 of file gnc-aqbanking-templates.cpp.

204 {
205  g_return_val_if_fail(t, NULL);
206  return t->name();
207 }

◆ gnc_ab_trans_templ_get_purpose()

const gchar* gnc_ab_trans_templ_get_purpose ( const GncABTransTempl t)
Parameters
tTemplate
Returns
First purpose line, an internal string

Definition at line 238 of file gnc-aqbanking-templates.cpp.

239 {
240  g_return_val_if_fail(t, NULL);
241  return t->purpose();
242 }

◆ gnc_ab_trans_templ_get_purpose_cont()

const gchar* gnc_ab_trans_templ_get_purpose_cont ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Second purpose line, an internal string

Definition at line 245 of file gnc-aqbanking-templates.cpp.

246 {
247  g_return_val_if_fail(t, NULL);
248  return t->purpose_continuation();
249 }

◆ gnc_ab_trans_templ_get_recp_account()

const gchar* gnc_ab_trans_templ_get_recp_account ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Account Number of the recipient, an internal string

Definition at line 217 of file gnc-aqbanking-templates.cpp.

218 {
219  g_return_val_if_fail(t, NULL);
220  return t->recipient_account();
221 }

◆ gnc_ab_trans_templ_get_recp_bankcode()

const gchar* gnc_ab_trans_templ_get_recp_bankcode ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Bank Code of the recipient, an internal string

Definition at line 224 of file gnc-aqbanking-templates.cpp.

225 {
226  g_return_val_if_fail(t, NULL);
227  return t->recipient_bankcode();
228 }

◆ gnc_ab_trans_templ_get_recp_name()

const gchar* gnc_ab_trans_templ_get_recp_name ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Name of the recipient, an internal string

Definition at line 210 of file gnc-aqbanking-templates.cpp.

211 {
212  g_return_val_if_fail(t, NULL);
213  return t->recipient_name();
214 }

◆ gnc_ab_trans_templ_list_free()

void gnc_ab_trans_templ_list_free ( GList *  l)

Free the memory used by a list of templates, including the list itself.

Parameters
lGList of GncABTransTempl

Definition at line 170 of file gnc-aqbanking-templates.cpp.

171 {
172  for(GList *node = l; node != NULL; node = g_list_next(node))
173  delete static_cast<_GncABTransTempl*>(node->data);
174 }

◆ gnc_ab_trans_templ_list_new_from_book()

GList* gnc_ab_trans_templ_list_new_from_book ( QofBook *  b)

Obtain the list of QofTemplates saved in a Book.

Parameters
bQofBook containing the templates.
Returns
A GList of newly allocated GncABTransTempls

Definition at line 136 of file gnc-aqbanking-templates.cpp.

137 {
138  GList *retval = NULL;
139  auto toplevel = qof_instance_get_slots (QOF_INSTANCE (b));
140  auto slot = toplevel->get_slot({"hbci", "template-list"});
141  if (slot == nullptr)
142  return retval;
143  auto list = slot->get<GList*>();
144  for (auto node = list; node != NULL; node = g_list_next (node))
145  {
146  KvpFrame *frame = static_cast<KvpValue*>(node->data)->get<KvpFrame*>();
147  auto c_func = [frame](const char* key)
148  { auto slot = frame->get_slot({key});
149  return slot == nullptr ? std::string("") : std::string(slot->get<const char*>());};
150  auto n_func = [frame](const char* key)
151  { auto slot = frame->get_slot({key});
152  return slot == nullptr ? gnc_numeric_zero() : slot->get<gnc_numeric>();};
153  auto templ = new _GncABTransTempl (c_func(TT_NAME), c_func(TT_RNAME),
154  c_func(TT_RACC), c_func(TT_RBCODE),
155  n_func(TT_AMOUNT), c_func(TT_PURPOS),
156  c_func(TT_PURPOSCT));
157  retval = g_list_prepend (retval, templ);
158  }
159  retval = g_list_reverse (retval);
160  return retval;
161 }
STL namespace.

◆ gnc_ab_trans_templ_new()

GncABTransTempl* gnc_ab_trans_templ_new ( void  )

Create a template with unset contents.

Returns
A newly allocated GncABTransTempl

Definition at line 120 of file gnc-aqbanking-templates.cpp.

121 {
122  return new _GncABTransTempl;
123 }

◆ gnc_ab_trans_templ_new_full()

GncABTransTempl* gnc_ab_trans_templ_new_full ( const gchar *  name,
const gchar *  recp_name,
const gchar *  recp_account,
const gchar *  recp_bankcode,
gnc_numeric  amount,
const gchar *  purpose,
const gchar *  purpose_cont 
)

Create a template with given contents.

Parameters
nameName of the template
recp_nameName of the recipient
recp_accountAccount Number of the recipient
recp_bankcodeBank Code of the recipient
amountAmount
purposeFirst purpose line
purpose_contSecond purpose line
Returns
A newly allocated GncABTransTempl

Definition at line 126 of file gnc-aqbanking-templates.cpp.

130 {
131  return new _GncABTransTempl(name, recp_name, recp_account, recp_bankcode,
132  amount, purpose, purpose_cont);
133 }

◆ gnc_ab_trans_templ_set_amount()

void gnc_ab_trans_templ_set_amount ( GncABTransTempl t,
gnc_numeric  amount 
)

Replace the amount stored in a template.

Parameters
tTemplate
amountAmount

Definition at line 282 of file gnc-aqbanking-templates.cpp.

283 {
284  g_return_if_fail(t);
285  t->set_amount(amount);
286 }

◆ gnc_ab_trans_templ_set_name()

void gnc_ab_trans_templ_set_name ( GncABTransTempl t,
const gchar *  name 
)

Set the name of a template.

Parameters
tTemplate
nameName

Definition at line 252 of file gnc-aqbanking-templates.cpp.

253 {
254  g_return_if_fail(t);
255  t->set_name(name);
256 }

◆ gnc_ab_trans_templ_set_purpose()

void gnc_ab_trans_templ_set_purpose ( GncABTransTempl t,
const gchar *  purpose 
)

Replace the first purpose line stored in a template.

Parameters
tTemplate
purposeFirst purpose line

Definition at line 289 of file gnc-aqbanking-templates.cpp.

290 {
291  g_return_if_fail(t);
292  t->set_purpose(purpose);
293 }

◆ gnc_ab_trans_templ_set_purpose_cont()

void gnc_ab_trans_templ_set_purpose_cont ( GncABTransTempl t,
const gchar *  purpose_cont 
)

Replace the second purpose line stored in a template.

Parameters
tTemplate
purpose_contSecond purpose line

Definition at line 296 of file gnc-aqbanking-templates.cpp.

298 {
299  g_return_if_fail(t);
300  t->set_purpose_continuation (purpose_cont);
301 }

◆ gnc_ab_trans_templ_set_recp_account()

void gnc_ab_trans_templ_set_recp_account ( GncABTransTempl t,
const gchar *  recp_account 
)

Replace the Account Number of the recipient stored in a template.

Parameters
tTemplate
recp_accountAccount Number of the recipient

Definition at line 266 of file gnc-aqbanking-templates.cpp.

268 {
269  g_return_if_fail(t);
270  t->set_recipient_account(recp_account);
271 }

◆ gnc_ab_trans_templ_set_recp_bankcode()

void gnc_ab_trans_templ_set_recp_bankcode ( GncABTransTempl t,
const gchar *  recp_bankcode 
)

Replace the Bank Code of the recipient stored in a template.

Parameters
tTemplate
recp_bankcodeBank Code of the recipient

Definition at line 274 of file gnc-aqbanking-templates.cpp.

276 {
277  g_return_if_fail(t);
278  t->set_recipient_bankcode(recp_bankcode);
279 }

◆ gnc_ab_trans_templ_set_recp_name()

void gnc_ab_trans_templ_set_recp_name ( GncABTransTempl t,
const gchar *  recp_name 
)

Replace the Account Number of the recipient stored in a template.

Parameters
tTemplate
recp_nameAccount Number of the recipient

Definition at line 259 of file gnc-aqbanking-templates.cpp.

260 {
261  g_return_if_fail(t);
262  t->set_recipient_name(recp_name);
263 }

◆ gnc_ab_trans_to_gnc()

Transaction* gnc_ab_trans_to_gnc ( const AB_TRANSACTION *  ab_trans,
Account gnc_acc 
)

Create an unbalanced and dirty GnuCash transaction with a split to gnc_acc from the information available in the AqBanking transaction ab_trans.

Parameters
ab_transAqBanking transaction
gnc_accAccount of to use for the split
Returns
A dirty GnuCash transaction or NULL otherwise

Definition at line 560 of file gnc-ab-utils.c.

561 {
562  QofBook *book;
563  Transaction *gnc_trans;
564  const gchar *fitid;
565  const GNC_GWEN_DATE *valuta_date;
566  time64 current_time;
567  const char *custref;
568  gchar *description;
569  Split *split;
570  gchar *memo;
571 
572  g_return_val_if_fail(ab_trans && gnc_acc, NULL);
573 
574  /* Create new GnuCash transaction for the given AqBanking one */
575  book = gnc_account_get_book(gnc_acc);
576  gnc_trans = xaccMallocTransaction(book);
577  xaccTransBeginEdit(gnc_trans);
578 
579  /* Date / Time */
580  valuta_date = AB_Transaction_GetValutaDate(ab_trans);
581  if (!valuta_date)
582  {
583  const GNC_GWEN_DATE *normal_date = AB_Transaction_GetDate(ab_trans);
584  if (normal_date)
585  valuta_date = normal_date;
586  }
587  if (valuta_date)
588  {
589  time64 secs = gnc_gwen_date_to_time64(valuta_date);
590  xaccTransSetDatePostedSecsNormalized(gnc_trans, secs);
591  }
592  else
593  {
594  g_warning("transaction_cb: Oops, date 'valuta_date' was NULL");
595  }
596  xaccTransSetDateEnteredSecs(gnc_trans, gnc_time (NULL));
597 
598  /* Currency. We take simply the default currency of the gnucash account */
599  xaccTransSetCurrency(gnc_trans, xaccAccountGetCommodity(gnc_acc));
600 
601  /* Trans-Num or Split-Action set with gnc_set_num_action below per book
602  * option */
603 
604  fitid = AB_Transaction_GetFiId(ab_trans);
605 
606  /* Description */
607  description = gnc_ab_description_to_gnc(ab_trans, (fitid && *fitid));
608  xaccTransSetDescription(gnc_trans, description);
609  g_free(description);
610 
611  /* Notes. */
612  /* xaccTransSetNotes(gnc_trans, g_notes); */
613  /* But Nobody ever uses the Notes field? */
614 
615  /* Add one split */
616  split = xaccMallocSplit(book);
617  xaccSplitSetParent(split, gnc_trans);
618  xaccSplitSetAccount(split, gnc_acc);
619 
620  /* Set the transaction number or split action field based on book option.
621  * We use the "customer reference", if there is one. */
622  custref = AB_Transaction_GetCustomerReference(ab_trans);
623  if (custref && *custref
624  && g_ascii_strncasecmp(custref, "NONREF", 6) != 0)
625  gnc_set_num_action (gnc_trans, split, custref, NULL);
626 
627  /* Set OFX unique transaction ID */
628  if (fitid && *fitid)
629  gnc_import_set_split_online_id(split, fitid);
630 
631  /* FIXME: Extract function */
632  {
633  /* Amount into the split */
634  const AB_VALUE *ab_value = AB_Transaction_GetValue(ab_trans);
635  double d_value = ab_value ? AB_Value_GetValueAsDouble (ab_value) : 0.0;
636  AB_TRANSACTION_TYPE ab_type = AB_Transaction_GetType (ab_trans);
637  gnc_numeric gnc_amount;
638 
639  /*printf("Transaction with value %f has type %d\n", d_value, ab_type);*/
640  /* If the value is positive, but the transaction type says the
641  money is transferred away from our account (Transfer instead of
642  DebitNote), we switch the value to negative. */
643  if (d_value > 0.0 && ab_type == AB_Transaction_TypeTransfer)
644  d_value = -d_value;
645 
646  gnc_amount = double_to_gnc_numeric(
647  d_value,
650  if (!ab_value)
651  g_warning("transaction_cb: Oops, value was NULL. Using 0");
652  xaccSplitSetBaseValue(split, gnc_amount, xaccAccountGetCommodity(gnc_acc));
653  }
654 
655  /* Memo in the Split. */
656  memo = gnc_ab_memo_to_gnc(ab_trans);
657  xaccSplitSetMemo(split, memo);
658  g_free(memo);
659 
660  return gnc_trans;
661 }
Transaction * xaccMallocTransaction(QofBook *book)
The xaccMallocTransaction() will malloc memory and initialize it.
Definition: Transaction.c:510
void xaccSplitSetBaseValue(Split *s, gnc_numeric value, const gnc_commodity *base_currency)
Depending on the base_currency, set either the value or the amount of this split or both: If the base...
Definition: Split.c:1319
void xaccTransSetDatePostedSecsNormalized(Transaction *trans, time64 time)
This function sets the posted date of the transaction, specified by a time64 (see ctime(3))...
gnc_numeric double_to_gnc_numeric(double in, gint64 denom, gint how)
Convert a floating-point number to a gnc_numeric.
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
Definition: Account.cpp:2682
void xaccTransSetDescription(Transaction *trans, const char *desc)
Sets the transaction Description.
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 ...
Definition: gnc-ab-utils.c:502
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
Definition: gnc-numeric.h:166
void xaccTransSetCurrency(Transaction *trans, gnc_commodity *curr)
Set a new currency on a transaction.
Definition: Transaction.c:1425
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...
Definition: gnc-ab-utils.c:466
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
Definition: Split.c:1728
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
Split * xaccMallocSplit(QofBook *book)
Constructor.
Definition: gmock-Split.cpp:37
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account&#39;s commodity.
Definition: Account.cpp:3405
time64 gnc_time(time64 *tbuf)
get the current local time
Definition: gnc-date.cpp:273
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
Definition: gnc-date.h:93
void xaccTransSetDateEnteredSecs(Transaction *trans, time64 secs)
Modify the date of when the transaction was entered.
Definition: Transaction.c:2052

◆ gnc_AB_VALUE_to_readable_string()

gchar* gnc_AB_VALUE_to_readable_string ( const AB_VALUE *  value)

Print the value of value with two decimal places and value's currency appended, or 0.0 otherwise.

Parameters
valueAB_VALUE or NULL
Returns
A newly allocated string

Definition at line 324 of file gnc-ab-utils.c.

325 {
326  if (value)
327  return g_strdup_printf("%.2f %s",
328  AB_Value_GetValueAsDouble(value),
329  AB_Value_GetCurrency(value));
330  else
331  return g_strdup_printf("%.2f", 0.0);
332 }

◆ gnc_file_aqbanking_import()

G_BEGIN_DECLS void gnc_file_aqbanking_import ( GtkWindow *  parent,
const gchar *  aqbanking_importername,
const gchar *  aqbanking_formatname,
gboolean  exec_as_aqbanking_jobs 
)

This routine will pop up a standard file selection dialog asking the user to pick a file to import.

This file will be opened and read. Its contents will be imported into the current book, using the import matcher from import-main-matcher.h.

Parameters
aqbanking_importernameThe aqbanking importer module that should be used. Possible values: "dtaus", "csv", "swift", or more.
aqbanking_formatnameIn aqbanking, each importer has one or more data formats available which define the actual data fields that should be used. In aqbanking, such a different format is called a "profile". Possible values for swift: "swift-mt940" or "swift-mt942", but for all others: "default", or more precisely: Look into $datadir/aqbanking/imexporters and look into the "name" field of the foo.conf files.
exec_as_aqbanking_jobsIf TRUE, additionally queue the imported transactions as online jobs over aqbanking/HBCI. If FALSE, just import the transactions and that's it.

Definition at line 65 of file gnc-file-aqb-import.c.

69 {
70  gchar *default_dir;
71  gchar *selected_filename = NULL;
72  gint dtaus_fd = -1;
73  AB_BANKING *api = NULL;
74  gboolean online = FALSE;
75  GncGWENGui *gui = NULL;
76 #ifndef AQBANKING6
77  AB_IMEXPORTER *importer;
78 #endif
79  GWEN_DB_NODE *db_profiles = NULL;
80  GWEN_DB_NODE *db_profile;
81  AB_IMEXPORTER_CONTEXT *context = NULL;
82  GWEN_IO_LAYER *io = NULL;
83  GncABImExContextImport *ieci = NULL;
84  GNC_AB_JOB_LIST2 *job_list = NULL;
85  GNC_AB_JOB_LIST2_ITERATOR *jit;
86  GNC_AB_JOB *job;
87  GNC_AB_JOB_STATUS job_status;
88  gboolean successful = TRUE;
89  int num_jobs = 0;
90  int num_jobs_failed = 0;
91  int max_failures = 5;
92  GString *errstr = NULL;
93 
94  /* Select a file */
95  default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_AQBANKING);
96  selected_filename = gnc_file_dialog(parent, _("Select a file to import"),
97  NULL, default_dir,
98  GNC_FILE_DIALOG_IMPORT);
99  g_free(default_dir);
100 
101  if (!selected_filename)
102  goto cleanup;
103  DEBUG("filename: %s", selected_filename);
104 
105  /* Remember the directory as the default */
106  default_dir = g_path_get_dirname(selected_filename);
107  gnc_set_default_directory(GNC_PREFS_GROUP_AQBANKING, default_dir);
108  g_free(default_dir);
109 
110 #ifndef AQBANKING6
111  dtaus_fd = g_open(selected_filename, O_RDONLY, 0);
112  if (dtaus_fd == -1)
113  {
114  DEBUG("Could not open file %s", selected_filename);
115  goto cleanup;
116  }
117 #endif
118  /* Get the API */
119  api = gnc_AB_BANKING_new();
120  if (!api)
121  {
122  g_warning("gnc_file_aqbanking_import: Couldn't get AqBanking API");
123  goto cleanup;
124  }
125 #ifndef AQBANKING6
126  if (AB_Banking_OnlineInit(api) != 0)
127  {
128  g_warning("gnc_file_aqbanking_import: "
129  "Couldn't initialize AqBanking API");
130  goto cleanup;
131  }
132  online = TRUE;
133 
134  /* Get import module */
135  importer = AB_Banking_GetImExporter(api, aqbanking_importername);
136  if (!importer)
137  {
138  g_warning("Import module %s not found", aqbanking_importername);
139  gnc_error_dialog(parent, "%s",
140  _("Import module for DTAUS import not found."));
141  goto cleanup;
142  }
143 
144  /* Load the import profile */
145  db_profiles = AB_Banking_GetImExporterProfiles(api, aqbanking_importername);
146 
147  /* Select profile */
148  db_profile = GWEN_DB_GetFirstGroup(db_profiles);
149  while (db_profile)
150  {
151  const gchar *name;
152 
153  name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
154  g_return_if_fail(name);
155  if (g_ascii_strcasecmp(name, aqbanking_profilename) == 0)
156  break;
157  db_profile = GWEN_DB_GetNextGroup(db_profile);
158  }
159  if (!db_profile)
160  {
161  g_warning("Profile \"%s\" for importer \"%s\" not found",
162  aqbanking_profilename, aqbanking_importername);
163  /* For debugging: Print those available names that have been found */
164  db_profile = GWEN_DB_GetFirstGroup(db_profiles);
165  while (db_profile)
166  {
167  const char *name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
168  g_warning("Only found profile \"%s\"\n", name ? name : "(null)");
169  db_profile = GWEN_DB_GetNextGroup(db_profile);
170  }
171  goto cleanup;
172  }
173 #endif
174 
175  /* Create a context to store the results */
176  context = AB_ImExporterContext_new();
177 
178 #ifdef AQBANKING6
179  if (AB_Banking_ImportFromFileLoadProfile(api, aqbanking_importername,
180  context, aqbanking_profilename,
181  NULL, selected_filename) < 0)
182  {
183  g_warning("gnc_file_aqbanking_import: Error on import");
184  goto cleanup;
185  }
186 #else
187  /* Wrap file in buffered gwen io */
188  close(dtaus_fd);
189  io = GWEN_SyncIo_File_new(selected_filename, GWEN_SyncIo_File_CreationMode_OpenExisting);
190  g_assert(io);
191  GWEN_SyncIo_AddFlags(io, GWEN_SYNCIO_FILE_FLAGS_READ);
192  {
193  /* We must explicitly call "Connect" on the GWEN_SYNCIO
194  * object. */
195  int rv = GWEN_SyncIo_Connect(io);
196  if (rv < 0)
197  {
198  g_warning("gnc_file_aqbanking_import: Failed to open file %s: %d", selected_filename, rv);
199  goto cleanup;
200  }
201  g_assert(GWEN_SyncIo_GetStatus(io) == GWEN_SyncIo_Status_Connected);
202  }
203  dtaus_fd = -1;
204 
205  /* Run the import */
206  if (AB_ImExporter_Import(importer, context, io, db_profile))
207  {
208  g_warning("gnc_file_aqbanking_import: Error on import");
209  goto cleanup;
210  }
211 
212  /* Close the file */
213  GWEN_SyncIo_free(io);
214  io = NULL;
215 #endif
216 
217  /* Before importing the results, if this is a new book, let user specify
218  * book options, since they affect how transactions are created */
219  if (gnc_is_new_book())
220  gnc_new_book_option_display (GTK_WIDGET (parent));
221 
222  /* Import the results */
223  ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS,
224  execute_transactions,
225  execute_transactions ? api : NULL,
226  GTK_WIDGET(parent));
227 
228  if (execute_transactions)
229  {
230  if (gnc_ab_ieci_run_matcher(ieci))
231  {
232  AB_IMEXPORTER_CONTEXT *execution_context;
233 
234  /* Extract the list of jobs */
235  job_list = gnc_ab_ieci_get_job_list(ieci);
236 
237  /* Create a context to store possible results */
238  execution_context = AB_ImExporterContext_new();
239 
240  /* Get a GUI object */
241  gui = gnc_GWEN_Gui_get(NULL);
242  if (!gui)
243  {
244  g_warning("gnc_file_aqbanking_import: Couldn't initialize Gwenhywfar GUI");
245  goto cleanup;
246  }
247 
248  /* And execute the jobs */
249 #ifdef AQBANKING6
250  AB_Banking_SendCommands(api, job_list, execution_context);
251 #else
252  AB_Banking_ExecuteJobs(api, job_list, execution_context);
253 #endif
254  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
255  * status always describes better whether the job was actually
256  * transferred to and accepted by the bank. See also
257  * https://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
258  */
259 
260  /* So we must go through all jobs and check AB_Job_GetStatus(job)
261  * to give the appropriate feedback if any of the jobs didn't
262  * work. */
263 
264 #ifdef AQBANKING6
265  jit = AB_Transaction_List2_First(job_list);
266 #else
267  jit = AB_Job_List2_First(job_list);
268 #endif
269  if (jit)
270  {
271 #ifdef AQBANKING6
272  job = AB_Transaction_List2Iterator_Data(jit);
273 #else
274  job = AB_Job_List2Iterator_Data(jit);
275 #endif
276  while (job)
277  {
278  num_jobs += 1;
279 #ifdef AQBANKING6
280  job_status = AB_Transaction_GetStatus(job);
281  if (job_status != AB_Transaction_StatusAccepted &&
282  job_status != AB_Transaction_StatusPending)
283 #else
284  job_status = AB_Job_GetStatus(job);
285  if (job_status != AB_Job_StatusFinished &&
286  job_status != AB_Job_StatusPending)
287 #endif
288  {
289  successful = FALSE;
290  num_jobs_failed += 1;
291 
292  if (num_jobs_failed <= max_failures)
293  {
294 #ifdef AQBANKING6
295  gchar *fmt_str =_("Job %d status %d - %s\n");
296 #else
297  gchar *fmt_str =_("Job %d status %d - %s: %s\n");
298 #endif
299  if (num_jobs_failed == 1)
300  {
301  errstr = g_string_new("Failed jobs:\n");
302  }
303  g_string_append_printf(errstr, fmt_str, num_jobs,
304  job_status,
305 #ifdef AQBANKING6
306  AB_Transaction_Status_toString(job_status));
307 #else
308  AB_Job_Status2Char(job_status),
309  AB_Job_GetResultText(job));
310 #endif
311  }
312  else
313  {
314  if (num_jobs_failed == (max_failures + 1) )
315  {
316  /* indicate that additional failures exist */
317  g_string_append(errstr, _("...\n"));
318  }
319  }
320  }
321 #ifdef AQBANKING6
322  job = AB_Transaction_List2Iterator_Next(jit);
323 #else
324  job = AB_Job_List2Iterator_Next(jit);
325 #endif
326  } /* while */
327 #ifdef AQBANKING6
328  AB_Transaction_List2Iterator_free(jit);
329 #else
330  AB_Job_List2Iterator_free(jit);
331 #endif
332  }
333 
334  if (!successful)
335  {
336  g_warning("%s", errstr->str);
337  gnc_error_dialog(parent,
338  _("An error occurred while executing jobs: %d of %d failed. "
339  "Please check the log window or gnucash.trace for the exact "
340  "error message.\n\n%s")
341  , num_jobs_failed, num_jobs, errstr->str);
342  }
343  else
344  {
345  if (num_jobs == 0)
346  {
347  gnc_info_dialog(parent,
348  _("No jobs to be sent.")
349  );
350  }
351  else
352  {
353  gnc_info_dialog(parent, ngettext
354  ("The job was executed successfully, but as a precaution "
355  "please check the log window for potential errors.",
356  "All %d jobs were executed successfully, but as a precaution "
357  "please check the log window for potential errors.",
358  num_jobs), num_jobs);
359  }
360  }
361  AB_ImExporterContext_free(execution_context);
362  }
363  }
364 
365 cleanup:
366  if (job_list)
367 #ifdef AQBANKING6
368  AB_Transaction_List2_freeAll(job_list);
369 #else
370  AB_Job_List2_FreeAll(job_list);
371  if (io)
372  GWEN_SyncIo_free(io);
373  if (db_profiles)
374  GWEN_DB_Group_free(db_profiles);
375  if (online)
376  AB_Banking_OnlineFini(api);
377  if (dtaus_fd != -1)
378  close(dtaus_fd);
379 #endif
380  if (ieci)
381  g_free(ieci);
382  if (context)
383  AB_ImExporterContext_free(context);
384  if (gui)
386  if (api)
387  gnc_AB_BANKING_fini(api);
388  if (selected_filename)
389  g_free(selected_filename);
390  if (errstr)
391  g_string_free(errstr, TRUE);
392 }
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:264
gboolean gnc_ab_ieci_run_matcher(GncABImExContextImport *ieci)
Run the generic transaction matcher dialog.
GNC_AB_JOB_LIST2 * gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci)
Extract the job list from data.
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...
Definition: gnc-gwen-gui.c:259
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Currently a no-op.
Definition: gnc-gwen-gui.c:294
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
Definition: gnc-ab-utils.c:158
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:247
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.

◆ gnc_GWEN_Gui_get()

GncGWENGui* gnc_GWEN_Gui_get ( GtkWidget *  parent)

When called for the first time, create a unique GncGWENGui object featuring a GWEN_GUI with all necessary callbacks, which can serve as a user interface for AqBanking jobs.

On later calls, return the object only when it is not active and save to use. Typically, you only need to call gnc_GWEN_Gui_release() once your job has finished.

Parameters
parentWidget to set new dialogs transient for, may be NULL
Returns
The unique GncGWENGui object or NULL otherwise

Definition at line 259 of file gnc-gwen-gui.c.

260 {
261  GncGWENGui *gui;
262 
263  ENTER("parent=%p", parent);
264 
265  if (full_gui)
266  {
267  if (full_gui->state == INIT || full_gui->state == RUNNING)
268  {
269  LEAVE("full_gui in use, state=%d", full_gui->state);
270  return NULL;
271  }
272 
273  gui = full_gui;
274  gui->parent = parent;
275  reset_dialog(gui);
276  register_callbacks(gui);
277 
278  LEAVE("gui=%p", gui);
279  return gui;
280  }
281 
282  gui = g_new0(GncGWENGui, 1);
283  gui->parent = parent;
284  setup_dialog(gui);
285  register_callbacks(gui);
286 
287  full_gui = gui;
288 
289  LEAVE("new gui=%p", gui);
290  return gui;
291 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ gnc_GWEN_Gui_get_close_flag()

gboolean gnc_GWEN_Gui_get_close_flag ( void  )

Get "Close when finished" flag.

Returns
gboolean close_when_finished

Definition at line 358 of file gnc-gwen-gui.c.

359 {
360  return gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH);
361 }
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.

◆ gnc_GWEN_Gui_hide_dialog()

void gnc_GWEN_Gui_hide_dialog ( void  )

Hides Online Banking Connection Window (Close log window)

Definition at line 392 of file gnc-gwen-gui.c.

393 {
394  GncGWENGui *gui = full_gui;
395 
396  if (gui)
397  {
398  hide_dialog(gui);
399  }
400 }

◆ gnc_GWEN_Gui_log_init()

void gnc_GWEN_Gui_log_init ( void  )

Hook our logging into the gwenhywfar logging framework by creating a minimalistic GWEN_GUI with only a callback for Gwen_Gui_LogHook().

This function can be called more than once, it will unref and replace the currently set GWEN_GUI though.

Definition at line 243 of file gnc-gwen-gui.c.

244 {
245  if (!log_gwen_gui)
246  {
247  log_gwen_gui = Gtk3_Gui_new();
248 
249  /* Always use our own logging */
250  GWEN_Gui_SetLogHookFn(log_gwen_gui, loghook_cb);
251 
252  /* Keep a reference so that the GWEN_GUI survives a GUI switch */
253  GWEN_Gui_Attach(log_gwen_gui);
254  }
255  GWEN_Gui_SetGui(log_gwen_gui);
256 }

◆ gnc_GWEN_Gui_release()

void gnc_GWEN_Gui_release ( GncGWENGui *  gui)

Currently a no-op.

The GncGWENGui will not be freed and it is considered finished once the first tracked progress has ended.

Parameters
guiThe GncGwenGUI returned by gnc_GWEN_Gui_get()

Definition at line 294 of file gnc-gwen-gui.c.

295 {
296  g_return_if_fail(gui && gui == full_gui);
297 
298  /* Currently a no-op */
299  ENTER("gui=%p", gui);
300  LEAVE(" ");
301 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ gnc_GWEN_Gui_set_close_flag()

void gnc_GWEN_Gui_set_close_flag ( gboolean  close_when_finished)

Set "Close when finished" flag.

Parameters
gbooleanclose_when_finished

Definition at line 339 of file gnc-gwen-gui.c.

340 {
342  GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
343  close_when_finished);
344 
345  if (full_gui)
346  {
347  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(full_gui->close_checkbutton))
348  != close_when_finished)
349  {
350  gtk_toggle_button_set_active(
351  GTK_TOGGLE_BUTTON(full_gui->close_checkbutton),
352  close_when_finished);
353  }
354  }
355 }
gboolean gnc_prefs_set_bool(const gchar *group, const gchar *pref_name, gboolean value)
Store a boolean value into the preferences backend.
Definition: gnc-prefs.c:277

◆ gnc_GWEN_Gui_show_dialog()

gboolean gnc_GWEN_Gui_show_dialog ( void  )

Unhides Online Banking Connection Window (Make log visible)

Returns
gboolean window is visible

Definition at line 364 of file gnc-gwen-gui.c.

365 {
366  GncGWENGui *gui = full_gui;
367 
368  if (!gui)
369  {
370  gnc_GWEN_Gui_get(NULL);
371  }
372 
373  if (gui)
374  {
375  if (gui->state == HIDDEN)
376  {
377  gui->state = FINISHED;
378  }
379  gtk_toggle_button_set_active(
380  GTK_TOGGLE_BUTTON(gui->close_checkbutton),
381  gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH));
382 
383  show_dialog(gui, FALSE);
384 
385  return TRUE;
386  }
387 
388  return FALSE;
389 }
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...
Definition: gnc-gwen-gui.c:259
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.

◆ gnc_plugin_aqbanking_get_type()

GType gnc_plugin_aqbanking_get_type ( void  )
Returns
The glib runtime type of an aqbanking plugin page

◆ gnc_plugin_aqbanking_new()

GncPlugin* gnc_plugin_aqbanking_new ( void  )
Returns
A new GncPluginAqBanking object

Definition at line 203 of file gnc-plugin-aqbanking.c.

204 {
205  return GNC_PLUGIN(g_object_new(GNC_TYPE_PLUGIN_AQBANKING, (gchar*) NULL));
206 }

◆ ini_flicker_gui()

void ini_flicker_gui ( const char *  pChallenge,
GncFlickerGui gui 
)

Initialize the dialog and drawing area.

Parameters
pChallengeThe answer from the bank which is shown as a flickering picture
guiThe structure of the Dialog-Widgets

Definition at line 391 of file gnc-flicker-gui.c.

392 {
393  /* Establish reference to the dialog widgets created in gnc_gwen_gui */
394  flickergui = gui;
395 
396  /* Load window size and initial setting values */
397  do_flicker_load_state (GTK_WIDGET (flickergui->dialog));
398 
399  /* Initialize application */
400  flickerdraw.barheight = BAR_HEIGHT;
401  flickerdraw.margin = MARGIN;
402  flickerdraw.y_barpos = 20; /* First painting position */
403  flickerdraw.halfbyteid = 0;
404  flickerdraw.clock = 1;
405 
406  flickerdraw.challenge = pChallenge;
407 
408  g_signal_connect (GTK_WINDOW (flickergui->dialog), "destroy",
409  G_CALLBACK (on_dialog_destroy), NULL);
410 
411  g_signal_connect (GTK_WIDGET (flickergui->flicker_challenge), "map",
412  G_CALLBACK (on_flicker_challenge_map), NULL);
413  g_signal_connect (GTK_WIDGET (flickergui->flicker_challenge), "draw",
414  G_CALLBACK (on_flicker_challenge_draw), NULL);
415  g_signal_connect (GTK_WIDGET (flickergui->flicker_challenge), "destroy",
416  G_CALLBACK (on_flicker_challenge_destroy), NULL);
417 
418  g_signal_connect (GTK_WIDGET (flickergui->flicker_marker), "map",
419  G_CALLBACK (on_flicker_marker_map), NULL);
420  g_signal_connect (GTK_WIDGET (flickergui->flicker_marker), "draw",
421  G_CALLBACK (on_flicker_marker_draw), NULL);
422 
423  flickergui->adj_barwidth = gtk_adjustment_new (0.0, 10.0, 80.0, 1.0, 10.0, 0.0);
424  gtk_spin_button_set_adjustment (flickergui->spin_barwidth, flickergui->adj_barwidth);
425  gtk_spin_button_set_value (GTK_SPIN_BUTTON (flickergui->spin_barwidth),
426  flickerdraw.barwidth);
427  g_signal_connect (GTK_WIDGET (flickergui->spin_barwidth), "value-changed",
428  G_CALLBACK (on_spin_barwidth_value_changed),
429  flickergui->flicker_marker);
430  gtk_widget_set_focus_on_click (GTK_WIDGET (flickergui->spin_barwidth), FALSE);
431 
432  flickergui->adj_delay = gtk_adjustment_new (0.0, 10.0, 100.0, 10.0, 10.0, 0.0);
433  gtk_spin_button_set_adjustment (flickergui->spin_delay, flickergui->adj_delay);
434  gtk_spin_button_set_value (GTK_SPIN_BUTTON (flickergui->spin_delay),
435  flickerdraw.delay);
436  g_signal_connect (GTK_WIDGET (flickergui->spin_delay), "value-changed",
437  G_CALLBACK (on_spin_delay_value_changed),
438  flickergui->flicker_challenge);
439  gtk_widget_set_focus_on_click (GTK_WIDGET (flickergui->spin_delay), FALSE);
440 
441  gtk_widget_grab_focus (GTK_WIDGET (flickergui->input_entry));
442 }