2020-12-28 22:35:34 +00:00
|
|
|
# Generated by Django 3.1 on 2020-12-28 22:19
|
2020-03-02 06:17:04 +00:00
|
|
|
|
|
|
|
from django.conf import settings
|
|
|
|
import django.core.validators
|
|
|
|
from django.db import migrations, models
|
|
|
|
import django.db.models.deletion
|
2020-06-21 12:35:12 +00:00
|
|
|
import django.utils.timezone
|
2020-10-11 20:32:08 +00:00
|
|
|
import uncloud.models
|
2020-12-13 10:38:41 +00:00
|
|
|
import uncloud_pay.models
|
2020-03-02 06:17:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
initial = True
|
|
|
|
|
|
|
|
dependencies = [
|
2020-06-21 12:35:12 +00:00
|
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
2020-12-13 10:38:41 +00:00
|
|
|
('uncloud_auth', '0001_initial'),
|
2020-03-02 06:17:04 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.CreateModel(
|
|
|
|
name='Bill',
|
|
|
|
fields=[
|
2020-06-21 12:35:12 +00:00
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
2020-03-03 16:50:52 +00:00
|
|
|
('creation_date', models.DateTimeField(auto_now_add=True)),
|
2020-08-01 16:38:38 +00:00
|
|
|
('starting_date', models.DateTimeField(default=uncloud_pay.models.start_of_this_month)),
|
2020-12-13 10:38:41 +00:00
|
|
|
('ending_date', models.DateTimeField()),
|
2020-08-01 16:38:38 +00:00
|
|
|
('due_date', models.DateField(default=uncloud_pay.models.default_payment_delay)),
|
2020-12-13 10:38:41 +00:00
|
|
|
('is_final', models.BooleanField(default=False)),
|
2020-06-21 12:35:12 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
migrations.CreateModel(
|
|
|
|
name='BillingAddress',
|
|
|
|
fields=[
|
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
2020-12-13 10:38:41 +00:00
|
|
|
('full_name', models.CharField(max_length=256)),
|
|
|
|
('organization', models.CharField(blank=True, max_length=256, null=True)),
|
|
|
|
('street', models.CharField(max_length=256)),
|
|
|
|
('city', models.CharField(max_length=256)),
|
|
|
|
('postal_code', models.CharField(max_length=64)),
|
2020-10-11 20:32:08 +00:00
|
|
|
('country', uncloud.models.CountryField(blank=True, choices=[('AD', 'Andorra'), ('AE', 'United Arab Emirates'), ('AF', 'Afghanistan'), ('AG', 'Antigua & Barbuda'), ('AI', 'Anguilla'), ('AL', 'Albania'), ('AM', 'Armenia'), ('AN', 'Netherlands Antilles'), ('AO', 'Angola'), ('AQ', 'Antarctica'), ('AR', 'Argentina'), ('AS', 'American Samoa'), ('AT', 'Austria'), ('AU', 'Australia'), ('AW', 'Aruba'), ('AZ', 'Azerbaijan'), ('BA', 'Bosnia and Herzegovina'), ('BB', 'Barbados'), ('BD', 'Bangladesh'), ('BE', 'Belgium'), ('BF', 'Burkina Faso'), ('BG', 'Bulgaria'), ('BH', 'Bahrain'), ('BI', 'Burundi'), ('BJ', 'Benin'), ('BM', 'Bermuda'), ('BN', 'Brunei Darussalam'), ('BO', 'Bolivia'), ('BR', 'Brazil'), ('BS', 'Bahama'), ('BT', 'Bhutan'), ('BV', 'Bouvet Island'), ('BW', 'Botswana'), ('BY', 'Belarus'), ('BZ', 'Belize'), ('CA', 'Canada'), ('CC', 'Cocos (Keeling) Islands'), ('CF', 'Central African Republic'), ('CG', 'Congo'), ('CH', 'Switzerland'), ('CI', 'Ivory Coast'), ('CK', 'Cook Iislands'), ('CL', 'Chile'), ('CM', 'Cameroon'), ('CN', 'China'), ('CO', 'Colombia'), ('CR', 'Costa Rica'), ('CU', 'Cuba'), ('CV', 'Cape Verde'), ('CX', 'Christmas Island'), ('CY', 'Cyprus'), ('CZ', 'Czech Republic'), ('DE', 'Germany'), ('DJ', 'Djibouti'), ('DK', 'Denmark'), ('DM', 'Dominica'), ('DO', 'Dominican Republic'), ('DZ', 'Algeria'), ('EC', 'Ecuador'), ('EE', 'Estonia'), ('EG', 'Egypt'), ('EH', 'Western Sahara'), ('ER', 'Eritrea'), ('ES', 'Spain'), ('ET', 'Ethiopia'), ('FI', 'Finland'), ('FJ', 'Fiji'), ('FK', 'Falkland Islands (Malvinas)'), ('FM', 'Micronesia'), ('FO', 'Faroe Islands'), ('FR', 'France'), ('FX', 'France, Metropolitan'), ('GA', 'Gabon'), ('GB', 'United Kingdom (Great Britain)'), ('GD', 'Grenada'), ('GE', 'Georgia'), ('GF', 'French Guiana'), ('GH', 'Ghana'), ('GI', 'Gibraltar'), ('GL', 'Greenland'), ('GM', 'Gambia'), ('GN', 'Guinea'), ('GP', 'Guadeloupe'), ('GQ', 'Equatorial Guinea'), ('GR', 'Greece'), ('GS', 'South Georgia and the South Sandwich Islands'), ('GT', 'Guatemala'), ('GU', 'Guam'), ('GW', 'Guinea-Bissau'), ('GY', 'Guyana'), ('HK', 'Hong Kong'), ('HM', 'Heard & McDonald Islands'), ('HN', 'Honduras'), ('HR', 'Croatia'), ('HT', 'Haiti'), ('HU', 'Hungary'), ('ID', 'Indonesia'), ('IE', 'Ireland'), ('IL', 'Israel'), ('IN', 'India'), ('IO', 'British Indian Ocean Territory'), ('IQ', 'Iraq'), ('IR', 'Islamic Republic of Iran'), ('IS', 'Iceland'), ('IT', 'Italy'), ('JM', 'Jamaica'), ('JO', 'Jordan'), ('JP', 'Japan'), ('KE', 'Kenya'), ('KG', 'Kyrgyzstan'), ('KH', 'Cambodia'), ('KI', 'Kiribati'), ('KM', 'Comoros'), ('KN', 'St. Kitts and Nevis'), ('KP', "Korea, Democratic People's Republic of"), ('KR', 'Korea, Republic of'), ('KW', 'Kuwait'), ('KY', 'Cayman Islands'), ('KZ', 'Kazakhstan'), ('LA', "Lao People's Democratic Republic"), ('LB', 'Lebanon'), ('LC', 'Saint Lucia'), ('LI', 'Liechtenstein'), ('LK', 'Sri Lanka'), ('LR', 'Liberia'), ('LS', 'Lesotho'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('LV', 'Latvia'), ('LY', 'Libyan Arab Jamahiriya'), ('MA', 'Morocco'), ('MC', 'Monaco'), ('MD', 'Moldova, Republic of'), ('MG', 'Madagascar'), ('MH', 'Marshall Islands'), ('ML', 'Mali'), ('MN', 'Mongolia'), ('MM', 'Myanmar'), ('MO', 'Macau'), ('MP', 'Northern Mariana Islands'), ('MQ', 'Martinique'), ('MR', 'Mauritania'), ('MS', 'Monserrat'), ('MT', 'Malta'), ('MU', 'Mauritius'), ('MV', 'Maldives'), ('MW', 'Malawi'), ('MX', 'Mexico'), ('MY', 'Malaysia'), ('MZ', 'Mozambique'), ('NA', 'Namibia'), ('NC', 'New Caledonia'), ('NE', 'Niger'), ('NF', 'Norfolk Island'), ('NG', 'Nigeria'), ('NI', 'Nicaragua'), ('NL', 'Netherlands'), ('NO', 'Norway'), ('NP', 'Nepal'), ('NR', 'Nauru'), ('NU', 'Niue'), ('NZ', 'New Zealand'), ('OM', 'Oman'), ('PA', 'Panama'), ('PE', 'Peru'), ('PF', 'French Polynesia'), ('PG', 'Papua New Guinea'), ('PH', 'Philippines'), ('PK', 'Pakistan'), ('PL', 'Poland'), ('PM', 'St. Pierre & Miquelon'), ('PN', 'Pitcairn'), ('PR', 'Puerto Rico'), ('PT', 'Portugal'), ('PW', 'Palau'), ('PY', 'Paraguay'), ('QA', 'Qatar'), ('RE', 'Reunion'), ('RO', 'Romania'), ('RU', 'Russian Federation'), ('RW', 'Rwanda'), ('SA', 'Saudi Arabi
|
2020-06-21 12:35:12 +00:00
|
|
|
('vat_number', models.CharField(blank=True, default='', max_length=100)),
|
|
|
|
('active', models.BooleanField(default=False)),
|
2020-03-03 16:50:52 +00:00
|
|
|
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
migrations.CreateModel(
|
2020-12-13 10:38:41 +00:00
|
|
|
name='Product',
|
2020-03-03 16:50:52 +00:00
|
|
|
fields=[
|
2020-06-21 12:35:12 +00:00
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
2020-12-13 10:38:41 +00:00
|
|
|
('name', models.CharField(max_length=256, unique=True)),
|
|
|
|
('description', models.CharField(max_length=1024)),
|
|
|
|
('config', models.JSONField()),
|
|
|
|
('currency', models.CharField(choices=[('CHF', 'Swiss Franc'), ('EUR', 'Euro'), ('USD', 'US Dollar')], default='CHF', max_length=32)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
migrations.CreateModel(
|
|
|
|
name='RecurringPeriod',
|
|
|
|
fields=[
|
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
|
|
('name', models.CharField(max_length=100, unique=True)),
|
|
|
|
('duration_seconds', models.IntegerField(unique=True)),
|
2020-03-02 06:17:04 +00:00
|
|
|
],
|
|
|
|
),
|
2020-03-05 10:17:30 +00:00
|
|
|
migrations.CreateModel(
|
|
|
|
name='StripeCustomer',
|
|
|
|
fields=[
|
2020-12-13 10:38:41 +00:00
|
|
|
('owner', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='uncloud_auth.user')),
|
2020-03-05 10:17:30 +00:00
|
|
|
('stripe_id', models.CharField(max_length=32)),
|
|
|
|
],
|
|
|
|
),
|
2020-06-21 12:35:12 +00:00
|
|
|
migrations.CreateModel(
|
|
|
|
name='VATRate',
|
|
|
|
fields=[
|
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
2020-12-13 10:38:41 +00:00
|
|
|
('starting_date', models.DateField(blank=True, null=True)),
|
|
|
|
('ending_date', models.DateField(blank=True, null=True)),
|
2020-06-21 12:35:12 +00:00
|
|
|
('territory_codes', models.TextField(blank=True, default='')),
|
|
|
|
('currency_code', models.CharField(max_length=10)),
|
|
|
|
('rate', models.FloatField()),
|
|
|
|
('rate_type', models.TextField(blank=True, default='')),
|
|
|
|
('description', models.TextField(blank=True, default='')),
|
|
|
|
],
|
|
|
|
),
|
2020-12-28 22:35:34 +00:00
|
|
|
migrations.CreateModel(
|
|
|
|
name='StripeCreditCard',
|
|
|
|
fields=[
|
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
|
|
('card_name', models.CharField(default='My credit card', max_length=128)),
|
|
|
|
('card_id', models.CharField(max_length=32)),
|
|
|
|
('last4', models.CharField(max_length=4)),
|
|
|
|
('brand', models.CharField(max_length=64)),
|
|
|
|
('expiry_date', models.DateField()),
|
|
|
|
('owner', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
|
|
|
],
|
|
|
|
),
|
2020-12-13 10:38:41 +00:00
|
|
|
migrations.CreateModel(
|
|
|
|
name='ProductToRecurringPeriod',
|
|
|
|
fields=[
|
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
|
|
('is_default', models.BooleanField(default=False)),
|
|
|
|
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.product')),
|
|
|
|
('recurring_period', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.recurringperiod')),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
migrations.AddField(
|
|
|
|
model_name='product',
|
|
|
|
name='recurring_periods',
|
|
|
|
field=models.ManyToManyField(through='uncloud_pay.ProductToRecurringPeriod', to='uncloud_pay.RecurringPeriod'),
|
|
|
|
),
|
2020-06-21 12:35:12 +00:00
|
|
|
migrations.CreateModel(
|
|
|
|
name='PaymentMethod',
|
|
|
|
fields=[
|
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
|
|
('source', models.CharField(choices=[('stripe', 'Stripe'), ('unknown', 'Unknown')], default='stripe', max_length=256)),
|
|
|
|
('description', models.TextField()),
|
|
|
|
('primary', models.BooleanField(default=False, editable=False)),
|
|
|
|
('stripe_payment_method_id', models.CharField(blank=True, max_length=32, null=True)),
|
|
|
|
('stripe_setup_intent_id', models.CharField(blank=True, max_length=32, null=True)),
|
|
|
|
('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
|
|
|
],
|
|
|
|
),
|
2020-03-02 06:17:04 +00:00
|
|
|
migrations.CreateModel(
|
|
|
|
name='Payment',
|
|
|
|
fields=[
|
2020-06-21 12:35:12 +00:00
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
2020-03-02 06:17:04 +00:00
|
|
|
('amount', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])),
|
2020-03-03 16:50:52 +00:00
|
|
|
('source', models.CharField(choices=[('wire', 'Wire Transfer'), ('stripe', 'Stripe'), ('voucher', 'Voucher'), ('referral', 'Referral'), ('unknown', 'Unknown')], default='unknown', max_length=256)),
|
|
|
|
('timestamp', models.DateTimeField(auto_now_add=True)),
|
|
|
|
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
2020-03-02 06:17:04 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
migrations.CreateModel(
|
2020-12-13 10:38:41 +00:00
|
|
|
name='Order',
|
2020-03-03 16:50:52 +00:00
|
|
|
fields=[
|
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
2020-12-13 10:38:41 +00:00
|
|
|
('description', models.TextField()),
|
|
|
|
('config', models.JSONField()),
|
|
|
|
('creation_date', models.DateTimeField(auto_now_add=True)),
|
|
|
|
('starting_date', models.DateTimeField(default=django.utils.timezone.now)),
|
|
|
|
('ending_date', models.DateTimeField(blank=True, null=True)),
|
2020-03-05 10:17:30 +00:00
|
|
|
('one_time_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])),
|
2020-03-03 16:50:52 +00:00
|
|
|
('recurring_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])),
|
2020-12-13 10:38:41 +00:00
|
|
|
('currency', models.CharField(choices=[('CHF', 'Swiss Franc'), ('EUR', 'Euro'), ('USD', 'US Dollar')], default='CHF', max_length=32)),
|
|
|
|
('should_be_billed', models.BooleanField(default=True)),
|
|
|
|
('billing_address', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.billingaddress')),
|
|
|
|
('depends_on', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='parent_of', to='uncloud_pay.order')),
|
|
|
|
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
|
|
|
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.product')),
|
|
|
|
('recurring_period', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.recurringperiod')),
|
|
|
|
('replaces', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='replaced_by', to='uncloud_pay.order')),
|
2020-03-03 16:50:52 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
migrations.CreateModel(
|
2020-12-28 22:35:34 +00:00
|
|
|
name='Membership',
|
|
|
|
fields=[
|
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
|
|
('starting_date', models.DateField(blank=True, null=True)),
|
|
|
|
('ending_date', models.DateField(blank=True, null=True)),
|
|
|
|
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
migrations.CreateModel(
|
2020-06-21 12:35:12 +00:00
|
|
|
name='BillRecord',
|
2020-03-02 06:17:04 +00:00
|
|
|
fields=[
|
2020-06-21 12:35:12 +00:00
|
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
|
|
('creation_date', models.DateTimeField(auto_now_add=True)),
|
|
|
|
('starting_date', models.DateTimeField()),
|
|
|
|
('ending_date', models.DateTimeField()),
|
2020-12-13 10:38:41 +00:00
|
|
|
('is_recurring_record', models.BooleanField()),
|
|
|
|
('bill', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.bill')),
|
|
|
|
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.order')),
|
2020-03-02 06:17:04 +00:00
|
|
|
],
|
2020-06-21 12:35:12 +00:00
|
|
|
),
|
|
|
|
migrations.AddField(
|
|
|
|
model_name='bill',
|
2020-12-13 10:38:41 +00:00
|
|
|
name='billing_address',
|
|
|
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.billingaddress'),
|
2020-06-21 12:35:12 +00:00
|
|
|
),
|
|
|
|
migrations.AddField(
|
|
|
|
model_name='bill',
|
|
|
|
name='owner',
|
|
|
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
|
|
|
),
|
2020-12-13 10:38:41 +00:00
|
|
|
migrations.AddConstraint(
|
|
|
|
model_name='producttorecurringperiod',
|
|
|
|
constraint=models.UniqueConstraint(condition=models.Q(is_default=True), fields=('product',), name='one_default_recurring_period_per_product'),
|
|
|
|
),
|
|
|
|
migrations.AddConstraint(
|
|
|
|
model_name='producttorecurringperiod',
|
|
|
|
constraint=models.UniqueConstraint(fields=('product', 'recurring_period'), name='recurring_period_once_per_product'),
|
|
|
|
),
|
2020-06-21 12:35:12 +00:00
|
|
|
migrations.AddConstraint(
|
|
|
|
model_name='billingaddress',
|
2020-06-21 12:45:05 +00:00
|
|
|
constraint=models.UniqueConstraint(condition=models.Q(active=True), fields=('owner',), name='one_active_billing_address_per_user'),
|
2020-03-02 06:17:04 +00:00
|
|
|
),
|
2020-08-01 16:38:38 +00:00
|
|
|
migrations.AddConstraint(
|
|
|
|
model_name='bill',
|
|
|
|
constraint=models.UniqueConstraint(fields=('owner', 'starting_date', 'ending_date'), name='one_bill_per_month_per_user'),
|
|
|
|
),
|
2020-03-02 06:17:04 +00:00
|
|
|
]
|