mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
[fix] [minor] rounding error in purchase invoice gl entry
This commit is contained in:
@@ -359,6 +359,7 @@ class DocType(BuyingController):
|
|||||||
# item gl entries
|
# item gl entries
|
||||||
stock_item_and_auto_accounting_for_stock = False
|
stock_item_and_auto_accounting_for_stock = False
|
||||||
stock_items = self.get_stock_items()
|
stock_items = self.get_stock_items()
|
||||||
|
rounding_diff = 0.0
|
||||||
for item in self.doclist.get({"parentfield": "entries"}):
|
for item in self.doclist.get({"parentfield": "entries"}):
|
||||||
if auto_accounting_for_stock and item.item_code in stock_items:
|
if auto_accounting_for_stock and item.item_code in stock_items:
|
||||||
if flt(item.valuation_rate):
|
if flt(item.valuation_rate):
|
||||||
@@ -367,8 +368,13 @@ class DocType(BuyingController):
|
|||||||
# expense will be booked in sales invoice
|
# expense will be booked in sales invoice
|
||||||
stock_item_and_auto_accounting_for_stock = True
|
stock_item_and_auto_accounting_for_stock = True
|
||||||
|
|
||||||
valuation_amt = flt(item.valuation_rate) * flt(item.qty) * \
|
valuation_amt = flt(flt(item.valuation_rate) * flt(item.qty) * \
|
||||||
flt(item.conversion_factor)
|
flt(item.conversion_factor), self.precision("valuation_rate", item))
|
||||||
|
|
||||||
|
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(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
@@ -397,6 +403,12 @@ class DocType(BuyingController):
|
|||||||
expenses_included_in_valuation = \
|
expenses_included_in_valuation = \
|
||||||
self.get_company_default("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)
|
||||||
|
|
||||||
for cost_center, amount in valuation_tax.items():
|
for cost_center, amount in valuation_tax.items():
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
|
|||||||
Reference in New Issue
Block a user