mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Fix converted_cost
- Incompatibility between float and decimal
This commit is contained in:
parent
c6a435eba0
commit
09cb82cdc0
@ -8,6 +8,7 @@ from __future__ import unicode_literals
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@ -311,7 +312,8 @@ class SupplierPart(models.Model):
|
|||||||
# If this price-break quantity is the largest so far, use it!
|
# If this price-break quantity is the largest so far, use it!
|
||||||
if pb.quantity > pb_quantity:
|
if pb.quantity > pb_quantity:
|
||||||
pb_quantity = pb.quantity
|
pb_quantity = pb.quantity
|
||||||
pb_cost = pb.get_cost()
|
# Convert everything to base currency
|
||||||
|
pb_cost = pb.converted_cost
|
||||||
|
|
||||||
if pb_found:
|
if pb_found:
|
||||||
cost = pb_cost * quantity
|
cost = pb_cost * quantity
|
||||||
@ -381,10 +383,11 @@ class SupplierPriceBreak(models.Model):
|
|||||||
|
|
||||||
currency = models.ForeignKey(Currency, blank=True, null=True, on_delete=models.SET_NULL)
|
currency = models.ForeignKey(Currency, blank=True, null=True, on_delete=models.SET_NULL)
|
||||||
|
|
||||||
def get_cost(self):
|
@property
|
||||||
|
def converted_cost(self):
|
||||||
""" Return the cost of this price break, converted to the base currency """
|
""" Return the cost of this price break, converted to the base currency """
|
||||||
|
|
||||||
scaler = 1.0
|
scaler = Decimal(1.0)
|
||||||
|
|
||||||
if self.currency:
|
if self.currency:
|
||||||
scaler = self.currency.value
|
scaler = self.currency.value
|
||||||
|
@ -88,7 +88,10 @@ InvenTree | {{ company.name }} - Parts
|
|||||||
{% for pb in part.price_breaks.all %}
|
{% for pb in part.price_breaks.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ pb.quantity }}</td>
|
<td>{{ pb.quantity }}</td>
|
||||||
<td>{{ pb.cost }}
|
<td>
|
||||||
|
{% if pb.currency %}{{ pb.currency.symbol }}{% endif %}
|
||||||
|
{{ pb.cost }}
|
||||||
|
{% if pb.currency %}{{ pb.currency.suffix }}{% endif %}
|
||||||
<div class='btn-group' style='float: right;'>
|
<div class='btn-group' style='float: right;'>
|
||||||
<button title='Edit Price Break' class='btn btn-primary pb-edit-button btn-sm' type='button' url="{% url 'price-break-edit' pb.id %}"><span class='glyphicon glyphicon-small glyphicon-edit'></span></button>
|
<button title='Edit Price Break' class='btn btn-primary pb-edit-button btn-sm' type='button' url="{% url 'price-break-edit' pb.id %}"><span class='glyphicon glyphicon-small glyphicon-edit'></span></button>
|
||||||
<button title='Delete Price Break' class='btn btn-danger pb-delete-button btn-sm' type='button' url="{% url 'price-break-delete' pb.id %}"><span class='glyphicon glyphicon-small glyphicon-trash'></span></button>
|
<button title='Delete Price Break' class='btn btn-danger pb-delete-button btn-sm' type='button' url="{% url 'price-break-delete' pb.id %}"><span class='glyphicon glyphicon-small glyphicon-trash'></span></button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user