# Generated by Django 2.0.2 on 2018-02-28 10:51

from django.db import migrations


def populate_orders_shipping_price_net(apps, schema_editor):
    Order = apps.get_model("order", "Order")
    orders_with_shipping_price_gross = Order.objects.filter(
        shipping_price_gross__isnull=False
    ).iterator()

    for order in orders_with_shipping_price_gross:
        # At the time of writing this migration we lack information to reliably
        # calculate shipping's net price, so we equal it to gross
        order.shipping_price_net = order.shipping_price_gross
        order.save()


class Migration(migrations.Migration):

    dependencies = [("order", "0037_auto_20180228_0450")]

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