# Generated by Django 3.1.3 on 2020-11-20 23:37

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('pedido', '0001_initial'),
        ('revendedor', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='CashBackRevendedor',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('valor', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='Valor CashBack')),
                ('data', models.DateTimeField(blank=True, null=True, verbose_name='Data/Hora Pedido')),
                ('perc_cashback', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='Perc. CashBack Aplicado')),
                ('pedido', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='cashback_pedido', to='pedido.pedido', verbose_name='Pedido')),
                ('revendedor', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='revendedor_cashback_pedido', to='revendedor.revendedor', verbose_name='Revendedor')),
            ],
            options={
                'verbose_name': 'CashBack Revendedor',
                'verbose_name_plural': 'CashBack Revendedores',
                'db_table': 'cashback_revendedor',
                'ordering': ['data'],
            },
        ),
        migrations.AddConstraint(
            model_name='cashbackrevendedor',
            constraint=models.CheckConstraint(check=models.Q(perc_cashback__lte=20), name='perc_cashback_lte_20'),
        ),
        migrations.AlterUniqueTogether(
            name='cashbackrevendedor',
            unique_together={('revendedor', 'pedido')},
        ),
    ]
