Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move max digits to settings
Pacu28f245fb3387c
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.pyindex d4a6a28dc7..e5e0520c89 100644--- a/saleor/checkout/models.py+++ b/saleor/checkout/models.py@@ -56,7 +56,8 @@ class Cart(models.Model):on_delete=models.SET_NULL)note = models.TextField(blank=True, default='')discount_amount = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=zero_money)discount_name = models.CharField(max_length=255, blank=True, null=True)diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.pyindex 55a66426de..78bb2e8093 100644--- a/saleor/dashboard/order/forms.py+++ b/saleor/dashboard/order/forms.py@@ -255,7 +255,7 @@ class ManagePaymentForm(forms.Form):amount = MoneyField(label=pgettext_lazy('Payment management form (capture, refund, void)', 'Amount'),- max_digits=12,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,currency=settings.DEFAULT_CURRENCY)diff --git a/saleor/discount/models.py b/saleor/discount/models.pyindex f9d602322c..9672674e20 100644--- a/saleor/discount/models.py+++ b/saleor/discount/models.py@@ -52,11 +52,13 @@ class Voucher(models.Model):max_length=10, choices=DiscountValueType.CHOICES,default=DiscountValueType.FIXED)discount_value = models.DecimalField(- max_digits=12, decimal_places=settings.DEFAULT_DECIMAL_PLACES)+ max_digits=settings.DEFAULT_MAX_DIGITS,+ decimal_places=settings.DEFAULT_DECIMAL_PLACES)# not mandatory fields, usage depends on typecountries = CountryField(multiple=True, blank=True)min_amount_spent = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES, null=True, blank=True)products = models.ManyToManyField('product.Product', blank=True)collections = models.ManyToManyField('product.Collection', blank=True)@@ -159,7 +161,8 @@ class Sale(models.Model):max_length=10, choices=DiscountValueType.CHOICES,default=DiscountValueType.FIXED)value = models.DecimalField(- max_digits=12, decimal_places=settings.DEFAULT_DECIMAL_PLACES,+ max_digits=settings.DEFAULT_MAX_DIGITS,+ decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=0)products = models.ManyToManyField('product.Product', blank=True)categories = models.ManyToManyField('product.Category', blank=True)diff --git a/saleor/order/models.py b/saleor/order/models.pyindex 4a358811a1..294a833793 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -83,11 +83,13 @@ class Order(models.Model):ShippingMethod, blank=True, null=True, related_name='orders',on_delete=models.SET_NULL)shipping_price_net = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=0, editable=False)shipping_price_gross = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=0, editable=False)shipping_price = TaxedMoneyField(@@ -96,11 +98,13 @@ class Order(models.Model):max_length=255, null=True, default=None, blank=True, editable=False)token = models.CharField(max_length=36, unique=True, blank=True)total_net = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=zero_money)total_gross = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=zero_money)total = TaxedMoneyField(net_field='total_net', gross_field='total_gross')@@ -108,7 +112,8 @@ class Order(models.Model):Voucher, blank=True, null=True, related_name='+',on_delete=models.SET_NULL)discount_amount = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=zero_money)discount_name = models.CharField(max_length=255, default='', blank=True)@@ -283,10 +288,12 @@ class OrderLine(models.Model):quantity_fulfilled = models.IntegerField(validators=[MinValueValidator(0)], default=0)unit_price_net = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES)unit_price_gross = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES)unit_price = TaxedMoneyField(net_field='unit_price_net', gross_field='unit_price_gross')diff --git a/saleor/payment/models.py b/saleor/payment/models.pyindex 65762c19ff..303ae1a0bf 100644--- a/saleor/payment/models.py+++ b/saleor/payment/models.py@@ -51,16 +51,17 @@ class Payment(models.Model):extra_data = models.TextField(blank=True, default='')token = models.CharField(max_length=36, blank=True, default='')- total = MoneyField(- currency=settings.DEFAULT_CURRENCY,- max_digits=12,+ #: Currency code (may be provider-specific)+ currency = models.CharField(max_length=10)+ #: Total amount (gross)+ total = models.DecimalField(+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,- default=zero_money)- captured_amount = MoneyField(- currency=settings.DEFAULT_CURRENCY,- max_digits=12,+ default='0.0')+ captured_amount = models.DecimalField(+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,- default=zero_money)+ default='0.0')checkout = models.ForeignKey(Cart, null=True, related_name='payments', on_delete=models.SET_NULL)@@ -117,11 +118,13 @@ class Transaction(models.Model):# FIXME probably we should have error/pending/success status instead of# a bool, eg for payments with 3d secureis_success = models.BooleanField(default=False)- amount = MoneyField(- currency=settings.DEFAULT_CURRENCY,- max_digits=12,+ #: Currency code (may be provider-specific)+ currency = models.CharField(max_length=10)+ #: Total amount (gross)+ amount = models.DecimalField(+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,- default=zero_money)+ default='0.0')gateway_response = JSONField()diff --git a/saleor/product/models.py b/saleor/product/models.pyindex 47887c9f63..c2565306ac 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -120,7 +120,8 @@ class Product(SeoModel):category = models.ForeignKey(Category, related_name='products', on_delete=models.CASCADE)price = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES)available_on = models.DateField(blank=True, null=True)is_published = models.BooleanField(default=True)@@ -212,7 +213,8 @@ class ProductVariant(models.Model):sku = models.CharField(max_length=32, unique=True)name = models.CharField(max_length=255, blank=True)price_override = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES, blank=True, null=True)product = models.ForeignKey(Product, related_name='variants', on_delete=models.CASCADE)@@ -224,7 +226,8 @@ class ProductVariant(models.Model):quantity_allocated = models.IntegerField(validators=[MinValueValidator(0)], default=Decimal(0))cost_price = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES, blank=True, null=True)weight = MeasurementField(measurement=Weight, unit_choices=WeightUnits.CHOICES,diff --git a/saleor/settings.py b/saleor/settings.pyindex ebd752ddc5..53bc86d6bb 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -313,6 +313,7 @@ LOGIN_URL = '/account/login/'DEFAULT_COUNTRY = os.environ.get('DEFAULT_COUNTRY', 'US')DEFAULT_CURRENCY = os.environ.get('DEFAULT_CURRENCY', 'USD')DEFAULT_DECIMAL_PLACES = get_currency_fraction(DEFAULT_CURRENCY)+DEFAULT_MAX_DIGITS = 12AVAILABLE_CURRENCIES = [DEFAULT_CURRENCY]COUNTRIES_OVERRIDE = {'EU': pgettext_lazy(diff --git a/saleor/shipping/models.py b/saleor/shipping/models.pyindex 6001ee867e..a2cbddb6db 100644--- a/saleor/shipping/models.py+++ b/saleor/shipping/models.py@@ -84,17 +84,20 @@ class ShippingMethod(models.Model):name = models.CharField(max_length=100)type = models.CharField(max_length=30, choices=ShippingMethodType.CHOICES)price = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES, default=0)shipping_zone = models.ForeignKey(ShippingZone, related_name='shipping_methods',on_delete=models.CASCADE)minimum_order_price = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES, default=0, blank=True,null=True)maximum_order_price = MoneyField(- currency=settings.DEFAULT_CURRENCY, max_digits=12,+ currency=settings.DEFAULT_CURRENCY,+ max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES, blank=True, null=True)minimum_order_weight = MeasurementField(measurement=Weight, unit_choices=WeightUnits.CHOICES,