From f2d4df975ee97fcbf480df6d1a4cfd6ca23a5553 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 7 May 2013 13:12:02 +0530 Subject: [PATCH] [fixes] floating point issue in buying rate --- controllers/selling_controller.py | 3 ++- stock/doctype/stock_entry/stock_entry.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py index b22042d0fe9..80af3370315 100644 --- a/controllers/selling_controller.py +++ b/controllers/selling_controller.py @@ -59,7 +59,8 @@ class SellingController(StockController): buying_amount = get_buying_amount(item.item_code, item.warehouse, -1*item.qty, self.doc.doctype, self.doc.name, item.name, stock_ledger_entries, item_sales_bom) - item.buying_amount = buying_amount > 0 and buying_amount or 0 + + item.buying_amount = buying_amount >= 0.01 and buying_amount or 0 webnotes.conn.set_value(item.doctype, item.name, "buying_amount", item.buying_amount) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index fa600725185..d08deefa2b1 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -194,10 +194,10 @@ class DocType(StockController): total_valuation_amount = 0 for item in self.doclist.get({"parentfield": "mtn_details"}): if item.t_warehouse and not item.s_warehouse: - total_valuation_amount += flt(item.incoming_rate) * flt(item.transfer_qty) + total_valuation_amount += flt(item.incoming_rate, 2) * flt(item.transfer_qty) if item.s_warehouse and not item.t_warehouse: - total_valuation_amount -= flt(item.incoming_rate) * flt(item.transfer_qty) + total_valuation_amount -= flt(item.incoming_rate, 2) * flt(item.transfer_qty) return total_valuation_amount @@ -607,7 +607,7 @@ class DocType(StockController): 'voucher_no': self.doc.name, 'voucher_detail_no': d.name, 'actual_qty': qty, - 'incoming_rate': flt(d.incoming_rate) or 0, + 'incoming_rate': flt(d.incoming_rate, 2) or 0, 'stock_uom': d.stock_uom, 'company': self.doc.company, 'is_cancelled': (is_cancelled ==1) and 'Yes' or 'No',