lib: fixed amount vs amount1 conflict detection in csv parser
This commit is contained in:
parent
f40d045251
commit
825b9ce5b3
@ -782,14 +782,19 @@ transactionFromCsvRecord sourcepos rules record = t
|
||||
amount =
|
||||
let al = pamount legacy
|
||||
a1 = pamount posting1
|
||||
in if al == a1 then al
|
||||
else if isZeroMixedAmount a1 then al
|
||||
else error' $ unlines [ "amount/amount-in/amount-out and amount1/amount1-in/amount1-out produced conflicting values"
|
||||
, showRecord record
|
||||
, showRules rules record
|
||||
, "amount/amount-in/amount-out is " ++ show al
|
||||
, "amount1/amount1-in/amount1-out is" ++ show a1
|
||||
]
|
||||
in
|
||||
if al == a1 then al
|
||||
else
|
||||
case (isZeroMixedAmount al, isZeroMixedAmount a1) of
|
||||
(True, _) -> a1
|
||||
(False, True) -> al
|
||||
(False, False) ->
|
||||
error' $ unlines [ "amount/amount-in/amount-out and amount1/amount1-in/amount1-out produced conflicting values"
|
||||
, showRecord record
|
||||
, showRules rules record
|
||||
, "amount/amount-in/amount-out is " ++ showMixedAmount al
|
||||
, "amount1/amount1-in/amount1-out is " ++ showMixedAmount a1
|
||||
]
|
||||
in posting {paccount=paccount posting1, pamount=amount, ptransaction=Just t, pbalanceassertion=balanceassertion, pcomment = pcomment posting1}
|
||||
(Nothing, Nothing) -> error' $ unlines [ "sadly, no posting was generated for account1"
|
||||
, showRecord record
|
||||
|
||||
@ -311,22 +311,28 @@ $ ./hledger-csv
|
||||
|
||||
>=0
|
||||
|
||||
# 16. use a script for cleaner csv tests?
|
||||
# 16. Real life-ish paypal parsing example
|
||||
<
|
||||
myacct,10/2009/09,Flubber Co,50,
|
||||
"12/22/2018","06:22:50","PST","Someone","Subscription Payment","Completed","USD","10.00","-0.59","9.41","someone@some.where","simon@joyful.com","123456789","Joyful Systems","","9KCXZZZZZXXAX","","57.60",""
|
||||
|
||||
RULES
|
||||
|
||||
fields account1, date, description, amount-in, amount-out
|
||||
date-format %d/%Y/%m
|
||||
fields date, time, timezone, description, type, status_, currency, grossamount, feeamount, netamount, fromemail, toemail, code, itemtitle, itemid, referencetxnid, receiptid, balance, note
|
||||
account1 sm:assets:online:paypal
|
||||
amount1 %netamount
|
||||
account2 sm:expenses:unknown
|
||||
account3 JS:expenses:banking:paypal
|
||||
amount3 %feeamount
|
||||
balance %18
|
||||
code %13
|
||||
currency $
|
||||
if Flubber
|
||||
account1 assets:%account1
|
||||
amount-in (%amount-in)
|
||||
date %1
|
||||
date-format %m/%d/%Y
|
||||
description %description for %itemtitle
|
||||
$ ./hledger-csv
|
||||
2009/09/10 Flubber Co
|
||||
assets:myacct $-50
|
||||
income:unknown
|
||||
2018/12/22 (123456789) Someone for Joyful Systems
|
||||
sm:assets:online:paypal $9.41 = $57.60
|
||||
sm:expenses:unknown
|
||||
JS:expenses:banking:paypal $-0.59
|
||||
|
||||
>=0
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user