Add OrderRecord model
This commit is contained in:
parent
4f25086a63
commit
8e41b894c0
2 changed files with 43 additions and 5 deletions
25
uncloud/uncloud_pay/migrations/0012_orderrecord.py
Normal file
25
uncloud/uncloud_pay/migrations/0012_orderrecord.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 3.0.3 on 2020-03-01 16:04
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uncloud_pay', '0011_auto_20200229_1459'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='OrderRecord',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('setup_fee', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])),
|
||||
('recurring_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])),
|
||||
('description', models.TextField()),
|
||||
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -98,12 +98,25 @@ class Order(models.Model):
|
|||
|
||||
@property
|
||||
def amount(self):
|
||||
# amount = recurring_price
|
||||
# if recurring and first_month:
|
||||
# amount += one_time_price
|
||||
records = OrderRecord.objects.filter(order=self)
|
||||
return 1
|
||||
|
||||
amount=1
|
||||
return amount
|
||||
class OrderRecord(models.Model):
|
||||
order = models.ForeignKey(Order, on_delete=models.CASCADE)
|
||||
setup_fee = models.DecimalField(default=0.0,
|
||||
max_digits=AMOUNT_MAX_DIGITS,
|
||||
decimal_places=AMOUNT_DECIMALS,
|
||||
validators=[MinValueValidator(0)])
|
||||
recurring_price = models.DecimalField(default=0.0,
|
||||
max_digits=AMOUNT_MAX_DIGITS,
|
||||
decimal_places=AMOUNT_DECIMALS,
|
||||
validators=[MinValueValidator(0)])
|
||||
|
||||
description = models.TextField()
|
||||
|
||||
@property
|
||||
def recurring_period(self):
|
||||
return self.order.recurring_period
|
||||
|
||||
class PaymentMethod(models.Model):
|
||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
|
|
Loading…
Reference in a new issue