Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import. gnucash file #158

Open
MadFisa opened this issue Jun 21, 2024 · 17 comments
Open

Unable to import. gnucash file #158

MadFisa opened this issue Jun 21, 2024 · 17 comments
Labels
area/dataports import, export, backup

Comments

@MadFisa
Copy link

MadFisa commented Jun 21, 2024

Steps to reproduce the behaviour

  1. Open gnucass
  2. Tap on 3 lines to expand menu
  3. Tap on open and choose .gnucash file generated by desktop gnucash application

Expected behaviour

GnuCash accounts on pc is successfully imported

Actual behaviour

A message popup with message
"An error occurred while importing gnucash accoimts".
No further information is show regarding the nature of error.

Software specifications

  • GnuCash Android version: 2.5.1
  • System Android version: 14
  • Device type: Motorola edge 40

Suggested Resolution

I don't have enough knowledge, but could it be due to some kind of lock on file by desktop gnucash?? Sometimes desktop application shows the file has not been properly closed by previous instance or something and suggest to open as read only. You can still force to open it and continue to use without any problems.

@djbrown djbrown added the area/dataports import, export, backup label Jun 28, 2024
@arunkd13
Copy link

arunkd13 commented Jul 3, 2024

I am also facing similar problem. When I try to open the .gnucash file created with Gnucash for desktop, Gnucash Pocket just stays in the importing popup. It never completes. When I tap anywhere on the screen the popup just disappears, without any error message.

  • Gnucash Android version: 2.5.1
  • Android version: 13 (Go edition)
  • Device type: Redmi A2
  • Gnucash Desktop version: 4.13 (Debian 12)

@arunkd13
Copy link

arunkd13 commented Jul 3, 2024

I just found that, the gnucash file format I had for the desktop was gzipped XML file. I switched to SQLite3 backend and this file fails with the message "An error occurred while opening the GnuCash accounts", as mentioned in this issue.

@Kaligula0
Copy link
Collaborator

did you try to use not gzipped XML file?

@MadFisa
Copy link
Author

MadFisa commented Jul 3, 2024

@Kaligula0 I'm not using a gzipped version, just a plain old .gnucash file.

Is there a way to debug this further through adb or something? I'm ready to dig around figure out what is causing this, but I have no experience with android apps.
Currently only information on failure to read is just a pop up saying "An error occured while opening the GnuCash accounts", which is not much.

@MadFisa
Copy link
Author

MadFisa commented Jul 3, 2024

Just an update, I have set up android studio and is able to build the app and run it. How to proceed further?

@MadFisa
Copy link
Author

MadFisa commented Jul 3, 2024

@djbrown @Kaligula0 So I managed to get the logs, Turns out the problem is probably caused by the custom commodities that I made. Not sure what is the cause though. I am attaching the log file.

log.txt

@djbrown
Copy link

djbrown commented Jul 3, 2024

Thank you for providing the log.
The following errors remind me of #156:

D  Start import
I  Creating database tables
I  Bulk adding 224 Commodity records to the database
E  Commodity not found in the database: ASIANPAINT
E  Commodity not found in the database: HDFC_MIDC_OPPO_UP4UI9
E  Commodity not found in the database: ICIC_PRU_TECH_1027WGP
E  Commodity not found in the database: NIPP_INDI_LARG_COGPO7
E  Commodity not found in the database: NIPP_INDI_SMAL_1AOBL3E
E  Commodity not found in the database: PGIM_INDI_ELSS_156PSD9
E  Commodity not found in the database: template
E  Commodity not found in the database: QUAN_ELSS_TAX_KBGFAS

And the following exception comes from here:

* @throws CurrencyMismatchException if the `Money` objects to be added have different Currencies
*/
@Throws(CurrencyMismatchException::class)
operator fun minus(subtrahend: Money): Money {
if (commodity != subtrahend.commodity) throw CurrencyMismatchException()

Error importing: content://com.android.providers.downloads.documents/document/3881
org.gnucash.android.model.Money$CurrencyMismatchException: Cannot perform operation on Money instances with different currencies
	at org.gnucash.android.model.Money.minus(Money.kt:324)
	at org.gnucash.android.model.Transaction.getImbalance(Transaction.kt:239)
	at org.gnucash.android.model.Transaction.createAutoBalanceSplit(Transaction.kt:130)
	at org.gnucash.android.importer.GncXmlHandler.endElement(GncXmlHandler.java:680)
	at org.apache.harmony.xml.ExpatParser.endElement(ExpatParser.java:167)
	at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
	at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:526)
	at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:487)
	at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:324)
	at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:287)
	at org.gnucash.android.importer.GncXmlImporter.parse(GncXmlImporter.java:70)
	at org.gnucash.android.importer.ImportAsyncTask.doInBackground(ImportAsyncTask.java:84)
	at org.gnucash.android.importer.ImportAsyncTask.doInBackground(ImportAsyncTask.java:44)
	at android.os.AsyncTask$3.call(AsyncTask.java:394)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)

@MadFisa can you give minimum steps to reproduce the problem from scratch, or even better provide an automated unit or instrumentation-test?
also @pnemonic78 could you look into this?

@pnemonic78
Copy link
Collaborator

pnemonic78 commented Jul 3, 2024 via email

@MadFisa
Copy link
Author

MadFisa commented Jul 27, 2024

Hi,
@pnemonic78 @djbrown sorry for the late reply. I'm not a developer by trade, so I don't know how to setup automated tests.

I'm happy to share the file, I have uploaded the file in the following link.

https://drive.google.com/file/d/11iNqXt07zR0r_N7Fk8774r9D1dR5cgLb/view?usp=sharing

Let me know when you try to access the file. I will have to accept the request.

My laptop is fried, so I'm unable to reproduce the situation for now.
But broadly, it will involve

  1. Adding entries into security editor (say for a mutual fund or stock) with source "google web, US stocks",
  2. fetch the prices in price database using "Get Quotes" button.
  3. Then create an account with the commodity as aforementioned mutual fund or stock.
  4. Create a transaction in the account.

@MadFisa
Copy link
Author

MadFisa commented Jul 28, 2024

@pnemonic78 I believe I recieved your request for access. You should be able to download the file now.

@pnemonic78
Copy link
Collaborator

examples of problematic ocmmodities in the gnucash file:

<gnc:commodity version="2.0.0">
  <cmdty:space>Indian</cmdty:space>
  <cmdty:id>ASIANPAINT</cmdty:id>
  <cmdty:name>ASIANPAINT</cmdty:name>
  <cmdty:xcode>INE021A01026</cmdty:xcode>
  <cmdty:fraction>10000</cmdty:fraction>
  <cmdty:get_quotes/>
  <cmdty:quote_source>nseindia</cmdty:quote_source>
  <cmdty:quote_tz/>
  <cmdty:slots>
    <slot>
      <slot:key>user_symbol</slot:key>
      <slot:value type="string">ASIANPAINT</slot:value>
    </slot>
  </cmdty:slots>
</gnc:commodity>
<gnc:commodity version="2.0.0">
  <cmdty:space>MF</cmdty:space>
  <cmdty:id>HDFC_MIDC_OPPO_UP4UI9</cmdty:id>
  <cmdty:name>HDFC Mid-Cap Opportunities Fund -Direct Plan - Growth Option</cmdty:name>
  <cmdty:fraction>10000</cmdty:fraction>
  <cmdty:get_quotes/>
  <cmdty:quote_source>googleweb</cmdty:quote_source>
  <cmdty:quote_tz/>
</gnc:commodity>

@fisian
Copy link

fisian commented Aug 3, 2024

I had a similar problem with the import of GnuCash files from desktop, but could fix it like this:
I am using GnuCash Pocket on Android with version 2.5.2.
I exported the file to GnuCash XML and opened it with GnuCash desktop.
I noticed that the accounts for funds had their commodity changed to the currency "XXX (No currency)".
(This must have already happened earlier when importing/exporting between Android and desktop, but I'm not sure.)
To fix it using desktop, I could not change the commodity of the existing accounts, but had to recreate the accounts with the correct commodity and delete the other ones.
Additionally, I had to delete all entries in the price database that referenced the old corrupted currency "XXX (No currency)".
After these changes the files could be imported into GnuCash Pocket again.

Thank you for your work 👍

@bdmartens
Copy link

I also have had errors importing my GnuCash desktop accounts into GnuCash Pocket. I have tried both exported csv accounts (habit, from the GnucashMobile app I was using previously and an exported .XML file. "An error occurred when importing the GnuCash acco..."

The XML file was obtained in the Desktop application via: File>Export>Export,
Data Format: XML

I used the .gnucash extension, as well as a renamed .XML extension.

The CSV file was obtained via File>Export>Export Account Tree to CSV
(& this version worked in GnuCash Mobile)

I have enabled crash logging. I am not sure where to find this log, despite looking broadly, including:
\Android\data\org.gnucash.pocket.pnemonic - no log files in here or the subdirectories
\Documents\GnuCash - not sure this location is from Pocket GnuCash

I do see a lot of 'backup' gz files in:
This PC\Ben's Galaxy S21+ 5G\Internal storage\Android\data\org.gnucash.pocket.pnemonic\files[hash]\backups

  • they seem to correspond to each time I tried to import the accounts. They are small (608-611 bytes), and when opened only contain a folder and no actual contents.
    Is there a better way of getting contents into Pocket GnuCash? Is anyone able to point me to the location of the log file, to be able to better identify the issue?
    Thanks

@Kaligula0
Copy link
Collaborator

Kaligula0 commented Oct 31, 2024

So this is the same problem as reported in #34 ?

@bdmartens
Copy link

I don't see the similarity between 'unable to import .gnucash file' and 'non-currency assets are displayed as "XXX"'. Is this the issue you meant to reference?

@Kaligula0
Copy link
Collaborator

Kaligula0 commented Nov 1, 2024

@bdmartens Yes I think they're connected. djbrown and pneumonic78 found that the issue is caused by custom commodities. fisian noted that their currency becomes XXX.

@MadFisa
Copy link
Author

MadFisa commented Nov 27, 2024

@pnemonic78 I'm able to import with newer versions of the app without any issues and custom commodities are imported successfully.
I think we can close this issue now if you think it's been fully fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dataports import, export, backup
Projects
None yet
Development

No branches or pull requests

7 participants