mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge PR #623 into maint
This commit is contained in:
@@ -63,6 +63,7 @@ G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
|
||||
static AB_BANKING *gnc_AB_BANKING = NULL;
|
||||
static gint gnc_AB_BANKING_refcount = 0;
|
||||
|
||||
static gchar* create_online_id(const gchar *bankcode, const gchar *accountnumber);
|
||||
static gpointer join_ab_strings_cb(const gchar *str, gpointer user_data);
|
||||
static Account *gnc_ab_accinfo_to_gnc_acc(GtkWidget *parent,
|
||||
AB_IMEXPORTER_ACCOUNTINFO *account_info);
|
||||
@@ -316,6 +317,28 @@ gnc_AB_VALUE_to_readable_string(const AB_VALUE *value)
|
||||
return g_strdup_printf("%.2f", 0.0);
|
||||
}
|
||||
|
||||
|
||||
static gchar*
|
||||
create_online_id(const gchar *bankcode, const gchar *accountnumber)
|
||||
{
|
||||
gchar *online_id;
|
||||
|
||||
/* The accountnumber may have leading zeros, depending on where them
|
||||
* accountnumber is came from, e.g. the accountnumber of accountinfo
|
||||
* has no leading zeros while the (local)accountnumber of a transaction
|
||||
* has leading zeros.
|
||||
* So remove all leading '0', to get a consistent online_id.
|
||||
*/
|
||||
while (accountnumber && *accountnumber == '0')
|
||||
accountnumber++;
|
||||
|
||||
online_id = g_strconcat(bankcode ? bankcode : "",
|
||||
accountnumber ? accountnumber : "",
|
||||
(gchar*)NULL);
|
||||
|
||||
return online_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a string from a GWEN_STRINGLIST, strip invalid utf8 and join it
|
||||
* to the rest.
|
||||
@@ -328,7 +351,7 @@ join_ab_strings_cb(const gchar *str, gpointer user_data)
|
||||
|
||||
if (!str || !*str)
|
||||
return NULL;
|
||||
|
||||
|
||||
tmp = g_strdup(str);
|
||||
g_strstrip(tmp);
|
||||
gnc_utf8_strip_invalid_and_controls(tmp);
|
||||
@@ -392,7 +415,7 @@ gnc_ab_get_purpose(const AB_TRANSACTION *ab_trans, gboolean is_ofx)
|
||||
|
||||
g_return_val_if_fail(ab_trans, g_strdup(""));
|
||||
|
||||
if (!is_ofx && gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_USE_TRANSACTION_TXT))
|
||||
if (!is_ofx && gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_USE_TRANSACTION_TXT))
|
||||
{
|
||||
/* According to AqBanking, some of the non-swift lines have a special
|
||||
* meaning. Some banks place valuable text into the transaction text,
|
||||
@@ -646,9 +669,7 @@ gnc_ab_accinfo_to_gnc_acc(GtkWidget *parent, AB_IMEXPORTER_ACCOUNTINFO *acc_info
|
||||
|
||||
bankcode = AB_ImExporterAccountInfo_GetBankCode(acc_info);
|
||||
accountnumber = AB_ImExporterAccountInfo_GetAccountNumber(acc_info);
|
||||
online_id = g_strconcat(bankcode ? bankcode : "",
|
||||
accountnumber ? accountnumber : "",
|
||||
(gchar*)NULL);
|
||||
online_id = create_online_id(bankcode, accountnumber);
|
||||
gnc_acc = gnc_import_select_account(
|
||||
parent, online_id, 1, AB_ImExporterAccountInfo_GetAccountName(acc_info),
|
||||
NULL, ACCT_TYPE_NONE, NULL, NULL);
|
||||
@@ -687,9 +708,7 @@ gnc_ab_txn_to_gnc_acc(GtkWidget *parent, const AB_TRANSACTION *transaction)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
online_id = g_strconcat(bankcode ? bankcode : "",
|
||||
accountnumber ? accountnumber : "",
|
||||
(gchar*)NULL);
|
||||
online_id = create_online_id(bankcode, accountnumber);
|
||||
gnc_acc = gnc_import_select_account(
|
||||
parent, online_id, 1, AB_Transaction_GetLocalName(transaction),
|
||||
NULL, ACCT_TYPE_NONE, NULL, NULL);
|
||||
|
||||
Reference in New Issue
Block a user