From 7e8bd015036906eb456447ca3a9a545bd991fb6d Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 14 Nov 2022 20:00:01 -0500 Subject: hledger updates --- hledger-overview.hs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'hledger-overview.hs') diff --git a/hledger-overview.hs b/hledger-overview.hs index bdb807b..0c4bad7 100755 --- a/hledger-overview.hs +++ b/hledger-overview.hs @@ -51,6 +51,7 @@ janj = Just . AtNow . Just main = do let banner txt = Process.callProcess "figlet" ["-f", "small", txt ] + -- cur :: a -> Tagged a (cur, value_) <- getArgs >>= \case @@ -83,7 +84,9 @@ main = do let thisMonth = bal "^ex:me:want ^ex:..:need date:thismonth" sec "metrics" - row " in-ex" (Limit 0 $ bal "^in ^ex:me:want ^ex:..:need" / monthsSinceBeginning t) $ Just "keep this negative to make progress" + let balCategorize = bal "^ex:us:to-categorize" + row " attn" (Target 0 balCategorize) $ Just $ "todo: count number of to-categorize" + -- row " in-ex" (Limit 0 $ bal "^in ^ex:me:want ^ex:..:need" / monthsSinceBeginning t) $ Just "keep this negative to make progress" row " li:as" (Percent_ $ 100 * (- bal "^li") / bal "^as") Nothing -- let lastyear = 2020 -- row " in:net" (- getTotal j t (defreportopts {value_ = value_, period_ = YearPeriod 2020}) "^in:me") Nothing @@ -121,12 +124,14 @@ main = do row " nnext" (levelup 0.2) $ Just $ nextLevel 0.2 row " nnnext" (levelup 0.3) $ Just $ nextLevel 0.3 let satbal = getTotal j t (defreportopts {value_ = janj "sat"}) "^as cur:'BTC|sat|sats'" - row "real sats" satbal Nothing + row "real sats" (Target 450000000 satbal) Nothing --- | +-- | TODO: extend this to 'Tagged', not just 'Quantity'. data Metric - = Target Quantity Quantity - | Limit Quantity Quantity + = Target { expected :: Quantity, actual :: Quantity } + -- ^ actual should not be less than expected + | Limit { expected :: Quantity, actual :: Quantity } + -- ^ actual should not be more than expected -- | Tag displayable things so I can change how things print, e.g. add a percent -- sign, or some coloring, etc. @@ -186,6 +191,9 @@ instance Display Quantity where go (x : y : z : xs) = x : y : z : ',' : go xs go xs = xs +instance Display Int where + display d = chunk $ T.pack $ show d + sec :: String -> IO () sec label = putStrLn $ "\n=== " <> label <> " ===" -- cgit v1.2.3