diff --git a/hledger-lib/Hledger/Read/CsvReader.hs b/hledger-lib/Hledger/Read/CsvReader.hs index 1291f44e4..9a7385171 100644 --- a/hledger-lib/Hledger/Read/CsvReader.hs +++ b/hledger-lib/Hledger/Read/CsvReader.hs @@ -880,16 +880,21 @@ getAmount rules record currency p1IsVirtual n = -- flip the sign and convert to cost, as they did before 1.17 , let a' = if f `elem` unnumberedfieldnames && n==2 then costOfMixedAmount (-a) else a ] - in case nonzeroamounts of + -- if there's "amount" and "amountN"s, just discard the former + nonzeroamounts' + | length nonzeroamounts > 1 = filter ((/="amount").fst) nonzeroamounts + | otherwise = nonzeroamounts + in case nonzeroamounts' of [] -> Nothing [(f,a)] | "-out" `isSuffixOf` f -> Just (-a) -- for -out fields, flip the sign [(_,a)] -> Just a fs -> error' $ "more than one non-zero amount for this record, please ensure just one\n" - ++ unlines [" " ++ padright 11 f ++ ": " ++ showMixedAmount a - ++ " from rule: " ++ fromMaybe "" (hledgerField rules record f) - | (f,a) <- fs] ++ " " ++ showRecord record ++ "\n" + ++ unlines [" rule: " ++ f ++ " " ++ + fromMaybe "" (hledgerField rules record f) ++ + " amount parsed: " ++ showMixedAmount a -- XXX not sure this is showing all the right info + | (f,a) <- fs] where -- | Given a non-empty amount string to parse, along with a possibly -- non-empty currency symbol to prepend, parse as a hledger amount (as diff --git a/hledger-lib/hledger_csv.m4.md b/hledger-lib/hledger_csv.m4.md index 4409b8560..9546af348 100644 --- a/hledger-lib/hledger_csv.m4.md +++ b/hledger-lib/hledger_csv.m4.md @@ -434,6 +434,7 @@ Also, for compatibility with hledger <1.17: `amount` or `amount-in`/`amount-out` with no number sets the amount for postings 1 and 2. For posting 2 the amount is negated, and converted to cost if there's a [transaction price](journal.html#transaction-prices). +But if any numbered `amountN`/`amountN-in`/`amountN-out` fields are present, `amount` is ignored. #### currency