codinguser / gnucash-android

Gnucash for Android mobile companion application.
Apache License 2.0
1.23k stars 539 forks source link

Gnucash 2.7 file not importing currencies #764

Closed stonewareslord closed 6 years ago

stonewareslord commented 6 years ago

Steps to reproduce the behaviour

  1. Open GnuCash 2.7.3
  2. Create a new book with currency USD some default accounts (or just open a 2.6 book and re-save it)
    • It's possible this also affects other currencies, but I only tested with USD
  3. Import the .gnucash into GnuCash-Android

Expected behaviour

  1. The accounts are imported with the USD currency

Actual behaviour

  1. Every account has currency type XXX, even if you change the Default Currency setting to USD before or after importing

Software specifications

Notes

I created two books with two GnuCash verions with default accounts and a couple transactions with USD currency and imported both into GnuCash-Android. The 2.6 version worked (imported as USD), and the 2.7 did not (imported as XXX).

If you run a diff (diff -Naur <(zcat 2.6.15-base.gnucash) <(zcat 2.7.3-base.gnucash)) on the files, you'll notice (aside from guid/date differences) <cmdty:space>ISO4217</cmdty:space> has been replaced with <cmdty:space>CURRENCY</cmdty:space>. I have attached the diff and both files.

It looks like 2.7.3 introduces breaking changes:

Their news page mentions these breaking changes on their Update Notes page, but I can't seem to access that page at the moment.

olmet commented 6 years ago

Under my system, the import does not work either. The same procedure. I tested with EUR.


GnuCash Android version: F-Droid 2.3.0 System Android version:6.0.1 LineageOS 13.0-20180305 Device type: Huawei MediapadX2, rooted GnuCash desktop version: Version: 3.0. Build ID: git 3.0+ (2018-04-01)

Oisins commented 6 years ago

Can also confirm:

stonewareslord commented 6 years ago

It seems that they replaced ISO4217 with CURRENCY.

All instances of ISO4217 in current master excluding .gnucash and .xml files:

./app/src/main/java/org/gnucash/android/db/DatabaseHelper.java:            + CommodityEntry.COLUMN_NAMESPACE   + " varchar(255) not null default " + Commodity.Namespace.ISO4217.name() + ", "
./app/src/main/java/org/gnucash/android/db/MigrationHelper.java:                    + CommodityEntry.COLUMN_NAMESPACE   + " varchar(255) not null default " + Commodity.Namespace.ISO4217.name() + ", "
./app/src/main/java/org/gnucash/android/db/adapter/CommoditiesDbAdapter.java:     * Returns the commodity associated with the ISO4217 currency code
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:    boolean mISO4217Currency    = false;
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:                mISO4217Currency = false;
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:                mISO4217Currency = false;
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:                mISO4217Currency = false;
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:                mISO4217Currency = false;
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:                if (characterString.equals("ISO4217")) {
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:                    mISO4217Currency = true;
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:                    // price of non-ISO4217 commodities cannot be handled
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:                String currencyCode = mISO4217Currency ? characterString : NO_CURRENCY_CODE;
./app/src/main/java/org/gnucash/android/importer/GncXmlHandler.java:                    mISO4217Currency = false;
./app/src/main/java/org/gnucash/android/model/Commodity.java: * At the moment only ISO4217 currencies are supported
./app/src/main/java/org/gnucash/android/model/Commodity.java:    public enum Namespace { ISO4217 } //Namespace for commodities
./app/src/main/java/org/gnucash/android/model/Commodity.java:    private Namespace mNamespace = Namespace.ISO4217;
./app/src/main/java/org/gnucash/android/model/Commodity.java:     * This is the currency code for ISO4217 currencies
./app/src/main/java/org/gnucash/android/model/Commodity.java:     * Returns the mnemonic, or currency code for ISO4217 currencies
xzfantom commented 6 years ago

There is one place in GncXmlHandler.java that influence import of new format for currency. I made some fixes in https://github.com/codinguser/gnucash-android/pull/779 and it seems like working for me and can import from new and old files.

codinguser commented 6 years ago

Fixed in develop via #779 Thanks @xzfantom