fix: ordering
This commit is contained in:
+10
-3
@@ -113,15 +113,22 @@ class ProductPrice(TimestampedModel):
|
||||
on_delete=models.PROTECT,
|
||||
verbose_name=_("impuesto aplicable"),
|
||||
)
|
||||
price_with_tax = models.DecimalField(
|
||||
max_digits=11,
|
||||
decimal_places=2,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_("precio con impuestos"),
|
||||
)
|
||||
current = models.BooleanField(default=False, verbose_name=_("es el precio actual"))
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.price} - {self.tax.code}"
|
||||
|
||||
@property
|
||||
def price_with_tax(self) -> Decimal:
|
||||
def save(self, *args, **kwargs):
|
||||
tax_value = self.price * Decimal(self.tax.value / 100)
|
||||
return round(self.price + tax_value, 2)
|
||||
self.price_with_tax = round(self.price + tax_value, 2)
|
||||
super().save()
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("precio de producto")
|
||||
|
||||
Reference in New Issue
Block a user