diff --git a/hledger-lib/Hledger/Data/Types.hs b/hledger-lib/Hledger/Data/Types.hs index 332fc5f75..c58a9e46c 100644 --- a/hledger-lib/Hledger/Data/Types.hs +++ b/hledger-lib/Hledger/Data/Types.hs @@ -552,7 +552,8 @@ data TimeclockEntry = TimeclockEntry { -- It declares two things: a historical exchange rate between two commodities, -- and an amount display style for the second commodity. data PriceDirective = PriceDirective { - pddate :: Day + pdsourcepos :: SourcePos + ,pddate :: Day ,pdcommodity :: CommoditySymbol ,pdamount :: Amount } deriving (Eq,Ord,Generic,Show) diff --git a/hledger-lib/Hledger/Data/Valuation.hs b/hledger-lib/Hledger/Data/Valuation.hs index 03f5cfb39..2827b1baf 100644 --- a/hledger-lib/Hledger/Data/Valuation.hs +++ b/hledger-lib/Hledger/Data/Valuation.hs @@ -119,7 +119,7 @@ amountPriceDirectiveFromCost d amt@Amount{acommodity=fromcomm, aquantity=n} = ca where u = amountSetFullPrecisionUpTo Nothing $ divideAmount n t _ -> Nothing where - pd = PriceDirective{pddate = d, pdcommodity = fromcomm, pdamount = nullamt} + pd = PriceDirective{pdsourcepos=nullsourcepos, pddate=d, pdcommodity=fromcomm, pdamount=nullamt} ------------------------------------------------------------------------------ -- Converting things to value diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index 905e80c13..5718501ab 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -671,6 +671,7 @@ defaultcommoditydirectivep = do marketpricedirectivep :: JournalParser m PriceDirective marketpricedirectivep = do + pos <- getSourcePos char 'P' "market price" lift skipNonNewlineSpaces date <- try (do {LocalTime d _ <- datetimep; return d}) <|> datep -- a time is ignored @@ -679,7 +680,7 @@ marketpricedirectivep = do lift skipNonNewlineSpaces price <- amountp lift restofline - return $ PriceDirective date symbol price + return $ PriceDirective pos date symbol price ignoredpricecommoditydirectivep :: JournalParser m () ignoredpricecommoditydirectivep = do @@ -1145,6 +1146,7 @@ tests_JournalReader = testGroup "JournalReader" [ ,testCase "marketpricedirectivep" $ assertParseEq marketpricedirectivep "P 2017/01/30 BTC $922.83\n" PriceDirective{ + pdsourcepos = nullsourcepos, pddate = fromGregorian 2017 1 30, pdcommodity = "BTC", pdamount = usd 922.83