From 4a3fe1d9fb419e134b593fbb491cdd1b08a4e320 Mon Sep 17 00:00:00 2001 From: Jed Fox <git@jedfox.com> Date: Fri, 17 Mar 2023 14:00:35 -0400 Subject: [PATCH] node-libofx: add transaction_acct_name function (#670) I am currently not working on adding support for importing to multiple accounts, but I wanted to give anyone who takes that on a starting point by updating the underlying C library to provide access to the account name field. --- packages/node-libofx/emscripten.cpp | 7 +++++++ packages/node-libofx/ffi.js | 14 ++++++++++---- upcoming-release-notes/670.md | 6 ++++++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 upcoming-release-notes/670.md diff --git a/packages/node-libofx/emscripten.cpp b/packages/node-libofx/emscripten.cpp index 49657ada3..ae8f34710 100644 --- a/packages/node-libofx/emscripten.cpp +++ b/packages/node-libofx/emscripten.cpp @@ -69,6 +69,13 @@ extern "C" { // Transaction accessors + char *transaction_acct_name(OfxTransactionData *trans) { + if (trans->account_ptr && trans->account_ptr->account_id_valid) { + return trans->account_ptr->account_id; + } + return ""; + } + double transaction_amount(OfxTransactionData *trans) { return trans->amount; } diff --git a/packages/node-libofx/ffi.js b/packages/node-libofx/ffi.js index f3e9d7dfc..422ec6947 100644 --- a/packages/node-libofx/ffi.js +++ b/packages/node-libofx/ffi.js @@ -8,11 +8,14 @@ function create(libofx) { ofx_set_transaction_cb: libofx.cwrap('ofx_set_transaction_cb', null, [ 'number', 'number', - 'number' + 'number', ]), + transaction_acct_name: libofx.cwrap('transaction_acct_name', 'string', [ + 'number', + ]), transaction_amount: libofx.cwrap('transaction_amount', 'number', [ - 'number' + 'number', ]), transaction_fi_id: libofx.cwrap('transaction_fi_id', 'string', ['number']), transaction_date: libofx.cwrap('transaction_date', 'number', ['number']), @@ -22,10 +25,13 @@ function create(libofx) { set_ofx_version: libofx.cwrap('set_ofx_version', null, [ 'number', - 'string' + 'string', ]), set_app_id: libofx.cwrap('set_app_id', null, ['number', 'string']), - set_app_version: libofx.cwrap('set_app_version', null, ['number', 'string']) + set_app_version: libofx.cwrap('set_app_version', null, [ + 'number', + 'string', + ]), }; } diff --git a/upcoming-release-notes/670.md b/upcoming-release-notes/670.md new file mode 100644 index 000000000..2db228d6f --- /dev/null +++ b/upcoming-release-notes/670.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [j-f1] +--- + +`node-libofx`: add transaction_acct_name function -- GitLab