Merge branch 'develop'
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index 6c71fff..404627a 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -350,7 +350,7 @@
# item gl entries
stock_item_and_auto_accounting_for_stock = False
stock_items = self.get_stock_items()
- rounding_diff = 0.0
+ # rounding_diff = 0.0
for item in self.doclist.get({"parentfield": "entries"}):
if auto_accounting_for_stock and item.item_code in stock_items:
if flt(item.valuation_rate):
@@ -359,13 +359,12 @@
# expense will be booked in sales invoice
stock_item_and_auto_accounting_for_stock = True
- valuation_amt = flt(flt(item.valuation_rate) * flt(item.qty) * \
- flt(item.conversion_factor), self.precision("valuation_rate", item))
+ valuation_amt = item.amount + item.item_tax_amount + item.rm_supp_cost
- rounding_diff += (flt(item.amount, self.precision("amount", item)) +
- flt(item.item_tax_amount, self.precision("item_tax_amount", item)) +
- flt(item.rm_supp_cost, self.precision("rm_supp_cost", item)) -
- valuation_amt)
+ # rounding_diff += (flt(item.amount, self.precision("amount", item)) +
+ # flt(item.item_tax_amount, self.precision("item_tax_amount", item)) +
+ # flt(item.rm_supp_cost, self.precision("rm_supp_cost", item)) -
+ # valuation_amt)
gl_entries.append(
self.get_gl_dict({
@@ -394,11 +393,11 @@
expenses_included_in_valuation = \
self.get_company_default("expenses_included_in_valuation")
- if rounding_diff:
- import operator
- cost_center_with_max_value = max(valuation_tax.iteritems(),
- key=operator.itemgetter(1))[0]
- valuation_tax[cost_center_with_max_value] -= flt(rounding_diff)
+ # if rounding_diff:
+ # import operator
+ # cost_center_with_max_value = max(valuation_tax.iteritems(),
+ # key=operator.itemgetter(1))[0]
+ # valuation_tax[cost_center_with_max_value] -= flt(rounding_diff)
for cost_center, amount in valuation_tax.items():
gl_entries.append(
diff --git a/accounts/general_ledger.py b/accounts/general_ledger.py
index bc0ac1d..575a2b0 100644
--- a/accounts/general_ledger.py
+++ b/accounts/general_ledger.py
@@ -45,7 +45,7 @@
same_head.credit = flt(same_head.credit) + flt(entry.credit)
else:
merged_gl_map.append(entry)
-
+
# filter zero debit and credit entries
merged_gl_map = filter(lambda x: flt(x.debit)!=0 or flt(x.credit)!=0, merged_gl_map)
return merged_gl_map
diff --git a/config.json b/config.json
index 45f8e27..23561d5 100644
--- a/config.json
+++ b/config.json
@@ -1,6 +1,6 @@
{
"app_name": "ERPNext",
- "app_version": "3.3.5",
+ "app_version": "3.3.6",
"base_template": "app/portal/templates/base.html",
"modules": {
"Accounts": {
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index b52d51c..35b9d25 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -108,10 +108,11 @@
item.import_amount = flt(item.import_rate * item.qty,
self.precision("import_amount", item))
item.item_tax_amount = 0.0;
-
+
+ self._set_in_company_currency(item, "import_amount", "amount")
self._set_in_company_currency(item, "import_ref_rate", "purchase_ref_rate")
self._set_in_company_currency(item, "import_rate", "rate")
- self._set_in_company_currency(item, "import_amount", "amount")
+
def calculate_net_total(self):
self.doc.net_total = self.doc.net_total_import = 0.0
@@ -183,14 +184,12 @@
if item.item_code and item.qty:
self.round_floats_in(item)
-
- purchase_rate = item.rate if self.doc.doctype == "Purchase Invoice" else item.purchase_rate
-
+
# if no item code, which is sometimes the case in purchase invoice,
# then it is not possible to track valuation against it
- item.valuation_rate = flt((purchase_rate +
- (item.item_tax_amount + item.rm_supp_cost) / item.qty) / item.conversion_factor,
- self.precision("valuation_rate", item))
+ qty_in_stock_uom = flt(item.qty * item.conversion_factor)
+ item.valuation_rate = ((item.amount + item.item_tax_amount + item.rm_supp_cost)
+ / qty_in_stock_uom)
else:
item.valuation_rate = 0.0
diff --git a/stock/doctype/delivery_note/test_delivery_note.py b/stock/doctype/delivery_note/test_delivery_note.py
index 64ddff8..ae69db6 100644
--- a/stock/doctype/delivery_note/test_delivery_note.py
+++ b/stock/doctype/delivery_note/test_delivery_note.py
@@ -58,11 +58,6 @@
self.assertEqual(stock_value, 0)
self.assertEqual(stock_value_difference, -375)
-
- gl_entries = webnotes.conn.sql("""select account, debit, credit
- from `tabGL Entry` where voucher_type='Delivery Note' and voucher_no=%s
- order by account desc""", dn.doc.name, as_dict=1)
-
self.assertFalse(get_gl_entries("Delivery Note", dn.doc.name))
def test_delivery_note_gl_entry(self):
@@ -111,8 +106,8 @@
gl_entries = get_gl_entries("Delivery Note", dn.doc.name)
self.assertTrue(gl_entries)
expected_values = {
- stock_in_hand_account: [0.0, 666.65],
- "Cost of Goods Sold - _TC": [666.65, 0.0]
+ stock_in_hand_account: [0.0, 666.67],
+ "Cost of Goods Sold - _TC": [666.67, 0.0]
}
for i, gle in enumerate(gl_entries):
self.assertEquals([gle.debit, gle.credit], expected_values.get(gle.account))
diff --git a/stock/report/item_prices/item_prices.py b/stock/report/item_prices/item_prices.py
index 9a25c13..da8b500 100644
--- a/stock/report/item_prices/item_prices.py
+++ b/stock/report/item_prices/item_prices.py
@@ -15,8 +15,8 @@
bom_rate = get_item_bom_rate()
val_rate_map = get_valuation_rate()
- precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
-
+ precision = get_currency_precision or 2
+
data = []
for item in sorted(item_map):
data.append([item, item_map[item]["item_name"],
@@ -30,6 +30,14 @@
])
return columns, data
+
+def get_currency_precision():
+ company_currency = webnotes.conn.get_value("Company",
+ webnotes.conn.get_default("company"), "default_currency")
+ currency_format = webnotes.conn.get_value("Currency", company_currency, "number_format")
+
+ from webnotes.utils import get_number_format_info
+ return get_number_format_info(currency_format)[2]
def get_columns(filters):
"""return columns based on filters"""
diff --git a/stock/report/stock_ageing/stock_ageing.py b/stock/report/stock_ageing/stock_ageing.py
index defe724..1a84f93 100644
--- a/stock/report/stock_ageing/stock_ageing.py
+++ b/stock/report/stock_ageing/stock_ageing.py
@@ -67,7 +67,7 @@
item.name, item.item_name, item_group, brand, description, item.stock_uom,
actual_qty, posting_date
from `tabStock Ledger Entry` sle,
- (select name, item_name, description, stock_uom, brand
+ (select name, item_name, description, stock_uom, brand, item_group
from `tabItem` {item_conditions}) item
where item_code = item.name and
company = %(company)s and
diff --git a/stock/stock_ledger.py b/stock/stock_ledger.py
index 8702744..980dcd6 100644
--- a/stock/stock_ledger.py
+++ b/stock/stock_ledger.py
@@ -113,7 +113,14 @@
(qty_after_transaction * valuation_rate) or 0
else:
stock_value = sum((flt(batch[0]) * flt(batch[1]) for batch in stock_queue))
-
+
+ # rounding as per precision
+ from webnotes.model.meta import get_field_precision
+ meta = webnotes.get_doctype("Stock Ledger Entry")
+
+ stock_value = flt(stock_value, get_field_precision(meta.get_field("stock_value"),
+ webnotes._dict({"fields": sle})))
+
stock_value_difference = stock_value - prev_stock_value
prev_stock_value = stock_value