summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar/ishtar_base/models.py18
-rw-r--r--ishtar/templates/sheet_operation.html4
2 files changed, 20 insertions, 2 deletions
diff --git a/ishtar/ishtar_base/models.py b/ishtar/ishtar_base/models.py
index 1e9cf9b21..42b79f163 100644
--- a/ishtar/ishtar_base/models.py
+++ b/ishtar/ishtar_base/models.py
@@ -685,6 +685,24 @@ class Operation(BaseHistorizedItem, OwnPerms):
def is_own(self, person):
return False
+
+ @property
+ def surface_ha(self):
+ if self.surface:
+ return self.surface/10000.0
+
+ @property
+ def cost_by_m2(self):
+ if not self.surface or not self.cost:
+ return
+ return round(float(self.cost)/self.surface, 2)
+
+ @property
+ def cost_by_m2(self):
+ if not self.surface or not self.cost:
+ return
+ return round(float(self.cost)/self.surface, 2)
+
@classmethod
def get_query_owns(cls, user):
return Q(in_charge=user.person)|Q(history_modifier=user)\
diff --git a/ishtar/templates/sheet_operation.html b/ishtar/templates/sheet_operation.html
index 1fb2850c1..1b6755385 100644
--- a/ishtar/templates/sheet_operation.html
+++ b/ishtar/templates/sheet_operation.html
@@ -22,8 +22,8 @@
<p><label>{%trans "Closing date:"%}</label> <span class='value'>{{ item.closing.date }} <strong>{%trans "by" %}</strong> {{ item.closing.user }}</span></p>
{% endif %}
<p><label>{%trans "Type:"%}</label> <span class='value'>{{ item.operation_type }}</span></p>
-{#<p><label>{%trans "Surface:"%}</label> <span class='value'>{{ item.total_surface }} m<sup>2</sup> ({{ item.total_surface_ha }} ha)</span></p>#}
-{% if item.cost %}<p><label>{%trans "Cost:"%}</label> <span class='value'>{{ item.cost }} Euros, ({{ item.cost_by_m2 }} Euros/m<sup>2</sup>)</span></p>{%endif%}
+{% if item.surface %}<p><label>{%trans "Surface:"%}</label> <span class='value'>{{ item.surface }} m<sup>2</sup> ({{ item.surface_ha }} ha)</span></p>{% endif %}
+{% if item.cost %}<p><label>{%trans "Cost:"%}</label> <span class='value'>{{ item.cost }} &euro;{% if item.cost_by_m2 %}, ({{ item.cost_by_m2 }} &euro;/m<sup>2</sup>){%endif%}</span></p>{%endif%}
{% if item.duration %}<p><label>{%trans "Duration:"%}</label> <span class='value'>{{ item.duration }} {%trans "Day"%}s</span></p>{%endif%}
<p><label>{%trans "Remains:"%}</label> <span class='value'>{{ item.remains.all|join:", " }}</span></p>