# Generated by Django 2.2.17 on 2020-12-23 13:08

from django.db import migrations


def company_balance(apps, schema_editor):
    '''
    take value of customer_balance field in company model  and fill the customer_balance in customer models
    '''
    Customer = apps.get_model('pyfb_company', 'Customer')
    for customer in Customer.objects.all():
        customer.customer_balance = customer.company.customer_balance
        customer.customer_balance_update = customer.company.customer_balance_update
        customer.save()

    Provider = apps.get_model('pyfb_company', 'Provider')
    for provider in Provider.objects.all():
        provider.supplier_balance = provider.company.supplier_balance
        provider.provider_balance_update = provider.company.provider_balance_update
        provider.save()


class Migration(migrations.Migration):

    dependencies = [
        ('pyfb_company', '0008_auto_20201223_0759'),
    ]

    operations = [
        migrations.RunPython(company_balance),
    ]
