fix profit margin calculation

This commit is contained in:
Thomas Steen Rasmussen 2021-07-21 21:36:50 +02:00
parent 21111e0c2c
commit 0973709ef0
2 changed files with 2 additions and 2 deletions

View file

@ -29,7 +29,7 @@
<td class="text-right">{{ p.price|floatformat:"2" }} DKK</td>
<td class="text-right">{{ p.cost|floatformat:"2" }} DKK</td>
<td class="text-right">{{ p.profit|floatformat:"2" }} DKK</td>
<td class="text-right">{{ p.margin }}%</td>
<td class="text-right">{{ p.margin|floatformat:"2" }}%</td>
</tr>
{% endfor %}
</tbody>

View file

@ -522,7 +522,7 @@ class Product(CreatedUpdatedModel, UUIDModel):
@property
def margin(self):
try:
return (self.price / self.profit) * 100
return (self.profit / self.price) * 100
except ValueError:
return 0