Created attachment 373202 [details] This is a more general report on CSV export import Sections 1.1, 1.2 and 1.4.3 cover this bug If a transaction between accounts in two different currencies is created in GnuCash(V3.4) and is exported in multiline form and then is imported into a new blank book a spurious split is created. Original transaction, book currency is AUD Savings Account is AUD initial balance was 0.00 Savings USD is USD account initial balance 0.00 Transfer of $110 USD to Savings Account in AUD with exchange rate/price of 11/10 viewedfrom Savings Account Register: Debit Credit Asset:Current Assets:Saving Account 100 Asset:current Assets:Savings USD 100 viewed from Savings USD register Debit Credit Asset:Current Assets:Saving Account 110 Asset:current Assets:Savings USD 110 Exported CSV: Date,Transaction ID,Number,Description,Notes,Commodity/Currency,Void Reason,Action,Memo,Full Account Name,Account Name,Amount With Sym,Amount Num.,Reconcile,Reconcile Date,Rate/Price 15/11/18,b60da83af9b84334aa2f5e129c23016f,,Transfer with currency exchange,,CURRENCY::AUD,,,,Assets:Current Assets:Savings Account,Savings Account,$100.00,100.00,n,,1.00 ,,,,,,,,,Assets:Current Assets:Savings USD,Savings USD,-$110.00,-110.00,n,,10/11 After import using GnuCash Export Format and Multiline setting viewed from Savings Account Register: Debit Credit Asset:Current Assets:Saving Account 100 Asset:current Assets:Savings USD 1000 Asset:current Assets:Savings USD 1100 Balance after transaction $100 AUD viewed from Savings USD register (2 transactions are created inthis register) first transaction Debit Credit Asset:Current Assets:Saving Account 100 Asset:current Assets:Savings USD 1000 Asset:current Assets:Savings USD 110 Balance after this transaction is -110.00 USD second transaction Debit Credit Asset:Current Assets:Saving Account 100 Asset:current Assets:Savings USD 1000 Asset:current Assets:Savings USD 110 Balance after second transaction 890.00 USD
In developing the importer documentation, importing a currency transfer record as follows: 20/09/2016,a6fda7a9c1e34b1da03314bc61b22340,,Transfer of Funds from Singapore Saving account,,CURRENCY::AUD,,,,Assets:Current Assets:Checking Account,Checking Account,"$10,000.00","10,000.00",n,,1.00 ,,,,,,,,,Assets:Current Assets:Savings Account SGD,Savings Account SGD,"-S$9,440.20","-9,440.20",n,,1 + 2799/47201 previously exported from GnuCash would not import correctly. It appears to be related to the above and importing of price information as a rational number (1 + 2799/47201). The above record was imported with the difference between AUD10000 and SGD9440.20 assigned to an AUD Imbalance account rather than being recognized as a currency conversion.
Can also confirm that in the previous example converting the price information froma rational number to a decimal number will import correctlywhereas the rational number did not. Also tried selecting the Use trading accounts option when setting up the new file but this did not affect the price not importing correctly if it was a rational number.
What if it's a normal rational number, i.e. 50000/47201 instead of 1 + 2799/47201?
Comment 3 was a good clue. The price string was being converted to a GncNumeric using xaccParseAmount. However that function can't handle neither format ("x/y" or "a + b/c"). I have changed this to use GnuCash' expression parser and now both multi-split format examples are imported properly in my tests. The fix will appear in gnucash 3.9 (I asked our release manager to hold off the release for this fix :) I will however still keep this bug open as I need more time to verify all of the other points (like the single-split use case) in the attached document.