From f826eecfc778da976f7239360749bc1b209a3321 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 Aug 2012 10:50:18 +0530 Subject: [PATCH 1/4] fixes in bom: updating cost --- erpnext/production/doctype/bom/bom.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/production/doctype/bom/bom.py b/erpnext/production/doctype/bom/bom.py index 81297b4f1b..df64bb6678 100644 --- a/erpnext/production/doctype/bom/bom.py +++ b/erpnext/production/doctype/bom/bom.py @@ -198,6 +198,7 @@ class DocType: hour_rate = sql("select hour_rate from `tabWorkstation` where name = %s", cstr(d.workstation)) d.hour_rate = hour_rate and flt(hour_rate[0][0]) or 0 d.operating_cost = flt(d.hour_rate) * flt(d.time_in_mins) / 60 + d.save() total_op_cost += d.operating_cost self.doc.operating_cost = total_op_cost @@ -214,6 +215,7 @@ class DocType: d.fields[k] = ret[k] d.amount = flt(d.rate) * flt(d.qty) + d.save() total_rm_cost += d.amount self.doc.raw_material_cost = total_rm_cost From 9c043b2f5104fa27289461cc6fcba5446bbac438 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 Aug 2012 11:46:12 +0530 Subject: [PATCH 2/4] Billed amount in SO and DN based on export amount and patch for it --- erpnext/patches/august_2012/repost_billed_amt.py | 9 +++++++++ erpnext/selling/doctype/sales_common/sales_common.py | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 erpnext/patches/august_2012/repost_billed_amt.py diff --git a/erpnext/patches/august_2012/repost_billed_amt.py b/erpnext/patches/august_2012/repost_billed_amt.py new file mode 100644 index 0000000000..e6b463c157 --- /dev/null +++ b/erpnext/patches/august_2012/repost_billed_amt.py @@ -0,0 +1,9 @@ +def execute(): + import webnotes + from webnotes.model.code import get_obj + from selling.doctype.sales_common.sales_common import StatusUpdater + + invoices = webnotes.conn.sql("select name from `tabSales Invoice` where docstatus = 1") + for inv in invoices: + inv_obj = get_obj('Sales Invoice', inv[0], with_children=1) + StatusUpdater(inv_obj, 1).update_all_qty() \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py index 57724acb66..b3d9f4047c 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.py +++ b/erpnext/selling/doctype/sales_common/sales_common.py @@ -689,14 +689,14 @@ class StatusUpdater: self.validate_qty({ 'source_dt' :'Sales Invoice Item', 'compare_field' :'billed_amt', - 'compare_ref_field' :'amount', + 'compare_ref_field' :'export_amount', 'target_dt' :'Sales Order Item', 'join_field' :'so_detail' }) self.validate_qty({ 'source_dt' :'Sales Invoice Item', 'compare_field' :'billed_amt', - 'compare_ref_field' :'amount', + 'compare_ref_field' :'export_amount', 'target_dt' :'Delivery Note Item', 'join_field' :'dn_detail' }, no_tolerance =1) @@ -808,9 +808,9 @@ class StatusUpdater: 'target_dt' :'Sales Order Item', 'target_parent_dt' :'Sales Order', 'target_parent_field' :'per_billed', - 'target_ref_field' :'amount', + 'target_ref_field' :'export_amount', 'source_dt' :'Sales Invoice Item', - 'source_field' :'amount', + 'source_field' :'export_amount', 'join_field' :'so_detail', 'percent_join_field' :'sales_order', 'status_field' :'billing_status', @@ -822,9 +822,9 @@ class StatusUpdater: 'target_dt' :'Delivery Note Item', 'target_parent_dt' :'Delivery Note', 'target_parent_field' :'per_billed', - 'target_ref_field' :'amount', + 'target_ref_field' :'export_amount', 'source_dt' :'Sales Invoice Item', - 'source_field' :'amount', + 'source_field' :'export_amount', 'join_field' :'dn_detail', 'percent_join_field' :'delivery_note', 'status_field' :'billing_status', From fff16c337d0cc6d75d7789847685c89de808349a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 Aug 2012 12:07:32 +0530 Subject: [PATCH 3/4] fixes in over billing validation --- .../selling/doctype/sales_common/sales_common.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py index b3d9f4047c..f131491553 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.py +++ b/erpnext/selling/doctype/sales_common/sales_common.py @@ -736,7 +736,7 @@ class StatusUpdater: tolerance = self.get_tolerance_for(item['item_code']) overflow_percent = ((item[args['compare_field']] - item[args['compare_ref_field']]) / item[args['compare_ref_field']] * 100) - if overflow_percent - tolerance > 0.0001: + if overflow_percent - tolerance > 0.01: item['max_allowed'] = flt(item[args['compare_ref_field']] * (100+tolerance)/100) item['reduce_by'] = item[args['compare_field']] - item['max_allowed'] @@ -766,18 +766,19 @@ class StatusUpdater: if item: item = item[0] item['idx'] = d.idx - item['compare_ref_field'] = args['compare_ref_field'] + item['compare_ref_field'] = args['compare_ref_field'].replace('_', ' ') if not item[args['compare_ref_field']]: msgprint("As %(compare_ref_field)s for item: %(item_code)s in %(parenttype)s: %(parent)s is zero, system will not check over-delivery or over-billed" % item) elif no_tolerance: item['reduce_by'] = item[args['compare_field']] - item[args['compare_ref_field']] - msgprint(""" - Row #%(idx)s: Max %(compare_ref_field)s allowed for Item %(item_code)s against - %(parenttype)s %(parent)s is """ % item - + cstr(item[args['compare_ref_field']]) + """. + if item['reduce_by'] > .01: + msgprint(""" + Row #%(idx)s: Max %(compare_ref_field)s allowed for Item %(item_code)s against + %(parenttype)s %(parent)s is """ % item + + cstr(item[args['compare_ref_field']]) + """. - You must reduce the %(compare_ref_field)s by %(reduce_by)s""" % item, raise_exception=1) + You must reduce the %(compare_ref_field)s by %(reduce_by)s""" % item, raise_exception=1) else: self.check_overflow_with_tolerance(item, args) From 26da576f1ec7075f1937b12c6b1b5433e800d736 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 Aug 2012 12:09:35 +0530 Subject: [PATCH 4/4] patch list updated --- erpnext/patches/patch_list.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 5a0a9d7857..d1d09e6608 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -525,4 +525,8 @@ patch_list = [ 'patch_module': 'patches.august_2012', 'patch_file': 'changed_blog_date_format', }, + { + 'patch_module': 'patches.august_2012', + 'patch_file': 'repost_billed_amt', + }, ] \ No newline at end of file