chore: migrations

This commit is contained in:
Livio Bieri 2023-11-17 01:24:58 +01:00 committed by Christian Cueni
parent 30d2919be2
commit c9fe4007f7
5 changed files with 112 additions and 13 deletions

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.20 on 2023-11-16 12:36
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('shop', '0003_auto_20231114_2036'),
]
operations = [
migrations.RenameField(
model_name='checkoutinformation',
old_name='street_address',
new_name='street',
),
migrations.RenameField(
model_name='checkoutinformation',
old_name='street_number_address',
new_name='street_number',
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.20 on 2023-11-16 12:38
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('shop', '0004_auto_20231116_1336'),
]
operations = [
migrations.RenameField(
model_name='checkoutinformation',
old_name='company_street_address',
new_name='company_street',
),
migrations.RenameField(
model_name='checkoutinformation',
old_name='company_street_number_address',
new_name='company_street_number',
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2023-11-16 17:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0005_auto_20231116_1338'),
]
operations = [
migrations.AlterField(
model_name='checkoutinformation',
name='state',
field=models.CharField(choices=[('initialized', 'Initialized'), ('settled', 'Settled'), ('transmitted', 'Transmitted'), ('canceled', 'Canceled'), ('failed', 'Failed')], max_length=50),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2023-11-16 23:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0006_alter_checkoutinformation_state'),
]
operations = [
migrations.AddField(
model_name='checkoutinformation',
name='webhook_history',
field=models.JSONField(default=list),
),
]

View File

@ -1,5 +1,7 @@
from django.db import models
VV_PRODUCT_SKU = "VV"
class Country(models.Model):
country_id = models.IntegerField(primary_key=True)
@ -48,11 +50,28 @@ class Product(models.Model):
description = models.CharField(max_length=255)
class CheckoutInformation(models.Model):
class CheckoutState(models.TextChoices):
"""
Immutable checkout information for a purchase from the shop.
The state of a checkout process transaction.
1) We use the `autoSettle` feature of DataTrans! Therefore, there are less possible states:
-> https://docs.datatrans.ch/docs/after-the-payment
-> https://api-reference.datatrans.ch/#tag/v1transactions/operation/status
2) Difference between `settled` and `transmitted`:
- https://www.datatrans.ch/en/know-how/faq/#what-does-the-status-transaction-settled-or-settledtransmitted-mean
3) Related relevant code:init_transaction and get_transaction_state in shop/services.py
"""
INITIALIZED = "initialized"
SETTLED = "settled"
TRANSMITTED = "transmitted"
CANCELED = "canceled"
FAILED = "failed"
class CheckoutInformation(models.Model):
user = models.ForeignKey("core.User", on_delete=models.PROTECT)
# immutable product information at time of purchase
@ -65,13 +84,8 @@ class CheckoutInformation(models.Model):
updated_at = models.DateTimeField(auto_now=True)
state = models.CharField(
max_length=255,
choices=[
("initialized", "initialized"),
("settled", "settled"),
("canceled", "canceled"),
("failed", "failed"),
],
max_length=50,
choices=CheckoutState.choices,
)
invoice_transmitted_at = models.DateTimeField(blank=True, null=True)
@ -80,16 +94,19 @@ class CheckoutInformation(models.Model):
# 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)
street = models.CharField(max_length=255)
street_number = 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_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)
# webhook metadata
webhook_history = models.JSONField(default=list)