[GNC] OFX Import with Multiple Banks/Accounts in a single file
Ove Grunnér
write2ove at gmail.com
Tue Apr 14 13:11:39 EDT 2020
it works for me as well, but I know I need to put a specific line in the
beginning of the file to let gnuCash know it is multi account
open up your file and check if the firs line is: !Clear:AutoSwitch
Try to add the line if it is missing.
I use the below java code to write my import files.
br
try {
FileWriter fstream = new FileWriter(targetDirectoryPointer +
targetQifFileName);
BufferedWriter info = new BufferedWriter(fstream);
// WRITE TO FILE
// indicator for multi account import
info.write("!Clear:AutoSwitch"+"\n");
for (int acc=0; acc< maxAcc; acc++) {
int transactionTableMaxRows =
accountTable.getTransactionTableMaxRows(acc);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// get data for this account
String targetFileAccountName =
accountTable.getTransactionTableAccountName(acc);
String[] transactionDescription =
accountTable.getTransactionDescription(acc);
float[] transactionAmount = accountTable.getTransactionAmount(acc);
float[] transactionBalance = accountTable.getTransactionBalance(acc);
Date[] transactionDate = accountTable.getTransactionDate(acc);
// WRITE TO FILE
// New Account
String account = accountDetailsGnuCashName[acc] ;
info.write("!Account" + "\n" + "N" + account + "\n" + "^" + "\n");
for (int l = 0; l < transactionTableMaxRows; l++) {
// Transaction
String type = "Bank";
String date = dateFormat.format(transactionDate[l]);
String amount = String.valueOf(transactionAmount[l]);
String description = transactionDescription[l];
String category = transactionDescription[l];
info.write("!Type:" + type + "\n");
info.write("D" + date + "\n");
info.write("T" + amount + "\n");
info.write("P" + description +"\n");
info.write("L" + category + "\n");
info.write("^" + "\n");
}
}
// Close File
info.close();
}
catch (IOException e) {
System.out.println("A write error has occurred");
e.printStackTrace();
}
On Fri, 13 Mar 2020 at 15:21, David Carlson <david.carlson.417 at gmail.com>
wrote:
> Stu,
>
> I have been importing OFX files from my bank for years with three or four
> checking or savings accounts in one file, so I know GnuCash release 2.6.19
> can import OFX files with multiple accounts. It is possible but unlikely
> that GnuCash has lost that ability in recent releases. You may have
> something else happening in your case.
>
> On Fri, Mar 13, 2020 at 9:58 AM Stu Perlman <sgperlman at gmail.com> wrote:
>
> > Hello,
> >
> > I am using GNC on Windows 10. I have a fairly recent build, dated March
> 9
> > from the maintenance branch.
> >
> > I noticed that I'm still unable to use AqBanking to get OFX data from
> Citi
> > into GNC. I Did a little exploring and discovered that if I manipulate
> the
> > file in C:\tmp\ofx.log and break it into separate parts for each account
> > that was downloaded that GNC will import the data just fine if it's
> limited
> > to one account per file. I also believe, but I need to confirm that I
> can
> > leave all of the data in a single file but that I need to eliminate a lot
> > lines starting with the closing tags for the first account's response
> body
> > and up to and including the opening tags for the subsequent accounts'
> > response bodies.
> >
> > Has anyone else encountered this issue and if so, do you have any ideas
> how
> > to fix this? Is it a defect?
> >
> > Thanks in advance for your help.
> > _______________________________________________
> > gnucash-user mailing list
> > gnucash-user at gnucash.org
> > To update your subscription preferences or to unsubscribe:
> > https://lists.gnucash.org/mailman/listinfo/gnucash-user
> > If you are using Nabble or Gmane, please see
> > https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
> > -----
> > Please remember to CC this list on all your replies.
> > You can do this by using Reply-To-List or Reply-All.
> >
>
>
> --
> David Carlson
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> To update your subscription preferences or to unsubscribe:
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> If you are using Nabble or Gmane, please see
> https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.
>
More information about the gnucash-user
mailing list