From 14a3dd79aa82d8afee96c70f69357ee244f092fa Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 7 Oct 2017 11:10:42 +0200 Subject: [PATCH 1/2] update decimalsfields to have max 20 digits, with 8 decimal places to map btc and cheaper currencies (12 places) --- payments/models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/payments/models.py b/payments/models.py index 2cbd8206a..751af342e 100644 --- a/payments/models.py +++ b/payments/models.py @@ -54,10 +54,10 @@ class BasePayment(models.Model): #: Currency code (may be provider-specific) currency = models.CharField(max_length=10) #: Total amount (gross) - total = models.DecimalField(max_digits=9, decimal_places=2, default='0.0') - delivery = models.DecimalField( - max_digits=9, decimal_places=2, default='0.0') - tax = models.DecimalField(max_digits=9, decimal_places=2, default='0.0') + total = models.DecimalField(max_digits=20, decimal_places=8, default='0.0') + delivery = models.DecimalField(max_digits=20, + decimal_places=8, default='0.0') + tax = models.DecimalField(max_digits=20, decimal_places=8, default='0.0') description = models.TextField(blank=True, default='') billing_first_name = models.CharField(max_length=256, blank=True) billing_last_name = models.CharField(max_length=256, blank=True) @@ -73,7 +73,7 @@ class BasePayment(models.Model): message = models.TextField(blank=True, default='') token = models.CharField(max_length=36, blank=True, default='') captured_amount = models.DecimalField( - max_digits=9, decimal_places=2, default='0.0') + max_digits=20, decimal_places=8, default='0.0') class Meta: abstract = True From a75300c6e37b0579a304a6c50bb3ba9cdb343271 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 9 Oct 2017 22:45:11 +0200 Subject: [PATCH 2/2] fix empty value is string --- payments/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/payments/models.py b/payments/models.py index 751af342e..c1c88a35e 100644 --- a/payments/models.py +++ b/payments/models.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import json from uuid import uuid4 +from decimal import Decimal from django.conf import settings from django.core.urlresolvers import reverse @@ -54,10 +55,10 @@ class BasePayment(models.Model): #: Currency code (may be provider-specific) currency = models.CharField(max_length=10) #: Total amount (gross) - total = models.DecimalField(max_digits=20, decimal_places=8, default='0.0') + total = models.DecimalField(max_digits=20, decimal_places=8, default=Decimal('0.0')) delivery = models.DecimalField(max_digits=20, - decimal_places=8, default='0.0') - tax = models.DecimalField(max_digits=20, decimal_places=8, default='0.0') + decimal_places=8, default=Decimal('0.0')) + tax = models.DecimalField(max_digits=20, decimal_places=8, default=Decimal('0.0')) description = models.TextField(blank=True, default='') billing_first_name = models.CharField(max_length=256, blank=True) billing_last_name = models.CharField(max_length=256, blank=True) @@ -73,7 +74,7 @@ class BasePayment(models.Model): message = models.TextField(blank=True, default='') token = models.CharField(max_length=36, blank=True, default='') captured_amount = models.DecimalField( - max_digits=20, decimal_places=8, default='0.0') + max_digits=20, decimal_places=8, default=Decimal('0.0')) class Meta: abstract = True