From a52c07bb9d1b4364558491e102e571af483f4d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Tue, 7 May 2024 15:35:41 +0200 Subject: [PATCH] Add clear function for t to null out balance for item --- symlinks/bin/t | 10 ++++++++++ symlinks/config/fish/completions/t.fish | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/symlinks/bin/t b/symlinks/bin/t index 9881907..70111c6 100755 --- a/symlinks/bin/t +++ b/symlinks/bin/t @@ -25,6 +25,7 @@ usage () { echo " toggle - toggle current timer" echo " bal - outputs current timesheet" echo " invoice - generate an invoice from account balance" + echo " clear - clear time for account and comment" echo " invoice_list - generate data for an invoice from account balance" echo " waybar - generate output for waybar module" echo "" @@ -219,6 +220,12 @@ time_invoice () { echo "Please review it and use pdflatex to generate it!" } +time_clear () { + echo "" >> "$TIMESHEET_LEDGER_HOME/invoices/$(date +%Y).journal" + echo "$(date '+%Y-%m-%d') * $COMMENT" >> "$TIMESHEET_LEDGER_HOME/invoices/$(date +%Y).journal" + echo " ($PROJECT) -$(ledger -f "$TIMESHEET_LEDGER_HOME/main.journal" bal $PROJECT and @"$COMMENT" --format "%(total)")" >> "$TIMESHEET_LEDGER_HOME/invoices/$(date +%Y).journal" +} + time_invoice_list () { if [ -z "$PROJECT" ]; then echo "Project is required!" @@ -257,6 +264,9 @@ case $COMMAND in invoice) time_invoice ;; + clear) + time_clear + ;; invoice_list) time_invoice_list ;; diff --git a/symlinks/config/fish/completions/t.fish b/symlinks/config/fish/completions/t.fish index 777ea50..5e3605f 100644 --- a/symlinks/config/fish/completions/t.fish +++ b/symlinks/config/fish/completions/t.fish @@ -39,5 +39,9 @@ complete -c t -x -n "__fish_seen_subcommand_from bal" -a '(__fish-timesheets-ava complete -c t -x -n "__fish_seen_subcommand_from invoice" -n "__fish_timesheets_arg_number 2" -a '(__fish-timesheets-available-projects)' complete -c t -x -n "__fish_seen_subcommand_from invoice" -n "__fish_timesheets_arg_number 3" -a '(__fish-timesheets-existing-comments)' +# clear +complete -c t -x -n "__fish_seen_subcommand_from clear" -n "__fish_timesheets_arg_number 2" -a '(__fish-timesheets-available-projects)' +complete -c t -x -n "__fish_seen_subcommand_from clear" -n "__fish_timesheets_arg_number 3" -a '(__fish-timesheets-existing-comments)' + # Invoice list complete -c t -x -n "__fish_seen_subcommand_from invoice_list" -a '(__fish-timesheets-available-projects)'