# Generated by Django 2.1.7 on 2019-10-12 18:51

from django.db import migrations


def create_sales(apps, schema_editor):
    Entry = apps.get_model('accounting', 'Entry')
    Sale = apps.get_model('accounting', 'Sale')
    entries = Entry.objects.filter(date__year=2019) \
        .filter(transaction__account__number__startswith='7')
    for entry in entries:
        sale = Sale(entry_ptr=entry)
        sale.__dict__.update(entry.__dict__)
        sale.save()


class Migration(migrations.Migration):

    dependencies = [
        ('accounting', '0051_auto_20191012_2051'),
    ]

    operations = [
        migrations.RunPython(create_sales, migrations.RunPython.noop),
    ]
