Merge branch 'develop'
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index 0246af2..084a388 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
from __future__ import unicode_literals
-__version__ = '5.7.5'
+__version__ = '5.7.6'
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 9f38696..4b25a88 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -236,7 +236,7 @@
if voucher_properties[0] != 1:
frappe.throw(_("{0} {1} is not submitted").format(reference_type, reference_name))
- if flt(voucher_properties[1]) < total:
+ if total and flt(voucher_properties[1]) < total:
frappe.throw(_("Payment against {0} {1} cannot be greater \
than Outstanding Amount {2}").format(reference_type, reference_name, voucher_properties[1]))
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 2c9e7d4..c7600df 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -215,14 +215,15 @@
"""Returns list of advances against Account, Party, Reference"""
order_list = list(set([d.get(against_order_field) for d in self.get("items") if d.get(against_order_field)]))
- if not order_list:
- return
-
- in_placeholder = ', '.join(['%s'] * len(order_list))
-
# conver sales_order to "Sales Order"
reference_type = against_order_field.replace("_", " ").title()
-
+
+ condition = ""
+ if order_list:
+ in_placeholder = ', '.join(['%s'] * len(order_list))
+ condition = "or (t2.reference_type = '{0}' and ifnull(t2.reference_name, '') in ({1}))"\
+ .format(reference_type, in_placeholder)
+
res = frappe.db.sql("""
select
t1.name as jv_no, t1.remark, t2.{0} as amount, t2.name as jv_detail_no,
@@ -233,11 +234,9 @@
t1.name = t2.parent and t2.account = %s
and t2.party_type = %s and t2.party = %s
and t2.is_advance = 'Yes' and t1.docstatus = 1
- and (
- ifnull(t2.reference_type, '')=''
- or (t2.reference_type = %s and ifnull(t2.reference_name, '') in ({1})))
- order by t1.posting_date""".format(dr_or_cr, in_placeholder),
- [account_head, party_type, party, reference_type] + order_list, as_dict=1)
+ and (ifnull(t2.reference_type, '')='' {1})
+ order by t1.posting_date""".format(dr_or_cr, condition),
+ [account_head, party_type, party] + order_list, as_dict=1)
self.set(parentfield, [])
for d in res:
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 2a116ca..3ae43fa 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -27,7 +27,7 @@
"""
app_icon = "icon-th"
app_color = "#e74c3c"
-app_version = "5.7.5"
+app_version = "5.7.6"
github_link = "https://github.com/frappe/erpnext"
error_report_email = "support@erpnext.com"
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 53233ce..2979c12 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -291,7 +291,7 @@
if warehouse_account.get(d.warehouse):
val_rate_db_precision = 6 if cint(d.precision("valuation_rate")) <= 6 else 9
-
+
# warehouse account
gl_entries.append(self.get_gl_dict({
"account": warehouse_account[d.warehouse],
@@ -334,22 +334,21 @@
}))
# divisional loss adjustment
- if not self.get("taxes"):
- sle_valuation_amount = flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
- self.precision("base_net_amount", d))
+ sle_valuation_amount = flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
+ self.precision("base_net_amount", d))
- distributed_amount = flt(flt(d.base_net_amount, self.precision("base_net_amount", d))) + \
- flt(d.landed_cost_voucher_amount) + flt(d.rm_supp_cost)
+ distributed_amount = flt(flt(d.base_net_amount, self.precision("base_net_amount", d))) + \
+ flt(d.landed_cost_voucher_amount) + flt(d.rm_supp_cost) + flt(d.item_tax_amount)
- divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_net_amount", d))
- if divisional_loss:
- gl_entries.append(self.get_gl_dict({
- "account": stock_rbnb,
- "against": warehouse_account[d.warehouse],
- "cost_center": d.cost_center,
- "remarks": self.get("remarks") or _("Accounting Entry for Stock"),
- "debit": divisional_loss
- }))
+ divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_net_amount", d))
+ if divisional_loss:
+ gl_entries.append(self.get_gl_dict({
+ "account": stock_rbnb,
+ "against": warehouse_account[d.warehouse],
+ "cost_center": d.cost_center,
+ "remarks": self.get("remarks") or _("Accounting Entry for Stock"),
+ "debit": divisional_loss
+ }))
elif d.warehouse not in warehouse_with_no_account or \
d.rejected_warehouse not in warehouse_with_no_account:
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 59a68b7..cdfdc78 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -80,7 +80,8 @@
for item in self.get("items"):
if not flt(item.qty):
frappe.throw(_("Row {0}: Qty is mandatory").format(item.idx))
-
+ if not flt(item.conversion_factor):
+ frappe.throw(_("Row {0}: UOM Conversion Factor is mandatory").format(item.idx))
item.transfer_qty = flt(item.qty * item.conversion_factor, self.precision("transfer_qty", item))
def validate_item(self):
diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
index 5b5419d..2676493 100644
--- a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
+++ b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
@@ -88,9 +88,12 @@
if flt(conversion_factor) != flt(1):
frappe.db.sql("""update `tabStock Ledger Entry`
- set stock_uom = %s, actual_qty = ifnull(actual_qty,0) * %s
+ set
+ stock_uom = %s,
+ actual_qty = ifnull(actual_qty,0) * %s,
+ qty_after_transaction = ifnull(qty_after_transaction, 0) * %s
where item_code = %s""",
- (new_stock_uom, conversion_factor, item_code))
+ (new_stock_uom, conversion_factor, conversion_factor, item_code))
else:
frappe.db.sql("""update `tabStock Ledger Entry` set stock_uom=%s
where item_code=%s""", (new_stock_uom, item_code))
diff --git a/setup.py b/setup.py
index 9ef03d2..7d4b20b 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages
-version = "5.7.5"
+version = "5.7.6"
with open("requirements.txt", "r") as f:
install_requires = f.readlines()