Skip to content

Commit

Permalink
Showing 'amount left to dish out' in loss view and xls dump
Browse files Browse the repository at this point in the history
  • Loading branch information
reinout committed Oct 9, 2024
1 parent fe96e40 commit 577f908
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
11 changes: 7 additions & 4 deletions trs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,15 @@ def overbooked_percentage(self):
return round(self.overbooked() / self.hour_budget() * 100)

def left_to_dish_out(self):
return self.total_income() - self.total_costs()

def budget_ok(self):
raw = self.total_income() - self.total_costs()
# Note: a little margin around zero is allowed to account for contract
# amounts not always being rounded.
return -1 < self.left_to_dish_out() < 1
if (-1 < raw < 1):
return 0
return raw

def budget_ok(self):
return not self.left_to_dish_out()

def budget_not_ok_style(self):
"""Return orange/red style depending on whether were above/below zero."""
Expand Down
11 changes: 6 additions & 5 deletions trs/templates/trs/projects_loss.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h1>
<th class="text-right">Budget-<br>overschijding</th>
<th class="text-right column-separator-right">Nog om te<br>zetten</th>
<th class="text-right">Reservering</th>
<th></th>
<th class="text-right">Nog te verdelen</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -88,10 +88,11 @@ <h1>

<td class="text-right">
{% if not line.project.budget_ok %}
<a href="{{ line.project.get_absolute_url }}#budget">
<span class="{{ view.project.budget_not_ok_style }} glyphicon glyphicon-warning-sign"
title="Budget is niet goed verdeeld: {{ line.project.left_to_dish_out }}"></span>
</a>
<span class="{{ view.project.budget_not_ok_style }} glyphicon glyphicon-warning-sign"
title="Budget is niet goed verdeeld"></span>
<a href="{{ line.project.get_absolute_url }}#budget">
{{ line.project.left_to_dish_out|money }}
</a>
{% endif %}
</td>

Expand Down
2 changes: 2 additions & 0 deletions trs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3042,6 +3042,7 @@ def has_form_permissions(self):
"Nog om te zetten",
"",
"Reservering",
"Nog te verdelen",
"",
"Opmerking",
"Financiele opmerking",
Expand Down Expand Up @@ -3101,6 +3102,7 @@ def excel_lines(self):
line["left_to_turn_over"],
"",
line["reservation"],
project.left_to_dish_out(),
"",
remark,
financial_remark,
Expand Down

0 comments on commit 577f908

Please sign in to comment.