from django.db import models class BillingAddress(models.Model): """ Draft of a billing address for a purchase from the shop. """ user = models.ForeignKey("core.User", on_delete=models.CASCADE) # user first_name = models.CharField(max_length=255, blank=True) last_name = models.CharField(max_length=255, blank=True) street = models.CharField(max_length=255, blank=True) street_number = models.CharField(max_length=255, blank=True) postal_code = models.CharField(max_length=255, blank=True) city = models.CharField(max_length=255, blank=True) country = models.CharField(max_length=255, blank=True) # company (optional) company_name = models.CharField(max_length=255, blank=True) company_street = models.CharField(max_length=255, blank=True) company_street_number = models.CharField(max_length=255, blank=True) company_postal_code = models.CharField(max_length=255, blank=True) company_city = models.CharField(max_length=255, blank=True) company_country = models.CharField(max_length=255, blank=True) SKUS = [("1", "VV")] class Product(models.Model): price = models.IntegerField() # 10_00 = 10.00 CHF sku = models.CharField(max_length=255, unique=True, choices=SKUS) name = models.CharField(max_length=255) description = models.CharField(max_length=255) class CheckoutInformation(models.Model): """ Immutable checkout information for a purchase from the shop. """ user = models.ForeignKey("core.User", on_delete=models.PROTECT) # immutable product information at time of purchase product_sku = models.CharField(max_length=255, choices=SKUS) product_price = models.IntegerField() # 10_00 = 10.00 CHF product_name = models.CharField(max_length=255) product_description = models.CharField(max_length=255) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) state = models.CharField( max_length=255, choices=[ ("initialized", "initialized"), ("settled", "settled"), ("canceled", "canceled"), ("failed", "failed"), ], ) invoice_transmitted_at = models.DateTimeField(blank=True, null=True) transaction_id = models.CharField(max_length=255) # end user (required) first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) street_address = models.CharField(max_length=255) street_number_address = models.CharField(max_length=255) postal_code = models.CharField(max_length=255) city = models.CharField(max_length=255) country = models.CharField(max_length=255) # company (optional) company_name = models.CharField(max_length=255, blank=True) company_street_address = models.CharField(max_length=255, blank=True) company_street_number_address = models.CharField(max_length=255, blank=True) company_postal_code = models.CharField(max_length=255, blank=True) company_city = models.CharField(max_length=255, blank=True) company_country = models.CharField(max_length=255, blank=True)