From 16c07c537b31c20551a58281ca54efbc6fdb6d0b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 15 Aug 2017 08:40:52 -0700 Subject: [PATCH] csv: also switch which posting is converted to cost After switching the postings, make sure it's the second which is converted to cost. --- hledger-lib/Hledger/Read/CsvReader.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hledger-lib/Hledger/Read/CsvReader.hs b/hledger-lib/Hledger/Read/CsvReader.hs index 63be7cfb7..3c23615c3 100644 --- a/hledger-lib/Hledger/Read/CsvReader.hs +++ b/hledger-lib/Hledger/Read/CsvReader.hs @@ -662,10 +662,10 @@ transactionFromCsvRecord sourcepos rules record = t ++"change your amount or currency rules, " ++"or "++maybe "add a" (const "change your") mskip++" skip rule" ] - -- Using costOfMixedAmount here to allow complex costs like "10 GBP @@ 15 USD". - -- Aim is to have "10 GBP @@ 15 USD" applied to account2, but have "-15USD" applied to account1 - amount1 = costOfMixedAmount amount - amount2 = (-amount) + amount1 = amount + -- convert balancing amount to cost like hledger print, so eg if + -- amount1 is "10 GBP @@ 15 USD", amount2 will be "-15 USD". + amount2 = costOfMixedAmount (-amount) s `or` def = if null s then def else s defaccount1 = fromMaybe "unknown" $ mdirective "default-account1" defaccount2 = case isNegativeMixedAmount amount2 of