Refactor commerce models and add configuration app

Major refactor of commerce models: restructured Carrier, Payment, and DiscountCode models, improved order total calculation, and integrated Zasilkovna and Stripe logic. Added new configuration Django app for shop settings, updated Zasilkovna and Stripe models, and fixed Zasilkovna client WSDL URL. Removed unused serializers and views in commerce, and registered new apps in settings.
This commit is contained in:
2025-11-14 02:21:20 +01:00
parent 052f7ab533
commit f14c09bf7a
16 changed files with 249 additions and 275 deletions

View File

@@ -0,0 +1,29 @@
from django.db import models
# Create your models here.
class ShopConfiguration(models.Model):
name = models.CharField(max_length=100, default="Shop name", unique=True)
zasilkovna_shipping_price = models.DecimalField(max_digits=10, decimal_places=2, default=50)
zasilkovna_address_id = models.CharField(max_length=100, blank=True, null=True, help_text="ID výdejního místa Zásilkovny pro odesílání zásilek")
free_shipping_over = models.DecimalField(max_digits=10, decimal_places=2, default=2000)
class CURRENCY(models.TextChoices):
CZK = "CZK", "Czech Koruna"
EUR = "EUR", "Euro"
currency = models.CharField(max_length=10, default=CURRENCY.CZK, choices=CURRENCY.choices)
class Meta:
verbose_name = "Shop Configuration"
verbose_name_plural = "Shop Configuration"
def save(self, *args, **kwargs):
# zajištění singletonu
self.pk = 1
super().save(*args, **kwargs)
@classmethod
def get_solo(cls):
obj, _ = cls.objects.get_or_create(pk=1)
return obj