# Generated by Django 3.2.13 on 2022-06-07 11:23

from django.db import migrations
from django.db.models import Q

from ocyan.core.fender import config


def forwards(apps, schema_editor):
    FixedSurcharge = apps.get_model("checkout", "FixedSurcharge")
    USE_PRICE_INCL_TAX = config.get("oscar", "use_price_incl_tax", True)
    
    for surcharge in FixedSurcharge.objects.all():
        if USE_PRICE_INCL_TAX:
            surcharge.price = surcharge.incl_tax
        else:
            surcharge.price = surcharge.excl_tax
            
        surcharge.save()



class Migration(migrations.Migration):

    dependencies = [
        ('checkout', '0015_add_vat_rates_surcharges'),
    ]

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