# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-20 19:34
from __future__ import unicode_literals

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import jsonfield.fields


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Address',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('city', models.TextField(verbose_name='City')),
                ('state', models.TextField(verbose_name='State')),
                ('line1', models.CharField(max_length=100, verbose_name='Street (Line 1)')),
                ('line2', models.CharField(blank=True, max_length=100, verbose_name='Street (Line 2)')),
                ('line3', models.CharField(blank=True, max_length=100, verbose_name='Street (Line 3)')),
                ('postal_code', models.IntegerField(verbose_name='Postal Code')),
                ('country_code', models.CharField(blank=True, choices=[('AF', 'Afganistán'), ('AL', 'Albania'), ('DE', 'Alemania'), ('AD', 'Andorra'), ('AO', 'Angola'), ('AI', 'Anguila'), ('AG', 'Antigua y Barbuda'), ('AN', 'Antillas Holandesas'), ('AQ', 'Antártida'), ('SA', 'Arabia Saudita'), ('DZ', 'Argelia'), ('AR', 'Argentina'), ('AM', 'Armenia'), ('AW', 'Aruba'), ('AU', 'Australia'), ('AT', 'Austria'), ('AZ', 'Azerbaiyán'), ('BS', 'Bahamas'), ('BH', 'Bahráin'), ('BD', 'Bangladesh'), ('BB', 'Barbados'), ('BZ', 'Belice'), ('BJ', 'Benín'), ('BM', 'Bermudas'), ('BY', 'Bielorrusia'), ('BO', 'Bolivia'), ('BQ', 'Bonaire, San Eustaquio y Saba'), ('BA', 'Bosnia y Hercegovina'), ('BW', 'Botsuana'), ('BR', 'Brasil'), ('BN', 'Brunéi'), ('BG', 'Bulgaria'), ('BF', 'Burkina Faso'), ('BI', 'Burundi'), ('BT', 'Bután'), ('BE', 'Bélgica'), ('CV', 'Cabo Verde'), ('KH', 'Camboya'), ('CM', 'Camerún'), ('CA', 'Canadá'), ('TD', 'Chad'), ('CZ', 'Chequia'), ('CL', 'Chile'), ('CN', 'China'), ('CY', 'Chipre'), ('VA', 'Ciudad del Vaticano'), ('CO', 'Colombia'), ('KM', 'Comores'), ('CG', 'Congo'), ('KP', 'Corea del Norte'), ('KR', 'Corea del Sur'), ('CR', 'Costa Rica'), ('CI', 'Costa de Marfil'), ('HR', 'Croacia'), ('CU', 'Cuba'), ('CW', 'Curaçao'), ('DK', 'Dinamarca'), ('DM', 'Dominica'), ('EC', 'Ecuador'), ('EG', 'Egipto'), ('SV', 'El Salvador'), ('AE', 'Emiratos Árabes Unidos'), ('ER', 'Eritrea'), ('SK', 'Eslovaquia'), ('SI', 'Eslovenia'), ('ES', 'España'), ('US', 'Estados Unidos'), ('EE', 'Estonia'), ('ET', 'Etiopía'), ('PH', 'Filipinas'), ('FI', 'Finlandia'), ('FJ', 'Fiyi'), ('FR', 'Francia'), ('GA', 'Gabón'), ('GM', 'Gambia'), ('GE', 'Georgia'), ('GH', 'Ghana'), ('GI', 'Gibraltar'), ('GD', 'Granada'), ('GR', 'Grecia'), ('GL', 'Groenlandia'), ('GP', 'Guadalupe'), ('GU', 'Guam'), ('GT', 'Guatemala'), ('GF', 'Guayana Francesa'), ('GG', 'Guernsey'), ('GN', 'Guinea'), ('GQ', 'Guinea Ecuatorial'), ('GW', 'Guinea-Bissau'), ('GY', 'Guyana'), ('HT', 'Haití'), ('NL', 'Holanda'), ('HN', 'Honduras'), ('HK', 'Hong Kong'), ('HU', 'Hungría'), ('IN', 'India'), ('ID', 'Indonesia'), ('IQ', 'Iraq'), ('IE', 'Irlanda'), ('IR', 'Irán'), ('BV', 'Isla Bouvet'), ('CX', 'Isla Christmas'), ('NF', 'Isla Norfolk'), ('IM', 'Isla de Man'), ('IS', 'Islandia'), ('AX', 'Islas Aland'), ('KY', 'Islas Caimán'), ('CC', 'Islas Cocos'), ('CK', 'Islas Cook'), ('FO', 'Islas Feroe'), ('GS', 'Islas Georgia del Sur y Sandwich del Sur'), ('HM', 'Islas Heard y McDonald'), ('FK', 'Islas Malvinas'), ('MP', 'Islas Marianas del Norte'), ('MH', 'Islas Marshall'), ('PN', 'Islas Pitcairn'), ('SB', 'Islas Salomón'), ('TC', 'Islas Turcas y Caicos'), ('VI', 'Islas Vírgenes Americanas'), ('VG', 'Islas Vírgenes Británicas'), ('UM', 'Islas menores alejadas de los Estados Unidos'), ('IL', 'Israel'), ('IT', 'Italia'), ('JM', 'Jamaica'), ('JP', 'Japón'), ('JE', 'Jersey'), ('JO', 'Jordania'), ('KZ', 'Kazajstán'), ('KE', 'Kenia'), ('KG', 'Kirguizistán'), ('KI', 'Kiribati'), ('KW', 'Kuwait'), ('LA', 'Laos'), ('LS', 'Lesoto'), ('LV', 'Letonia'), ('LR', 'Liberia'), ('LY', 'Libia'), ('LI', 'Liechtenstein'), ('LT', 'Lituania'), ('LU', 'Luxemburgo'), ('LB', 'Líbano'), ('MO', 'Macao'), ('MK', 'Macedonia'), ('MG', 'Madagascar'), ('MY', 'Malasia'), ('MW', 'Malaui'), ('MV', 'Maldivas'), ('MT', 'Malta'), ('ML', 'Malí'), ('MA', 'Marruecos'), ('MQ', 'Martinica'), ('MU', 'Mauricio'), ('MR', 'Mauritania'), ('YT', 'Mayotte'), ('FM', 'Micronesia'), ('MD', 'Moldavia'), ('MN', 'Mongolia'), ('ME', 'Montenegro'), ('MS', 'Montserrat'), ('MZ', 'Mozambique'), ('MM', 'Myanmar'), ('MX', 'México'), ('MC', 'Mónaco'), ('NA', 'Namibia'), ('NR', 'Nauru'), ('NP', 'Nepal'), ('NI', 'Nicaragua'), ('NG', 'Nigeria'), ('NU', 'Niue'), ('NO', 'Noruega'), ('NC', 'Nueva Caledonia'), ('NZ', 'Nueva Zelanda'), ('NE', 'Níger'), ('OM', 'Omán'), ('PW', 'Palaos'), ('PS', 'Palestina'), ('PA', 'Panamá'), ('PG', 'Papúa New Guinea'), ('PK', 'Paquistán'), ('PY', 'Paraguay'), ('PE', 'Perú'), ('PF', 'Polinesia Francesa'), ('PL', 'Polonia'), ('PT', 'Portugal'), ('PR', 'Puerto Rico'), ('QA', 'Qatar'), ('GB', 'Reino Unido'), ('CF', 'República Centroafricana'), ('CD', 'República Democrática del Congo'), ('DO', 'República Dominicana'), ('RE', 'Reunión'), ('RW', 'Ruanda'), ('RO', 'Rumania'), ('RU', 'Rusia'), ('EH', 'Sahara Occidental'), ('WS', 'Samoa'), ('AS', 'Samoa Americana'), ('BL', 'San Bartolomé'), ('KN', 'San Cristóbal y Nieves'), ('SM', 'San Marino'), ('MF', 'San Martín'), ('SX', 'San Martín (región holandesa)'), ('PM', 'San Pedro y Miquelón'), ('VC', 'San Vicente y las Granadinas'), ('SH', 'Santa Helena'), ('LC', 'Santa Lucia'), ('ST', 'Santo Tomé y Príncipe'), ('SN', 'Senegal'), ('RS', 'Serbia'), ('SC', 'Seychelles'), ('SL', 'Sierra Leona'), ('SG', 'Singapur'), ('SY', 'Siria'), ('SO', 'Somalia'), ('LK', 'Sri Lanka'), ('SZ', 'Suazilandia'), ('ZA', 'Sudáfrica'), ('SD', 'Sudán'), ('SS', 'Sudán del Sur'), ('SE', 'Suecia'), ('CH', 'Suiza'), ('SR', 'Surinam'), ('SJ', 'Svalbard y Jan Mayen'), ('TH', 'Tailandia'), ('TW', 'Taiwán'), ('TZ', 'Tanzania'), ('TJ', 'Tayikistán'), ('IO', 'Territorio Británico del Océano Índico'), ('TF', 'Territorios Franceses del Sur'), ('TL', 'Timor Oriental'), ('TG', 'Togo'), ('TK', 'Tokelau'), ('TO', 'Tonga'), ('TT', 'Trinidad y Tobago'), ('TM', 'Turkmenistán'), ('TR', 'Turquía'), ('TV', 'Tuvalu'), ('TN', 'Túnez'), ('UA', 'Ucrania'), ('UG', 'Uganda'), ('UY', 'Uruguay'), ('UZ', 'Uzbekistán'), ('VU', 'Vanuatu'), ('VE', 'Venezuela'), ('VN', 'Vietnam'), ('WF', 'Wallis y Futuna'), ('YE', 'Yemen'), ('DJ', 'Yibuti'), ('ZM', 'Zambia'), ('ZW', 'Zimbabue')], default='MX', max_length=5, verbose_name='Country')),
                ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='Creation date')),
            ],
        ),
        migrations.CreateModel(
            name='Card',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('openpay_id', models.CharField(blank=True, max_length=100, verbose_name='OpenPay ID')),
                ('creation_date', models.DateTimeField(blank=True, verbose_name='Creation date')),
                ('alias', models.CharField(blank=True, max_length=100, verbose_name='Alias')),
                ('card_type', models.CharField(max_length=15, verbose_name='Card type')),
                ('holder', models.CharField(blank=True, max_length=100, verbose_name='Holder name')),
                ('number', models.CharField(max_length=5, verbose_name='Number')),
                ('month', models.CharField(blank=True, max_length=3, verbose_name='Expiration month')),
                ('year', models.CharField(blank=True, max_length=3, verbose_name='Expiration year')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Charge',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('openpay_id', models.CharField(blank=True, max_length=100, verbose_name='OpenPay ID')),
                ('creation_date', models.DateTimeField(blank=True, verbose_name='Creation date')),
                ('authorization', models.CharField(blank=True, max_length=10, null=True, verbose_name='Authorization')),
                ('transaction_type', models.CharField(blank=True, choices=[('charge', 'Charge')], default='charge', max_length=10, verbose_name='Transaction Type')),
                ('operation_type', models.CharField(blank=True, choices=[('in', 'In'), ('out', 'Out')], default='in', max_length=4, verbose_name='Operation Type')),
                ('method', models.CharField(blank=True, choices=[('card', 'Card')], default='card', max_length=10, verbose_name='Method')),
                ('order_id', models.CharField(blank=True, max_length=20, null=True, verbose_name='Order ID')),
                ('status', models.CharField(blank=True, choices=[('completed', 'Completed'), ('in_progress', 'In Progress'), ('failed', 'Failed')], default='in_progress', max_length=14, verbose_name='Status')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=20, verbose_name='Amount')),
                ('description', models.TextField(blank=True, null=True, verbose_name='Description')),
                ('error_message', models.TextField(blank=True, null=True, verbose_name='Error Message')),
                ('currency', models.CharField(blank=True, choices=[('MXN', 'MXN'), ('USD', 'USD')], default='MXN', max_length=8, verbose_name='Currency')),
                ('operation_date', models.DateTimeField(blank=True, null=True, verbose_name='Operation date')),
                ('conciliated', models.BooleanField(default=True, verbose_name='Conciliated')),
                ('card', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='django_openpay.Card', verbose_name='Card')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Customer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('openpay_id', models.CharField(blank=True, max_length=100, verbose_name='OpenPay ID')),
                ('creation_date', models.DateTimeField(blank=True, verbose_name='Creation date')),
                ('first_name', models.CharField(max_length=60, verbose_name='First Name')),
                ('last_name', models.CharField(blank=True, max_length=60, null=True, verbose_name='Last Name')),
                ('email', models.EmailField(max_length=254, verbose_name='Email')),
                ('phone_number', models.CharField(blank=True, max_length=15, null=True, validators=[django.core.validators.RegexValidator(message='The telephone number can only contain digits.  The maximum number of digits is 15.', regex='^\\d{9,15}$')], verbose_name='Phone Number')),
                ('address', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='customer', to='django_openpay.Address', verbose_name='Address')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Plan',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('openpay_id', models.CharField(blank=True, max_length=100, verbose_name='OpenPay ID')),
                ('creation_date', models.DateTimeField(blank=True, verbose_name='Creation date')),
                ('name', models.CharField(max_length=60, verbose_name='Name')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=20, verbose_name='Amount')),
                ('retry_times', models.IntegerField(blank=True, default=3, verbose_name='Number of retries')),
                ('excerpt', models.CharField(blank=True, max_length=250, verbose_name='Excerpt')),
                ('description', models.TextField(blank=True, verbose_name='Description')),
                ('benefits', jsonfield.fields.JSONField(blank=True, verbose_name='Benefits (as JSON)')),
                ('status', models.CharField(blank=True, choices=[('active', 'Active'), ('deleted', 'Deleted')], default='active', max_length=9, verbose_name='Status')),
                ('status_after_retry', models.CharField(blank=True, choices=[('unpaid', 'Unpaid'), ('cancelled', 'Cancelled')], default='unpaid', max_length=11, verbose_name='Status when retries are exhausted')),
                ('trial_days', models.IntegerField(blank=True, default=0, verbose_name='Trial days')),
                ('repeat_every', models.IntegerField(blank=True, default=1, verbose_name='Frecuency Number')),
                ('repeat_unit', models.CharField(blank=True, choices=[('week', 'Week'), ('month', 'Month'), ('year', 'Year')], default='month', max_length=15, verbose_name='Frecuency Unit')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Refund',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('openpay_id', models.CharField(blank=True, max_length=100, verbose_name='OpenPay ID')),
                ('creation_date', models.DateTimeField(blank=True, verbose_name='Creation date')),
                ('authorization', models.CharField(blank=True, max_length=10, null=True, verbose_name='Authorization')),
                ('transaction_type', models.CharField(blank=True, choices=[('charge', 'Charge')], default='charge', max_length=10, verbose_name='Transaction Type')),
                ('operation_type', models.CharField(blank=True, choices=[('in', 'In'), ('out', 'Out')], default='in', max_length=4, verbose_name='Operation Type')),
                ('method', models.CharField(blank=True, choices=[('card', 'Card')], default='card', max_length=10, verbose_name='Method')),
                ('order_id', models.CharField(blank=True, max_length=20, null=True, verbose_name='Order ID')),
                ('status', models.CharField(blank=True, choices=[('completed', 'Completed'), ('in_progress', 'In Progress'), ('failed', 'Failed')], default='in_progress', max_length=14, verbose_name='Status')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=20, verbose_name='Amount')),
                ('description', models.TextField(blank=True, null=True, verbose_name='Description')),
                ('error_message', models.TextField(blank=True, null=True, verbose_name='Error Message')),
                ('currency', models.CharField(blank=True, choices=[('MXN', 'MXN'), ('USD', 'USD')], default='MXN', max_length=8, verbose_name='Currency')),
                ('operation_date', models.DateTimeField(blank=True, null=True, verbose_name='Operation date')),
                ('conciliated', models.BooleanField(default=True, verbose_name='Conciliated')),
                ('card', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='django_openpay.Card', verbose_name='Card')),
                ('charge', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='refund', to='django_openpay.Charge', verbose_name='Charge')),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_openpay.Customer', verbose_name='Customer')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Subscription',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('openpay_id', models.CharField(blank=True, max_length=100, verbose_name='OpenPay ID')),
                ('creation_date', models.DateTimeField(blank=True, verbose_name='Creation date')),
                ('cancel_at_period_end', models.BooleanField(default=False, verbose_name='Cancel at the end of period')),
                ('charge_date', models.DateField(blank=True, null=True, verbose_name='Charge date')),
                ('period_end_date', models.DateField(blank=True, null=True, verbose_name='Period end date')),
                ('status', models.CharField(blank=True, choices=[('trial', 'Trial'), ('active', 'Active'), ('past_due', 'Past Due'), ('unpaid', 'Unpaid'), ('cancelled', 'Cancelled')], default='trial', max_length=10, verbose_name='Status')),
                ('current_period_number', models.IntegerField(blank=True, default=0, verbose_name='Trial days')),
                ('trial_end_date', models.DateField(blank=True, null=True, verbose_name='Trial end date')),
                ('card', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions', to='django_openpay.Card', verbose_name='Card')),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions', to='django_openpay.Customer', verbose_name='Customer')),
                ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions', to='django_openpay.Plan', verbose_name='Plan')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='charge',
            name='customer',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_openpay.Customer', verbose_name='Customer'),
        ),
        migrations.AddField(
            model_name='card',
            name='customer',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cards', to='django_openpay.Customer', verbose_name='Owner'),
        ),
    ]
