mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 796956 - Aqbanking 6 will drop DTAUS
More important, the AQBanking API has some naming changes. This commit is substantially cribbed from Martin Pruess's adaptation in the AQBanking repository. Thanks, Martin!
This commit is contained in:
parent
d8c6af2d65
commit
62f7aa66a5
@ -85,8 +85,8 @@ Libraries/Deps
|
||||
|
||||
optional
|
||||
--------
|
||||
aqbanking 4.0.0 online banking; also requires
|
||||
gwehywfar and ktoblzcheck
|
||||
aqbanking 5.3.4 online banking; also requires
|
||||
gwehywfar.
|
||||
|
||||
libdbi 0.8.3 SQL backend; also requires at
|
||||
least one of libdbd-sqlite3,
|
||||
|
@ -36,7 +36,13 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "gnc-ab-utils.h" /* For version macros */
|
||||
|
||||
#include <aqbanking/banking.h>
|
||||
#ifdef AQBANKING6
|
||||
#include <aqbanking/types/account_spec.h>
|
||||
#include <gwenhywfar/gui.h>
|
||||
#endif
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gstdio.h>
|
||||
@ -57,8 +63,9 @@
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-session.h"
|
||||
#include "import-account-matcher.h"
|
||||
#include <aqbanking/dlg_setup.h>
|
||||
|
||||
#ifndef AQBANKING6
|
||||
# include <aqbanking/dlg_setup.h>
|
||||
#endif
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static QofLogModule log_module = GNC_MOD_ASSISTANT;
|
||||
|
||||
@ -87,8 +94,8 @@ void aai_match_page_prepare (GtkAssistant *assistant, gpointer user_data);
|
||||
static gboolean banking_has_accounts(AB_BANKING *banking);
|
||||
static void hash_from_kvp_acc_cb(Account *gnc_acc, gpointer user_data);
|
||||
static ABInitialInfo *single_info = NULL;
|
||||
static gchar *ab_account_longname(const AB_ACCOUNT *ab_acc);
|
||||
static AB_ACCOUNT *update_account_list_acc_cb(AB_ACCOUNT *ab_acc, gpointer user_data);
|
||||
static gchar *ab_account_longname(const GNC_AB_ACCOUNT_SPEC *ab_acc);
|
||||
static GNC_AB_ACCOUNT_SPEC *update_account_list_acc_cb(GNC_AB_ACCOUNT_SPEC *ab_acc, gpointer user_data);
|
||||
static void update_account_list(ABInitialInfo *info);
|
||||
static gboolean find_gnc_acc_cb(gpointer key, gpointer value, gpointer user_data);
|
||||
static gboolean clear_line_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data);
|
||||
@ -133,7 +140,7 @@ struct _AccCbData
|
||||
struct _RevLookupData
|
||||
{
|
||||
Account *gnc_acc;
|
||||
AB_ACCOUNT *ab_acc;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_acc;
|
||||
};
|
||||
|
||||
enum account_list_cols
|
||||
@ -187,7 +194,9 @@ aai_destroy_cb(GtkWidget *object, gpointer user_data)
|
||||
|
||||
if (info->gnc_hash)
|
||||
{
|
||||
#ifndef AQBANKING6
|
||||
AB_Banking_OnlineFini(info->api);
|
||||
#endif
|
||||
g_hash_table_destroy(info->gnc_hash);
|
||||
info->gnc_hash = NULL;
|
||||
}
|
||||
@ -240,14 +249,16 @@ aai_wizard_button_clicked_cb(GtkButton *button, gpointer user_data)
|
||||
}
|
||||
|
||||
{
|
||||
GWEN_DIALOG *dlg =
|
||||
AB_SetupDialog_new(banking);
|
||||
#ifdef AQBANKING6
|
||||
GWEN_DIALOG *dlg = AB_Banking_CreateSetupDialog(banking);
|
||||
#else
|
||||
GWEN_DIALOG *dlg = AB_SetupDialog_new(banking);
|
||||
|
||||
if (AB_Banking_OnlineInit(banking) != 0)
|
||||
{
|
||||
PERR("Got error on AB_Banking_OnlineInit!");
|
||||
}
|
||||
|
||||
#endif
|
||||
if (!dlg)
|
||||
{
|
||||
PERR("Could not lookup Setup Dialog of aqbanking!");
|
||||
@ -262,11 +273,12 @@ aai_wizard_button_clicked_cb(GtkButton *button, gpointer user_data)
|
||||
}
|
||||
GWEN_Dialog_free(dlg);
|
||||
}
|
||||
|
||||
#ifndef AQBANKING6
|
||||
if (AB_Banking_OnlineFini(banking) != 0)
|
||||
{
|
||||
PERR("Got error on AB_Banking_OnlineFini!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Enable the Assistant Buttons if we accounts */
|
||||
@ -293,8 +305,10 @@ aai_match_page_prepare (GtkAssistant *assistant, gpointer user_data)
|
||||
/* Do not run this twice */
|
||||
if (!info->match_page_prepared)
|
||||
{
|
||||
#ifndef AQBANKING6
|
||||
/* Load aqbanking accounts */
|
||||
AB_Banking_OnlineInit(info->api);
|
||||
#endif
|
||||
/* Determine current mapping */
|
||||
root = gnc_book_get_root_account(gnc_get_current_book());
|
||||
info->gnc_hash = g_hash_table_new(&g_direct_hash, &g_direct_equal);
|
||||
@ -331,23 +345,29 @@ aai_on_finish (GtkAssistant *assistant, gpointer user_data)
|
||||
static gboolean
|
||||
banking_has_accounts(AB_BANKING *banking)
|
||||
{
|
||||
AB_ACCOUNT_LIST2 *accl;
|
||||
gboolean result;
|
||||
GNC_AB_ACCOUNT_SPEC_LIST *accl = NULL;
|
||||
gboolean result = FALSE;
|
||||
|
||||
g_return_val_if_fail(banking, FALSE);
|
||||
|
||||
#ifdef AQBANKING6
|
||||
if (AB_Banking_GetAccountSpecList (banking, &accl) >= 0 &&
|
||||
accl && AV_AccountSpec_List_GetCount (accl))
|
||||
result = TRUE;
|
||||
if (accl)
|
||||
AB_AccountSpec_List_Free (accl);
|
||||
#else
|
||||
AB_Banking_OnlineInit(banking);
|
||||
|
||||
accl = AB_Banking_GetAccounts(banking);
|
||||
if (accl && (AB_Account_List2_GetSize(accl) > 0))
|
||||
result = TRUE;
|
||||
else
|
||||
result = FALSE;
|
||||
|
||||
if (accl)
|
||||
AB_Account_List2_free(accl);
|
||||
|
||||
AB_Banking_OnlineFini(banking);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -356,7 +376,7 @@ static void
|
||||
hash_from_kvp_acc_cb(Account *gnc_acc, gpointer user_data)
|
||||
{
|
||||
AccCbData *data = user_data;
|
||||
AB_ACCOUNT *ab_acc;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_acc;
|
||||
|
||||
ab_acc = gnc_ab_get_ab_account(data->api, gnc_acc);
|
||||
if (ab_acc)
|
||||
@ -364,25 +384,29 @@ hash_from_kvp_acc_cb(Account *gnc_acc, gpointer user_data)
|
||||
}
|
||||
|
||||
static gchar *
|
||||
ab_account_longname(const AB_ACCOUNT *ab_acc)
|
||||
ab_account_longname(const GNC_AB_ACCOUNT_SPEC *ab_acc)
|
||||
{
|
||||
gchar *bankname;
|
||||
gchar *result;
|
||||
const char *ab_bankname, *bankcode, *subAccountId;
|
||||
gchar *bankname = "";
|
||||
gchar *result = NULL;
|
||||
const char *ab_bankname, *bankcode, *subAccountId, *account_number;
|
||||
|
||||
g_return_val_if_fail(ab_acc, NULL);
|
||||
|
||||
#ifdef AQBANKING6
|
||||
bankcode = AB_AccountSpec_GetBankCode(ab_acc);
|
||||
subAccountId = AB_AccountSpec_GetSubAccountId(ab_acc);
|
||||
account_number = AB_AccountSpec_GetAccountNumber (ab_acc);
|
||||
#else
|
||||
ab_bankname = AB_Account_GetBankName(ab_acc);
|
||||
bankname = ab_bankname ? gnc_utf8_strip_invalid_strdup(ab_bankname) : NULL;
|
||||
bankname = ab_bankname ? gnc_utf8_strip_invalid_strdup(ab_bankname) : "";
|
||||
bankcode = AB_Account_GetBankCode(ab_acc);
|
||||
subAccountId = AB_Account_GetSubAccountId(ab_acc);
|
||||
|
||||
account_number = AB_Account_GetAccountNumber (ab_acc);
|
||||
#endif
|
||||
/* Translators: Strings are 1. Bank code, 2. Bank name,
|
||||
* 3. Account Number, 4. Subaccount ID */
|
||||
result = g_strdup_printf(_("Bank code %s (%s), Account %s (%s)"),
|
||||
bankcode,
|
||||
bankname ? bankname : "",
|
||||
AB_Account_GetAccountNumber(ab_acc),
|
||||
bankcode, bankname, account_number,
|
||||
subAccountId ? subAccountId : "");
|
||||
g_free(bankname);
|
||||
|
||||
@ -390,8 +414,8 @@ ab_account_longname(const AB_ACCOUNT *ab_acc)
|
||||
|
||||
}
|
||||
|
||||
static AB_ACCOUNT *
|
||||
update_account_list_acc_cb(AB_ACCOUNT *ab_acc, gpointer user_data)
|
||||
static GNC_AB_ACCOUNT_SPEC *
|
||||
update_account_list_acc_cb(GNC_AB_ACCOUNT_SPEC *ab_acc, gpointer user_data)
|
||||
{
|
||||
ABInitialInfo *info = user_data;
|
||||
gchar *gnc_name, *ab_name;
|
||||
@ -428,7 +452,7 @@ update_account_list_acc_cb(AB_ACCOUNT *ab_acc, gpointer user_data)
|
||||
static void
|
||||
update_account_list(ABInitialInfo *info)
|
||||
{
|
||||
AB_ACCOUNT_LIST2 *acclist;
|
||||
GNC_AB_ACCOUNT_SPEC_LIST *acclist = NULL;
|
||||
|
||||
g_return_if_fail(info && info->api && info->gnc_hash);
|
||||
|
||||
@ -438,9 +462,14 @@ update_account_list(ABInitialInfo *info)
|
||||
|
||||
/* Refill the list */
|
||||
gtk_list_store_clear(info->account_store);
|
||||
#ifdef AQBANKING6
|
||||
if (AB_Banking_GetAccountSpecList(info->api, &acclist) >= 0 && acclist)
|
||||
AB_AccountSpec_List_ForEach(acclist, update_account_list_acc_cb, info);
|
||||
#else
|
||||
acclist = AB_Banking_GetAccounts(info->api);
|
||||
if (acclist)
|
||||
AB_Account_List2_ForEach(acclist, update_account_list_acc_cb, info);
|
||||
#endif
|
||||
else
|
||||
g_warning("update_account_list: Oops, account list from AB_Banking "
|
||||
"is NULL");
|
||||
@ -461,7 +490,7 @@ find_gnc_acc_cb(gpointer key, gpointer value, gpointer user_data)
|
||||
|
||||
if (value == data->gnc_acc)
|
||||
{
|
||||
data->ab_acc = (AB_ACCOUNT*) key;
|
||||
data->ab_acc = (GNC_AB_ACCOUNT_SPEC*) key;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@ -495,7 +524,7 @@ account_list_clicked_cb (GtkTreeView *view, GtkTreePath *path,
|
||||
ABInitialInfo *info = user_data;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
AB_ACCOUNT *ab_acc;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_acc;
|
||||
gchar *longname, *gnc_name;
|
||||
Account *old_value, *gnc_acc;
|
||||
const gchar *currency;
|
||||
@ -518,7 +547,11 @@ account_list_clicked_cb (GtkTreeView *view, GtkTreePath *path,
|
||||
old_value = g_hash_table_lookup(info->gnc_hash, ab_acc);
|
||||
|
||||
longname = ab_account_longname(ab_acc);
|
||||
#ifdef AQBANKING6
|
||||
currency = AB_AccountSpec_GetCurrency(ab_acc);
|
||||
#else
|
||||
currency = AB_Account_GetCurrency(ab_acc);
|
||||
#endif
|
||||
if (currency && *currency)
|
||||
{
|
||||
commodity = gnc_commodity_table_lookup(
|
||||
@ -588,7 +621,7 @@ clear_kvp_acc_cb(Account *gnc_acc, gpointer user_data)
|
||||
static void
|
||||
save_kvp_acc_cb(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
AB_ACCOUNT *ab_acc = key;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_acc = key;
|
||||
Account *gnc_acc = value;
|
||||
guint32 ab_account_uid;
|
||||
const gchar *ab_accountid, *gnc_accountid;
|
||||
@ -596,18 +629,30 @@ save_kvp_acc_cb(gpointer key, gpointer value, gpointer user_data)
|
||||
|
||||
g_return_if_fail(ab_acc && gnc_acc);
|
||||
|
||||
#ifdef AQBANKING6
|
||||
ab_account_uid = AB_AccountSpec_GetUniqueId(ab_acc);
|
||||
#else
|
||||
ab_account_uid = AB_Account_GetUniqueId(ab_acc);
|
||||
#endif
|
||||
if (gnc_ab_get_account_uid(gnc_acc) != ab_account_uid)
|
||||
gnc_ab_set_account_uid(gnc_acc, ab_account_uid);
|
||||
|
||||
#ifdef AQBANKING6
|
||||
ab_accountid = AB_AccountSpec_GetAccountNumber(ab_acc);
|
||||
#else
|
||||
ab_accountid = AB_Account_GetAccountNumber(ab_acc);
|
||||
#endif
|
||||
gnc_accountid = gnc_ab_get_account_accountid(gnc_acc);
|
||||
if (ab_accountid
|
||||
&& (!gnc_accountid
|
||||
|| (strcmp(ab_accountid, gnc_accountid) != 0)))
|
||||
gnc_ab_set_account_accountid(gnc_acc, ab_accountid);
|
||||
|
||||
#ifdef AQBANKING6
|
||||
ab_bankcode = AB_AccountSpec_GetBankCode(ab_acc);
|
||||
#else
|
||||
ab_bankcode = AB_Account_GetBankCode(ab_acc);
|
||||
#endif
|
||||
gnc_bankcode = gnc_ab_get_account_bankcode(gnc_acc);
|
||||
if (ab_bankcode
|
||||
&& (!gnc_bankcode
|
||||
|
@ -37,6 +37,9 @@
|
||||
#include <aqbanking/jobinternaltransfer.h>
|
||||
#include <aqbanking/jobsepatransfer.h>
|
||||
#include <aqbanking/jobsepadebitnote.h>
|
||||
#ifdef AQBANKING6
|
||||
# include <aqbanking/types/transaction.h>
|
||||
#endif
|
||||
|
||||
#include <gnc-aqbanking-templates.h>
|
||||
#include "dialog-ab-trans.h"
|
||||
@ -61,7 +64,7 @@ static gboolean gnc_ab_trans_dialog_get_templ_helper(GtkTreeModel *model,
|
||||
gpointer data);
|
||||
|
||||
static AB_TRANSACTION *gnc_ab_trans_dialog_fill_values(GncABTransDialog *td);
|
||||
static AB_JOB *gnc_ab_trans_dialog_get_available_empty_job(AB_ACCOUNT *ab_acc,
|
||||
static GNC_AB_JOB *gnc_ab_trans_dialog_get_available_empty_job(GNC_AB_ACCOUNT_SPEC *ab_acc,
|
||||
GncABTransType trans_type);
|
||||
|
||||
static void gnc_ab_trans_dialog_check_iban(const GncABTransDialog *td,
|
||||
@ -102,7 +105,7 @@ struct _GncABTransDialog
|
||||
/* The dialog itself */
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *parent;
|
||||
AB_ACCOUNT *ab_acc;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_acc;
|
||||
|
||||
/* Whether this is a transfer or a direct debit */
|
||||
GncABTransType trans_type;
|
||||
@ -182,11 +185,11 @@ gnc_ab_trans_dialog_fill_values(GncABTransDialog *td)
|
||||
AB_TRANSACTION *trans = AB_Transaction_new();
|
||||
AB_VALUE *value;
|
||||
|
||||
#ifdef AQBNKING6
|
||||
AB_Banking_FillTransactionFromAccountSpec(trans, td->ab_acc);
|
||||
#else
|
||||
AB_Transaction_FillLocalFromAccount(trans, td->ab_acc);
|
||||
//AB_Transaction_SetLocalBankCode(trans, AB_Account_GetBankCode(td->ab_acc));
|
||||
//AB_Transaction_SetLocalAccountNumber(
|
||||
// trans, AB_Account_GetAccountNumber(td->ab_acc));
|
||||
//AB_Transaction_SetLocalCountry(trans, "DE");
|
||||
#endif
|
||||
|
||||
if (gnc_ab_trans_isSEPA(td->trans_type))
|
||||
{
|
||||
@ -205,6 +208,17 @@ gnc_ab_trans_dialog_fill_values(GncABTransDialog *td)
|
||||
trans, gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry)));
|
||||
}
|
||||
AB_Transaction_SetRemoteCountry(trans, "DE");
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_SetRemoteName(
|
||||
trans, gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)));
|
||||
|
||||
AB_Transaction_AddPurposeLine(
|
||||
trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_entry)));
|
||||
AB_Transaction_AddPurposeLine(
|
||||
trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont_entry)));
|
||||
AB_Transaction_AddPurposeLine(
|
||||
trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont2_entry)));
|
||||
#else
|
||||
AB_Transaction_AddRemoteName(
|
||||
trans, gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)), FALSE);
|
||||
|
||||
@ -216,7 +230,7 @@ gnc_ab_trans_dialog_fill_values(GncABTransDialog *td)
|
||||
trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont2_entry)), FALSE);
|
||||
AB_Transaction_AddPurpose(
|
||||
trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont3_entry)), FALSE);
|
||||
|
||||
#endif
|
||||
value = AB_Value_fromDouble(gnc_amount_edit_get_damount(
|
||||
GNC_AMOUNT_EDIT(td->amount_edit)));
|
||||
/* FIXME: Replace "EUR" by account-dependent string here. */
|
||||
@ -242,7 +256,7 @@ gnc_ab_trans_dialog_fill_values(GncABTransDialog *td)
|
||||
}
|
||||
|
||||
GncABTransDialog *
|
||||
gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc,
|
||||
gnc_ab_trans_dialog_new(GtkWidget *parent, GNC_AB_ACCOUNT_SPEC *ab_acc,
|
||||
gint commodity_scu, GncABTransType trans_type,
|
||||
GList *templates)
|
||||
{
|
||||
@ -270,6 +284,14 @@ gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc,
|
||||
|
||||
g_return_val_if_fail(ab_acc, NULL);
|
||||
|
||||
#ifdef AQBANKING6
|
||||
ab_ownername = AB_AccountSpec_GetOwnerName(ab_acc);
|
||||
if (!ab_ownername)
|
||||
ab_ownername = "";
|
||||
ab_accountnumber = AB_AccountSpec_GetAccountNumber(ab_acc);
|
||||
ab_bankcode = AB_AccountSpec_GetBankCode(ab_acc);
|
||||
ab_bankname = _("(unknown)");
|
||||
#else
|
||||
ab_ownername = AB_Account_GetOwnerName(ab_acc);
|
||||
if (!ab_ownername)
|
||||
ab_ownername = "";
|
||||
@ -278,6 +300,7 @@ gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc,
|
||||
ab_bankname = AB_Account_GetBankName(ab_acc);
|
||||
if (!ab_bankname || !*ab_bankname)
|
||||
ab_bankname = _("(unknown)");
|
||||
#endif
|
||||
|
||||
td = g_new0(GncABTransDialog, 1);
|
||||
td->parent = parent;
|
||||
@ -404,8 +427,13 @@ gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc,
|
||||
if (gnc_ab_trans_isSEPA(trans_type))
|
||||
{
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(td->orig_name_entry), TRUE);
|
||||
#if AQBANKING6
|
||||
ab_accountnumber = AB_AccountSpec_GetIBAN(ab_acc);
|
||||
ab_bankcode = AB_AccountSpec_GetBIC(ab_acc);
|
||||
#else
|
||||
ab_accountnumber = AB_Account_GetIBAN(ab_acc);
|
||||
ab_bankcode = AB_Account_GetBIC(ab_acc);
|
||||
#endif
|
||||
gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber);
|
||||
gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode);
|
||||
}
|
||||
@ -623,7 +651,7 @@ gint
|
||||
gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td)
|
||||
{
|
||||
gint result;
|
||||
AB_JOB *job;
|
||||
GNC_AB_JOB *job;
|
||||
const AB_TRANSACTION_LIMITS *joblimits;
|
||||
guint8 max_purpose_lines;
|
||||
|
||||
@ -636,7 +664,11 @@ gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td)
|
||||
}
|
||||
|
||||
/* Activate as many purpose entries as available for the job */
|
||||
#ifdef AQBANKING6
|
||||
joblimits = AB_AccountSpec_GetTransactionLimitsForCommand(td->ab_acc, AB_Transaction_GetCommand(job));
|
||||
#else
|
||||
joblimits = AB_Job_GetFieldLimits (job);
|
||||
#endif
|
||||
max_purpose_lines = joblimits ?
|
||||
AB_TransactionLimits_GetMaxLinesPurpose(joblimits) : 2;
|
||||
gtk_widget_set_sensitive(td->purpose_cont_entry, max_purpose_lines > 1);
|
||||
@ -772,11 +804,39 @@ gnc_ab_trans_dialog_get_ab_trans(const GncABTransDialog *td)
|
||||
return td->ab_trans;
|
||||
}
|
||||
|
||||
static AB_JOB *
|
||||
gnc_ab_trans_dialog_get_available_empty_job(AB_ACCOUNT *ab_acc, GncABTransType trans_type)
|
||||
static GNC_AB_JOB *
|
||||
gnc_ab_trans_dialog_get_available_empty_job(GNC_AB_ACCOUNT_SPEC *ab_acc, GncABTransType trans_type)
|
||||
{
|
||||
AB_JOB *job;
|
||||
GNC_AB_JOB *job;
|
||||
#ifdef AQBANKING6
|
||||
AB_TRANSACTION_COMMAND cmd = AB_Transaction_CommandUnknown;
|
||||
|
||||
switch (trans_type)
|
||||
{
|
||||
case SINGLE_DEBITNOTE:
|
||||
cmd=AB_Transaction_CommandDebitNote;
|
||||
break;
|
||||
case SINGLE_INTERNAL_TRANSFER:
|
||||
cmd=AB_Transaction_CommandInternalTransfer;
|
||||
break;
|
||||
case SEPA_TRANSFER:
|
||||
cmd=AB_Transaction_CommandSepaTransfer;
|
||||
break;
|
||||
case SEPA_DEBITNOTE:
|
||||
cmd=AB_Transaction_CommandSepaDebitNote;
|
||||
break;
|
||||
case SEPA_TRANSFER:
|
||||
default:
|
||||
cmd=AB_Transaction_CommandTransfer;
|
||||
break;
|
||||
};
|
||||
if (!AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, cmd))
|
||||
return NULL;
|
||||
|
||||
job = AB_Transaction_new();
|
||||
AB_Transaction_SetCommand(job, cmd);
|
||||
AB_Transaction_SetUniqueAccountId(job, AB_AccountSpec_GetUniqueId(ab_acc));
|
||||
#else
|
||||
switch (trans_type)
|
||||
{
|
||||
case SINGLE_DEBITNOTE:
|
||||
@ -796,36 +856,56 @@ gnc_ab_trans_dialog_get_available_empty_job(AB_ACCOUNT *ab_acc, GncABTransType t
|
||||
job = AB_JobSepaTransfer_new(ab_acc);
|
||||
break;
|
||||
};
|
||||
|
||||
if (!job || AB_Job_CheckAvailability(job))
|
||||
{
|
||||
if (job) AB_Job_free(job);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
return job;
|
||||
}
|
||||
|
||||
AB_JOB *
|
||||
GNC_AB_JOB *
|
||||
gnc_ab_trans_dialog_get_job(const GncABTransDialog *td)
|
||||
{
|
||||
g_return_val_if_fail(td, NULL);
|
||||
return gnc_ab_get_trans_job(td->ab_acc, td->ab_trans, td->trans_type);
|
||||
}
|
||||
|
||||
AB_JOB *
|
||||
gnc_ab_get_trans_job(AB_ACCOUNT *ab_acc, const AB_TRANSACTION *ab_trans,
|
||||
GNC_AB_JOB *
|
||||
gnc_ab_get_trans_job(GNC_AB_ACCOUNT_SPEC *ab_acc,
|
||||
const AB_TRANSACTION *ab_trans,
|
||||
GncABTransType trans_type)
|
||||
{
|
||||
AB_JOB *job;
|
||||
GNC_AB_JOB *job;
|
||||
|
||||
g_return_val_if_fail(ab_acc && ab_trans, NULL);
|
||||
|
||||
#ifdef AQBANKING6
|
||||
job = gnc_ab_trans_dialog_get_available_empty_job(ab_acc, trans_type);
|
||||
if (job)
|
||||
{
|
||||
AB_TRANSACTION *new_job;
|
||||
|
||||
/* merge transactions */
|
||||
new_job=AB_Transaction_dup(ab_trans);
|
||||
AB_Transaction_SetCommand(new_job, AB_Transaction_GetCommand(job));
|
||||
AB_Transaction_SetUniqueAccountId(new_job,
|
||||
AB_Transaction_GetUniqueAccountId(job));
|
||||
|
||||
AB_Transaction_free(job);
|
||||
return new_job;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
#else
|
||||
job = gnc_ab_trans_dialog_get_available_empty_job(ab_acc, trans_type);
|
||||
if (job)
|
||||
{
|
||||
AB_Job_SetTransaction(job, ab_trans);
|
||||
}
|
||||
return job;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -35,6 +35,7 @@
|
||||
#ifndef DIALOG_AB_TRANS_H
|
||||
#define DIALOG_AB_TRANS_H
|
||||
|
||||
#include "gnc-ab-utils.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include <aqbanking/banking.h>
|
||||
|
||||
@ -74,7 +75,7 @@ gboolean gnc_ab_trans_isSEPA(GncABTransType t);
|
||||
* gnc_ab_trans_dialog_get_templ()
|
||||
* @return A new GncABTransDialog, free with gnc_ab_trans_dialog_free()
|
||||
*/
|
||||
GncABTransDialog *gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc,
|
||||
GncABTransDialog *gnc_ab_trans_dialog_new(GtkWidget *parent, GNC_AB_ACCOUNT_SPEC *ab_acc,
|
||||
gint commodity_scu,
|
||||
GncABTransType trans_type,
|
||||
GList *templates);
|
||||
@ -125,25 +126,25 @@ GtkWidget *gnc_ab_trans_dialog_get_parent(const GncABTransDialog *td);
|
||||
* @param td Transaction dialog
|
||||
* @return An Aqbanking transaction
|
||||
*/
|
||||
const AB_TRANSACTION *gnc_ab_trans_dialog_get_ab_trans(
|
||||
const GncABTransDialog *td);
|
||||
const AB_TRANSACTION *gnc_ab_trans_dialog_get_ab_trans(const GncABTransDialog *td);
|
||||
|
||||
/**
|
||||
* Receive the Aqbanking job associated with the transaction
|
||||
* Receive the Aqbanking job filled by the dialog.
|
||||
*
|
||||
* @param td Transaction dialog
|
||||
* @return An Aqbanking job
|
||||
*/
|
||||
AB_JOB *gnc_ab_trans_dialog_get_job(const GncABTransDialog *td);
|
||||
GNC_AB_JOB *gnc_ab_trans_dialog_get_job(const GncABTransDialog *td);
|
||||
|
||||
/**
|
||||
* FIXME
|
||||
* Return the AqBanking job associated with the transaction.
|
||||
*
|
||||
* @param td Transaction dialog
|
||||
* @return FIXME
|
||||
* @return An AQBanking job
|
||||
*/
|
||||
AB_JOB *gnc_ab_get_trans_job(AB_ACCOUNT *ab_acc, const AB_TRANSACTION *ab_trans,
|
||||
GncABTransType trans_type);
|
||||
GNC_AB_JOB *gnc_ab_get_trans_job(GNC_AB_ACCOUNT_SPEC *ab_acc,
|
||||
const AB_TRANSACTION *ab_trans,
|
||||
GncABTransType trans_type);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -29,13 +29,18 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "gnc-ab-utils.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <aqbanking/banking.h>
|
||||
#ifdef AQBANKING6
|
||||
# include <aqbanking/types/transaction.h>
|
||||
#else
|
||||
#include <aqbanking/jobgetbalance.h>
|
||||
#endif
|
||||
|
||||
#include "gnc-ab-getbalance.h"
|
||||
#include "gnc-ab-kvp.h"
|
||||
#include "gnc-ab-utils.h"
|
||||
#include "gnc-gwen-gui.h"
|
||||
#include "gnc-ui.h"
|
||||
|
||||
@ -47,13 +52,13 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc)
|
||||
{
|
||||
AB_BANKING *api;
|
||||
gboolean online = FALSE;
|
||||
AB_ACCOUNT *ab_acc;
|
||||
AB_JOB *job = NULL;
|
||||
AB_JOB_LIST2 *job_list = NULL;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_acc;
|
||||
GNC_AB_JOB *job = NULL;
|
||||
GNC_AB_JOB_LIST2 *job_list = NULL;
|
||||
GncGWENGui *gui = NULL;
|
||||
AB_IMEXPORTER_CONTEXT *context = NULL;
|
||||
GncABImExContextImport *ieci = NULL;
|
||||
AB_JOB_STATUS job_status;
|
||||
GNC_AB_JOB_STATUS job_status;
|
||||
|
||||
g_return_if_fail(parent && gnc_acc);
|
||||
|
||||
@ -64,13 +69,15 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc)
|
||||
g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef AQBANKING6
|
||||
if (AB_Banking_OnlineInit(api) != 0)
|
||||
{
|
||||
g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
|
||||
goto cleanup;
|
||||
}
|
||||
online = TRUE;
|
||||
|
||||
#endif
|
||||
/* Get the AqBanking Account */
|
||||
ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
|
||||
if (!ab_acc)
|
||||
@ -81,17 +88,29 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc)
|
||||
}
|
||||
|
||||
/* Get a GetBalance job and enqueue it */
|
||||
#ifdef AQBANKING6
|
||||
if (!AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_CommandGetBalance))
|
||||
#else
|
||||
job = AB_JobGetBalance_new(ab_acc);
|
||||
if (!job || AB_Job_CheckAvailability(job))
|
||||
#endif
|
||||
{
|
||||
g_warning("gnc_ab_getbalance: JobGetBalance not available for this "
|
||||
"account");
|
||||
gnc_error_dialog (GTK_WINDOW (parent), _("Online action \"Get Balance\" not available for this account."));
|
||||
goto cleanup;
|
||||
}
|
||||
#ifdef AQBANKING6
|
||||
job = AB_Transaction_new();
|
||||
AB_Transaction_SetCommand(job, AB_Transaction_CommandGetBalance);
|
||||
AB_Transaction_SetUniqueAccountId(job, AB_AccountSpec_GetUniqueId(ab_acc));
|
||||
|
||||
job_list = AB_Transaction_List2_new();
|
||||
AB_Transaction_List2_PushBack(job_list, job);
|
||||
#else
|
||||
job_list = AB_Job_List2_new();
|
||||
AB_Job_List2_PushBack(job_list, job);
|
||||
|
||||
#endif
|
||||
/* Get a GUI object */
|
||||
gui = gnc_GWEN_Gui_get(parent);
|
||||
if (!gui)
|
||||
@ -104,20 +123,34 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc)
|
||||
context = AB_ImExporterContext_new();
|
||||
|
||||
/* Execute the job */
|
||||
#ifdef AQBANKING6
|
||||
AB_Banking_SendCommands(api, job_list, context);
|
||||
#else
|
||||
AB_Banking_ExecuteJobs(api, job_list, context);
|
||||
#endif
|
||||
/* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
|
||||
* status always describes better whether the job was actually
|
||||
* transferred to and accepted by the bank. See also
|
||||
* http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
|
||||
*/
|
||||
#ifdef AQBANKING6
|
||||
#else
|
||||
job_status = AB_Job_GetStatus(job);
|
||||
if (job_status != AB_Job_StatusFinished
|
||||
&& job_status != AB_Job_StatusPending)
|
||||
#endif
|
||||
{
|
||||
g_warning("gnc_ab_getbalance: Error on executing job");
|
||||
gnc_error_dialog (GTK_WINDOW (parent), _("Error on executing job.\n\nStatus: %s - %s"),
|
||||
#ifdef AQBANKING6
|
||||
gnc_error_dialog (GTK_WINDOW (parent),
|
||||
_("Error on executing job.\n\nStatus: %s"),
|
||||
AB_Transaction_Status_toString(job_status));
|
||||
#else
|
||||
gnc_error_dialog (GTK_WINDOW (parent),
|
||||
_("Error on executing job.\n\nStatus: %s - %s"),
|
||||
AB_Job_Status2Char(job_status),
|
||||
AB_Job_GetResultText(job));
|
||||
#endif
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -131,11 +164,18 @@ cleanup:
|
||||
AB_ImExporterContext_free(context);
|
||||
if (gui)
|
||||
gnc_GWEN_Gui_release(gui);
|
||||
#ifdef AQBANKING6
|
||||
if (job_list)
|
||||
AB_Transaction_List2_free(job_list);
|
||||
if (job)
|
||||
AB_Transaction_free(job);
|
||||
#else
|
||||
if (job_list)
|
||||
AB_Job_List2_free(job_list);
|
||||
if (job)
|
||||
AB_Job_free(job);
|
||||
if (online)
|
||||
AB_Banking_OnlineFini(api);
|
||||
#endif
|
||||
gnc_AB_BANKING_fini(api);
|
||||
}
|
||||
|
@ -29,15 +29,19 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "gnc-ab-utils.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <aqbanking/banking.h>
|
||||
#include <aqbanking/jobgettransactions.h>
|
||||
|
||||
#ifdef AQBANKING6
|
||||
# include <aqbanking/types/transaction.h>
|
||||
#else
|
||||
# include <aqbanking/jobgettransactions.h>
|
||||
#endif
|
||||
#include "Account.h"
|
||||
#include "dialog-ab-daterange.h"
|
||||
#include "gnc-ab-gettrans.h"
|
||||
#include "gnc-ab-kvp.h"
|
||||
#include "gnc-ab-utils.h"
|
||||
#include "gnc-gwen-gui.h"
|
||||
#include "gnc-ui.h"
|
||||
|
||||
@ -98,15 +102,15 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc)
|
||||
{
|
||||
AB_BANKING *api;
|
||||
gboolean online = FALSE;
|
||||
AB_ACCOUNT *ab_acc;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_acc;
|
||||
GWEN_TIME *from_date = NULL, *to_date = NULL;
|
||||
time64 until;
|
||||
AB_JOB *job = NULL;
|
||||
AB_JOB_LIST2 *job_list = NULL;
|
||||
GNC_AB_JOB *job = NULL;
|
||||
GNC_AB_JOB_LIST2 *job_list = NULL;
|
||||
GncGWENGui *gui = NULL;
|
||||
AB_IMEXPORTER_CONTEXT *context = NULL;
|
||||
GncABImExContextImport *ieci = NULL;
|
||||
AB_JOB_STATUS job_status;
|
||||
GNC_AB_JOB_STATUS job_status;
|
||||
|
||||
g_return_if_fail(parent && gnc_acc);
|
||||
|
||||
@ -117,13 +121,14 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc)
|
||||
g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
|
||||
return;
|
||||
}
|
||||
#ifndef AQBANKING6
|
||||
if (AB_Banking_OnlineInit(api) != 0)
|
||||
{
|
||||
g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
|
||||
goto cleanup;
|
||||
}
|
||||
online = TRUE;
|
||||
|
||||
#endif
|
||||
/* Get the AqBanking Account */
|
||||
ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
|
||||
if (!ab_acc)
|
||||
@ -143,19 +148,49 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc)
|
||||
until = GWEN_Time_toTime_t(to_date);
|
||||
|
||||
/* Get a GetTransactions job and enqueue it */
|
||||
#ifdef AQBANKING6
|
||||
if (!AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_CommandGetTransactions))
|
||||
#else
|
||||
job = AB_JobGetTransactions_new(ab_acc);
|
||||
if (!job || AB_Job_CheckAvailability(job))
|
||||
#endif
|
||||
{
|
||||
g_warning("gnc_ab_gettrans: JobGetTransactions not available for this "
|
||||
"account");
|
||||
gnc_error_dialog (GTK_WINDOW (parent), _("Online action \"Get Transactions\" not available for this account."));
|
||||
goto cleanup;
|
||||
}
|
||||
#ifdef AQBANKING6
|
||||
job = AB_Transaction_new();
|
||||
AB_Transaction_SetCommand(job, AB_Transaction_CommandGetTransactions);
|
||||
AB_Transaction_SetUniqueAccountId(job, AB_AccountSpec_GetUniqueId(ab_acc));
|
||||
|
||||
if (from_date) /* TODO: this should be simplified */
|
||||
{
|
||||
GWEN_DATE *dt;
|
||||
|
||||
dt=GWEN_Date_fromLocalTime(GWEN_Time_toTime_t(from_date));
|
||||
AB_Transaction_SetFirstDate(job, dt);
|
||||
GWEN_Date_free(dt);
|
||||
}
|
||||
|
||||
if (to_date)
|
||||
{
|
||||
GWEN_DATE *dt;
|
||||
|
||||
dt=GWEN_Date_fromLocalTime(GWEN_Time_toTime_t(to_date));
|
||||
AB_Transaction_SetLastDate(job, dt);
|
||||
GWEN_Date_free(dt);
|
||||
}
|
||||
|
||||
job_list = AB_Transaction_List2_new();
|
||||
AB_Transaction_List2_PushBack(job_list, job);
|
||||
#else
|
||||
AB_JobGetTransactions_SetFromTime(job, from_date);
|
||||
AB_JobGetTransactions_SetToTime(job, to_date);
|
||||
job_list = AB_Job_List2_new();
|
||||
AB_Job_List2_PushBack(job_list, job);
|
||||
|
||||
#endif
|
||||
/* Get a GUI object */
|
||||
gui = gnc_GWEN_Gui_get(parent);
|
||||
if (!gui)
|
||||
@ -168,20 +203,38 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc)
|
||||
context = AB_ImExporterContext_new();
|
||||
|
||||
/* Execute the job */
|
||||
#ifdef AQBANKING6
|
||||
AB_Banking_SendCommands(api, job_list, context);
|
||||
#else
|
||||
AB_Banking_ExecuteJobs(api, job_list, context);
|
||||
#endif
|
||||
/* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
|
||||
* status always describes better whether the job was actually
|
||||
* transferred to and accepted by the bank. See also
|
||||
* http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
|
||||
*/
|
||||
#ifdef AQBANKING6
|
||||
job_status = AB_Transaction_GetStatus(job);
|
||||
if (job_status != AB_Transaction_StatusAccepted
|
||||
&& job_status != AB_Transaction_StatusPending)
|
||||
#else
|
||||
job_status = AB_Job_GetStatus(job);
|
||||
if (job_status != AB_Job_StatusFinished
|
||||
&& job_status != AB_Job_StatusPending)
|
||||
#endif
|
||||
{
|
||||
g_warning("gnc_ab_gettrans: Error on executing job");
|
||||
gnc_error_dialog (GTK_WINDOW (parent), _("Error on executing job.\n\nStatus: %s - %s"),
|
||||
#ifdef AQBANKING6
|
||||
gnc_error_dialog (GTK_WINDOW (parent),
|
||||
_("Error on executing job.\n\nStatus: %s (%d)"),
|
||||
AB_Transaction_Status_toString(job_status),
|
||||
job_status);
|
||||
#else
|
||||
gnc_error_dialog (GTK_WINDOW (parent),
|
||||
_("Error on executing job.\n\nStatus: %s - %s"),
|
||||
AB_Job_Status2Char(job_status),
|
||||
AB_Job_GetResultText(job));
|
||||
#endif
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -214,14 +267,24 @@ cleanup:
|
||||
if (gui)
|
||||
gnc_GWEN_Gui_release(gui);
|
||||
if (job_list)
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_List2_free(job_list);
|
||||
#else
|
||||
AB_Job_List2_free(job_list);
|
||||
#endif
|
||||
if (job)
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_free(job);
|
||||
#else
|
||||
AB_Job_free(job);
|
||||
#endif
|
||||
if (to_date)
|
||||
GWEN_Time_free(to_date);
|
||||
if (from_date)
|
||||
GWEN_Time_free(from_date);
|
||||
#ifndef AQBANKING6
|
||||
if (online)
|
||||
AB_Banking_OnlineFini(api);
|
||||
#endif
|
||||
gnc_AB_BANKING_fini(api);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
|
||||
{
|
||||
AB_BANKING *api;
|
||||
gboolean online = FALSE;
|
||||
AB_ACCOUNT *ab_acc;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_acc;
|
||||
GList *templates = NULL;
|
||||
GncABTransDialog *td = NULL;
|
||||
gboolean successful = FALSE;
|
||||
@ -97,13 +97,14 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
|
||||
g_warning("gnc_ab_maketrans: Couldn't get AqBanking API");
|
||||
return;
|
||||
}
|
||||
#ifndef AQBANKING6
|
||||
if (AB_Banking_OnlineInit(api) != 0)
|
||||
{
|
||||
g_warning("gnc_ab_maketrans: Couldn't initialize AqBanking API");
|
||||
goto cleanup;
|
||||
}
|
||||
online = TRUE;
|
||||
|
||||
#endif
|
||||
/* Get the AqBanking Account */
|
||||
ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
|
||||
if (!ab_acc)
|
||||
@ -130,15 +131,15 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
|
||||
gint result;
|
||||
gboolean changed;
|
||||
const AB_TRANSACTION *ab_trans;
|
||||
AB_JOB *job = NULL;
|
||||
AB_JOB_LIST2 *job_list = NULL;
|
||||
GNC_AB_JOB *job = NULL;
|
||||
GNC_AB_JOB_LIST2 *job_list = NULL;
|
||||
XferDialog *xfer_dialog = NULL;
|
||||
gnc_numeric amount;
|
||||
gchar *description;
|
||||
gchar *memo;
|
||||
Transaction *gnc_trans = NULL;
|
||||
AB_IMEXPORTER_CONTEXT *context = NULL;
|
||||
AB_JOB_STATUS job_status;
|
||||
GNC_AB_JOB_STATUS job_status;
|
||||
GncABImExContextImport *ieci = NULL;
|
||||
|
||||
/* Get a GUI object */
|
||||
@ -170,7 +171,11 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
|
||||
/* Get a job and enqueue it */
|
||||
ab_trans = gnc_ab_trans_dialog_get_ab_trans(td);
|
||||
job = gnc_ab_trans_dialog_get_job(td);
|
||||
#ifdef AQBANKING6
|
||||
if (!job || AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_GetCommand(job))==NULL)
|
||||
#else
|
||||
if (!job || AB_Job_CheckAvailability(job))
|
||||
#endif
|
||||
{
|
||||
if (!gnc_verify_dialog (
|
||||
GTK_WINDOW (parent), FALSE, "%s",
|
||||
@ -186,9 +191,13 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
|
||||
aborted = TRUE;
|
||||
goto repeat;
|
||||
}
|
||||
#ifdef AQBANKING6
|
||||
job_list = AB_Transaction_List2_new();
|
||||
AB_Transaction_List2_PushBack(job_list, job);
|
||||
#else
|
||||
job_list = AB_Job_List2_new();
|
||||
AB_Job_List2_PushBack(job_list, job);
|
||||
|
||||
#endif
|
||||
/* Setup a Transfer Dialog for the GnuCash transaction */
|
||||
xfer_dialog = gnc_xfer_dialog(gnc_ab_trans_dialog_get_parent(td),
|
||||
gnc_acc);
|
||||
@ -265,16 +274,25 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
|
||||
}
|
||||
|
||||
/* Finally, execute the job */
|
||||
#ifdef AQBANKING6
|
||||
AB_Banking_SendCommands(api, job_list, context);
|
||||
#else
|
||||
AB_Banking_ExecuteJobs(api, job_list, context);
|
||||
|
||||
#endif
|
||||
/* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
|
||||
* status always describes better whether the job was actually
|
||||
* transferred to and accepted by the bank. See also
|
||||
* http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
|
||||
*/
|
||||
#ifdef AQBANKING6
|
||||
job_status = AB_Transaction_GetStatus(job);
|
||||
if (job_status != AB_Transaction_StatusAccepted
|
||||
&& job_status != AB_Transaction_StatusPending)
|
||||
#else
|
||||
job_status = AB_Job_GetStatus(job);
|
||||
if (job_status != AB_Job_StatusFinished
|
||||
&& job_status != AB_Job_StatusPending)
|
||||
#endif
|
||||
{
|
||||
successful = FALSE;
|
||||
if (!gnc_verify_dialog (
|
||||
@ -315,12 +333,20 @@ repeat:
|
||||
AB_ImExporterContext_free(context);
|
||||
if (job_list)
|
||||
{
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_List2_free(job_list);
|
||||
#else
|
||||
AB_Job_List2_free(job_list);
|
||||
#endif
|
||||
job_list = NULL;
|
||||
}
|
||||
if (job)
|
||||
{
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_free(job);
|
||||
#else
|
||||
AB_Job_free(job);
|
||||
#endif
|
||||
job = NULL;
|
||||
}
|
||||
if (gui)
|
||||
@ -335,7 +361,9 @@ repeat:
|
||||
cleanup:
|
||||
if (td)
|
||||
gnc_ab_trans_dialog_free(td);
|
||||
#ifndef AQBANKING6
|
||||
if (online)
|
||||
AB_Banking_OnlineFini(api);
|
||||
#endif
|
||||
gnc_AB_BANKING_fini(api);
|
||||
}
|
||||
|
@ -29,15 +29,18 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "gnc-ab-utils.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gwenhywfar/gwenhywfar.h>
|
||||
#include <aqbanking/banking.h>
|
||||
|
||||
#ifdef AQBANKING6
|
||||
# include <aqbanking/types/balance.h>
|
||||
#endif
|
||||
#include "window-reconcile.h"
|
||||
#include "Transaction.h"
|
||||
#include "dialog-ab-trans.h"
|
||||
#include "gnc-ab-kvp.h"
|
||||
#include "gnc-ab-utils.h"
|
||||
#include "gnc-glib-utils.h"
|
||||
#include "gnc-gwen-gui.h"
|
||||
#include "gnc-prefs.h"
|
||||
@ -73,11 +76,11 @@ struct _GncABImExContextImport
|
||||
guint awaiting;
|
||||
gboolean txn_found;
|
||||
Account *gnc_acc;
|
||||
AB_ACCOUNT *ab_acc;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_acc;
|
||||
gboolean execute_txns;
|
||||
AB_BANKING *api;
|
||||
GtkWidget *parent;
|
||||
AB_JOB_LIST2 *job_list;
|
||||
GNC_AB_JOB_LIST2 *job_list;
|
||||
GNCImportMainMatcher *generic_importer;
|
||||
GData *tmp_job_list;
|
||||
};
|
||||
@ -230,10 +233,10 @@ gnc_AB_BANKING_fini(AB_BANKING *api)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AB_ACCOUNT *
|
||||
GNC_AB_ACCOUNT_SPEC *
|
||||
gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
|
||||
{
|
||||
AB_ACCOUNT *ab_account = NULL;
|
||||
GNC_AB_ACCOUNT_SPEC *ab_account = NULL;
|
||||
const gchar *bankcode = NULL;
|
||||
const gchar *accountid = NULL;
|
||||
guint32 account_uid = 0;
|
||||
@ -244,6 +247,23 @@ gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
|
||||
|
||||
if (account_uid > 0)
|
||||
{
|
||||
#ifdef AQBANKING6
|
||||
gint rv;
|
||||
|
||||
rv = AB_Banking_GetAccountSpecByUniqueId(api, account_uid, &ab_account);
|
||||
|
||||
if ( (rv<0 || !ab_account) && bankcode && *bankcode &&
|
||||
accountid && *accountid)
|
||||
{
|
||||
/* Finding the account by code and number is suspended in AQBANKING 6 pending
|
||||
* implementation of a replacement for AB_Banking_GetAccountByCodeAndNumber.
|
||||
*/
|
||||
g_message("gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, "
|
||||
"trying bank code\n", account_uid);
|
||||
return NULL;
|
||||
}
|
||||
return ab_account;
|
||||
#else
|
||||
ab_account = AB_Banking_GetAccount(api, account_uid);
|
||||
|
||||
if (!ab_account && bankcode && *bankcode && accountid && *accountid)
|
||||
@ -251,7 +271,7 @@ gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
|
||||
g_message("gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, "
|
||||
"trying bank code\n", account_uid);
|
||||
ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
|
||||
accountid);
|
||||
accountid);
|
||||
}
|
||||
return ab_account;
|
||||
|
||||
@ -261,6 +281,7 @@ gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
|
||||
ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
|
||||
accountid);
|
||||
return ab_account;
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -311,16 +332,30 @@ join_ab_strings_cb(const gchar *str, gpointer user_data)
|
||||
gchar *
|
||||
gnc_ab_get_remote_name(const AB_TRANSACTION *ab_trans)
|
||||
{
|
||||
#ifndef AQBANKING6
|
||||
const GWEN_STRINGLIST *ab_remote_name;
|
||||
#endif
|
||||
gchar *gnc_other_name = NULL;
|
||||
|
||||
g_return_val_if_fail(ab_trans, NULL);
|
||||
|
||||
ab_remote_name = AB_Transaction_GetRemoteName(ab_trans);
|
||||
if (ab_remote_name)
|
||||
#ifdef AQBANKING6
|
||||
ab_transactionText = AB_Transaction_GetPurpose(ab_trans);
|
||||
if (ab_transactionText)
|
||||
{
|
||||
gchar *tmp;
|
||||
|
||||
tmp = g_strdup(ab_transactionText);
|
||||
g_strstrip(tmp);
|
||||
gnc_utf8_strip_invalid(tmp);
|
||||
gnc_description=tmp;
|
||||
}
|
||||
#else
|
||||
GWEN_StringList_ForEach(ab_remote_name, join_ab_strings_cb,
|
||||
&gnc_other_name);
|
||||
|
||||
#endif
|
||||
if (!gnc_other_name || !*gnc_other_name)
|
||||
{
|
||||
g_free(gnc_other_name);
|
||||
@ -460,7 +495,7 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
|
||||
QofBook *book;
|
||||
Transaction *gnc_trans;
|
||||
const gchar *fitid;
|
||||
const GWEN_TIME *valuta_date;
|
||||
const GNC_GWEN_DATE *valuta_date;
|
||||
time64 current_time;
|
||||
const char *custref;
|
||||
gchar *description;
|
||||
@ -478,15 +513,23 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
|
||||
valuta_date = AB_Transaction_GetValutaDate(ab_trans);
|
||||
if (!valuta_date)
|
||||
{
|
||||
const GWEN_TIME *normal_date = AB_Transaction_GetDate(ab_trans);
|
||||
const GNC_GWEN_DATE *normal_date = AB_Transaction_GetDate(ab_trans);
|
||||
if (normal_date)
|
||||
valuta_date = normal_date;
|
||||
}
|
||||
if (valuta_date)
|
||||
xaccTransSetDatePostedSecsNormalized(gnc_trans, GWEN_Time_toTime_t(valuta_date));
|
||||
{
|
||||
#ifdef AQBANKING6
|
||||
time64 secs = GWEN_Date_toLocalTime(valuta_date);
|
||||
#else
|
||||
time64 secs = GWEN_Time_toTime_t(valuta_date);
|
||||
#endif
|
||||
xaccTransSetDatePostedSecsNormalized(gnc_trans, secs);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning("transaction_cb: Oops, date 'valuta_date' was NULL");
|
||||
|
||||
}
|
||||
xaccTransSetDateEnteredSecs(gnc_trans, gnc_time (NULL));
|
||||
|
||||
/* Currency. We take simply the default currency of the gnucash account */
|
||||
@ -647,14 +690,21 @@ txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data)
|
||||
if (data->execute_txns && data->ab_acc)
|
||||
{
|
||||
AB_TRANSACTION *ab_trans = AB_Transaction_dup(element);
|
||||
AB_JOB *job;
|
||||
GNC_AB_JOB *job;
|
||||
|
||||
/* NEW: The imported transaction has been imported into gnucash.
|
||||
* Now also add it as a job to aqbanking */
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_SetLocalBankCode(
|
||||
ab_trans, AB_AccountSpec_GetBankCode(data->ab_acc));
|
||||
AB_Transaction_SetLocalAccountNumber(
|
||||
ab_trans, AB_AccountSpec_GetAccountNumber(data->ab_acc));
|
||||
#else
|
||||
AB_Transaction_SetLocalBankCode(
|
||||
ab_trans, AB_Account_GetBankCode(data->ab_acc));
|
||||
AB_Transaction_SetLocalAccountNumber(
|
||||
ab_trans, AB_Account_GetAccountNumber(data->ab_acc));
|
||||
#endif
|
||||
AB_Transaction_SetLocalCountry(ab_trans, "DE");
|
||||
|
||||
|
||||
@ -676,7 +726,11 @@ txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data)
|
||||
job = gnc_ab_get_trans_job(data->ab_acc, ab_trans, trans_type);
|
||||
|
||||
/* Check whether we really got a job */
|
||||
#ifdef AQBANKING6
|
||||
if (!job || AB_AccountSpec_GetTransactionLimitsForCommand(data->ab_acc, AB_Transaction_GetCommand(job))==NULL)
|
||||
#else
|
||||
if (!job || AB_Job_CheckAvailability(job))
|
||||
#endif
|
||||
{
|
||||
/* Oops, no job, probably not supported by bank */
|
||||
if (gnc_verify_dialog(
|
||||
@ -697,8 +751,13 @@ txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data)
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_gen_trans_list_add_trans_with_ref_id(data->generic_importer, gnc_trans, AB_Job_GetJobId(job));
|
||||
|
||||
gnc_gen_trans_list_add_trans_with_ref_id(data->generic_importer,
|
||||
gnc_trans,
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_GetUniqueId));
|
||||
#else
|
||||
AB_Job_GetJobId(job));
|
||||
#endif
|
||||
/* AB_Job_List2_PushBack(data->job_list, job); -> delayed until trans is successfully imported */
|
||||
g_datalist_set_data(&data->tmp_job_list, gnc_AB_JOB_to_readable_string(job), job);
|
||||
}
|
||||
@ -719,26 +778,38 @@ static void gnc_ab_trans_processed_cb(GNCImportTransInfo *trans_info,
|
||||
{
|
||||
GncABImExContextImport *data = user_data;
|
||||
gchar *jobname = gnc_AB_JOB_ID_to_string(gnc_import_TransInfo_get_ref_id(trans_info));
|
||||
AB_JOB *job = g_datalist_get_data(&data->tmp_job_list, jobname);
|
||||
GNC_AB_JOB *job = g_datalist_get_data(&data->tmp_job_list, jobname);
|
||||
|
||||
if (imported)
|
||||
{
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_List2_PushBack(data->job_list, job);
|
||||
#else
|
||||
AB_Job_List2_PushBack(data->job_list, job);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_free(job);
|
||||
#else
|
||||
AB_Job_free(job);
|
||||
#endif
|
||||
}
|
||||
|
||||
g_datalist_remove_data(&data->tmp_job_list, jobname);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gnc_AB_JOB_to_readable_string(const AB_JOB *job)
|
||||
gnc_AB_JOB_to_readable_string(const GNC_AB_JOB *job)
|
||||
{
|
||||
if (job)
|
||||
{
|
||||
#ifdef AQBANKING6
|
||||
return gnc_AB_JOB_ID_to_string(AB_Transaction_GetUniqueId(job));
|
||||
#else
|
||||
return gnc_AB_JOB_ID_to_string(AB_Job_GetJobId(job));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -765,8 +836,12 @@ txn_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
|
||||
/* Ignore them */
|
||||
return NULL;
|
||||
|
||||
#ifdef AQBANKING6
|
||||
if (!AB_ImExporterAccountInfo_GetFirstTransaction(element, AB_Transaction_TypeStatement, 0))
|
||||
#else
|
||||
if (!AB_ImExporterAccountInfo_GetFirstTransaction(element))
|
||||
/* No transaction found */
|
||||
#endif
|
||||
/* No transaction found */
|
||||
return NULL;
|
||||
else
|
||||
data->awaiting |= FOUND_TRANSACTIONS;
|
||||
@ -823,9 +898,16 @@ txn_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
|
||||
}
|
||||
|
||||
/* Iterate through all transactions */
|
||||
#ifdef AQBANKING6
|
||||
ab_trans_list = AB_ImExporterAccountInfo_GetTransactionList(element);
|
||||
if (ab_trans_list)
|
||||
AB_Transaction_List_ForEachByType(ab_trans_list,
|
||||
txn_transaction_cb, data,
|
||||
AB_Transaction_TypeStatement, 0);
|
||||
#else
|
||||
AB_ImExporterAccountInfo_TransactionsForEach(element, txn_transaction_cb,
|
||||
data);
|
||||
|
||||
data);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -850,12 +932,21 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
|
||||
/* Ignore them */
|
||||
return NULL;
|
||||
|
||||
#ifdef AQBANKING6
|
||||
if (!AB_ImExporterAccountInfo_GetFirstBalance(element))
|
||||
#else
|
||||
if (!AB_ImExporterAccountInfo_GetFirstAccountStatus(element))
|
||||
#endif
|
||||
/* No balance found */
|
||||
return NULL;
|
||||
else
|
||||
data->awaiting |= FOUND_BALANCES;
|
||||
|
||||
#ifdef AQBANKING6
|
||||
/* Lookup the most recent BALANCE available */
|
||||
booked_bal=AB_Balance_List_GetLatestByType(AB_ImExporterAccountInfo_GetBalanceList(element),
|
||||
AB_Balance_TypeBooked);
|
||||
#else
|
||||
/* Lookup the most recent ACCOUNT_STATUS available */
|
||||
item = AB_ImExporterAccountInfo_GetFirstAccountStatus(element);
|
||||
while (item)
|
||||
@ -870,6 +961,8 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
|
||||
}
|
||||
|
||||
booked_bal = AB_AccountStatus_GetBookedBalance(best);
|
||||
#endif
|
||||
|
||||
if (!(data->awaiting & AWAIT_BALANCES))
|
||||
{
|
||||
/* Ignore zero balances if we don't await a balance */
|
||||
@ -900,10 +993,15 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
|
||||
/* Lookup booked balance and time */
|
||||
if (booked_bal)
|
||||
{
|
||||
const GWEN_TIME *ti = AB_Balance_GetTime(booked_bal);
|
||||
const GNC_GWEN_DATE *ti = AB_Balance_GetTime(booked_bal);
|
||||
if (ti)
|
||||
{
|
||||
booked_tt = gnc_time64_get_day_neutral(GWEN_Time_toTime_t(ti));
|
||||
#ifdef AQBANKING6
|
||||
time64 secs = GWEN_Date_toLocalTime_t(dt);
|
||||
#else
|
||||
time64 secs = GWEN_Time_toTime_t(ti);
|
||||
#endif
|
||||
booked_tt = gnc_time64_get_day_neutral(secs);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -930,7 +1028,12 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
|
||||
}
|
||||
|
||||
/* Lookup noted balance */
|
||||
#ifdef AQBANKING6
|
||||
noted_bal = AB_Balance_List_GetLatestByType(AB_ImExporterAccountInfo_GetBalanceList(element),
|
||||
AB_Balance_TypeNoted);
|
||||
#else
|
||||
noted_bal = AB_AccountStatus_GetNotedBalance(best);
|
||||
#endif
|
||||
if (noted_bal)
|
||||
{
|
||||
noted_val = AB_Balance_GetValue(noted_bal);
|
||||
@ -1034,7 +1137,9 @@ gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context,
|
||||
AB_BANKING *api, GtkWidget *parent)
|
||||
{
|
||||
GncABImExContextImport *data = g_new(GncABImExContextImport, 1);
|
||||
|
||||
#ifdef AQBANKING6
|
||||
AB_IMEXPORTER_ACCOUNTINFO_LIST *ab_ail;
|
||||
#endif
|
||||
g_return_val_if_fail(context, NULL);
|
||||
/* Do not await and ignore at the same time */
|
||||
g_return_val_if_fail(!(awaiting & AWAIT_BALANCES)
|
||||
@ -1053,13 +1158,31 @@ gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context,
|
||||
data->execute_txns = execute_txns;
|
||||
data->api = api;
|
||||
data->parent = parent;
|
||||
#ifdef AQBANKING6
|
||||
data->job_list = AB_Transaction_List2_new();
|
||||
#else
|
||||
data->job_list = AB_Job_List2_new();
|
||||
#endif
|
||||
data->tmp_job_list = NULL;
|
||||
data->generic_importer = NULL;
|
||||
|
||||
g_datalist_init(&data->tmp_job_list);
|
||||
|
||||
/* Import transactions */
|
||||
#ifdef AQBANKING6
|
||||
ab_ail = AB_ImExporterContext_GetAccountInfoList(context);
|
||||
if (ab_ail && AB_ImExporterAccountInfo_List_GetCount(ab_ail))
|
||||
{
|
||||
if (!(awaiting & IGNORE_TRANSACTIONS))
|
||||
AB_ImExporterAccountInfo_List_ForEach(ab_ail, txn_accountinfo_cb,
|
||||
data);
|
||||
|
||||
/* Check balances */
|
||||
if (!(awaiting & IGNORE_BALANCES))
|
||||
AB_ImExporterAccountInfo_List_ForEach(ab_ail, bal_accountinfo_cb,
|
||||
data);
|
||||
}
|
||||
#else
|
||||
if (!(awaiting & IGNORE_TRANSACTIONS))
|
||||
AB_ImExporterContext_AccountInfoForEach(context, txn_accountinfo_cb,
|
||||
data);
|
||||
@ -1068,6 +1191,7 @@ gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context,
|
||||
if (!(awaiting & IGNORE_BALANCES))
|
||||
AB_ImExporterContext_AccountInfoForEach(context, bal_accountinfo_cb,
|
||||
data);
|
||||
#endif
|
||||
|
||||
/* Check bank-messages */
|
||||
{
|
||||
@ -1082,7 +1206,11 @@ gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context,
|
||||
subject,
|
||||
text);
|
||||
|
||||
#ifdef AQBANKING6
|
||||
bankmsg = AB_Message_List_Next(bankmsg);
|
||||
#else
|
||||
bankmsg = AB_ImExporterContext_GetNextMessage(context); // The interator is incremented within aqbanking
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1097,7 +1225,7 @@ gnc_ab_ieci_get_found(GncABImExContextImport *ieci)
|
||||
return ieci->awaiting;
|
||||
}
|
||||
|
||||
AB_JOB_LIST2 *
|
||||
GNC_AB_JOB_LIST2 *
|
||||
gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci)
|
||||
{
|
||||
g_return_val_if_fail(ieci, NULL);
|
||||
|
@ -52,6 +52,28 @@ G_BEGIN_DECLS
|
||||
* in the interval [0..99]. */
|
||||
#define GWENHYWFAR_VERSION_INT (10000 * GWENHYWFAR_VERSION_MAJOR + 100 * GWENHYWFAR_VERSION_MINOR + GWENHYWFAR_VERSION_PATCHLEVEL)
|
||||
|
||||
#if AQBANKING_VERSION_INT >= 59900
|
||||
# define AQBANKING6 1
|
||||
# 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
|
||||
#else
|
||||
# define GNC_AB_ACCOUNT_SPEC AB_ACCOUNT
|
||||
# define GNC_AB_ACCOUNT_SPEC_LIST AB_ACCOUNT_LIST2
|
||||
# define GNC_AB_JOB AB_JOB
|
||||
# define GNC_AB_JOB_LIST2 AB_JOB_LIST2
|
||||
# define GNC_AB_JOB_LIST2_ITERATOR AB_JOB_LIST2_ITERATOR
|
||||
# define GNC_AB_JOB_STATUS AB_JOB_STATUS
|
||||
# define GNC_GWEN_DATE GWEN_TIME
|
||||
#endif
|
||||
#if GWENHYWFAR_VERSION_INT >= 49900
|
||||
# define GWENHYWFAR5
|
||||
#endif
|
||||
|
||||
#define GNC_PREFS_GROUP_AQBANKING "dialogs.import.hbci"
|
||||
#define GNC_PREF_FORMAT_SWIFT940 "format-swift-mt940"
|
||||
#define GNC_PREF_FORMAT_SWIFT942 "format-swift-mt942"
|
||||
@ -112,11 +134,11 @@ gint gnc_AB_BANKING_fini(AB_BANKING *api);
|
||||
* 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.
|
||||
*
|
||||
* @param api The AB_BANKING to get the AB_ACCOUNT from
|
||||
* @param gnc_acc The GnuCash account to query for AB_ACCOUNT reference data
|
||||
* @return The AB_ACCOUNT found or NULL otherwise
|
||||
* @param api The AB_BANKING to get the GNC_AB_ACCOUNT_SPEC from
|
||||
* @param gnc_acc The GnuCash account to query for GNC_AB_ACCOUNT_SPEC reference data
|
||||
* @return The GNC_AB_ACCOUNT_SPEC found or NULL otherwise
|
||||
*/
|
||||
AB_ACCOUNT *gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc);
|
||||
GNC_AB_ACCOUNT_SPEC *gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc);
|
||||
|
||||
/**
|
||||
* Print the value of @a value with two decimal places and @a value's
|
||||
@ -130,10 +152,10 @@ gchar *gnc_AB_VALUE_to_readable_string(const AB_VALUE *value);
|
||||
/**
|
||||
* Return the job as string.
|
||||
*
|
||||
* @param value AB_JOB or NULL
|
||||
* @param value GNC_AB_JOB or NULL
|
||||
* @return A newly allocated string
|
||||
*/
|
||||
gchar *gnc_AB_JOB_to_readable_string(const AB_JOB *job);
|
||||
gchar *gnc_AB_JOB_to_readable_string(const GNC_AB_JOB *job);
|
||||
|
||||
/**
|
||||
* Return the job_id as string.
|
||||
@ -208,7 +230,7 @@ Transaction *gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_ac
|
||||
* create an aqbanking job for each of the transactions found
|
||||
*
|
||||
* @param api If @a execute_txns is TRUE, the AB_BANKING to get
|
||||
* AB_ACCOUNTs from
|
||||
* GNC_AB_ACCOUNT_SPECs from
|
||||
*
|
||||
* @param parent Widget to set new dialogs transient for, may be NULL
|
||||
*
|
||||
@ -236,7 +258,7 @@ guint gnc_ab_ieci_get_found(GncABImExContextImport *ieci);
|
||||
* @param ieci The return value of gnc_ab_import_context()
|
||||
* @return The list of jobs, freeable with AB_Job_List2_FreeAll()
|
||||
*/
|
||||
AB_JOB_LIST2 *gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci);
|
||||
GNC_AB_JOB_LIST2 *gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci);
|
||||
|
||||
/**
|
||||
* Run the generic transaction matcher dialog.
|
||||
|
@ -79,10 +79,10 @@ gnc_file_aqbanking_import(GtkWindow *parent,
|
||||
AB_IMEXPORTER_CONTEXT *context = NULL;
|
||||
GWEN_IO_LAYER *io = NULL;
|
||||
GncABImExContextImport *ieci = NULL;
|
||||
AB_JOB_LIST2 *job_list = NULL;
|
||||
AB_JOB_LIST2_ITERATOR *jit;
|
||||
AB_JOB *job;
|
||||
AB_JOB_STATUS job_status;
|
||||
GNC_AB_JOB_LIST2 *job_list = NULL;
|
||||
GNC_AB_JOB_LIST2_ITERATOR *jit;
|
||||
GNC_AB_JOB *job;
|
||||
GNC_AB_JOB_STATUS job_status;
|
||||
gboolean successful = TRUE;
|
||||
int num_jobs = 0;
|
||||
int num_jobs_failed = 0;
|
||||
@ -105,13 +105,14 @@ gnc_file_aqbanking_import(GtkWindow *parent,
|
||||
gnc_set_default_directory(GNC_PREFS_GROUP_AQBANKING, default_dir);
|
||||
g_free(default_dir);
|
||||
|
||||
#ifndef AQBANKING6
|
||||
dtaus_fd = g_open(selected_filename, O_RDONLY, 0);
|
||||
if (dtaus_fd == -1)
|
||||
{
|
||||
DEBUG("Could not open file %s", selected_filename);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Get the API */
|
||||
api = gnc_AB_BANKING_new();
|
||||
if (!api)
|
||||
@ -119,6 +120,7 @@ gnc_file_aqbanking_import(GtkWindow *parent,
|
||||
g_warning("gnc_file_aqbanking_import: Couldn't get AqBanking API");
|
||||
goto cleanup;
|
||||
}
|
||||
#ifndef AQBANKING6
|
||||
if (AB_Banking_OnlineInit(api) != 0)
|
||||
{
|
||||
g_warning("gnc_file_aqbanking_import: "
|
||||
@ -166,10 +168,20 @@ gnc_file_aqbanking_import(GtkWindow *parent,
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Create a context to store the results */
|
||||
context = AB_ImExporterContext_new();
|
||||
|
||||
#ifdef AQBANKING6
|
||||
if (AB_Banking_ImportFromFileLoadProfile(api, aqbanking_importername,
|
||||
context, aqbanking_profilename,
|
||||
NULL, selected_filename) < 0)
|
||||
{
|
||||
g_warning("gnc_file_aqbanking_import: Error on import");
|
||||
goto cleanup;
|
||||
}
|
||||
#else
|
||||
/* Wrap file in buffered gwen io */
|
||||
close(dtaus_fd);
|
||||
io = GWEN_SyncIo_File_new(selected_filename, GWEN_SyncIo_File_CreationMode_OpenExisting);
|
||||
@ -198,6 +210,7 @@ gnc_file_aqbanking_import(GtkWindow *parent,
|
||||
/* Close the file */
|
||||
GWEN_SyncIo_free(io);
|
||||
io = NULL;
|
||||
#endif
|
||||
|
||||
/* Before importing the results, if this is a new book, let user specify
|
||||
* book options, since they affect how transactions are created */
|
||||
@ -231,8 +244,11 @@ gnc_file_aqbanking_import(GtkWindow *parent,
|
||||
}
|
||||
|
||||
/* And execute the jobs */
|
||||
#ifdef AQBANKING6
|
||||
AB_Banking_SendCommands(api, job_list, execution_context);
|
||||
#else
|
||||
AB_Banking_ExecuteJobs(api, job_list, execution_context);
|
||||
|
||||
#endif
|
||||
/* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
|
||||
* status always describes better whether the job was actually
|
||||
* transferred to and accepted by the bank. See also
|
||||
@ -243,33 +259,50 @@ gnc_file_aqbanking_import(GtkWindow *parent,
|
||||
* to give the appropriate feedback if any of the jobs didn't
|
||||
* work. */
|
||||
|
||||
#ifdef AQBANKING6
|
||||
jit = AB_Transaction_List2_First(job_list);
|
||||
#else
|
||||
jit = AB_Job_List2_First(job_list);
|
||||
#endif
|
||||
if (jit)
|
||||
{
|
||||
|
||||
job = AB_Job_List2Iterator_Data(jit);
|
||||
while (job)
|
||||
{
|
||||
num_jobs += 1;
|
||||
#ifdef AQBANKING6
|
||||
job_status = AB_Transaction_GetStatus(job);
|
||||
if (job_status != AB_Transaction_StatusFinished &&
|
||||
job_status != AB_Transaction_StatusPending)
|
||||
#else
|
||||
job_status = AB_Job_GetStatus(job);
|
||||
if (job_status != AB_Job_StatusFinished
|
||||
&& job_status != AB_Job_StatusPending)
|
||||
if (job_status != AB_Job_StatusFinished &&
|
||||
job_status != AB_Job_StatusPending)
|
||||
#endif
|
||||
{
|
||||
successful = FALSE;
|
||||
num_jobs_failed += 1;
|
||||
|
||||
if (num_jobs_failed <= max_failures)
|
||||
{
|
||||
#ifdef AQBANKING6
|
||||
gchar *fmt_str =_("Job %d status %d - %s\n");
|
||||
#else
|
||||
gchar *fmt_str =_("Job %d status %d - %s: %s\n");
|
||||
#endif
|
||||
if (num_jobs_failed == 1)
|
||||
{
|
||||
errstr = g_string_new("Failed jobs:\n");
|
||||
}
|
||||
g_string_append_printf(errstr, _("Job %d status %d - %s: %s \n")
|
||||
, num_jobs
|
||||
, job_status
|
||||
, AB_Job_Status2Char(job_status)
|
||||
, AB_Job_GetResultText(job));
|
||||
}
|
||||
g_string_append_printf(errstr, fmt_str, num_jobs,
|
||||
job_status,
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_Status_toString(job_status));
|
||||
#else
|
||||
AB_Job_Status2Char(job_status),
|
||||
AB_Job_GetResultText(job));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (num_jobs_failed == (max_failures + 1) )
|
||||
@ -279,10 +312,17 @@ gnc_file_aqbanking_import(GtkWindow *parent,
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef AQBANKING6
|
||||
job = AB_Transaction_List2Iterator_Next(jit);
|
||||
#else
|
||||
job = AB_Job_List2Iterator_Next(jit);
|
||||
#endif
|
||||
} /* while */
|
||||
|
||||
#ifdef AQBANKING6
|
||||
AB_Job_List2Iterator_free(jit);
|
||||
#else
|
||||
AB_Job_List2Iterator_free(jit);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!successful)
|
||||
@ -317,30 +357,30 @@ gnc_file_aqbanking_import(GtkWindow *parent,
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (io)
|
||||
{
|
||||
GWEN_SyncIo_free(io);
|
||||
}
|
||||
|
||||
if (job_list)
|
||||
#ifdef AQBANKING6
|
||||
AB_Transaction_List2_FreeAll(job_list);
|
||||
#else
|
||||
AB_Job_List2_FreeAll(job_list);
|
||||
if (io)
|
||||
GWEN_SyncIo_free(io);
|
||||
if (db_profiles)
|
||||
GWEN_DB_Group_free(db_profiles);
|
||||
if (online)
|
||||
AB_Banking_OnlineFini(api);
|
||||
if (dtaus_fd != -1)
|
||||
close(dtaus_fd);
|
||||
#endif
|
||||
if (ieci)
|
||||
g_free(ieci);
|
||||
if (context)
|
||||
AB_ImExporterContext_free(context);
|
||||
if (db_profiles)
|
||||
GWEN_DB_Group_free(db_profiles);
|
||||
if (gui)
|
||||
gnc_GWEN_Gui_release(gui);
|
||||
if (online)
|
||||
AB_Banking_OnlineFini(api);
|
||||
if (api)
|
||||
gnc_AB_BANKING_fini(api);
|
||||
if (dtaus_fd != -1)
|
||||
close(dtaus_fd);
|
||||
if (selected_filename)
|
||||
g_free(selected_filename);
|
||||
if (errstr)
|
||||
g_string_free(errstr, TRUE);
|
||||
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ static gint progress_advance_cb(GWEN_GUI *gwen_gui, uint32_t id,
|
||||
static gint progress_log_cb(GWEN_GUI *gwen_gui, guint32 id,
|
||||
GWEN_LOGGER_LEVEL level, const gchar *text);
|
||||
static gint progress_end_cb(GWEN_GUI *gwen_gui, guint32 id);
|
||||
#if GWENHYWFAR_VERSION_INT < 49900
|
||||
#ifndef GWENHYWFAR5
|
||||
static gint GNC_GWENHYWFAR_CB getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags,
|
||||
const gchar *token,
|
||||
const gchar *title,
|
||||
@ -1409,7 +1409,7 @@ progress_end_cb(GWEN_GUI *gwen_gui, guint32 id)
|
||||
}
|
||||
|
||||
static gint GNC_GWENHYWFAR_CB
|
||||
#if GWENHYWFAR_VERSION_INT < 49900
|
||||
#ifndef GWENHYWFAR5
|
||||
getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *token,
|
||||
const gchar *title, const gchar *text, gchar *buffer,
|
||||
gint min_len, gint max_len, guint32 guiid)
|
||||
|
Loading…
Reference in New Issue
Block a user