from __future__ import unicode_literals

from django.db import migrations, connection


def load_data(apps, schema_editor):
    Account = apps.get_model("ledger", "Account")

    Account(name="Cash", type="asset").save()
    Account(name="Bank", type="asset").save()
    Account(name="Fees", type="revenue").save()
    Account(name="Deposits", type="revenue").save()
    Account(name="Administrative", type="expense").save()
    Account(name="Purchases", type="expense").save()


def remove_data(apps, schema_editor):
    with connection.cursor() as cursor:
        cursor.execute('DELETE FROM ledger_entry')
        cursor.execute('DELETE FROM ledger_account')


class Migration(migrations.Migration):

    dependencies = [
        ('ledger', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(load_data, remove_data)
    ]

from __future__ import unicode_literals

from django.db import migrations, connection


def load_data(apps, schema_editor):
    Account = apps.get_model("ledger", "Account")

    Account(name="Cash", type="asset").save()
    Account(name="Bank", type="asset").save()
    Account(name="Fees", type="revenue").save()
    Account(name="Deposits", type="revenue").save()
    Account(name="Administrative", type="expense").save()
    Account(name="Purchases", type="expense").save()
    Account(name="Balance", type="equity").save()


def remove_data(apps, schema_editor):
    with connection.cursor() as cursor:
        cursor.execute('DELETE FROM ledger_entry')
        cursor.execute('DELETE FROM ledger_account')


class Migration(migrations.Migration):

    dependencies = [
        ('ledger', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(load_data, remove_data)
    ]

Add a balance (equity) account
Add a balance (equity) account

  from __future__ import unicode_literals
  
  from django.db import migrations, connection
  
  
  def load_data(apps, schema_editor):
      Account = apps.get_model("ledger", "Account")
  
      Account(name="Cash", type="asset").save()
      Account(name="Bank", type="asset").save()
      Account(name="Fees", type="revenue").save()
      Account(name="Deposits", type="revenue").save()
      Account(name="Administrative", type="expense").save()
      Account(name="Purchases", type="expense").save()
+     Account(name="Balance", type="equity").save()
  
  
  def remove_data(apps, schema_editor):
      with connection.cursor() as cursor:
          cursor.execute('DELETE FROM ledger_entry')
          cursor.execute('DELETE FROM ledger_account')
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('ledger', '0001_initial'),
      ]
  
      operations = [
          migrations.RunPython(load_data, remove_data)
      ]
  
Add a balance (equity) account
## Code Before:
from __future__ import unicode_literals

from django.db import migrations, connection


def load_data(apps, schema_editor):
    Account = apps.get_model("ledger", "Account")

    Account(name="Cash", type="asset").save()
    Account(name="Bank", type="asset").save()
    Account(name="Fees", type="revenue").save()
    Account(name="Deposits", type="revenue").save()
    Account(name="Administrative", type="expense").save()
    Account(name="Purchases", type="expense").save()


def remove_data(apps, schema_editor):
    with connection.cursor() as cursor:
        cursor.execute('DELETE FROM ledger_entry')
        cursor.execute('DELETE FROM ledger_account')


class Migration(migrations.Migration):

    dependencies = [
        ('ledger', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(load_data, remove_data)
    ]

## Instruction:
Add a balance (equity) account
## Code After:
from __future__ import unicode_literals

from django.db import migrations, connection


def load_data(apps, schema_editor):
    Account = apps.get_model("ledger", "Account")

    Account(name="Cash", type="asset").save()
    Account(name="Bank", type="asset").save()
    Account(name="Fees", type="revenue").save()
    Account(name="Deposits", type="revenue").save()
    Account(name="Administrative", type="expense").save()
    Account(name="Purchases", type="expense").save()
    Account(name="Balance", type="equity").save()


def remove_data(apps, schema_editor):
    with connection.cursor() as cursor:
        cursor.execute('DELETE FROM ledger_entry')
        cursor.execute('DELETE FROM ledger_account')


class Migration(migrations.Migration):

    dependencies = [
        ('ledger', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(load_data, remove_data)
    ]
