Merge branch 'develop'
This commit is contained in:
commit
68888a21ec
@ -350,7 +350,7 @@ class DocType(BuyingController):
|
||||
# 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 @@ class DocType(BuyingController):
|
||||
# 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 @@ class DocType(BuyingController):
|
||||
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(
|
||||
|
@ -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": {
|
||||
|
@ -109,9 +109,10 @@ class BuyingController(StockController):
|
||||
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
|
||||
@ -184,13 +185,11 @@ class BuyingController(StockController):
|
||||
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
|
||||
|
||||
|
@ -58,11 +58,6 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
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 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
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))
|
||||
|
@ -15,7 +15,7 @@ def execute(filters=None):
|
||||
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):
|
||||
@ -31,6 +31,14 @@ def execute(filters=None):
|
||||
|
||||
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"""
|
||||
|
||||
|
@ -67,7 +67,7 @@ def get_stock_ledger_entries(filters):
|
||||
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
|
||||
|
@ -114,6 +114,13 @@ def update_entries_after(args, verbose=1):
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user