Commit bcd14173 authored by Nico Schottelius's avatar Nico Schottelius

convert recurring period into an integerfield

Signed-off-by: default avatarNico Schottelius <nico@nico-notebook.schottelius.org>
parent 15535433
Pipeline #1535 failed with stage
in 45 seconds
# 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',
),
]
# 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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment