csv: also switch which posting is converted to cost

After switching the postings, make sure it's the second which is converted
to cost.
This commit is contained in:
Simon Michael 2017-08-15 08:40:52 -07:00
parent 501634d2e9
commit 16c07c537b

View File

@ -662,10 +662,10 @@ transactionFromCsvRecord sourcepos rules record = t
++"change your amount or currency rules, " ++"change your amount or currency rules, "
++"or "++maybe "add a" (const "change your") mskip++" skip rule" ++"or "++maybe "add a" (const "change your") mskip++" skip rule"
] ]
-- Using costOfMixedAmount here to allow complex costs like "10 GBP @@ 15 USD". amount1 = amount
-- Aim is to have "10 GBP @@ 15 USD" applied to account2, but have "-15USD" applied to account1 -- convert balancing amount to cost like hledger print, so eg if
amount1 = costOfMixedAmount amount -- amount1 is "10 GBP @@ 15 USD", amount2 will be "-15 USD".
amount2 = (-amount) amount2 = costOfMixedAmount (-amount)
s `or` def = if null s then def else s s `or` def = if null s then def else s
defaccount1 = fromMaybe "unknown" $ mdirective "default-account1" defaccount1 = fromMaybe "unknown" $ mdirective "default-account1"
defaccount2 = case isNegativeMixedAmount amount2 of defaccount2 = case isNegativeMixedAmount amount2 of