GnuCash  5.6-150-g038405b370+
Files | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
AqBanking

Files

file  assistant-ab-initial.h
 AqBanking setup functionality.
 
file  dialog-ab-select-imexporter.h
 Dialog to select AQBanking importer/exporter and format profile.
 
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  AB_Node_Pair
 
struct  GncFlickerGui
 

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_SPEC
 
#define GNC_AB_ACCOUNT_SPEC_LIST   AB_ACCOUNT_SPEC_LIST
 
#define GNC_AB_JOB   AB_TRANSACTION
 
#define GNC_AB_JOB_LIST2   AB_TRANSACTION_LIST2
 
#define GNC_AB_JOB_LIST2_ITERATOR   AB_TRANSACTION_LIST2_ITERATOR
 
#define GNC_AB_JOB_STATUS   AB_TRANSACTION_STATUS
 
#define GNC_GWEN_DATE   GWEN_DATE
 
#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_NAME   "gnc-plugin-aqbanking"
 

Typedefs

typedef struct _GncABSelectImExDlg GncABSelectImExDlg
 
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

GncABTransTempl * gnc_ab_trans_templ_new (void)
 Create a template with unset contents. More...
 
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. 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...
 
G_BEGIN_DECLS GncABSelectImExDlg * gnc_ab_select_imex_dlg_new (GtkWidget *parent, AB_BANKING *abi)
 Create an AQBanking importer/exporter selection dialog. More...
 
void gnc_ab_select_imex_dlg_destroy (GncABSelectImExDlg *imexd)
 Destroy an AQBanking importer/exporter selection dialog. More...
 
int gnc_ab_select_imex_dlg_run (GncABSelectImExDlg *imexd)
 Run an AQBanking importer/exporter selection dialog. More...
 
char * gnc_ab_select_imex_dlg_get_imexporter_name (GncABSelectImExDlg *imexd)
 Get the selected importer/exporter name. More...
 
void gnc_ab_select_imex_dlg_set_imexporter_name (GncABSelectImExDlg *imexd, const char *name)
 Get the selected importer/exporter name. More...
 
char * gnc_ab_select_imex_dlg_get_profile_name (GncABSelectImExDlg *imexd)
 Get the selected file format profile name. More...
 
void gnc_ab_select_imex_dlg_set_profile_name (GncABSelectImExDlg *imexd, const char *name)
 Get the selected file format profile name. 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...
 
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)
 Create SEPA transfers. 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...
 
GList * gnc_ab_imexporter_list (AB_BANKING *abi)
 Retrieve the available AQBanking importers. More...
 
GList * gnc_ab_imexporter_profile_list (AB_BANKING *abi, const char *importer_name)
 Retrieve the available format templates for an AQBanking importer. More...
 
G_BEGIN_DECLS void gnc_file_aqbanking_import_dialog (GtkWindow *parent)
 Import files via AQBanking's Import Dialog. 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...
 
GncPlugin * gnc_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 207 of file gnc-ab-utils.c.

208 {
209  if (!api)
210  api = gnc_AB_BANKING;
211 
212  if (api)
213  {
214  if (api == gnc_AB_BANKING)
215  {
216  gnc_AB_BANKING = NULL;
217  gnc_AB_BANKING_fini (api);
218  }
219 
220  AB_Banking_free (api);
221  }
222 }
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:226

◆ 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 226 of file gnc-ab-utils.c.

227 {
228  if (api == gnc_AB_BANKING)
229  {
230  if (--gnc_AB_BANKING_refcount == 0)
231  {
232  if (gnc_gwengui_extended_by_ABBanking)
233  AB_Gui_Unextend (gnc_gwengui_extended_by_ABBanking);
234  gnc_gwengui_extended_by_ABBanking = NULL;
235  return AB_Banking_Fini (api);
236  }
237  }
238  else
239  {
240  if (gnc_gwengui_extended_by_ABBanking)
241  AB_Gui_Unextend (gnc_gwengui_extended_by_ABBanking);
242  gnc_gwengui_extended_by_ABBanking = NULL;
243  return AB_Banking_Fini (api);
244  }
245  return 0;
246 }

◆ 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 163 of file gnc-ab-utils.c.

164 {
165  AB_BANKING *api;
166 
167  if (gnc_AB_BANKING)
168  {
169  /* API cached. */
170  api = gnc_AB_BANKING;
171 
172  /* Init the API again. */
173  if (gnc_AB_BANKING_refcount == 0)
174  g_return_val_if_fail (AB_Banking_Init (api) == 0, NULL);
175 
176  }
177  else
178  {
179  api = AB_Banking_new (PROJECT_NAME, NULL, 0);
180  g_return_val_if_fail (api, NULL);
181 
182  /* These two values must be set because newest bank regulation requires
183  the bank servers to require it. The string itself results from our
184  registration with the German bank association at
185  https://www.hbci-zka.de/register/prod_register.htm (where the
186  registration was requested and is managed by cstim). The function call was
187  introduced in aqbanking-5.99.25 and aqbanking-5.7.9. */
188  AB_Banking_RuntimeConfig_SetCharValue (api, "fintsRegistrationKey", "412748A1836CDD07181CE1910");
189  AB_Banking_RuntimeConfig_SetCharValue (api, "fintsApplicationVersionString", PROJECT_VERSION);
190 
191  /* Init the API */
192  g_return_val_if_fail (AB_Banking_Init (api) == 0, NULL);
193  gnc_gwengui_extended_by_ABBanking = GWEN_Gui_GetGui ();
194  AB_Gui_Extend (gnc_gwengui_extended_by_ABBanking, api);
195 
196  /* Cache it */
197  gnc_AB_BANKING = api;
198  gnc_AB_BANKING_refcount = 0;
199  }
200 
201  gnc_AB_BANKING_refcount++;
202 
203  return api;
204 }

◆ 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 295 of file gnc-ab-utils.c.

296 {
297  gchar *online_id;
298 
299  /* The accountnumber may have leading zeros, depending on where them
300  * accountnumber is came from, e.g. the accountnumber of accountinfo
301  * has no leading zeros while the (local)accountnumber of a transaction
302  * has leading zeros.
303  * So remove all leading '0', to get a consistent online_id.
304  */
305  while (accountnumber && *accountnumber == '0')
306  accountnumber++;
307 
308  online_id = g_strconcat (bankcode ? bankcode : "",
309  accountnumber ? accountnumber : "",
310  (gchar*)NULL);
311 
312  return online_id;
313 }

◆ 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 425 of file gnc-ab-utils.c.

426 {
427  GList *acc = NULL;
428  gchar *retval;
429 
430  acc = g_list_prepend (acc, gnc_ab_get_remote_name (ab_trans));
431  acc = g_list_prepend (acc, gnc_ab_get_purpose (ab_trans, is_ofx));
432  acc = g_list_prepend (acc, ab_ultimate_creditor_debtor_to_gnc (ab_trans, is_ofx));
433  retval = gnc_g_list_stringjoin_nodups (acc, "; ");
434 
435  g_list_free_full (acc, g_free);
436  return retval ? retval : g_strdup (_("Unspecified"));
437 }
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:350
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:370
gchar * gnc_g_list_stringjoin_nodups(GList *list_of_strings, const gchar *sep)
Like stringjoin but ensures that the string to be added isn&#39;t already part of the return string...

◆ 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 249 of file gnc-ab-utils.c.

250 {
251  GNC_AB_ACCOUNT_SPEC *ab_account = NULL;
252  const gchar *bankcode = NULL;
253  const gchar *accountid = NULL;
254  guint32 account_uid = 0;
255 
256  bankcode = gnc_ab_get_account_bankcode (gnc_acc);
257  accountid = gnc_ab_get_account_accountid (gnc_acc);
258  account_uid = gnc_ab_get_account_uid (gnc_acc);
259 
260  if (account_uid > 0)
261  {
262  gint rv;
263 
264  rv = AB_Banking_GetAccountSpecByUniqueId (api, account_uid, &ab_account);
265 
266  if ( (rv<0 || !ab_account) && bankcode && *bankcode &&
267  accountid && *accountid)
268  {
269 /* Finding the account by code and number is suspended in AQBANKING 6 pending
270  * implementation of a replacement for AB_Banking_GetAccountByCodeAndNumber.
271  */
272  PINFO("gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, "
273  "trying bank code\n", account_uid);
274  return NULL;
275  }
276  return ab_account;
277  }
278 
279  return NULL;
280 }
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 1167 of file gnc-ab-utils.c.

1168 {
1169  int rv;
1170  GWEN_DB_NODE *perm_certs = NULL;
1171  AB_BANKING *banking = gnc_AB_BANKING_new ();
1172 
1173  g_return_val_if_fail (banking, NULL);
1174  rv = AB_Banking_LoadSharedConfig (banking, "certs", &perm_certs);
1175  gnc_AB_BANKING_fini (banking);
1176  g_return_val_if_fail (rv >= 0, NULL);
1177  return perm_certs;
1178 }
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
Definition: gnc-ab-utils.c:163
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:226

◆ 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 370 of file gnc-ab-utils.c.

371 {
372  GWEN_STRINGLIST *ab_purpose;
373  const char *ab_transactionText = NULL;
374  gchar *gnc_description = NULL;
375 
376  g_return_val_if_fail (ab_trans, g_strdup (""));
377 
378  if (!is_ofx && gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_USE_TRANSACTION_TXT))
379  {
380  /* According to AqBanking, some of the non-swift lines have a special
381  * meaning. Some banks place valuable text into the transaction text,
382  * hence we put this text in front of the purpose. */
383  ab_transactionText = AB_Transaction_GetTransactionText (ab_trans);
384  if (ab_transactionText && *ab_transactionText)
385  gnc_description = g_utf8_normalize (ab_transactionText, -1, G_NORMALIZE_NFC);
386  }
387 
388  ab_purpose = AB_Transaction_GetPurposeAsStringList (ab_trans);
389  if (ab_purpose)
390  GWEN_StringList_ForEach (ab_purpose, join_ab_strings_cb,
391  &gnc_description);
392 
393  GWEN_StringList_free (ab_purpose);
394 
395  return gnc_description;
396 }
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 350 of file gnc-ab-utils.c.

351 {
352  const char* ab_remote_name;
353  gchar *gnc_other_name = NULL;
354 
355  g_return_val_if_fail (ab_trans, NULL);
356 
357  ab_remote_name = AB_Transaction_GetRemoteName (ab_trans);
358  if (ab_remote_name)
359  gnc_other_name = g_strdup(ab_remote_name);
360  if (!gnc_other_name || !*gnc_other_name)
361  {
362  g_free (gnc_other_name);
363  gnc_other_name = NULL;
364  }
365 
366  return gnc_other_name;
367 }

◆ 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 866 of file dialog-ab-trans.c.

869 {
870  GNC_AB_JOB *job;
871 
872  g_return_val_if_fail(ab_acc && ab_trans, NULL);
873 
874  job = gnc_ab_trans_dialog_get_available_empty_job(ab_acc, trans_type);
875  if (job)
876  {
877  AB_TRANSACTION *new_job;
878 
879  /* merge transactions */
880  new_job=AB_Transaction_dup(ab_trans);
881  AB_Transaction_SetCommand(new_job, AB_Transaction_GetCommand(job));
882  AB_Transaction_SetUniqueAccountId(new_job,
883  AB_Transaction_GetUniqueAccountId(job));
884 
885  AB_Transaction_free(job);
886  return new_job;
887  }
888  return NULL;
889 
890 }

◆ 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 47 of file gnc-ab-getbalance.c.

48 {
49  AB_BANKING *api;
50  GNC_AB_ACCOUNT_SPEC *ab_acc;
51  GNC_AB_JOB *job = NULL;
52  GNC_AB_JOB_LIST2 *job_list = NULL;
53  GncGWENGui *gui = NULL;
54  AB_IMEXPORTER_CONTEXT *context = NULL;
55  GncABImExContextImport *ieci = NULL;
56  GNC_AB_JOB_STATUS job_status;
57 
58  g_return_if_fail(parent && gnc_acc);
59 
60  /* Get the API */
61  api = gnc_AB_BANKING_new();
62  if (!api)
63  {
64  g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
65  return;
66  }
67 
68  /* Get the AqBanking Account */
69  ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
70  if (!ab_acc)
71  {
72  g_warning("gnc_ab_getbalance: No AqBanking account found");
73  gnc_error_dialog (GTK_WINDOW (parent), _("No valid online banking account assigned."));
74  goto cleanup;
75  }
76 
77  /* Get a GetBalance job and enqueue it */
78  if (!AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_CommandGetBalance))
79  {
80  g_warning("gnc_ab_getbalance: JobGetBalance not available for this "
81  "account");
82  gnc_error_dialog (GTK_WINDOW (parent), _("Online action \"Get Balance\" not available for this account."));
83  goto cleanup;
84  }
85  job = AB_Transaction_new();
86  AB_Transaction_SetCommand(job, AB_Transaction_CommandGetBalance);
87  AB_Transaction_SetUniqueAccountId(job, AB_AccountSpec_GetUniqueId(ab_acc));
88 
89  job_list = AB_Transaction_List2_new();
90  AB_Transaction_List2_PushBack(job_list, job);
91  /* Get a GUI object */
92  gui = gnc_GWEN_Gui_get(parent);
93  if (!gui)
94  {
95  g_warning("gnc_ab_getbalance: Couldn't initialize Gwenhywfar GUI");
96  goto cleanup;
97  }
98 
99  /* Create a context to store the results */
100  context = AB_ImExporterContext_new();
101 
102  /* Execute the job */
103  AB_Banking_SendCommands(api, job_list, context);
104  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
105  * status always describes better whether the job was actually
106  * transferred to and accepted by the bank. See also
107  * https://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
108  */
109  job_status = AB_Transaction_GetStatus(job);
110  if (job_status != AB_Transaction_StatusEnqueued
111  && job_status != AB_Transaction_StatusPending
112  && job_status != AB_Transaction_StatusAccepted)
113  {
114  g_warning("gnc_ab_getbalance: Error on executing job: %d", job_status);
115  gnc_error_dialog (GTK_WINDOW (parent),
116  _("Error on executing job.\n\nStatus: %s"),
117  AB_Transaction_Status_toString(job_status));
118  goto cleanup;
119  }
120 
121  /* Import the results */
122  ieci = gnc_ab_import_context(context, AWAIT_BALANCES, FALSE, NULL, parent);
123 
124 cleanup:
125  if (ieci)
126  g_free(ieci);
127  if (context)
128  AB_ImExporterContext_free(context);
129  if (gui)
131  if (job_list)
132  AB_Transaction_List2_free(job_list);
133  if (job)
134  AB_Transaction_free(job);
135  gnc_AB_BANKING_fini(api);
136 }
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:245
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Currently a no-op.
Definition: gnc-gwen-gui.c:280
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
Definition: gnc-ab-utils.c:163
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:226
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:249

◆ 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 97 of file gnc-ab-gettrans.c.

98 {
99  AB_BANKING *api;
100  GNC_AB_ACCOUNT_SPEC *ab_acc;
101  GWEN_TIME *from_date = NULL, *to_date = NULL;
102  time64 until;
103  GNC_AB_JOB *job = NULL;
104  GNC_AB_JOB_LIST2 *job_list = NULL;
105  GncGWENGui *gui = NULL;
106  AB_IMEXPORTER_CONTEXT *context = NULL;
107  GncABImExContextImport *ieci = NULL;
108  GNC_AB_JOB_STATUS job_status;
109 
110  g_return_if_fail(parent && gnc_acc);
111 
112  /* Get the API */
113  api = gnc_AB_BANKING_new();
114  if (!api)
115  {
116  g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
117  return;
118  }
119  /* Get the AqBanking Account */
120  ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
121  if (!ab_acc)
122  {
123  g_warning("gnc_ab_gettrans: No AqBanking account found");
124  gnc_error_dialog (GTK_WINDOW (parent), _("No valid online banking account assigned."));
125  goto cleanup;
126  }
127 
128  /* Get the start and end dates for the GetTransactions job. */
129  if (!gettrans_dates(parent, gnc_acc, &from_date, &to_date))
130  {
131  DEBUG("gnc_ab_gettrans: gettrans_dates aborted");
132  goto cleanup;
133  }
134  /* Use this as a local storage for the until_time below. */
135  until = GWEN_Time_toTime_t(to_date);
136 
137  /* Get a GetTransactions job and enqueue it */
138  if (!AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_CommandGetTransactions))
139  {
140  g_warning("gnc_ab_gettrans: JobGetTransactions not available for this "
141  "account");
142  gnc_error_dialog (GTK_WINDOW (parent), _("Online action \"Get Transactions\" not available for this account."));
143  goto cleanup;
144  }
145  job = AB_Transaction_new();
146  AB_Transaction_SetCommand(job, AB_Transaction_CommandGetTransactions);
147  AB_Transaction_SetUniqueAccountId(job, AB_AccountSpec_GetUniqueId(ab_acc));
148 
149  if (from_date) /* TODO: this should be simplified */
150  {
151  GWEN_DATE *dt;
152 
153  dt=GWEN_Date_fromLocalTime(GWEN_Time_toTime_t(from_date));
154  AB_Transaction_SetFirstDate(job, dt);
155  GWEN_Date_free(dt);
156  }
157 
158  if (to_date)
159  {
160  GWEN_DATE *dt;
161 
162  dt=GWEN_Date_fromLocalTime(GWEN_Time_toTime_t(to_date));
163  AB_Transaction_SetLastDate(job, dt);
164  GWEN_Date_free(dt);
165  }
166 
167  job_list = AB_Transaction_List2_new();
168  AB_Transaction_List2_PushBack(job_list, job);
169  /* Get a GUI object */
170  gui = gnc_GWEN_Gui_get(parent);
171  if (!gui)
172  {
173  g_warning("gnc_ab_gettrans: Couldn't initialize Gwenhywfar GUI");
174  goto cleanup;
175  }
176 
177  /* Create a context to store the results */
178  context = AB_ImExporterContext_new();
179 
180  /* Execute the job */
181  AB_Banking_SendCommands(api, job_list, context);
182 
183  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
184  * status always describes better whether the job was actually
185  * transferred to and accepted by the bank. See also
186  * https://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
187  */
188  job_status = AB_Transaction_GetStatus(job);
189  if (job_status != AB_Transaction_StatusAccepted
190  && job_status != AB_Transaction_StatusPending)
191  {
192  g_warning("gnc_ab_gettrans: Error on executing job");
193  gnc_error_dialog (GTK_WINDOW (parent),
194  _("Error on executing job.\n\nStatus: %s (%d)"),
195  AB_Transaction_Status_toString(job_status),
196  job_status);
197  goto cleanup;
198  }
199 
200  /* Import the results */
201  ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS, FALSE, NULL,
202  parent);
203  if (!(gnc_ab_ieci_get_found(ieci) & FOUND_TRANSACTIONS))
204  {
205  /* No transaction found */
206  GtkWidget *dialog = gtk_message_dialog_new(
207  GTK_WINDOW(parent),
208  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
209  GTK_MESSAGE_INFO,
210  GTK_BUTTONS_OK,
211  "%s",
212  _("The Online Banking import returned no transactions "
213  "for the selected time period."));
214  gtk_dialog_run(GTK_DIALOG(dialog));
215  gtk_widget_destroy(dialog);
216  }
217 
218  /* Store the date of this retrieval */
219  gnc_ab_set_account_trans_retrieval(gnc_acc, until);
220 
221 cleanup:
222  if (ieci)
223  g_free(ieci);
224  if (context)
225  AB_ImExporterContext_free(context);
226  if (gui)
228  if (job_list)
229  AB_Transaction_List2_free(job_list);
230  if (job)
231  AB_Transaction_free(job);
232  if (to_date)
233  GWEN_Time_free(to_date);
234  if (from_date)
235  GWEN_Time_free(from_date);
236  gnc_AB_BANKING_fini(api);
237 }
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:245
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Currently a no-op.
Definition: gnc-gwen-gui.c:280
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
Definition: gnc-ab-utils.c:163
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:226
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:249
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
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 1143 of file gnc-ab-utils.c.

1144 {
1145  g_return_val_if_fail (ieci, 0);
1146 
1147  return ieci->awaiting;
1148 }

◆ 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 1151 of file gnc-ab-utils.c.

1152 {
1153  g_return_val_if_fail (ieci, NULL);
1154 
1155  return ieci->job_list;
1156 }

◆ 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 1159 of file gnc-ab-utils.c.

1160 {
1161  g_return_val_if_fail (ieci, FALSE);
1162 
1163  return gnc_gen_trans_list_run (ieci->generic_importer);
1164 }
bool 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_imexporter_list()

GList* gnc_ab_imexporter_list ( AB_BANKING *  abi)

Retrieve the available AQBanking importers.

Parameters
abiThe AQBanking instance.
Returns
a GList<AB_Node_Pair> containing importer names and descriptions.

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

1231 {
1232  GList* desc_list = NULL;
1233  GWEN_PLUGIN_DESCRIPTION_LIST2 *il =
1234  AB_Banking_GetImExporterDescrs (api);
1235  GWEN_PLUGIN_DESCRIPTION_LIST2_ITERATOR *ilit;
1236  g_return_val_if_fail (il, NULL);
1237  ilit = GWEN_PluginDescription_List2_First(il);
1238 
1239  for (GWEN_PLUGIN_DESCRIPTION *pd =
1240  GWEN_PluginDescription_List2Iterator_Data(ilit);
1241  pd;
1242  pd = GWEN_PluginDescription_List2Iterator_Next(ilit))
1243  {
1244  AB_Node_Pair *node = NULL;
1245 
1246  node = g_slice_new (AB_Node_Pair);
1247  node->name = g_strdup(GWEN_PluginDescription_GetName(pd));
1248  node->descr = g_strdup(GWEN_PluginDescription_GetShortDescr(pd));
1249  desc_list = g_list_prepend (desc_list, node);
1250  }
1251  GWEN_PluginDescription_List2_free(il);
1252  return g_list_sort (desc_list, (GCompareFunc)ab_node_pair_compare);
1253 }

◆ gnc_ab_imexporter_profile_list()

GList* gnc_ab_imexporter_profile_list ( AB_BANKING *  abi,
const char *  importer_name 
)

Retrieve the available format templates for an AQBanking importer.

Parameters
apithe AQBanking instance.
importer_nameThe importer's name.
Returns
a GList<AB_Node_Pair> containing format template names and descriptions.

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

1257 {
1258  GList* prof_list = NULL;
1259  GWEN_DB_NODE* db = AB_Banking_GetImExporterProfiles(api, importer_name);
1260  g_return_val_if_fail (db, NULL);
1261 
1262  for (GWEN_DB_NODE *profile = GWEN_DB_GetFirstGroup(db); profile;
1263  profile = GWEN_DB_GetNextGroup(profile))
1264  {
1265  AB_Node_Pair *node = g_slice_new(AB_Node_Pair);
1266  if (!profile) continue;
1267  node->name = g_strdup(GWEN_DB_GetCharValue(profile, "name", 0, NULL));
1268  node->descr = g_strdup(GWEN_DB_GetCharValue(profile, "shortDescr", 0, NULL));
1269  prof_list = g_list_prepend (prof_list, node);
1270  }
1271  return g_list_sort (prof_list, (GCompareFunc)ab_node_pair_compare);
1272 }

◆ 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 1072 of file gnc-ab-utils.c.

1075 {
1076  GncABImExContextImport *data = g_new (GncABImExContextImport, 1);
1077  AB_IMEXPORTER_ACCOUNTINFO_LIST *ab_ail;
1078  g_return_val_if_fail (context, NULL);
1079  /* Do not await and ignore at the same time */
1080  g_return_val_if_fail (!(awaiting & AWAIT_BALANCES)
1081  || !(awaiting & IGNORE_BALANCES),
1082  NULL);
1083  g_return_val_if_fail (!(awaiting & AWAIT_TRANSACTIONS)
1084  || !(awaiting & IGNORE_TRANSACTIONS),
1085  NULL);
1086  /* execute_txns must be FALSE if txns are not awaited */
1087  g_return_val_if_fail (awaiting & AWAIT_TRANSACTIONS || !execute_txns, NULL);
1088  /* An api is needed for the jobs */
1089  g_return_val_if_fail (!execute_txns || api, NULL);
1090 
1091  data->awaiting = awaiting;
1092  data->txn_found = FALSE;
1093  data->execute_txns = execute_txns;
1094  data->api = api;
1095  data->parent = parent;
1096  data->job_list = AB_Transaction_List2_new ();
1097  data->tmp_job_list = NULL;
1098  data->generic_importer = NULL;
1099 
1100  g_datalist_init (&data->tmp_job_list);
1101 
1102  /* Import transactions */
1103  ab_ail = AB_ImExporterContext_GetAccountInfoList (context);
1104  if (ab_ail && AB_ImExporterAccountInfo_List_GetCount (ab_ail))
1105  {
1106  if (!(awaiting & IGNORE_TRANSACTIONS))
1107  AB_ImExporterAccountInfo_List_ForEach (ab_ail,
1108  txn_accountinfo_cb,
1109  data);
1110 
1111  /* populate and display the matching window */
1112  if (data->generic_importer)
1113  gnc_gen_trans_list_show_all (data->generic_importer);
1114 
1115  /* Check balances */
1116  if (!(awaiting & IGNORE_BALANCES))
1117  AB_ImExporterAccountInfo_List_ForEach (ab_ail,
1118  bal_accountinfo_cb,
1119  data);
1120  }
1121 
1122  /* Check bank-messages */
1123  {
1124  AB_MESSAGE * bankmsg = AB_ImExporterContext_GetFirstMessage (context);
1125  while (bankmsg)
1126  {
1127  const char* subject = AB_Message_GetSubject (bankmsg);
1128  const char* text = AB_Message_GetText (bankmsg);
1129  gnc_info_dialog (GTK_WINDOW(data->parent), "%s\n%s %s\n%s",
1130  _("The bank has sent a message in its response."),
1131  _("Subject:"),
1132  subject,
1133  text);
1134 
1135  bankmsg = AB_Message_List_Next (bankmsg);
1136  }
1137  }
1138 
1139  return data;
1140 }
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 794 of file gnc-ab-utils.c.

795 {
796  return g_strdup_printf ("job_%lu", job_id);
797 }

◆ 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 782 of file gnc-ab-utils.c.

783 {
784  if (job)
785  {
786  return gnc_AB_JOB_ID_to_string (AB_Transaction_GetUniqueId (job));
787  }
788  else
789  {
790  return gnc_AB_JOB_ID_to_string (0);
791  }
792 }
gchar * gnc_AB_JOB_ID_to_string(gulong job_id)
Return the job_id as string.
Definition: gnc-ab-utils.c:794

◆ gnc_ab_maketrans()

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

Create SEPA transfers.

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

441 {
442  const gchar *ab_remote_accountnumber =
443  AB_Transaction_GetRemoteAccountNumber (ab_trans);
444  const gchar *ab_remote_bankcode =
445  AB_Transaction_GetRemoteBankCode (ab_trans);
446 
447  gchar *ab_other_accountid;
448  gchar *ab_other_bankcode;
449 
450  gboolean have_accountid;
451  gboolean have_bankcode;
452 
453  gchar *retval;
454 
455  // For SEPA transactions, we need to ask for something different here
456  if (!ab_remote_accountnumber)
457  ab_remote_accountnumber = AB_Transaction_GetRemoteIban (ab_trans);
458  if (!ab_remote_bankcode)
459  ab_remote_bankcode = AB_Transaction_GetRemoteBic (ab_trans);
460 
461  ab_other_accountid = g_strdup (ab_remote_accountnumber ? ab_remote_accountnumber : "");
462  ab_other_bankcode = g_strdup (ab_remote_bankcode ? ab_remote_bankcode : "");
463 
464  /* Ensure string is in utf8 */
465  gnc_utf8_strip_invalid (ab_other_accountid);
466  gnc_utf8_strip_invalid (ab_other_bankcode);
467 
468  /* and -then- trim it */
469  g_strstrip (ab_other_accountid);
470  g_strstrip (ab_other_bankcode);
471 
472 
473  have_accountid = ab_other_accountid && *ab_other_accountid;
474  have_bankcode = ab_other_bankcode && *ab_other_bankcode;
475 
476  if ( have_accountid || have_bankcode )
477  {
478  retval = g_strdup_printf ("%s %s %s %s",
479  have_accountid ? _("Account") : "",
480  have_accountid ? ab_other_accountid : "",
481  have_bankcode ? _("Bank") : "",
482  have_bankcode ? ab_other_bankcode : ""
483  );
484  g_strstrip (retval);
485  }
486  else
487  {
488  retval = g_strdup ("");
489  }
490 
491  g_free (ab_other_accountid);
492  g_free (ab_other_bankcode);
493 
494  return retval;
495 }
void gnc_utf8_strip_invalid(gchar *str)
Strip any non-UTF-8 characters from a string.

◆ gnc_ab_select_imex_dlg_destroy()

void gnc_ab_select_imex_dlg_destroy ( GncABSelectImExDlg *  imexd)

Destroy an AQBanking importer/exporter selection dialog.

Parameters
imexdthe dialog.

Definition at line 136 of file dialog-ab-select-imexporter.c.

137 {
138 
139  if (imexd->imexporter_list)
140  gtk_list_store_clear (imexd->imexporter_list);
141 
142  if (imexd->profile_list)
143  gtk_list_store_clear (imexd->profile_list);
144 
145  if (imexd->dialog)
146  gtk_widget_destroy (imexd->dialog);
147 
148  g_free (imexd);
149 }

◆ gnc_ab_select_imex_dlg_get_imexporter_name()

char* gnc_ab_select_imex_dlg_get_imexporter_name ( GncABSelectImExDlg *  imexd)

Get the selected importer/exporter name.

Parameters
imexdthe dialog with the selection
Returns
the selected importer/exporter name, free with g_free.

Definition at line 266 of file dialog-ab-select-imexporter.c.

267 {
268  return tree_view_get_name (GTK_TREE_VIEW (imexd->select_imexporter));
269 }

◆ gnc_ab_select_imex_dlg_get_profile_name()

char* gnc_ab_select_imex_dlg_get_profile_name ( GncABSelectImExDlg *  imexd)

Get the selected file format profile name.

Parameters
imexdthe dialog with the selection
Returns
the selected format profile name, free with g_free.

Definition at line 272 of file dialog-ab-select-imexporter.c.

273 {
274  return tree_view_get_name (GTK_TREE_VIEW (imexd->select_profile));
275 }

◆ gnc_ab_select_imex_dlg_new()

G_BEGIN_DECLS GncABSelectImExDlg* gnc_ab_select_imex_dlg_new ( GtkWidget *  parent,
AB_BANKING *  abi 
)

Create an AQBanking importer/exporter selection dialog.

Parameters
parentA widget to center the dialog over.
abiThe AQBanking instance to query.
Returns
a GncABSelectImExDlg.

Definition at line 80 of file dialog-ab-select-imexporter.c.

81 {
82  GncABSelectImExDlg* imexd;
83  GtkBuilder* builder;
84  GList* imexporters;
85  GtkTreeSelection *imex_select = NULL, *prof_select = NULL;
86 
87  g_return_val_if_fail (abi, NULL);
88  imexporters = gnc_ab_imexporter_list (abi);
89  g_return_val_if_fail (imexporters, NULL);
90  imexd = g_new0(GncABSelectImExDlg, 1);
91  imexd->parent = parent;
92  imexd->abi = abi;
93 
94  g_signal_connect (parent, "destroy",
95  G_CALLBACK (gtk_widget_destroyed), &imexd->parent);
96  builder = gtk_builder_new();
97  gnc_builder_add_from_file (builder, "dialog-ab.glade", "imexporter-list");
98  gnc_builder_add_from_file (builder, "dialog-ab.glade", "profile-list");
99  gnc_builder_add_from_file (builder, "dialog-ab.glade",
100  "aqbanking-select-imexporter-dialog");
101  imexd->dialog =
102  GTK_WIDGET (gtk_builder_get_object (builder,
103  "aqbanking-select-imexporter-dialog"));
104  g_signal_connect (imexd->dialog, "destroy",
105  G_CALLBACK (gtk_widget_destroyed), &imexd->dialog);
106  imexd->imexporter_list =
107  GTK_LIST_STORE (gtk_builder_get_object (builder, "imexporter-list"));
108  imexd->profile_list =
109  GTK_LIST_STORE (gtk_builder_get_object (builder, "profile-list"));
110  imexd->select_imexporter =
111  GTK_WIDGET (gtk_builder_get_object (builder, "imexporter-sel"));
112  imexd->select_profile =
113  GTK_WIDGET (gtk_builder_get_object (builder, "profile-sel"));
114  imexd->ok_button =
115  GTK_WIDGET (gtk_builder_get_object (builder, "imex-okbutton"));
116 
117  imex_select = GTK_TREE_SELECTION (gtk_builder_get_object (builder, "imex-selection"));
118  prof_select = GTK_TREE_SELECTION (gtk_builder_get_object (builder, "prof-selection"));
119  populate_list_store (imexd->imexporter_list,
120  imexporters);
121 
122  g_signal_connect (imex_select, "changed", G_CALLBACK(imexporter_changed),
123  imexd);
124  g_signal_connect (prof_select, "changed", G_CALLBACK(profile_changed),
125  imexd);
126  g_list_free (imexporters);
127  g_object_unref (G_OBJECT (builder));
128 
129  gtk_window_set_transient_for (GTK_WINDOW (imexd->dialog),
130  GTK_WINDOW (imexd->parent));
131 
132  return imexd;
133 }
GList * gnc_ab_imexporter_list(AB_BANKING *api)
Retrieve the available AQBanking importers.

◆ gnc_ab_select_imex_dlg_run()

int gnc_ab_select_imex_dlg_run ( GncABSelectImExDlg *  imexd)

Run an AQBanking importer/exporter selection dialog.

Parameters
imexdthe dialog.
Returns
A GTK_RESPONSE status.

Definition at line 214 of file dialog-ab-select-imexporter.c.

215 {
216 
217  int response = gtk_dialog_run (GTK_DIALOG (imexd->dialog));
218  return response == GTK_RESPONSE_OK ? TRUE : FALSE;
219 }

◆ gnc_ab_select_imex_dlg_set_imexporter_name()

void gnc_ab_select_imex_dlg_set_imexporter_name ( GncABSelectImExDlg *  imexd,
const char *  name 
)

Get the selected importer/exporter name.

Parameters
imexdthe dialog with the selection name the importer/exporter name to select.

Definition at line 278 of file dialog-ab-select-imexporter.c.

279 {
280  if (name)
281  tree_view_set_name (GTK_TREE_VIEW (imexd->select_imexporter), name);
282 }

◆ gnc_ab_select_imex_dlg_set_profile_name()

void gnc_ab_select_imex_dlg_set_profile_name ( GncABSelectImExDlg *  imexd,
const char *  name 
)

Get the selected file format profile name.

Parameters
imexdthe dialog with the selection
namethe profile to select.

Definition at line 285 of file dialog-ab-select-imexporter.c.

286 {
287  if (name)
288  tree_view_set_name (GTK_TREE_VIEW (imexd->select_profile), name);
289 }

◆ 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:1473
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1514

◆ 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:1473
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1514

◆ 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:1473
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1514

◆ 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:1473
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition: Account.cpp:1514

◆ 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 180 of file gnc-aqbanking-templates.cpp.

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

◆ gnc_ab_trans_dialog_free()

void gnc_ab_trans_dialog_free ( GncABTransDialog *  td)

Free a Aqbanking transfer dialog.

Parameters
tdTransaction dialog

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

750 {
751  if (!td) return;
752  if (td->ab_trans)
753  AB_Transaction_free(td->ab_trans);
754  if (td->dialog)
755  gtk_widget_destroy(td->dialog);
756 
757 #if (AQBANKING_VERSION_INT >= 60400)
758  if (td->template_list_store)
759  {
760  gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
761  gnc_ab_trans_dialog_clear_templ_helper, NULL);
762  g_object_unref(td->template_list_store);
763  }
764 #endif
765  g_free(td);
766 }

◆ 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 814 of file dialog-ab-trans.c.

815 {
816  g_return_val_if_fail(td, NULL);
817  return td->ab_trans;
818 }

◆ 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 859 of file dialog-ab-trans.c.

860 {
861  g_return_val_if_fail(td, NULL);
862  return gnc_ab_get_trans_job(td->ab_acc, td->ab_trans, td->trans_type);
863 }
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 807 of file dialog-ab-trans.c.

808 {
809  g_return_val_if_fail(td, NULL);
810  return td->parent;
811 }

◆ 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 242 of file dialog-ab-trans.c.

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

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

◆ 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 161 of file gnc-aqbanking-templates.cpp.

162 {
163  delete t;
164 }

◆ gnc_ab_trans_templ_get_amount()

gnc_numeric gnc_ab_trans_templ_get_amount ( const GncABTransTempl *  t)
Parameters
tTemplate
Returns
Amount

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

229 {
230  g_return_val_if_fail(t, gnc_numeric_zero());
231  return t->amount();
232 }

◆ 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 200 of file gnc-aqbanking-templates.cpp.

201 {
202  g_return_val_if_fail(t, NULL);
203  return t->name();
204 }

◆ 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 235 of file gnc-aqbanking-templates.cpp.

236 {
237  g_return_val_if_fail(t, NULL);
238  return t->purpose();
239 }

◆ 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 242 of file gnc-aqbanking-templates.cpp.

243 {
244  g_return_val_if_fail(t, NULL);
245  return t->purpose_continuation();
246 }

◆ 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 214 of file gnc-aqbanking-templates.cpp.

215 {
216  g_return_val_if_fail(t, NULL);
217  return t->recipient_account();
218 }

◆ 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 221 of file gnc-aqbanking-templates.cpp.

222 {
223  g_return_val_if_fail(t, NULL);
224  return t->recipient_bankcode();
225 }

◆ 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 207 of file gnc-aqbanking-templates.cpp.

208 {
209  g_return_val_if_fail(t, NULL);
210  return t->recipient_name();
211 }

◆ 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 167 of file gnc-aqbanking-templates.cpp.

168 {
169  for(GList *node = l; node != NULL; node = g_list_next(node))
170  delete static_cast<_GncABTransTempl*>(node->data);
171 }

◆ 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 133 of file gnc-aqbanking-templates.cpp.

134 {
135  GList *retval = NULL;
136  auto toplevel = qof_instance_get_slots (QOF_INSTANCE (b));
137  auto slot = toplevel->get_slot({"hbci", "template-list"});
138  if (slot == nullptr)
139  return retval;
140  auto list = slot->get<GList*>();
141  for (auto node = list; node != NULL; node = g_list_next (node))
142  {
143  KvpFrame *frame = static_cast<KvpValue*>(node->data)->get<KvpFrame*>();
144  auto c_func = [frame](const char* key)
145  { auto slot = frame->get_slot({key});
146  return slot == nullptr ? std::string("") : std::string(slot->get<const char*>());};
147  auto n_func = [frame](const char* key)
148  { auto slot = frame->get_slot({key});
149  return slot == nullptr ? gnc_numeric_zero() : slot->get<gnc_numeric>();};
150  auto templ = new _GncABTransTempl (c_func(TT_NAME), c_func(TT_RNAME),
151  c_func(TT_RACC), c_func(TT_RBCODE),
152  n_func(TT_AMOUNT), c_func(TT_PURPOS),
153  c_func(TT_PURPOSCT));
154  retval = g_list_prepend (retval, templ);
155  }
156  retval = g_list_reverse (retval);
157  return retval;
158 }
A template for an AqBanking transaction.
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 117 of file gnc-aqbanking-templates.cpp.

118 {
119  return new _GncABTransTempl;
120 }
A template for an AqBanking transaction.

◆ 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 123 of file gnc-aqbanking-templates.cpp.

127 {
128  return new _GncABTransTempl(name, recp_name, recp_account, recp_bankcode,
129  amount, purpose, purpose_cont);
130 }
A template for an AqBanking transaction.

◆ 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 279 of file gnc-aqbanking-templates.cpp.

280 {
281  g_return_if_fail(t);
282  t->set_amount(amount);
283 }

◆ 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 249 of file gnc-aqbanking-templates.cpp.

250 {
251  g_return_if_fail(t);
252  t->set_name(name);
253 }

◆ 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 286 of file gnc-aqbanking-templates.cpp.

287 {
288  g_return_if_fail(t);
289  t->set_purpose(purpose);
290 }

◆ 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 293 of file gnc-aqbanking-templates.cpp.

295 {
296  g_return_if_fail(t);
297  t->set_purpose_continuation (purpose_cont);
298 }

◆ 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 263 of file gnc-aqbanking-templates.cpp.

265 {
266  g_return_if_fail(t);
267  t->set_recipient_account(recp_account);
268 }

◆ 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 271 of file gnc-aqbanking-templates.cpp.

273 {
274  g_return_if_fail(t);
275  t->set_recipient_bankcode(recp_bankcode);
276 }

◆ 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 256 of file gnc-aqbanking-templates.cpp.

257 {
258  g_return_if_fail(t);
259  t->set_recipient_name(recp_name);
260 }

◆ 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 498 of file gnc-ab-utils.c.

499 {
500  QofBook *book;
501  Transaction *gnc_trans;
502  const gchar *fitid;
503  const GNC_GWEN_DATE *value_date, *post_date;
504  time64 post_time;
505  const char *custref;
506  gchar *description;
507  Split *split;
508  gchar *memo;
509 
510  g_return_val_if_fail (ab_trans && gnc_acc, NULL);
511 
512  /* Create new GnuCash transaction for the given AqBanking one */
513  book = gnc_account_get_book (gnc_acc);
514  gnc_trans = xaccMallocTransaction (book);
515  xaccTransBeginEdit (gnc_trans);
516 
517  /* Date / Time */
518  /* SWIFT import formats (in particular MT940) provide for two
519  * dates, the entry date and the value date (valuta is value in
520  * German). The value date is the effective date for financial
521  * calculation purposes and is mandatory, the entry date is the
522  * date that the financial institution posted the
523  * transaction. Unfortunately if the transaction field doesn't
524  * provide an entry date AQBanking substitutes the date from the
525  * last balance instead of using the value date or NULL, making
526  * the field unreliable.
527  */
528  value_date = AB_Transaction_GetValutaDate (ab_trans);
529  if (value_date)
530  post_time = gnc_gwen_date_to_time64 (value_date);
531  else if ((post_date = AB_Transaction_GetDate (ab_trans))) // always true
532  post_time = gnc_gwen_date_to_time64 (post_date);
533  else
534  {
535  g_warning ("transaction_cb: Import had no transaction date");
536  post_time = gnc_time (NULL);
537  }
538  xaccTransSetDatePostedSecsNormalized (gnc_trans, post_time);
539 
540  xaccTransSetDateEnteredSecs (gnc_trans, gnc_time (NULL));
541 
542  /* Currency. We take simply the default currency of the gnucash account */
543  xaccTransSetCurrency (gnc_trans, xaccAccountGetCommodity (gnc_acc));
544 
545  /* Trans-Num or Split-Action set with gnc_set_num_action below per book
546  * option */
547 
548  fitid = AB_Transaction_GetFiId (ab_trans);
549 
550  /* Description */
551  description = gnc_ab_description_to_gnc (ab_trans, (fitid && *fitid));
552  xaccTransSetDescription (gnc_trans, description);
553  g_free (description);
554 
555  /* Notes. */
556  /* xaccTransSetNotes(gnc_trans, g_notes); */
557  /* But Nobody ever uses the Notes field? */
558 
559  /* Add one split */
560  split = xaccMallocSplit (book);
561  xaccSplitSetParent (split, gnc_trans);
562  xaccSplitSetAccount (split, gnc_acc);
563 
564  /* Set the transaction number or split action field based on book option.
565  * We use the "customer reference", if there is one. */
566  custref = AB_Transaction_GetCustomerReference (ab_trans);
567  if (custref && *custref && g_ascii_strncasecmp (custref, "NONREF", 6) != 0)
568  gnc_set_num_action (gnc_trans, split, custref, NULL);
569 
570  /* Set OFX unique transaction ID */
571  if (fitid && *fitid)
572  gnc_import_set_split_online_id (split, fitid);
573 
574  /* FIXME: Extract function */
575  {
576  /* Amount into the split */
577  const AB_VALUE *ab_value = AB_Transaction_GetValue (ab_trans);
578  double d_value = ab_value ? AB_Value_GetValueAsDouble (ab_value) : 0.0;
579  AB_TRANSACTION_TYPE ab_type = AB_Transaction_GetType (ab_trans);
580  gnc_numeric gnc_amount;
581 
582  /*printf("Transaction with value %f has type %d\n", d_value, ab_type);*/
583  /* If the value is positive, but the transaction type says the
584  money is transferred away from our account (Transfer instead of
585  DebitNote), we switch the value to negative. */
586  if (d_value > 0.0 && ab_type == AB_Transaction_TypeTransfer)
587  d_value = -d_value;
588 
589  gnc_amount = double_to_gnc_numeric (
590  d_value,
591  xaccAccountGetCommoditySCU (gnc_acc),
593  if (!ab_value)
594  g_warning ("transaction_cb: Oops, value was NULL. Using 0");
595  xaccSplitSetBaseValue (split, gnc_amount, xaccAccountGetCommodity (gnc_acc));
596  }
597 
598  /* Memo in the Split. */
599  memo = gnc_ab_memo_to_gnc (ab_trans);
600  xaccSplitSetMemo (split, memo);
601  g_free (memo);
602 
603  return gnc_trans;
604 }
Transaction * xaccMallocTransaction(QofBook *book)
The xaccMallocTransaction() will malloc memory and initialize it.
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.cpp: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 n, 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:2712
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:440
void xaccTransSetCurrency(Transaction *trans, gnc_commodity *curr)
Set a new currency on 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:425
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
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:3367
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
Definition: gnc-numeric.h:165
time64 gnc_time(time64 *tbuf)
get the current time
Definition: gnc-date.cpp:260
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
void xaccTransSetDateEnteredSecs(Transaction *trans, time64 secs)
Modify the date of when the transaction was entered.

◆ 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 283 of file gnc-ab-utils.c.

284 {
285  if (value)
286  return g_strdup_printf ("%.2f %s",
287  AB_Value_GetValueAsDouble (value),
288  AB_Value_GetCurrency (value));
289  else
290  return g_strdup_printf ("%.2f", 0.0);
291 }

◆ gnc_file_aqbanking_import_dialog()

G_BEGIN_DECLS void gnc_file_aqbanking_import_dialog ( GtkWindow *  parent)

Import files via AQBanking's Import Dialog.

This permits importing any file format that Aqbanking supports.

Parameters
parentA GtkWindow for setting the import dialog transient for.

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

134 {
135  AB_BANKING* api = gnc_AB_BANKING_new ();
136  GncABSelectImExDlg* imexd =
137  gnc_ab_select_imex_dlg_new (GTK_WIDGET (parent), api);
138  char *imexporter = NULL, *profile = NULL;
139  AB_IMEXPORTER_CONTEXT* ctx = NULL;
140 
141  if (!imexd)
142  {
143 
144  PERR ("Failed to create select imex dialog.");
145  gnc_AB_BANKING_fini(api);
146  return;
147  }
148  load_imexporter_and_profile(&imexporter, &profile);
151 
152  if (!gnc_ab_select_imex_dlg_run (imexd))
153  {
155  return;
156  }
157 
158  imexporter = gnc_ab_select_imex_dlg_get_imexporter_name (imexd);
159  profile = gnc_ab_select_imex_dlg_get_profile_name (imexd);
160 
161  if (imexporter && profile)
162  {
163  ctx = named_import_get_context (parent, api, imexporter, profile);
165 
166  if (ctx)
167  {
168  GncABImExContextImport* ieci = NULL;
169  ieci = gnc_ab_import_context (ctx, AWAIT_TRANSACTIONS, FALSE, api, GTK_WIDGET(parent));
170  g_free(ieci);
171  AB_ImExporterContext_free(ctx);
172  }
173 
174  save_imexporter_and_profile(imexporter, profile);
175  g_free (imexporter);
176  g_free (profile);
177  }
178 
179  gnc_AB_BANKING_fini(api);
180 }
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244
char * gnc_ab_select_imex_dlg_get_profile_name(GncABSelectImExDlg *imexd)
Get the selected file format profile name.
void gnc_ab_select_imex_dlg_set_imexporter_name(GncABSelectImExDlg *imexd, const char *name)
Get the selected importer/exporter name.
void gnc_ab_select_imex_dlg_destroy(GncABSelectImExDlg *imexd)
Destroy an AQBanking importer/exporter selection dialog.
gboolean gnc_ab_select_imex_dlg_run(GncABSelectImExDlg *imexd)
Run an AQBanking importer/exporter selection dialog.
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
Definition: gnc-ab-utils.c:163
GncABSelectImExDlg * gnc_ab_select_imex_dlg_new(GtkWidget *parent, AB_BANKING *abi)
Create an AQBanking importer/exporter selection dialog.
void gnc_ab_select_imex_dlg_set_profile_name(GncABSelectImExDlg *imexd, const char *name)
Get the selected file format profile name.
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Definition: gnc-ab-utils.c:226
char * gnc_ab_select_imex_dlg_get_imexporter_name(GncABSelectImExDlg *imexd)
Get the selected importer/exporter name.
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 245 of file gnc-gwen-gui.c.

246 {
247  GncGWENGui *gui;
248 
249  ENTER("parent=%p", parent);
250 
251  if (full_gui)
252  {
253  if (full_gui->state == INIT || full_gui->state == RUNNING)
254  {
255  LEAVE("full_gui in use, state=%d", full_gui->state);
256  return NULL;
257  }
258 
259  gui = full_gui;
260  gui->parent = parent;
261  reset_dialog(gui);
262  register_callbacks(gui);
263 
264  LEAVE("gui=%p", gui);
265  return gui;
266  }
267 
268  gui = g_new0(GncGWENGui, 1);
269  gui->parent = parent;
270  setup_dialog(gui);
271  register_callbacks(gui);
272 
273  full_gui = gui;
274 
275  LEAVE("new gui=%p", gui);
276  return gui;
277 }
#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 344 of file gnc-gwen-gui.c.

345 {
346  return gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH);
347 }
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 381 of file gnc-gwen-gui.c.

382 {
383  GncGWENGui *gui = full_gui;
384 
385  if (gui)
386  {
387  hide_dialog(gui);
388  }
389 }

◆ 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 229 of file gnc-gwen-gui.c.

230 {
231  if (!log_gwen_gui)
232  {
233  log_gwen_gui = Gtk3_Gui_new();
234 
235  /* Always use our own logging */
236  GWEN_Gui_SetLogHookFn(log_gwen_gui, loghook_cb);
237 
238  /* Keep a reference so that the GWEN_GUI survives a GUI switch */
239  GWEN_Gui_Attach(log_gwen_gui);
240  }
241  GWEN_Gui_SetGui(log_gwen_gui);
242 }

◆ 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 280 of file gnc-gwen-gui.c.

281 {
282  g_return_if_fail(gui && gui == full_gui);
283 
284  /* Currently a no-op */
285  ENTER("gui=%p", gui);
286  LEAVE(" ");
287 }
#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 325 of file gnc-gwen-gui.c.

326 {
328  GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
329  close_when_finished);
330 
331  if (full_gui)
332  {
333  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(full_gui->close_checkbutton))
334  != close_when_finished)
335  {
336  gtk_toggle_button_set_active(
337  GTK_TOGGLE_BUTTON(full_gui->close_checkbutton),
338  close_when_finished);
339  }
340  }
341 }
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.cpp: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 350 of file gnc-gwen-gui.c.

351 {
352  GncGWENGui *gui = full_gui;
353 
354  if (!gui)
355  {
356  gnc_GWEN_Gui_get(NULL);
357  gui = full_gui;
358  }
359 
360  if (gui)
361  {
362  if (gui->state == HIDDEN)
363  {
364  gui->state = FINISHED;
365  }
366  gtk_toggle_button_set_active(
367  GTK_TOGGLE_BUTTON(gui->close_checkbutton),
368  gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH));
369 
370  gtk_widget_set_sensitive(gui->close_button, TRUE);
371 
372  show_dialog(gui, FALSE);
373 
374  return TRUE;
375  }
376 
377  return FALSE;
378 }
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:245
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.

◆ gnc_plugin_aqbanking_new()

GncPlugin* gnc_plugin_aqbanking_new ( void  )
Returns
A new GncPluginAqBanking object

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

151 {
152  return GNC_PLUGIN(g_object_new(GNC_TYPE_PLUGIN_AQBANKING, (gchar*) NULL));
153 }

◆ 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 }