fix: ordering

This commit is contained in:
2024-11-24 13:36:32 +01:00
parent 1f02858477
commit 7d80c64e40
9 changed files with 67 additions and 7 deletions
+10 -3
View File
@@ -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")