diff options
-rwxr-xr-x | hledger-fadd | 13 | ||||
-rwxr-xr-x | hledger-overview.hs | 18 |
2 files changed, 18 insertions, 13 deletions
diff --git a/hledger-fadd b/hledger-fadd index be713e4..36e762a 100755 --- a/hledger-fadd +++ b/hledger-fadd @@ -16,9 +16,8 @@ function fz { fi } -# cache accounts for speed -accounts=$(mktemp) -hledger accounts > $accounts & +accounts=$(cache hledger accounts) +payees=$(cache hledger payees) date=$(for n in $(seq 0 31); do date -d"$n days ago" "+%Y/%m/%d (%a)"; done \ | fzf --height 50% --reverse --delimiter '/' \ @@ -29,7 +28,7 @@ date=$(for n in $(seq 0 31); do date -d"$n days ago" "+%Y/%m/%d (%a)"; done \ ) echo "date: $date" -payee=$(hledger payees | fz --prompt="payee: " --preview='hledger print payee:{..}') +payee=$(fz --prompt="payee: " --preview='hledger print payee:{..}' <<< $payees) echo "payee: $payee" # store past txs in a file, in the background, so I don't have to wait for the @@ -38,13 +37,11 @@ past_txs=$(mktemp) hledger print payee:"$payee" > $past_txs & read -rep "to amount: " to_amount -to_account=$(cat $accounts \ - | fz --prompt="to account: " --preview="cat $past_txs") +to_account=$(fz --prompt="to account: " --preview="cat $past_txs" <<< $accounts) echo "to account: $to_account" -from_account=$(cat $accounts \ - | fz --prompt="from account: " --preview="cat $past_txs") +from_account=$(fz --prompt="from account: " --preview="cat $past_txs" <<< $accounts) echo "from account: $from_account" read -rep "from amount: " -i "-$to_amount" from_amount 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 --- | <type> <expected> <actual> +-- | 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 <> " ===" |