Skip to content

Commit

Permalink
Merge John Ralls's 'aqb-file-import' into master.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Oct 30, 2022
2 parents fc94b41 + 79723b0 commit 6c7e50e
Show file tree
Hide file tree
Showing 27 changed files with 747 additions and 1,116 deletions.
49 changes: 4 additions & 45 deletions .github/workflows/ci-tests.yml
Expand Up @@ -2,17 +2,17 @@ name: ci-tests
on: [push, pull_request]
permissions: {}
jobs:
ci_tests_ubuntu-18:
runs-on: ubuntu-18.04
name: Ubuntu-18.04 CI Tests
ci_tests_ubuntu-22:
runs-on: ubuntu-22.04
name: Ubuntu-22.04 CI Tests
env:
TZ: America/Los_Angeles
steps:
- name: Checkout
uses: actions/checkout@v2
- run: sudo apt-get update
- name: Install additional dependencies
run: sudo apt-get install -y cmake libxslt-dev xsltproc ninja-build libboost-all-dev libgtk-3-dev guile-2.2-dev libgwengui-gtk3-dev libaqbanking-dev libofx-dev libdbi-dev libdbd-sqlite3 libwebkit2gtk-4.0-dev googletest
run: sudo apt-get install -y gettext cmake libxslt-dev xsltproc ninja-build libboost-all-dev libgtk-3-dev guile-2.2-dev libgwengui-gtk3-dev libaqbanking-dev libofx-dev libdbi-dev libdbd-sqlite3 libwebkit2gtk-4.0-dev googletest
- name: Install language packs.
run: sudo apt-get --reinstall install -y language-pack-en language-pack-fr
- run: |
Expand All @@ -38,44 +38,3 @@ jobs:
with:
name: TestLog
path: ${{ github.workspace }}/build/Testing/Temporary/LastTest.log
ci_tests_ubuntu-20:
runs-on: ubuntu-20.04
name: Ubuntu-20.04 CI Tests
env:
TZ: America/Los_Angeles
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install apt utils
run: sudo apt-get install -y --no-install-recommends apt-utils
- name: Update apt
run: |
sudo sed -i -e 's/^# deb-src/deb-src/' /etc/apt/sources.list
sudo apt-get update -y
- name: Install additional dependencies
run: |
sudo apt-get build-dep -y gnucash
sudo apt-get install ninja-build guile-3.0-dev libboost-program-options-dev
- name: Install language packs.
run: sudo apt-get --reinstall install -y language-pack-en language-pack-fr
- run: |
echo "ROOT_DIR=$GITHUB_WORKSPACE/.." >> $GITHUB_ENV
- name: Create Directories
run: |
pwd
mkdir $ROOT_DIR/inst
mkdir build
- name: Configure GnuCash
run: |
cd build
cmake -G Ninja -DWITH_PYTHON=ON -DCMAKE_INSTALL_PREFIX=$ROOT_DIR/inst $GITHUB_WORKSPACE
- name: Build and Test GnuCash
run: |
cd build
ninja
ninja check
- uses: actions/upload-artifact@v2
if: failure()
with:
name: TestLog
path: ${{ github.workspace }}/build/Testing/Temporary/LastTest.log
2 changes: 1 addition & 1 deletion .github/workflows/mac-tests.yaml
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: carlosperate/download-file-action@v1.0.3
id: dependencies
with:
file-url: 'https://downloads.sourceforge.net/gnucash/Dependencies/gnucash-4.x-mac-dependencies.tar.xz'
file-url: 'https://downloads.sourceforge.net/gnucash/Dependencies/gnucash-4.900-mac-dependencies.tar.xz'
file-name: gnucash-dependencies.tar.xz
- name: download googletest
uses: carlosperate/download-file-action@v1.0.3
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Expand Up @@ -48,7 +48,7 @@ include (TestBigEndian)
# SQL, put -D WITH_SQL=OFF on the command line.

option (WITH_SQL "Build this project with SQL (libdbi) support" ON)
option (WITH_AQBANKING "Build this project with aqbanking (online banking) support" ON)
option (WITH_AQBANKING "Build this project with aqbanking (online banking and a variety of file import formats) support" ON)
option (WITH_GNUCASH "Build all of GnuCash, not just the library" ON)
option (WITH_OFX "compile with ofx support (needs LibOFX)" ON)
option (WITH_PYTHON "enable python plugin and bindings" OFF)
Expand Down Expand Up @@ -358,8 +358,8 @@ find_guile_dirs()

# ############################################################
if (WITH_AQBANKING)
pkg_check_modules (GWENHYWFAR REQUIRED gwenhywfar>=4.20)
pkg_check_modules (AQBANKING REQUIRED aqbanking>=5.7.8)
pkg_check_modules (GWENHYWFAR REQUIRED gwenhywfar>=5.8.0)
pkg_check_modules (AQBANKING REQUIRED aqbanking>=6.4.0)
set(CMAKE_REQUIRED_INCLUDES "${AQBANKING_INCLUDE_DIRS}"
"${GWENHYWFAR_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${AQBANKING_LD_FLAGS}")
Expand Down
5 changes: 2 additions & 3 deletions README.dependencies
Expand Up @@ -93,9 +93,8 @@ Libraries/Deps

optional
--------
aqbanking 5.7.8 online banking; Note that 6.1.0
gwenhywfar 4.20.0 or higher is needed for German
FinTS.
aqbanking 6.4.0 online banking and SWIFT
gwenhywfar 5.8.0 file imports.

python 3.6.0 python bindings; headers
required, not just binaries.
Expand Down
2 changes: 2 additions & 0 deletions gnucash/import-export/aqb/CMakeLists.txt
Expand Up @@ -6,6 +6,7 @@ add_subdirectory(test)
set (aqbanking_SOURCES
dialog-ab-trans.c
dialog-ab-daterange.c
dialog-ab-select-imexporter.c
assistant-ab-initial.c
gnc-ab-getbalance.c
gnc-ab-gettrans.c
Expand All @@ -25,6 +26,7 @@ set_source_files_properties (${aqbanking_SOURCES} PROPERTIES OBJECT_DEPENDS ${CO
set (aqbanking_noinst_HEADERS
dialog-ab-trans.h
dialog-ab-daterange.h
dialog-ab-select-imexporter.h
assistant-ab-initial.h
gnc-ab-getbalance.h
gnc-ab-gettrans.h
Expand Down
86 changes: 0 additions & 86 deletions gnucash/import-export/aqb/assistant-ab-initial.c
Expand Up @@ -40,10 +40,8 @@
#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>
Expand All @@ -65,9 +63,6 @@
#include "gnc-session.h"
#include "import-account-matcher.h"
#include "import-utilities.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;

Expand All @@ -92,10 +87,8 @@ void aai_page_prepare (GtkAssistant *assistant, gpointer user_data);
void aai_button_clicked_cb(GtkButton *button, gpointer user_data);
void aai_match_delete_button_clicked_cb(GtkButton *button, gpointer user_data);

#ifdef AQBANKING6
static guint aai_ab_account_hash(gconstpointer v);
static gboolean aai_ab_account_equal(gconstpointer v1, gconstpointer v2);
#endif
void aai_match_page_prepare (GtkAssistant *assistant, gpointer user_data);

static gboolean banking_has_accounts(AB_BANKING *banking);
Expand Down Expand Up @@ -207,9 +200,6 @@ 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;
}
Expand Down Expand Up @@ -268,16 +258,7 @@ aai_button_clicked_cb(GtkButton *button, gpointer user_data)
}

{
#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!");
Expand All @@ -292,12 +273,6 @@ aai_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 */
Expand Down Expand Up @@ -369,7 +344,6 @@ aai_match_delete_button_clicked_cb(GtkButton *button, gpointer user_data)
}
}

#ifdef AQBANKING6
static guint
aai_ab_account_hash (gconstpointer v)
{
Expand All @@ -393,7 +367,6 @@ aai_ab_account_equal (gconstpointer v1, gconstpointer v2)
return uid1 == uid2;
}
}
#endif

static void
insert_acc_into_revhash_cb(gpointer ab_acc, gpointer gnc_acc, gpointer revhash)
Expand Down Expand Up @@ -424,17 +397,9 @@ 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());
#ifdef AQBANKING6
info->gnc_hash = g_hash_table_new(&aai_ab_account_hash, &aai_ab_account_equal);
#else
info->gnc_hash = g_hash_table_new(&g_direct_hash, &g_direct_equal);
#endif
data.api = info->api;
data.hash = info->gnc_hash;
gnc_account_foreach_descendant(root, (AccountCb) hash_from_kvp_acc_cb, &data);
Expand Down Expand Up @@ -479,24 +444,11 @@ banking_has_accounts(AB_BANKING *banking)

g_return_val_if_fail(banking, FALSE);

#ifdef AQBANKING6
if (AB_Banking_GetAccountSpecList (banking, &accl) >= 0 &&
accl && AB_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;

if (accl)
AB_Account_List2_free(accl);

AB_Banking_OnlineFini(banking);
#endif

return result;
}
Expand All @@ -521,17 +473,9 @@ ab_account_longname(const GNC_AB_ACCOUNT_SPEC *ab_acc)

g_return_val_if_fail(ab_acc, NULL);

#ifdef AQBANKING6
bankcode = AB_AccountSpec_GetBankCode(ab_acc);
subAccountId = AB_AccountSpec_GetSubAccountNumber(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;
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)"),
Expand Down Expand Up @@ -593,14 +537,8 @@ 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");
Expand Down Expand Up @@ -639,11 +577,7 @@ clear_line_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,

gtk_tree_model_get(model, iter, ACCOUNT_LIST_COL_AB_ACCT, &ab_acc, -1);

#ifdef AQBANKING6
if (aai_ab_account_equal(ab_acc, data->ab_acc))
#else
if (ab_acc == data->ab_acc)
#endif
{
gtk_list_store_set(store, iter, ACCOUNT_LIST_COL_GNC_NAME, "",
ACCOUNT_LIST_COL_CHECKED, TRUE, -1);
Expand Down Expand Up @@ -682,11 +616,7 @@ 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(
Expand Down Expand Up @@ -753,51 +683,35 @@ save_kvp_acc_cb(gpointer key, gpointer value, gpointer user_data)
guint32 ab_account_uid;
const gchar *ab_accountid, *gnc_accountid;
const gchar *ab_bankcode, *gnc_bankcode;
#ifdef AQBANKING6
gchar *ab_online_id;
gchar *gnc_online_id;
#endif

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
|| (strcmp(gnc_bankcode, ab_bankcode) != 0)))
gnc_ab_set_account_bankcode(gnc_acc, ab_bankcode);

#ifdef AQBANKING6
ab_online_id = gnc_ab_create_online_id(ab_bankcode, ab_accountid);
gnc_online_id = gnc_import_get_acc_online_id(gnc_acc);
if (ab_online_id && (!gnc_online_id || (strcmp(ab_online_id, gnc_online_id) != 0)))
gnc_import_set_acc_online_id(gnc_acc, ab_online_id);
g_free(ab_online_id);
g_free (gnc_online_id);
#endif
}

static void
Expand Down

0 comments on commit 6c7e50e

Please sign in to comment.