Merge branch 'develop'
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index ac1c3f2..4e60728 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
from __future__ import unicode_literals
-__version__ = '6.4.3'
+__version__ = '6.4.4'
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 4855fc6..a832315 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -29,7 +29,7 @@
"""
app_icon = "icon-th"
app_color = "#e74c3c"
-app_version = "6.4.3"
+app_version = "6.4.4"
github_link = "https://github.com/frappe/erpnext"
error_report_email = "support@erpnext.com"
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 5346a85..fe930c4 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -212,4 +212,5 @@
erpnext.patches.v5_8.tax_rule
erpnext.patches.v6_3.convert_applicable_territory
erpnext.patches.v6_4.round_status_updater_percentages
-erpnext.patches.v6_4.repost_gle_for_journal_entries_where_reference_name_missing
\ No newline at end of file
+erpnext.patches.v6_4.repost_gle_for_journal_entries_where_reference_name_missing
+erpnext.patches.v6_4.fix_journal_entries_due_to_reconciliation
\ No newline at end of file
diff --git a/erpnext/patches/v6_4/fix_journal_entries_due_to_reconciliation.py b/erpnext/patches/v6_4/fix_journal_entries_due_to_reconciliation.py
new file mode 100644
index 0000000..37b6c63
--- /dev/null
+++ b/erpnext/patches/v6_4/fix_journal_entries_due_to_reconciliation.py
@@ -0,0 +1,50 @@
+# 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
+
+def execute():
+ je_rows = frappe.db.sql("""
+ select name, parent, reference_type, reference_name, debit, credit
+ from `tabJournal Entry Account`
+ where docstatus=1 and date(modified) >= '2015-09-17'
+ and ((ifnull(debit_in_account_currency, 0)*exchange_rate != ifnull(debit, 0))
+ or (ifnull(credit_in_account_currency, 0)*exchange_rate != ifnull(credit, 0)))
+ order by parent
+ """, as_dict=True)
+
+ journal_entries = []
+
+ for d in je_rows:
+ if d.parent not in journal_entries:
+ journal_entries.append(d.parent)
+
+ is_advance_entry=None
+ if d.reference_type in ("Sales Invoice", "Purchase Invoice") and d.reference_name:
+ is_advance_entry = frappe.db.sql("""select name from `tab{0}`
+ where journal_entry=%s and jv_detail_no=%s
+ and ifnull(allocated_amount, 0) > 0 and docstatus=1"""
+ .format(d.reference_type + " Advance"), (d.parent, d.name))
+
+ if is_advance_entry or not (d.debit or d.credit):
+ frappe.db.sql("""
+ update `tabJournal Entry Account`
+ set debit=debit_in_account_currency*exchange_rate,
+ credit=credit_in_account_currency*exchange_rate
+ where name=%s""", d.name)
+ else:
+ frappe.db.sql("""
+ update `tabJournal Entry Account`
+ set debit_in_account_currency=debit/exchange_rate,
+ credit_in_account_currency=credit/exchange_rate
+ where name=%s""", d.name)
+
+ for d in journal_entries:
+ print d
+ # delete existing gle
+ frappe.db.sql("delete from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no=%s", d)
+
+ # repost gl entries
+ je = frappe.get_doc("Journal Entry", d)
+ je.make_gl_entries()
\ No newline at end of file
diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py
index a1f4879..cdddf90 100644
--- a/erpnext/setup/doctype/naming_series/naming_series.py
+++ b/erpnext/setup/doctype/naming_series/naming_series.py
@@ -181,6 +181,9 @@
naming_series = frappe.get_meta(doctype).get_field("naming_series").options or ""
naming_series = naming_series.split("\n")
out = naming_series[0] or (naming_series[1] if len(naming_series) > 1 else None)
- if out:
+
+ if not out:
frappe.throw(_("Please set Naming Series for {0} via Setup > Settings > Naming Series").format(doctype),
NamingSeriesNotSetError)
+ else:
+ return out
diff --git a/setup.py b/setup.py
index 339d864..21f5b56 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages
-version = "6.4.3"
+version = "6.4.4"
with open("requirements.txt", "r") as f:
install_requires = f.readlines()