web: make register item display a bit more consistent
This commit is contained in:
parent
c572addaa0
commit
918b3b45a5
@ -1,8 +1,8 @@
|
|||||||
<tr.item.#{evenodd}.#{firstposting}.#{datetransition}
|
<tr.item.#{evenodd}.#{firstposting}.#{datetransition}
|
||||||
<td.date>#{date}
|
<td.date>#{date}
|
||||||
<td.description title="#{show t}">#{elideRight 30 desc}
|
<td.description title="#{show t}">#{elideRight 30 desc}
|
||||||
<td.account>
|
<td.account title="#{show t}>
|
||||||
$if split
|
$if True
|
||||||
<a title="#{acct}"
|
<a title="#{acct}"
|
||||||
#{elideRight 40 acct}
|
#{elideRight 40 acct}
|
||||||
|
|
||||||
@ -14,8 +14,8 @@
|
|||||||
$if showamt
|
$if showamt
|
||||||
#{mixedAmountAsHtml amt}
|
#{mixedAmountAsHtml amt}
|
||||||
<td.balance align=right>#{mixedAmountAsHtml bal}
|
<td.balance align=right>#{mixedAmountAsHtml bal}
|
||||||
$if split
|
$if True
|
||||||
$forall p <- tpostings t'
|
$forall p <- tpostings t
|
||||||
<tr.item.#{evenodd}.posting.#{displayclass}
|
<tr.item.#{evenodd}.posting.#{displayclass}
|
||||||
<td.date
|
<td.date
|
||||||
<td.description
|
<td.description
|
||||||
|
|||||||
@ -183,7 +183,7 @@ journalRegisterReport :: [Opt] -> Journal -> Matcher -> AccountRegisterReport
|
|||||||
journalRegisterReport _ Journal{jtxns=ts} m = (totallabel, items)
|
journalRegisterReport _ Journal{jtxns=ts} m = (totallabel, items)
|
||||||
where
|
where
|
||||||
ts' = sortBy (comparing tdate) $ filter (not . null . tpostings) $ map (filterTransactionPostings m) ts
|
ts' = sortBy (comparing tdate) $ filter (not . null . tpostings) $ map (filterTransactionPostings m) ts
|
||||||
items = reverse $ accountRegisterReportItems m MatchNone nullmixedamt (+) ts'
|
items = reverse $ accountRegisterReportItems m MatchNone nullmixedamt id (+) ts'
|
||||||
|
|
||||||
-- | Get a conventional account register report, with the specified
|
-- | Get a conventional account register report, with the specified
|
||||||
-- options, for the currently focussed account (or possibly the focussed
|
-- options, for the currently focussed account (or possibly the focussed
|
||||||
@ -209,9 +209,9 @@ accountRegisterReport opts j m thisacctmatcher = (label, items)
|
|||||||
ts = sortBy (comparing tdate) $ filter (matchesTransaction thisacctmatcher) $ jtxns j
|
ts = sortBy (comparing tdate) $ filter (matchesTransaction thisacctmatcher) $ jtxns j
|
||||||
-- starting balance: if we are filtering by a start date and nothing else,
|
-- starting balance: if we are filtering by a start date and nothing else,
|
||||||
-- the sum of postings to this account before that date; otherwise zero.
|
-- the sum of postings to this account before that date; otherwise zero.
|
||||||
(startbal,label, sumfn) | matcherIsNull m = (nullmixedamt, balancelabel, (-))
|
(startbal,label, sumfn) | matcherIsNull m = (nullmixedamt, balancelabel, (+))
|
||||||
| matcherIsStartDateOnly effective m = (sumPostings priorps, balancelabel, (-))
|
| matcherIsStartDateOnly effective m = (sumPostings priorps, balancelabel, (+))
|
||||||
| otherwise = (nullmixedamt, totallabel, (+))
|
| otherwise = (nullmixedamt, totallabel, (-))
|
||||||
where
|
where
|
||||||
priorps = -- ltrace "priorps" $
|
priorps = -- ltrace "priorps" $
|
||||||
filter (matchesPosting
|
filter (matchesPosting
|
||||||
@ -221,14 +221,14 @@ accountRegisterReport opts j m thisacctmatcher = (label, items)
|
|||||||
tostartdatematcher = MatchDate True (DateSpan Nothing startdate)
|
tostartdatematcher = MatchDate True (DateSpan Nothing startdate)
|
||||||
startdate = matcherStartDate effective m
|
startdate = matcherStartDate effective m
|
||||||
effective = Effective `elem` opts
|
effective = Effective `elem` opts
|
||||||
items = reverse $ accountRegisterReportItems m thisacctmatcher startbal sumfn ts
|
items = reverse $ accountRegisterReportItems m thisacctmatcher startbal negate sumfn ts
|
||||||
|
|
||||||
-- | Generate account register line items from a list of transactions,
|
-- | Generate account register line items from a list of transactions,
|
||||||
-- using the provided query and "this account" matchers, starting balance,
|
-- using the provided query and "this account" matchers, starting balance,
|
||||||
-- and balance summing function.
|
-- sign-setting function and balance-summing function.
|
||||||
accountRegisterReportItems :: Matcher -> Matcher -> MixedAmount -> (MixedAmount -> MixedAmount -> MixedAmount) -> [Transaction] -> [AccountRegisterReportItem]
|
accountRegisterReportItems :: Matcher -> Matcher -> MixedAmount -> (MixedAmount -> MixedAmount) -> (MixedAmount -> MixedAmount -> MixedAmount) -> [Transaction] -> [AccountRegisterReportItem]
|
||||||
accountRegisterReportItems _ _ _ _ [] = []
|
accountRegisterReportItems _ _ _ _ _ [] = []
|
||||||
accountRegisterReportItems matcher thisacctmatcher bal sumfn (t:ts) =
|
accountRegisterReportItems matcher thisacctmatcher bal signfn sumfn (t:ts) =
|
||||||
case i of Just i' -> i':is
|
case i of Just i' -> i':is
|
||||||
Nothing -> is
|
Nothing -> is
|
||||||
where
|
where
|
||||||
@ -237,26 +237,29 @@ accountRegisterReportItems matcher thisacctmatcher bal sumfn (t:ts) =
|
|||||||
displaymatcher | numthisacctsposted > 1 = matcher
|
displaymatcher | numthisacctsposted > 1 = matcher
|
||||||
| otherwise = MatchAnd [negateMatcher thisacctmatcher, matcher]
|
| otherwise = MatchAnd [negateMatcher thisacctmatcher, matcher]
|
||||||
t'@Transaction{tpostings=ps'} = filterTransactionPostings displaymatcher t
|
t'@Transaction{tpostings=ps'} = filterTransactionPostings displaymatcher t
|
||||||
|
acct = summarisePostings $ tpostings t
|
||||||
(i,bal'') = case ps' of
|
(i,bal'') = case ps' of
|
||||||
[] -> (Nothing,bal) -- maybe a virtual transaction, or transfer to self
|
[] -> (Nothing,bal) -- maybe a virtual transaction, or transfer to self
|
||||||
[p] -> (Just (t, t', False, acct, amt, bal'), bal')
|
[p] -> (Just (t, t', False, acct, amt, bal'), bal')
|
||||||
where
|
where
|
||||||
acct = paccount p
|
amt = signfn $ pamount p
|
||||||
amt = pamount p
|
|
||||||
bal' = bal `sumfn` amt
|
bal' = bal `sumfn` amt
|
||||||
ps' -> (Just (t, t', True, acct, amt, bal'), bal')
|
ps'' -> (Just (t, t', True, acct, amt, bal'), bal')
|
||||||
where
|
where
|
||||||
-- describe split as from ..., to ... (not always right)
|
amt = signfn $ sum $ map pamount ps''
|
||||||
acct = case (simplify tos, simplify froms) of
|
bal' = bal `sumfn` amt
|
||||||
|
is = accountRegisterReportItems matcher thisacctmatcher bal'' signfn sumfn ts
|
||||||
|
|
||||||
|
-- | Generate a short readable summary of a transaction's postings.
|
||||||
|
summarisePostings ps =
|
||||||
|
case (simplify tos, simplify froms) of
|
||||||
([],ts) -> "to "++commafy ts
|
([],ts) -> "to "++commafy ts
|
||||||
(fs,[]) -> "from "++commafy fs
|
(fs,[]) -> "from "++commafy fs
|
||||||
(fs,ts) -> "to "++commafy ts++" from "++commafy fs
|
(fs,ts) -> "from "++commafy fs++" to "++commafy ts
|
||||||
where (tos,froms) = partition (fromMaybe False . isNegativeMixedAmount . pamount) ps'
|
where
|
||||||
|
(tos,froms) = partition (fromMaybe False . isNegativeMixedAmount . pamount) ps
|
||||||
simplify = nub . map (accountLeafName . paccount)
|
simplify = nub . map (accountLeafName . paccount)
|
||||||
commafy = intercalate ", "
|
commafy = intercalate ", "
|
||||||
amt = sum $ map pamount ps'
|
|
||||||
bal' = bal `sumfn` amt
|
|
||||||
is = accountRegisterReportItems matcher thisacctmatcher bal'' sumfn ts
|
|
||||||
|
|
||||||
filterTransactionPostings :: Matcher -> Transaction -> Transaction
|
filterTransactionPostings :: Matcher -> Transaction -> Transaction
|
||||||
filterTransactionPostings m t@Transaction{tpostings=ps} = t{tpostings=filter (m `matchesPosting`) ps}
|
filterTransactionPostings m t@Transaction{tpostings=ps} = t{tpostings=filter (m `matchesPosting`) ps}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user