mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-05 19:25:37 +03:00
;fix: bin: register-max: update/fix
This commit is contained in:
parent
49c4ccd0b7
commit
f847ef63e2
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env stack
|
#!/usr/bin/env stack
|
||||||
-- stack script --compile --resolver lts-20.13 --verbosity error --package hledger-lib --package hledger --package text --package safe
|
-- stack runghc
|
||||||
|
-- (requires hledger > 1.34)
|
||||||
|
-- -- stack script --compile --resolver nightly-2024-MM-DD --verbosity error --package hledger-lib --package hledger --package text --package safe
|
||||||
|
|
||||||
-- hledger-register-max - runs "hledger register" and prints the posting with largest running total/balance.
|
-- hledger-register-max - runs "hledger register" and prints the posting with largest running total/balance.
|
||||||
-- Usage:
|
-- Usage:
|
||||||
@ -25,9 +27,7 @@ import qualified "text" Data.Text as T
|
|||||||
import qualified Data.Text.IO as T
|
import qualified Data.Text.IO as T
|
||||||
import Safe
|
import Safe
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import Hledger
|
import Hledger.Cli.Script
|
||||||
import Hledger.Cli
|
|
||||||
import Hledger.Cli (argsToCliOpts)
|
|
||||||
|
|
||||||
-- XXX needs --help, see hledger-addon-example.hs
|
-- XXX needs --help, see hledger-addon-example.hs
|
||||||
|
|
||||||
@ -37,8 +37,9 @@ main = do
|
|||||||
withJournalDo opts $ \j -> do
|
withJournalDo opts $ \j -> do
|
||||||
let
|
let
|
||||||
r = postingsReport (reportspec_ opts) j
|
r = postingsReport (reportspec_ opts) j
|
||||||
maxbal = fifth5 $ maximumBy (comparing fifth5) r
|
getamt = pamount.fourth5
|
||||||
is = filter ((== maxbal).fifth5) r
|
maxbal = getamt $ maximumBy (comparing getamt) r
|
||||||
|
is = filter ((== maxbal).getamt) r
|
||||||
mapM_ printItem is
|
mapM_ printItem is
|
||||||
|
|
||||||
printItem (_, _, _, p, bal) = do
|
printItem (_, _, _, p, bal) = do
|
||||||
|
Loading…
Reference in New Issue
Block a user