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.
This commit is contained in:
Jed Fox
2023-03-17 14:00:35 -04:00
committed by GitHub
parent c5c4cbbeb2
commit 4a3fe1d9fb
3 changed files with 23 additions and 4 deletions

View File

@@ -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;
}

View File

@@ -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',
]),
};
}

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [j-f1]
---
`node-libofx`: add transaction_acct_name function