Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Add current totals to floating and investment SU table output
Browse files Browse the repository at this point in the history
  • Loading branch information
Comeani committed Mar 4, 2024
1 parent 4c78766 commit 2f13cd5
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions bank/account_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,28 +792,33 @@ def _build_usage_table(self) -> PrettyTable:
usage_percentage = self._calculate_percentage(aggregate_usage_total, allocation_total)

floating_su_percent = self._calculate_percentage(floating_su_usage, floating_su_total)
output_table.add_row(['Floating SUs', "SUs Remaining", "% Used"], divider=True)
output_table.add_row([f'*Floating SUs', "", ""])
output_table.add_row([f'are applied on', "", ""])
output_table.add_row([f'any cluster to', str(floating_su_remaining)+'*', floating_su_percent])
output_table.add_row([f'cover usage above', "", ""])
output_table.add_row([f'Total SUs', "", ""], divider=True)
output_table.add_row(["Floating SUs", "", ""], divider=True)
output_table.add_row(["Floating SUs", "", ""])
output_table.add_row(["are applied on", "", ""])
output_table.add_row(["any cluster to", "", ""])
output_table.add_row(["cover usage above", "", ""])
output_table.add_row(["Total Proposal SUs", "", ""])
output_table.add_row(["Total", "SUs Remaining", "% Used"])
output_table.add_row([floating_su_total, floating_su_remaining, floating_su_percent], divider=True)

# Add another inner table describing aggregate usage
if not investments:
output_table.add_row(['Aggregate Usage', usage_percentage, ""], divider=True)
else:
investment_total = sum(inv.service_units for inv in investments)
investment_remaining = sum(inv.current_sus for inv in investments)
investment_remaining = sum(inv.current_sus for inv in investments)
investment_used = investment_total - investment_remaining
investment_percentage = self._calculate_percentage(investment_used, investment_total)

output_table.add_row(['Investment SUs', "SUs Remaining", "% Used"], divider=True)
output_table.add_row([f'**Investment SUs', "",""])
output_table.add_row([f'are applied on', "", ""])
output_table.add_row([f'any cluster to', str(investment_remaining)+"**", investment_percentage])
output_table.add_row([f'cover usage above',"",""])
output_table.add_row([f'Total SUs', "", ""], divider=True)
output_table.add_row(["Investment SUs", "SUs Remaining", "% Used"], divider=True)
output_table.add_row(["Investment SUs", "", ""])
output_table.add_row(["are applied on", "", ""])
output_table.add_row(["any cluster to", "", ""])
output_table.add_row(["cover usage above", "", ""])
output_table.add_row(["Total Proposal SUs", "", ""])
output_table.add_row(["Total", "SUs Remaining", "% Used"])
output_table.add_row([investment_total, investment_remaining, investment_percentage])

output_table.add_row(['Aggregate Usage', usage_percentage, ""])
output_table.add_row(['(no investments)', "", ""])

Expand Down

0 comments on commit 2f13cd5

Please sign in to comment.