Repository: saleor/saleor

Issue:
Deploy to Heroku: Migrations fail from master branch
### What I'm trying to achieve
I just pulled new changes and merged to my repo https://github.com/umrashrf/hiemstore

### Steps to reproduce the problem
1. Deploy to Heroku 

### What I expected to happen
Successfulll Heroku Build and Release

### Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->
```
Operations to perform:
  Apply all migrations: account, auth, checkout, contenttypes, discount, django_prices_openexchangerates, django_prices_vatlayer, giftcard, impersonate, menu, order, page, payment, product, sessions, shipping, site, sites, social_django
Running migrations:
  Applying order.0048_auto_20180629_1055... OK
  Applying order.0049_auto_20180719_0520... OK
  Applying order.0050_auto_20180803_0528... OK
  Applying order.0050_auto_20180803_0337... OK
  Applying order.0051_merge_20180807_0704... OK
  Applying order.0052_auto_20180822_0720... OK
  Applying order.0053_orderevent... OK
  Applying order.0054_move_data_to_order_events... OK
  Applying order.0055_remove_order_note_order_history_entry... OK
  Applying order.0056_auto_20180911_1541... OK
  Applying order.0057_orderevent_parameters_new... OK
  Applying order.0058_remove_orderevent_parameters... OK
  Applying order.0059_auto_20180913_0841... OK
  Applying order.0060_auto_20180919_0731... OK
  Applying order.0061_auto_20180920_0859... OK
  Applying order.0062_auto_20180921_0949... OK
  Applying order.0063_auto_20180926_0446... OK
  Applying order.0064_auto_20181016_0819... OK
  Applying checkout.0009_cart_translated_discount_name... OK
  Applying checkout.0010_auto_20180822_0720... OK
  Applying checkout.0011_auto_20180913_0817... OK
  Applying checkout.0012_remove_cartline_data... OK
  Applying checkout.0013_auto_20180913_0841... OK
  Applying checkout.0014_auto_20180921_0751... OK
  Applying checkout.0015_auto_20181017_1346... OK
  Applying payment.0001_initial... OK
  Applying payment.0002_transfer_payment_to_payment_method...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 234, in handle
    fake_initial=fake_initial,
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/migrations/executor.py", line 245, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/migrations/migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/app/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py", line 146, in transfer_payments_to_payment_methods
    charge_status=get_charge_status(pay),
  File "/app/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py", line 27, in get_charge_status
    if payment.get_charge_amount() <= 0:
AttributeError: 'Payment' object has no attribute 'get_charge_amount'
```
**System information**
Operating system: Ubuntu 18.04.2 LTS 
Browser: Brave, Version 0.68.86 Chromium: 75.0.3770.100 (Official Build) dev (64-bit)


Discussion:

Resolving patch:
diff --git a/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py b/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py
--- a/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py
+++ b/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py
@@ -1,10 +1,9 @@
 # Generated by Django 2.1.2 on 2018-10-17 19:42
+from django.conf import settings
 from django.db import migrations
 from prices import Money
-from django.conf import settings
 
 from .. import ChargeStatus, TransactionKind
-from ..models import Transaction
 
 
 class PaymentStatus:
@@ -22,9 +21,13 @@ def is_fully_refunded(payment):
     return total == payment.order.total_gross
 
 
+def get_charge_amount(payment):
+    return payment.total - payment.captured_amount
+
+
 def get_charge_status(payment):
     if payment.status == PaymentStatus.CONFIRMED:
-        if payment.get_charge_amount() <= 0:
+        if get_charge_amount(payment) <= 0:
             return ChargeStatus.FULLY_CHARGED
         return ChargeStatus.PARTIALLY_CHARGED
     if payment.status == PaymentStatus.REFUNDED:


Test patch: