fix profit margin calculation
This commit is contained in:
parent
21111e0c2c
commit
0973709ef0
|
@ -29,7 +29,7 @@
|
||||||
<td class="text-right">{{ p.price|floatformat:"2" }} DKK</td>
|
<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.cost|floatformat:"2" }} DKK</td>
|
||||||
<td class="text-right">{{ p.profit|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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -522,7 +522,7 @@ class Product(CreatedUpdatedModel, UUIDModel):
|
||||||
@property
|
@property
|
||||||
def margin(self):
|
def margin(self):
|
||||||
try:
|
try:
|
||||||
return (self.price / self.profit) * 100
|
return (self.profit / self.price) * 100
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue