Fix invoice outstanding where party missing
Conflicts:
erpnext/accounts/doctype/gl_entry/gl_entry.py
erpnext/patches.txt
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 298c48c..b5fa71b 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -204,3 +204,4 @@
erpnext.patches.v6_0.default_activity_rate
execute:frappe.db.set_value("Stock Settings", None, "automatically_set_serial_nos_based_on_fifo", 1)
execute:frappe.db.sql("""update `tabProject` set percent_complete=round(percent_complete, 2) where percent_complete is not null""")
+erpnext.patches.v6_0.fix_outstanding_amount
diff --git a/erpnext/patches/v6_0/fix_outstanding_amount.py b/erpnext/patches/v6_0/fix_outstanding_amount.py
new file mode 100644
index 0000000..0de6890
--- /dev/null
+++ b/erpnext/patches/v6_0/fix_outstanding_amount.py
@@ -0,0 +1,16 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
+
+def execute():
+ for dt, party_field, account_field in (("Sales Invoice", "customer", "debit_to"),
+ ("Purchase Invoice", "supplier", "credit_to")):
+
+ wrong_invoices = frappe.db.sql("""select name, {0} as account from `tab{1}`
+ where docstatus=1 and ifnull({2}, '')=''""".format(account_field, dt, party_field))
+
+ for invoice, account in wrong_invoices:
+ update_outstanding_amt(account, party_field.title(), None, dt, invoice)
\ No newline at end of file