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 =
|
amount =
|
||||||
let al = pamount legacy
|
let al = pamount legacy
|
||||||
a1 = pamount posting1
|
a1 = pamount posting1
|
||||||
in if al == a1 then al
|
in
|
||||||
else if isZeroMixedAmount a1 then al
|
if al == a1 then al
|
||||||
else error' $ unlines [ "amount/amount-in/amount-out and amount1/amount1-in/amount1-out produced conflicting values"
|
else
|
||||||
, showRecord record
|
case (isZeroMixedAmount al, isZeroMixedAmount a1) of
|
||||||
, showRules rules record
|
(True, _) -> a1
|
||||||
, "amount/amount-in/amount-out is " ++ show al
|
(False, True) -> al
|
||||||
, "amount1/amount1-in/amount1-out is" ++ show a1
|
(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}
|
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"
|
(Nothing, Nothing) -> error' $ unlines [ "sadly, no posting was generated for account1"
|
||||||
, showRecord record
|
, showRecord record
|
||||||
|
|||||||
@ -311,22 +311,28 @@ $ ./hledger-csv
|
|||||||
|
|
||||||
>=0
|
>=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
|
RULES
|
||||||
|
fields date, time, timezone, description, type, status_, currency, grossamount, feeamount, netamount, fromemail, toemail, code, itemtitle, itemid, referencetxnid, receiptid, balance, note
|
||||||
fields account1, date, description, amount-in, amount-out
|
account1 sm:assets:online:paypal
|
||||||
date-format %d/%Y/%m
|
amount1 %netamount
|
||||||
|
account2 sm:expenses:unknown
|
||||||
|
account3 JS:expenses:banking:paypal
|
||||||
|
amount3 %feeamount
|
||||||
|
balance %18
|
||||||
|
code %13
|
||||||
currency $
|
currency $
|
||||||
if Flubber
|
date %1
|
||||||
account1 assets:%account1
|
date-format %m/%d/%Y
|
||||||
amount-in (%amount-in)
|
description %description for %itemtitle
|
||||||
$ ./hledger-csv
|
$ ./hledger-csv
|
||||||
2009/09/10 Flubber Co
|
2018/12/22 (123456789) Someone for Joyful Systems
|
||||||
assets:myacct $-50
|
sm:assets:online:paypal $9.41 = $57.60
|
||||||
income:unknown
|
sm:expenses:unknown
|
||||||
|
JS:expenses:banking:paypal $-0.59
|
||||||
|
|
||||||
>=0
|
>=0
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user