Skip to content

Commit

Permalink
Add clear function for t to null out balance for item
Browse files Browse the repository at this point in the history
  • Loading branch information
esensar committed May 7, 2024
1 parent 6170e78 commit a52c07b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions symlinks/bin/t
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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!"
Expand Down Expand Up @@ -257,6 +264,9 @@ case $COMMAND in
invoice)
time_invoice
;;
clear)
time_clear
;;
invoice_list)
time_invoice_list
;;
Expand Down
4 changes: 4 additions & 0 deletions symlinks/config/fish/completions/t.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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)'

0 comments on commit a52c07b

Please sign in to comment.