Skip to content

Commit

Permalink
Support zero amounts and priority with finance update
Browse files Browse the repository at this point in the history
The finance update command checks whether a parameter has been passed
and only updates the value if it has. With the previous implementation
an existence check is made. This masks out None values, but also masks
out zero values. In order to support zero values, an explicit check for
None is needed.

This changes the check in this way to allow for a zero amount or zero
priority to be passed as a parameter.
  • Loading branch information
llewelld committed Dec 16, 2024
1 parent 1980548 commit acfa3b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rctab_cli/sub_apps/sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,14 @@ def finance_update(
date_to_date = date(date_to_date.year, date_to_date.month, month_range[1])
new_finance["date_to"] = date_to_date.isoformat()

new_finance["amount"] = amount if amount else old_finance["amount"]
new_finance["amount"] = amount if amount is not None else old_finance["amount"]
new_finance["finance_code"] = (
finance_code if finance_code else old_finance["finance_code"]
)
new_finance["ticket"] = ticket if ticket else old_finance["ticket"]
new_finance["priority"] = priority if priority else old_finance["priority"]
new_finance["priority"] = (
priority if priority is not None else old_finance["priority"]
)

if new_finance == old_finance:
typer.echo("Finance records identical. Taking no action.")
Expand Down

0 comments on commit acfa3b2

Please sign in to comment.