csv, journal: debug output

The prolific "assignment" output is now at level 9.
This commit is contained in:
Simon Michael 2020-11-10 08:01:31 -08:00
parent a97daaf322
commit f43c7e41d1
2 changed files with 14 additions and 12 deletions

View File

@ -566,7 +566,7 @@ journalReverse j =
,jtxns = reverse $ jtxns j
,jtxnmodifiers = reverse $ jtxnmodifiers j
,jperiodictxns = reverse $ jperiodictxns j
,jpricedirectives = reverse $ jpricedirectives j
,jpricedirectives = reverse $ jpricedirectives j
}
-- | Set this journal's last read time, ie when its files were last read.
@ -982,14 +982,12 @@ journalCommodityStyles j =
-- "the format of the first amount, adjusted to the highest precision of all amounts".
-- Can return an error message eg if inconsistent number formats are found.
journalInferCommodityStyles :: Journal -> Either String Journal
journalInferCommodityStyles j =
journalInferCommodityStyles j =
case
commodityStylesFromAmounts $
dbg7 "journalInferCommodityStyles using amounts" $
journalStyleInfluencingAmounts j
commodityStylesFromAmounts $ journalStyleInfluencingAmounts j
of
Left e -> Left e
Right cs -> Right j{jinferredcommodities = cs}
Right cs -> Right j{jinferredcommodities = dbg7 "journalInferCommodityStyles" cs}
-- | Given a list of amounts, in parse order (roughly speaking; see journalStyleInfluencingAmounts),
-- build a map from their commodity names to standard commodity
@ -1119,7 +1117,9 @@ journalToCost j@Journal{jtxns=ts} = j{jtxns=map (transactionToCost styles) ts}
-- Transaction price amounts (posting amounts' aprice field) are not included.
--
journalStyleInfluencingAmounts :: Journal -> [Amount]
journalStyleInfluencingAmounts j = catMaybes $ concat [
journalStyleInfluencingAmounts j =
dbg7 "journalStyleInfluencingAmounts" $
catMaybes $ concat [
[mdefaultcommodityamt]
,map (Just . pdamount) $ jpricedirectives j
,map Just $ concatMap amounts $ map pamount $ journalPostings j

View File

@ -712,7 +712,7 @@ readJournalFromCsv mrulesfile csvfile csvdata =
else
return $ defaultRulesText rulesfile
rules <- either throwerr return $ parseAndValidateCsvRules rulesfile rulestext
dbg6IO "rules" rules
dbg6IO "csv rules" rules
-- parse the skip directive's value, if any
let skiplines = case getDirective "skip" rules of
@ -745,7 +745,7 @@ readJournalFromCsv mrulesfile csvfile csvdata =
let
-- convert CSV records to transactions
txns = snd $ mapAccumL
txns = dbg7 "csv txns" $ snd $ mapAccumL
(\pos r ->
let
SourcePos name line col = pos
@ -762,7 +762,9 @@ readJournalFromCsv mrulesfile csvfile csvdata =
-- than one date and the first date is more recent than the last):
-- reverse them to get same-date transactions ordered chronologically.
txns' =
(if newestfirst || mdataseemsnewestfirst == Just True then reverse else id) txns
(if newestfirst || mdataseemsnewestfirst == Just True
then dbg7 "reversed csv txns" . reverse else id)
txns
where
newestfirst = dbg6 "newestfirst" $ isJust $ getDirective "newest-first" rules
mdataseemsnewestfirst = dbg6 "mdataseemsnewestfirst" $
@ -770,7 +772,7 @@ readJournalFromCsv mrulesfile csvfile csvdata =
ds | length ds > 1 -> Just $ head ds > last ds
_ -> Nothing
-- Second, sort by date.
txns'' = sortBy (comparing tdate) txns'
txns'' = dbg7 "date-sorted csv txns" $ sortBy (comparing tdate) txns'
when (not rulesfileexists) $ do
dbg1IO "creating conversion rules file" rulesfile
@ -1190,7 +1192,7 @@ getEffectiveAssignment :: CsvRules -> CsvRecord -> HledgerFieldName -> Maybe Fie
getEffectiveAssignment rules record f = lastMay $ map snd $ assignments
where
-- all active assignments to field f, in order
assignments = dbg7 "assignments" $ filter ((==f).fst) $ toplevelassignments ++ conditionalassignments
assignments = dbg9 "csv assignments" $ filter ((==f).fst) $ toplevelassignments ++ conditionalassignments
where
-- all top level field assignments
toplevelassignments = rassignments rules