convert recurring period into an integerfield
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
15535433e8
commit
bcd141730d
3 changed files with 54 additions and 6 deletions
26
uncloud_pay/migrations/0015_auto_20200523_2132.py
Normal file
26
uncloud_pay/migrations/0015_auto_20200523_2132.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Generated by Django 3.0.6 on 2020-05-23 21:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uncloud_pay', '0014_paymentsettings'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='order',
|
||||
name='recurring_period',
|
||||
field=models.CharField(choices=[(31536000, 'Per 365 days'), (2592000, 'Per 30 days'), (604800, 'Per Week'), (86400, 'Per Day'), (3600, 'Per Hour'), (60, 'Per Minute'), (1, 'Per Second'), (0, 'Onetime')], default=2592000, max_length=32),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='ordertimothee',
|
||||
name='recurring_period',
|
||||
field=models.CharField(choices=[(31536000, 'Per 365 days'), (2592000, 'Per 30 days'), (604800, 'Per Week'), (86400, 'Per Day'), (3600, 'Per Hour'), (60, 'Per Minute'), (1, 'Per Second'), (0, 'Onetime')], default=2592000, max_length=32),
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='PaymentSettings',
|
||||
),
|
||||
]
|
23
uncloud_pay/migrations/0016_auto_20200523_2138.py
Normal file
23
uncloud_pay/migrations/0016_auto_20200523_2138.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.0.6 on 2020-05-23 21:38
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uncloud_pay', '0015_auto_20200523_2132'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='order',
|
||||
name='recurring_period',
|
||||
field=models.IntegerField(choices=[(31536000, 'Per 365 days'), (2592000, 'Per 30 days'), (604800, 'Per Week'), (86400, 'Per Day'), (3600, 'Per Hour'), (60, 'Per Minute'), (1, 'Per Second'), (0, 'Onetime')], default=2592000),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='ordertimothee',
|
||||
name='recurring_period',
|
||||
field=models.IntegerField(choices=[(31536000, 'Per 365 days'), (2592000, 'Per 30 days'), (604800, 'Per Week'), (86400, 'Per Day'), (3600, 'Per Hour'), (60, 'Per Minute'), (1, 'Per Second'), (0, 'Onetime')], default=2592000),
|
||||
),
|
||||
]
|
|
@ -315,8 +315,9 @@ class BillNico(models.Model):
|
|||
for order in Order.objects.filter(~Q(recurring_period=RecurringPeriod.ONE_TIME),
|
||||
Q(starting_date__lt=self.starting_date),
|
||||
owner=owner):
|
||||
pass
|
||||
|
||||
if order.recurring_period > 0: # avoid div/0 - these are one time payments
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
@ -661,8 +662,7 @@ class Order(models.Model):
|
|||
editable=False,
|
||||
blank=True)
|
||||
|
||||
recurring_period = models.CharField(max_length=32,
|
||||
choices = RecurringPeriod.choices, default = RecurringPeriod.PER_30D)
|
||||
recurring_period = models.IntegerField(choices = RecurringPeriod.choices, default = RecurringPeriod.PER_30D)
|
||||
|
||||
one_time_price = models.DecimalField(default=0.0,
|
||||
max_digits=AMOUNT_MAX_DIGITS,
|
||||
|
@ -766,9 +766,8 @@ class OrderTimothee(models.Model):
|
|||
editable=False,
|
||||
blank=True)
|
||||
|
||||
recurring_period = models.CharField(max_length=32,
|
||||
choices = RecurringPeriod.choices,
|
||||
default = RecurringPeriod.PER_30D)
|
||||
recurring_period = models.IntegerField(choices = RecurringPeriod.choices,
|
||||
default = RecurringPeriod.PER_30D)
|
||||
|
||||
# Trigger initial bill generation at order creation.
|
||||
def save(self, *args, **kwargs):
|
||||
|
|
Loading…
Reference in a new issue