34 #include <glib/gi18n.h> 35 #include <gwenhywfar/gwenhywfar.h> 36 #include <aqbanking/banking.h> 37 #include <aqbanking/types/balance.h> 38 #if (AQBANKING_VERSION_INT >= 60400) 39 #include <aqbanking/types/refaccount.h> 40 #include <gnc-aqbanking-templates.h> 42 #include "window-reconcile.h" 53 #include "engine-helpers.h" 54 #include <aqbanking/gui/abgui.h> 57 G_GNUC_UNUSED
static QofLogModule log_module =
G_LOG_DOMAIN;
60 static AB_BANKING *gnc_AB_BANKING = NULL;
61 static gint gnc_AB_BANKING_refcount = 0;
63 static gpointer join_ab_strings_cb (
const gchar *str, gpointer user_data);
64 static Account *gnc_ab_accinfo_to_gnc_acc (GtkWidget *parent,
65 AB_IMEXPORTER_ACCOUNTINFO *account_info);
66 static Account *gnc_ab_txn_to_gnc_acc (GtkWidget *parent,
67 const AB_TRANSACTION *transaction);
68 static const AB_TRANSACTION *txn_transaction_cb (
const AB_TRANSACTION *element,
70 static AB_IMEXPORTER_ACCOUNTINFO *txn_accountinfo_cb (AB_IMEXPORTER_ACCOUNTINFO *element,
72 static AB_IMEXPORTER_ACCOUNTINFO *bal_accountinfo_cb (AB_IMEXPORTER_ACCOUNTINFO *element,
80 GNC_AB_ACCOUNT_SPEC *ab_acc;
81 gboolean execute_txns;
84 GNC_AB_JOB_LIST2 *job_list;
85 GNCImportMainMatcher *generic_importer;
89 static inline gboolean is_leap_year (
int year)
91 return (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0 ));
95 gnc_gwen_date_to_time64 (
const GNC_GWEN_DATE* date)
97 int day = GWEN_Date_GetDay (date);
98 int month = GWEN_Date_GetMonth (date);
99 int year = GWEN_Date_GetYear (date);
106 while (month == 2 && day <= 30 && day > (is_leap_year (year) ? 29 : 28))
114 gchar* gwen_logging = g_strdup (g_getenv (
"GWEN_LOGLEVEL"));
115 gchar* aqb_logging = g_strdup (g_getenv (
"AQBANKING_LOGLEVEL"));
125 GWEN_Logger_SetLevel (NULL, GWEN_LoggerLevel_Info);
126 GWEN_Logger_SetLevel (GWEN_LOGDOMAIN, GWEN_LoggerLevel_Info);
129 GWEN_Logger_SetLevel (AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Debug);
135 GWEN_Logger_SetLevel (NULL, GWEN_LoggerLevel_Error);
136 GWEN_Logger_SetLevel (GWEN_LOGDOMAIN, GWEN_LoggerLevel_Error);
139 GWEN_Logger_SetLevel (AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);
141 g_free (gwen_logging);
142 g_free (aqb_logging);
151 GWEN_Logger_SetLevel (NULL, GWEN_LoggerLevel_Error);
152 GWEN_Logger_SetLevel (GWEN_LOGDOMAIN, GWEN_LoggerLevel_Warning);
153 GWEN_Logger_SetLevel (AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);
159 static GWEN_GUI *gnc_gwengui_extended_by_ABBanking;
169 api = gnc_AB_BANKING;
172 if (gnc_AB_BANKING_refcount == 0)
173 g_return_val_if_fail (AB_Banking_Init (api) == 0, NULL);
178 api = AB_Banking_new (PROJECT_NAME, NULL, 0);
179 g_return_val_if_fail (api, NULL);
187 AB_Banking_RuntimeConfig_SetCharValue (api,
"fintsRegistrationKey",
"412748A1836CDD07181CE1910");
188 AB_Banking_RuntimeConfig_SetCharValue (api,
"fintsApplicationVersionString", PROJECT_VERSION);
191 g_return_val_if_fail (AB_Banking_Init (api) == 0, NULL);
192 gnc_gwengui_extended_by_ABBanking = GWEN_Gui_GetGui ();
193 AB_Gui_Extend (gnc_gwengui_extended_by_ABBanking, api);
196 gnc_AB_BANKING = api;
197 gnc_AB_BANKING_refcount = 0;
200 gnc_AB_BANKING_refcount++;
209 api = gnc_AB_BANKING;
213 if (api == gnc_AB_BANKING)
215 gnc_AB_BANKING = NULL;
219 AB_Banking_free (api);
227 if (api == gnc_AB_BANKING)
229 if (--gnc_AB_BANKING_refcount == 0)
231 if (gnc_gwengui_extended_by_ABBanking)
232 AB_Gui_Unextend (gnc_gwengui_extended_by_ABBanking);
233 gnc_gwengui_extended_by_ABBanking = NULL;
234 return AB_Banking_Fini (api);
239 if (gnc_gwengui_extended_by_ABBanking)
240 AB_Gui_Unextend (gnc_gwengui_extended_by_ABBanking);
241 gnc_gwengui_extended_by_ABBanking = NULL;
242 return AB_Banking_Fini (api);
247 GNC_AB_ACCOUNT_SPEC *
250 GNC_AB_ACCOUNT_SPEC *ab_account = NULL;
251 const gchar *bankcode = NULL;
252 const gchar *accountid = NULL;
253 guint32 account_uid = 0;
263 rv = AB_Banking_GetAccountSpecByUniqueId (api, account_uid, &ab_account);
265 if ( (rv<0 || !ab_account) && bankcode && *bankcode &&
266 accountid && *accountid)
271 PINFO(
"gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, " 272 "trying bank code\n", account_uid);
285 return g_strdup_printf (
"%.2f %s",
286 AB_Value_GetValueAsDouble (value),
287 AB_Value_GetCurrency (value));
289 return g_strdup_printf (
"%.2f", 0.0);
304 while (accountnumber && *accountnumber ==
'0')
307 online_id = g_strconcat (bankcode ? bankcode :
"",
308 accountnumber ? accountnumber :
"",
319 join_ab_strings_cb (
const gchar *str, gpointer user_data)
321 gchar **acc = user_data;
327 tmp = g_utf8_normalize (str, -1, G_NORMALIZE_NFC);
333 if (!strstr (*acc, tmp))
335 gchar *join = g_strjoin (
" ", *acc, tmp, (gchar*) NULL);
351 const char* ab_remote_name;
352 gchar *gnc_other_name = NULL;
354 g_return_val_if_fail (ab_trans, NULL);
356 ab_remote_name = AB_Transaction_GetRemoteName (ab_trans);
358 gnc_other_name = g_strdup(ab_remote_name);
359 if (!gnc_other_name || !*gnc_other_name)
361 g_free (gnc_other_name);
362 gnc_other_name = NULL;
365 return gnc_other_name;
371 GWEN_STRINGLIST *ab_purpose;
372 const char *ab_transactionText = NULL;
373 gchar *gnc_description = NULL;
375 g_return_val_if_fail (ab_trans, g_strdup (
""));
377 if (!is_ofx &&
gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_USE_TRANSACTION_TXT))
382 ab_transactionText = AB_Transaction_GetTransactionText (ab_trans);
383 if (ab_transactionText && *ab_transactionText)
384 gnc_description = g_utf8_normalize (ab_transactionText, -1, G_NORMALIZE_NFC);
387 ab_purpose = AB_Transaction_GetPurposeAsStringList (ab_trans);
389 GWEN_StringList_ForEach (ab_purpose, join_ab_strings_cb,
392 GWEN_StringList_free (ab_purpose);
394 return gnc_description;
404 ab_ultimate_creditor_debtor_to_gnc (
const AB_TRANSACTION *ab_trans,
407 const gchar* ultimate;
412 ultimate = AB_Transaction_GetUltimateCreditor (ab_trans);
414 if (!ultimate || !*ultimate)
415 ultimate = AB_Transaction_GetUltimateDebtor (ab_trans);
417 if (!ultimate || !*ultimate)
420 return g_strdup (ultimate);
431 acc = g_list_prepend (acc, ab_ultimate_creditor_debtor_to_gnc (ab_trans, is_ofx));
434 g_list_free_full (acc, g_free);
435 return retval ? retval : g_strdup (_(
"Unspecified"));
441 const gchar *ab_remote_accountnumber =
442 AB_Transaction_GetRemoteAccountNumber (ab_trans);
443 const gchar *ab_remote_bankcode =
444 AB_Transaction_GetRemoteBankCode (ab_trans);
446 gchar *ab_other_accountid;
447 gchar *ab_other_bankcode;
449 gboolean have_accountid;
450 gboolean have_bankcode;
455 if (!ab_remote_accountnumber)
456 ab_remote_accountnumber = AB_Transaction_GetRemoteIban (ab_trans);
457 if (!ab_remote_bankcode)
458 ab_remote_bankcode = AB_Transaction_GetRemoteBic (ab_trans);
460 ab_other_accountid = g_strdup (ab_remote_accountnumber ? ab_remote_accountnumber :
"");
461 ab_other_bankcode = g_strdup (ab_remote_bankcode ? ab_remote_bankcode :
"");
468 g_strstrip (ab_other_accountid);
469 g_strstrip (ab_other_bankcode);
472 have_accountid = ab_other_accountid && *ab_other_accountid;
473 have_bankcode = ab_other_bankcode && *ab_other_bankcode;
475 if ( have_accountid || have_bankcode )
477 retval = g_strdup_printf (
"%s %s %s %s",
478 have_accountid ? _(
"Account") :
"",
479 have_accountid ? ab_other_accountid :
"",
480 have_bankcode ? _(
"Bank") :
"",
481 have_bankcode ? ab_other_bankcode :
"" 487 retval = g_strdup (
"");
490 g_free (ab_other_accountid);
491 g_free (ab_other_bankcode);
500 Transaction *gnc_trans;
502 const GNC_GWEN_DATE *value_date, *post_date;
509 g_return_val_if_fail (ab_trans && gnc_acc, NULL);
512 book = gnc_account_get_book (gnc_acc);
527 value_date = AB_Transaction_GetValutaDate (ab_trans);
529 post_time = gnc_gwen_date_to_time64 (value_date);
530 else if ((post_date = AB_Transaction_GetDate (ab_trans)))
531 post_time = gnc_gwen_date_to_time64 (post_date);
534 g_warning (
"transaction_cb: Import had no transaction date");
547 fitid = AB_Transaction_GetFiId (ab_trans);
552 g_free (description);
560 xaccSplitSetParent (split, gnc_trans);
561 xaccSplitSetAccount (split, gnc_acc);
565 custref = AB_Transaction_GetCustomerReference (ab_trans);
566 if (custref && *custref && g_ascii_strncasecmp (custref,
"NONREF", 6) != 0)
567 gnc_set_num_action (gnc_trans, split, custref, NULL);
576 const AB_VALUE *ab_value = AB_Transaction_GetValue (ab_trans);
577 double d_value = ab_value ? AB_Value_GetValueAsDouble (ab_value) : 0.0;
578 AB_TRANSACTION_TYPE ab_type = AB_Transaction_GetType (ab_trans);
579 gnc_numeric gnc_amount;
585 if (d_value > 0.0 && ab_type == AB_Transaction_TypeTransfer)
593 g_warning (
"transaction_cb: Oops, value was NULL. Using 0");
614 gnc_ab_accinfo_to_gnc_acc (GtkWidget *parent, AB_IMEXPORTER_ACCOUNTINFO *acc_info)
616 const gchar *bankcode, *accountnumber;
620 g_return_val_if_fail (acc_info, NULL);
622 bankcode = AB_ImExporterAccountInfo_GetBankCode (acc_info);
623 accountnumber = AB_ImExporterAccountInfo_GetAccountNumber (acc_info);
626 AB_ImExporterAccountInfo_GetAccountName (acc_info),
630 g_warning (
"gnc_ab_accinfo_to_gnc_acc: Could not determine source account" 631 " for online_id %s", online_id);
648 gnc_ab_txn_to_gnc_acc (GtkWidget *parent,
const AB_TRANSACTION *transaction)
650 const gchar *bankcode, *accountnumber;
654 g_return_val_if_fail(transaction, NULL);
656 bankcode = AB_Transaction_GetLocalBankCode (transaction);
657 accountnumber = AB_Transaction_GetLocalAccountNumber (transaction);
658 if (!bankcode && !accountnumber)
665 AB_Transaction_GetLocalName (transaction),
669 g_warning (
"gnc_ab_txn_to_gnc_acc: Could not determine source account" 670 " for online_id %s", online_id);
677 static const AB_TRANSACTION *
678 txn_transaction_cb (
const AB_TRANSACTION *element, gpointer user_data)
680 GncABImExContextImport *data = user_data;
681 Transaction *gnc_trans;
682 GncABTransType trans_type;
685 g_return_val_if_fail (element && data, NULL);
688 txnacc = gnc_ab_txn_to_gnc_acc (GTK_WIDGET(data->parent), element);
691 if (data->execute_txns && data->ab_acc)
693 AB_TRANSACTION *ab_trans = AB_Transaction_dup (element);
698 AB_Transaction_SetLocalBankCode (
699 ab_trans, AB_AccountSpec_GetBankCode (data->ab_acc));
700 AB_Transaction_SetLocalAccountNumber (
701 ab_trans, AB_AccountSpec_GetAccountNumber (data->ab_acc));
702 AB_Transaction_SetLocalCountry (ab_trans,
"DE");
705 switch (AB_Transaction_GetType (ab_trans))
707 case AB_Transaction_TypeDebitNote:
708 trans_type = SINGLE_DEBITNOTE;
710 case AB_Transaction_TypeTransaction:
713 case AB_Transaction_TypeTransfer:
715 trans_type = SEPA_TRANSFER;
722 if (!job || AB_AccountSpec_GetTransactionLimitsForCommand (data->ab_acc, AB_Transaction_GetCommand (job)) == NULL)
725 if (gnc_verify_dialog (
726 GTK_WINDOW(data->parent), FALSE,
"%s",
727 _(
"The backend found an error during the preparation " 728 "of the job. It is not possible to execute this job.\n" 730 "Most probably the bank does not support your chosen " 731 "job or your Online Banking account does not have the permission " 732 "to execute this job. More error messages might be " 733 "visible on your console log.\n" 735 "Do you want to enter the job again?")))
737 gnc_error_dialog (GTK_WINDOW(data->parent),
738 "Sorry, not implemented yet. Please check the console or trace file logs to see which job was rejected.");
745 AB_Transaction_GetUniqueId (job));
749 AB_Transaction_free (ab_trans);
760 static void gnc_ab_trans_processed_cb (GNCImportTransInfo *trans_info,
764 GncABImExContextImport *data = user_data;
766 GNC_AB_JOB *job = g_datalist_get_data (&data->tmp_job_list, jobname);
770 AB_Transaction_List2_PushBack (data->job_list, job);
774 AB_Transaction_free (job);
777 g_datalist_remove_data (&data->tmp_job_list, jobname);
795 return g_strdup_printf (
"job_%lu", job_id);
800 static AB_IMEXPORTER_ACCOUNTINFO *
801 txn_accountinfo_cb (AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
803 GncABImExContextImport *data = user_data;
806 g_return_val_if_fail (element && data, NULL);
808 if (data->awaiting & IGNORE_TRANSACTIONS)
812 if (!AB_ImExporterAccountInfo_GetFirstTransaction (element, AB_Transaction_TypeStatement, 0))
816 data->awaiting |= FOUND_TRANSACTIONS;
818 if (!(data->awaiting & AWAIT_TRANSACTIONS))
820 if (gnc_verify_dialog (GTK_WINDOW(data->parent), TRUE,
"%s",
821 _(
"The bank has sent transaction information " 824 "Do you want to import it?")))
826 data->awaiting |= AWAIT_TRANSACTIONS;
830 data->awaiting |= IGNORE_TRANSACTIONS;
836 gnc_acc = gnc_ab_accinfo_to_gnc_acc (GTK_WIDGET(data->parent), element);
837 if (!gnc_acc)
return NULL;
838 data->gnc_acc = gnc_acc;
840 if (data->execute_txns)
847 gnc_error_dialog (GTK_WINDOW(data->parent),
"%s",
848 _(
"No Online Banking account found for this " 849 "gnucash account. These transactions will " 850 "not be executed by Online Banking."));
858 if (!data->generic_importer)
862 if (data->execute_txns)
865 gnc_ab_trans_processed_cb, data);
871 AB_TRANSACTION_LIST *ab_trans_list = AB_ImExporterAccountInfo_GetTransactionList (element);
873 AB_Transaction_List_ForEachByType (ab_trans_list,
874 txn_transaction_cb, data,
875 AB_Transaction_TypeStatement, 0);
880 static AB_IMEXPORTER_ACCOUNTINFO *
881 bal_accountinfo_cb (AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
883 GncABImExContextImport *data = user_data;
885 const AB_BALANCE *booked_bal, *noted_bal;
886 const AB_VALUE *booked_val = NULL, *noted_val = NULL;
887 gdouble booked_value, noted_value;
891 gboolean show_recn_window = FALSE;
893 g_return_val_if_fail (element && data, NULL);
895 if (data->awaiting & IGNORE_BALANCES)
899 if (!AB_ImExporterAccountInfo_GetFirstBalance (element))
903 data->awaiting |= FOUND_BALANCES;
906 booked_bal = AB_Balance_List_GetLatestByType (AB_ImExporterAccountInfo_GetBalanceList (element),
907 AB_Balance_TypeBooked);
909 if (!(data->awaiting & AWAIT_BALANCES))
911 GtkWindow *parent = data->generic_importer ?
913 GTK_WINDOW(data->parent);
914 const char* balance_msg =
915 _(
"The bank has sent balance information in its response.\n" 916 "Do you want to import it?");
918 if (!booked_bal || AB_Value_IsZero (AB_Balance_GetValue (booked_bal)))
922 if (gnc_verify_dialog (parent, TRUE,
"%s", balance_msg))
924 data->awaiting |= AWAIT_BALANCES;
928 data->awaiting |= IGNORE_BALANCES;
934 gnc_acc = gnc_ab_accinfo_to_gnc_acc (GTK_WIDGET(data->parent), element);
935 if (!gnc_acc)
return NULL;
936 data->gnc_acc = gnc_acc;
941 const GWEN_DATE *ti = AB_Balance_GetDate (booked_bal);
944 booked_tt = gnc_gwen_date_to_time64 (ti);
952 booked_val = AB_Balance_GetValue (booked_bal);
955 booked_value = AB_Value_GetValueAsDouble (booked_val);
959 g_warning (
"bal_accountinfo_cb: booked_val == NULL. Assuming 0");
965 g_warning (
"bal_accountinfo_cb: booked_bal == NULL. Assuming 0");
971 noted_bal = AB_Balance_List_GetLatestByType (AB_ImExporterAccountInfo_GetBalanceList (element),
972 AB_Balance_TypeNoted);
975 noted_val = AB_Balance_GetValue (noted_bal);
977 noted_value = AB_Value_GetValueAsDouble (noted_val);
980 g_warning (
"bal_accountinfo_cb: noted_val == NULL. Assuming 0");
986 g_warning (
"bal_accountinfo_cb: noted_bal == NULL. Assuming 0");
993 if (noted_value == 0.0 && booked_value == 0.0)
995 dialog = gtk_message_dialog_new (
996 GTK_WINDOW(data->parent),
997 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
1008 _(
"The downloaded Online Banking Balance was zero.\n\n" 1009 "Either this is the correct balance, or your bank does not " 1010 "support Balance download in this Online Banking version. " 1011 "In the latter case you should choose a different " 1012 "Online Banking version number in the Online Banking " 1013 "(AqBanking or HBCI) Setup. After that, try again to " 1014 "download the Online Banking Balance."));
1015 gtk_dialog_run (GTK_DIALOG(dialog));
1016 gtk_widget_destroy (dialog);
1024 gchar *message1 = g_strdup_printf (
1025 _(
"Result of Online Banking job:\n" 1026 "Account booked balance is %s"),
1029 (noted_value == 0.0) ?
1031 g_strdup_printf (_(
"For your information: This account also " 1032 "has a noted balance of %s\n"),
1037 const gchar *message3 =
1038 _(
"The booked balance is identical to the current " 1039 "reconciled balance of the account.");
1040 dialog = gtk_message_dialog_new (
1041 GTK_WINDOW(data->parent),
1042 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
1046 message1, message2, message3);
1047 gtk_dialog_run (GTK_DIALOG(dialog));
1048 gtk_widget_destroy (GTK_WIDGET(dialog));
1053 const char *message3 = _(
"Reconcile account now?");
1055 show_recn_window = gnc_verify_dialog (GTK_WINDOW(data->parent), TRUE,
"%s\n%s\n%s",
1056 message1, message2, message3);
1058 g_free (booked_str);
1064 if (show_recn_window)
1065 recnWindowWithBalance (GTK_WIDGET(data->parent), gnc_acc, value, booked_tt);
1070 GncABImExContextImport *
1072 guint awaiting, gboolean execute_txns,
1073 AB_BANKING *api, GtkWidget *parent)
1075 GncABImExContextImport *data = g_new (GncABImExContextImport, 1);
1076 AB_IMEXPORTER_ACCOUNTINFO_LIST *ab_ail;
1077 g_return_val_if_fail (context, NULL);
1079 g_return_val_if_fail (!(awaiting & AWAIT_BALANCES)
1080 || !(awaiting & IGNORE_BALANCES),
1082 g_return_val_if_fail (!(awaiting & AWAIT_TRANSACTIONS)
1083 || !(awaiting & IGNORE_TRANSACTIONS),
1086 g_return_val_if_fail (awaiting & AWAIT_TRANSACTIONS || !execute_txns, NULL);
1088 g_return_val_if_fail (!execute_txns || api, NULL);
1090 data->awaiting = awaiting;
1091 data->txn_found = FALSE;
1092 data->execute_txns = execute_txns;
1094 data->parent = parent;
1095 data->job_list = AB_Transaction_List2_new ();
1096 data->tmp_job_list = NULL;
1097 data->generic_importer = NULL;
1099 g_datalist_init (&data->tmp_job_list);
1102 ab_ail = AB_ImExporterContext_GetAccountInfoList (context);
1103 if (ab_ail && AB_ImExporterAccountInfo_List_GetCount (ab_ail))
1105 if (!(awaiting & IGNORE_TRANSACTIONS))
1106 AB_ImExporterAccountInfo_List_ForEach (ab_ail,
1111 if (data->generic_importer)
1115 if (!(awaiting & IGNORE_BALANCES))
1116 AB_ImExporterAccountInfo_List_ForEach (ab_ail,
1123 AB_MESSAGE * bankmsg = AB_ImExporterContext_GetFirstMessage (context);
1126 const char* subject = AB_Message_GetSubject (bankmsg);
1127 const char* text = AB_Message_GetText (bankmsg);
1128 gnc_info_dialog (GTK_WINDOW(data->parent),
"%s\n%s %s\n%s",
1129 _(
"The bank has sent a message in its response."),
1134 bankmsg = AB_Message_List_Next (bankmsg);
1144 g_return_val_if_fail (ieci, 0);
1146 return ieci->awaiting;
1152 g_return_val_if_fail (ieci, NULL);
1154 return ieci->job_list;
1160 g_return_val_if_fail (ieci, FALSE);
1169 GWEN_DB_NODE *perm_certs = NULL;
1172 g_return_val_if_fail (banking, NULL);
1173 rv = AB_Banking_LoadSharedConfig (banking,
"certs", &perm_certs);
1175 g_return_val_if_fail (rv >= 0, NULL);
1179 #if (AQBANKING_VERSION_INT >= 60400) 1181 gnc_ab_trans_templ_list_new_from_ref_accounts (GNC_AB_ACCOUNT_SPEC *ab_acc)
1183 GList *retval = NULL;
1184 AB_REFERENCE_ACCOUNT *ra;
1185 AB_REFERENCE_ACCOUNT_LIST *ral;
1186 GWEN_BUFFER *accNameForTemplate = GWEN_Buffer_new (0,120,0,0);
1187 gnc_numeric zero = gnc_numeric_zero ();
1190 ral = AB_AccountSpec_GetRefAccountList (ab_acc);
1191 ra = AB_ReferenceAccount_List_First (ral);
1197 const char *iban = AB_ReferenceAccount_GetIban (ra);
1198 const char *accName = AB_ReferenceAccount_GetAccountName (ra);
1199 GWEN_Buffer_Reset (accNameForTemplate);
1202 GWEN_Buffer_AppendString (accNameForTemplate, accName);
1203 GWEN_Buffer_AppendString (accNameForTemplate,
": ");
1205 GWEN_Buffer_AppendString (accNameForTemplate, iban);
1211 retval = g_list_prepend (retval, new_templ);
1212 ra = AB_ReferenceAccount_List_Next (ra);
1214 retval = g_list_reverse (retval);
1216 GWEN_Buffer_free (accNameForTemplate);
1224 return left ? (right ? g_strcmp0 (left->name, right->name) : -1) :
1231 GList* desc_list = NULL;
1232 GWEN_PLUGIN_DESCRIPTION_LIST2 *il =
1233 AB_Banking_GetImExporterDescrs (api);
1234 GWEN_PLUGIN_DESCRIPTION_LIST2_ITERATOR *ilit;
1235 g_return_val_if_fail (il, NULL);
1236 ilit = GWEN_PluginDescription_List2_First(il);
1238 for (GWEN_PLUGIN_DESCRIPTION *pd =
1239 GWEN_PluginDescription_List2Iterator_Data(ilit);
1241 pd = GWEN_PluginDescription_List2Iterator_Next(ilit))
1246 node->name = g_strdup(GWEN_PluginDescription_GetName(pd));
1247 node->descr = g_strdup(GWEN_PluginDescription_GetShortDescr(pd));
1248 desc_list = g_list_prepend (desc_list, node);
1250 GWEN_PluginDescription_List2_free(il);
1251 return g_list_sort (desc_list, (GCompareFunc)ab_node_pair_compare);
1257 GList* prof_list = NULL;
1258 GWEN_DB_NODE* db = AB_Banking_GetImExporterProfiles(api, importer_name);
1259 g_return_val_if_fail (db, NULL);
1261 for (GWEN_DB_NODE *profile = GWEN_DB_GetFirstGroup(db); profile;
1262 profile = GWEN_DB_GetNextGroup(profile))
1265 if (!profile)
continue;
1266 node->name = g_strdup(GWEN_DB_GetCharValue(profile,
"name", 0, NULL));
1267 node->descr = g_strdup(GWEN_DB_GetCharValue(profile,
"shortDescr", 0, NULL));
1268 prof_list = g_list_prepend (prof_list, node);
1270 return g_list_sort (prof_list, (GCompareFunc)ab_node_pair_compare);
Dialog for AqBanking transaction data.
guint32 gnc_ab_get_account_uid(const Account *a)
Return the unique id for the AB_BANKING account in the Account a.
gchar * gnc_ab_create_online_id(const gchar *bankcode, const gchar *accountnumber)
Creates an online ID from bank code and account number.
gchar * gnc_ab_get_remote_name(const AB_TRANSACTION *ab_trans)
Retrieve the merged "remote name" fields from a transaction.
GList * gnc_ab_imexporter_list(AB_BANKING *api)
Retrieve the available AQBanking importers.
Transaction * xaccMallocTransaction(QofBook *book)
The xaccMallocTransaction() will malloc memory and initialize it.
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
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...
void xaccTransSetDatePostedSecsNormalized(Transaction *trans, time64 time)
This function sets the posted date of the transaction, specified by a time64 (see ctime(3))...
time64 gnc_dmy2time64_neutral(gint day, gint month, gint year)
Converts a day, month, and year to a time64 representing 11:00:00 UTC 11:00:00 UTC falls on the same ...
gnc_numeric double_to_gnc_numeric(double n, gint64 denom, gint how)
Convert a floating-point number to a gnc_numeric.
void gnc_gen_trans_list_show_all(GNCImportMainMatcher *info)
Shows widgets.
void gnc_GWEN_Gui_shutdown(void)
Free all memory related to both the full-blown and minimalistic GUI objects.
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
#define PINFO(format, args...)
Print an informational note.
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
gchar * gnc_ab_get_purpose(const AB_TRANSACTION *ab_trans, gboolean is_ofx)
Retrieve the merged purpose fields from a transaction.
void gnc_ab_trans_templ_set_amount(GncABTransTempl *t, gnc_numeric amount)
Replace the amount stored in a template.
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...
void xaccTransSetDescription(Transaction *trans, const char *desc)
Sets the transaction Description.
gchar * gnc_AB_JOB_ID_to_string(gulong job_id)
Return the job_id as string.
Transaction matcher main window.
void gnc_utf8_strip_invalid_and_controls(gchar *str)
Strip any non-utf8 characters and any control characters (everything < 0x20, , , ...
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 ...
Account * gnc_import_select_account(GtkWidget *parent, const gchar *account_online_id_value, gboolean prompt_on_no_match, const gchar *account_human_description, const gnc_commodity *new_account_default_commodity, GNCAccountType new_account_default_type, Account *default_selection, gboolean *ok_pressed)
Must be called with a string containing a unique identifier for the account.
gboolean gnc_ab_ieci_run_matcher(GncABImExContextImport *ieci)
Run the generic transaction matcher dialog.
void gnc_gen_trans_list_add_tp_cb(GNCImportMainMatcher *info, GNCTransactionProcessedCB trans_processed_cb, gpointer user_data)
Add transaction processed callback to the transaction importer.
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.
Generic and very flexible account matcher/picker.
GNC_AB_JOB_LIST2 * gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci)
Extract the job list from data.
void gnc_ab_trans_templ_set_name(GncABTransTempl *t, const gchar *name)
Set the name of a template.
guint32 gnc_import_TransInfo_get_ref_id(const GNCImportTransInfo *info)
Returns the reference id for this TransInfo.
const gchar * gnc_ab_get_account_bankcode(const Account *a)
Return the bankcode string in the Account a.
void gnc_gen_trans_list_add_trans(GNCImportMainMatcher *gui, Transaction *trans)
Add a newly imported Transaction to the Transaction Importer.
GWEN_DB_NODE * gnc_ab_get_permanent_certs(void)
get the GWEN_DB_NODE from AqBanking configuration files
void xaccTransSetCurrency(Transaction *trans, gnc_commodity *curr)
Set a new currency on a transaction.
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.
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.
GncABTransTempl * gnc_ab_trans_templ_new()
Create a template with unset contents.
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...
GtkWidget * gnc_gen_trans_list_widget(GNCImportMainMatcher *info)
Returns the widget of this dialog.
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 avail...
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
gchar * gnc_AB_JOB_to_readable_string(const GNC_AB_JOB *job)
Return the job as string.
GNCImportMainMatcher * gnc_gen_trans_list_new(GtkWidget *parent, const gchar *heading, bool all_from_same_account, gint match_date_hardlimit, bool show_all)
Create a new generic transaction dialog window and return it.
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
void gnc_utf8_strip_invalid(gchar *str)
Strip any non-UTF-8 characters from a string.
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
gnc_numeric xaccAccountGetReconciledBalance(const Account *acc)
Get the current balance of the account, only including reconciled transactions.
GList * gnc_ab_imexporter_profile_list(AB_BANKING *api, const char *importer_name)
Retrieve the available format templates for an AQBanking importer.
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
Split * xaccMallocSplit(QofBook *book)
Constructor.
gchar * gnc_g_list_stringjoin_nodups(GList *list_of_strings, const gchar *sep)
Like stringjoin but ensures that the string to be added isn't already part of the return string...
Generic api to store and retrieve preferences.
void gnc_gen_trans_list_add_trans_with_ref_id(GNCImportMainMatcher *gui, Transaction *trans, guint32 ref_id)
Add a newly imported Transaction to the Transaction Importer and provide an external reference id for...
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.
void gnc_AB_BANKING_delete(AB_BANKING *api)
Delete the AB_BANKING api.
void gnc_GWEN_Fini(void)
Finalize the gwenhywfar library.
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_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
void xaccSplitSetOnlineID(Split *split, const char *id)
The online_id is the OFX/HBCI "FITID" recorded on a split when it is imported.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
bool gnc_gen_trans_list_run(GNCImportMainMatcher *info)
Run this dialog and return only after the user pressed Ok, Cancel, or closed the window.
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
GNC_AB_ACCOUNT_SPEC * gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
Get the corresponding AqBanking account to the GnuCash account gnc_acc.
time64 gnc_time(time64 *tbuf)
get the current time
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
const gchar * gnc_ab_get_account_accountid(const Account *a)
Return accountid string in the Account a.
void xaccTransSetDateEnteredSecs(Transaction *trans, time64 secs)
Modify the date of when the transaction was entered.
void gnc_GWEN_Init(void)
Initialize the gwenhywfar library by calling GWEN_Init() and setting up gwenhywfar logging...
GUI callbacks for AqBanking.
guint gnc_ab_ieci_get_found(GncABImExContextImport *ieci)
Extract awaiting from data.
API for Transactions and Splits (journal entries)
void gnc_GWEN_Gui_log_init(void)
Hook our logging into the gwenhywfar logging framework by creating a minimalistic GWEN_GUI with only ...
AqBanking utility functions.
time64 gnc_time64_get_day_neutral(time64 time_val)
The gnc_time64_get_day_neutral() routine will take the given time in seconds and adjust it to 10:59:0...