yet another ledger add script
This commit is contained in:
parent
5ddd6b0195
commit
9d8be38b92
30
local/bin/iadd
Executable file
30
local/bin/iadd
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
tmp="$(mktemp)"
|
||||
trap "rm -f $tmp" EXIT KILL
|
||||
|
||||
add_file="${1:-${LEDGER_ADD_FILE:-$LEDGER_FILE}}"
|
||||
|
||||
description="$(hledger descriptions | sk -p 'description> ')" || exit
|
||||
date="$(for d in $(seq -7 0); do date --iso -d "$d days"; done | sk -p 'date> ' --no-sort --tac)"
|
||||
printf '\n%s %s\n' "$date" "$description" > "$tmp"
|
||||
diff="0.00"
|
||||
while account="$(hledger accounts desc:"$description" | sk -p "account ($diff)> " )"; do
|
||||
echo "$account"
|
||||
read -p "price ($diff): " price
|
||||
read -p 'comment: ' comment
|
||||
if [ -n "$comment" ]; then
|
||||
printf ' %-56s%10s ; %s\n' "$account" "€$price" "$comment" >> "$tmp"
|
||||
else
|
||||
printf ' %-56s%10s\n' "$account" "€$price" >> "$tmp"
|
||||
fi
|
||||
diff="$(printf '(%s) - (%s)\n' "$diff" "$price" | bc)"
|
||||
done
|
||||
|
||||
cat "$tmp" >> "$add_file"
|
||||
|
||||
# review change: open end of the file (if I know how)
|
||||
case "$EDITOR" in
|
||||
vi*|nvi*) "$EDITOR" +\$ "$add_file" ;;
|
||||
emacs) "$EDITOR" "$add_file" -f end-of-buffer ;;
|
||||
*) "$EDITOR" "$add_file" ;;
|
||||
esac
|
1
yashrc
1
yashrc
@ -82,6 +82,7 @@ alias agenda="khal list today 7d"
|
||||
# Ledger
|
||||
alias haccounts="hledger -I --alias '/.*:Accounts [^:]*:(.*)/=Accounts:\1' bal accounts"
|
||||
alias ladd='ladd -a /data/documents/ledger/2021/main.journal /data/documents/ledger/*/main.journal'
|
||||
alias iadd='iadd /data/documents/ledger/2021/main.journal'
|
||||
alias is='hledger is -b $(date -d "7 months ago" +%Y-%m) -e $(date +%Y-%m) -MTA --tree -2'
|
||||
alias cf='hledger cf -b $(date -d "7 months ago" +%Y-%m) -e $(date +%Y-%m) -MTA --tree -2'
|
||||
alias bs='hledger bs not:accounts'
|
||||
|
Loading…
Reference in New Issue
Block a user