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/patches/patch_list.py b/erpnext/patches/patch_list.py index 27dedf3387..c7df34c155 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -557,4 +557,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 diff --git a/erpnext/production/doctype/bom/bom.py b/erpnext/production/doctype/bom/bom.py index 83a3165d51..5f6954f217 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 diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py index bf16253a15..5411a5a04b 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.py +++ b/erpnext/selling/doctype/sales_common/sales_common.py @@ -687,14 +687,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) @@ -734,7 +734,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'] @@ -764,18 +764,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) @@ -806,9 +807,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', @@ -820,9 +821,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',