From 577f90809bfc19b59c53df2b09f39f5c560948db Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Wed, 9 Oct 2024 18:03:14 +0200 Subject: [PATCH] Showing 'amount left to dish out' in loss view and xls dump --- trs/models.py | 11 +++++++---- trs/templates/trs/projects_loss.html | 11 ++++++----- trs/views.py | 2 ++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/trs/models.py b/trs/models.py index 2830e38..437d2fa 100644 --- a/trs/models.py +++ b/trs/models.py @@ -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.""" diff --git a/trs/templates/trs/projects_loss.html b/trs/templates/trs/projects_loss.html index 1c32887..c9d9e8c 100644 --- a/trs/templates/trs/projects_loss.html +++ b/trs/templates/trs/projects_loss.html @@ -45,7 +45,7 @@

Budget-
overschijding Nog om te
zetten Reservering - + Nog te verdelen @@ -88,10 +88,11 @@

{% if not line.project.budget_ok %} - - - + + + {{ line.project.left_to_dish_out|money }} + {% endif %} diff --git a/trs/views.py b/trs/views.py index f343742..df87ae4 100644 --- a/trs/views.py +++ b/trs/views.py @@ -3042,6 +3042,7 @@ def has_form_permissions(self): "Nog om te zetten", "", "Reservering", + "Nog te verdelen", "", "Opmerking", "Financiele opmerking", @@ -3101,6 +3102,7 @@ def excel_lines(self): line["left_to_turn_over"], "", line["reservation"], + project.left_to_dish_out(), "", remark, financial_remark,