Merge branch 'master' of github.com:webnotes/erpnext into unicode

This commit is contained in:
Anand Doshi 2012-08-30 18:17:20 +05:30
commit 62a3881837
4 changed files with 29 additions and 13 deletions

View File

@ -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()

View File

@ -557,4 +557,8 @@ patch_list = [
'patch_module': 'patches.august_2012', 'patch_module': 'patches.august_2012',
'patch_file': 'changed_blog_date_format', 'patch_file': 'changed_blog_date_format',
}, },
{
'patch_module': 'patches.august_2012',
'patch_file': 'repost_billed_amt',
},
] ]

View File

@ -198,6 +198,7 @@ class DocType:
hour_rate = sql("select hour_rate from `tabWorkstation` where name = %s", cstr(d.workstation)) 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.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.operating_cost = flt(d.hour_rate) * flt(d.time_in_mins) / 60
d.save()
total_op_cost += d.operating_cost total_op_cost += d.operating_cost
self.doc.operating_cost = total_op_cost self.doc.operating_cost = total_op_cost
@ -214,6 +215,7 @@ class DocType:
d.fields[k] = ret[k] d.fields[k] = ret[k]
d.amount = flt(d.rate) * flt(d.qty) d.amount = flt(d.rate) * flt(d.qty)
d.save()
total_rm_cost += d.amount total_rm_cost += d.amount
self.doc.raw_material_cost = total_rm_cost self.doc.raw_material_cost = total_rm_cost

View File

@ -687,14 +687,14 @@ class StatusUpdater:
self.validate_qty({ self.validate_qty({
'source_dt' :'Sales Invoice Item', 'source_dt' :'Sales Invoice Item',
'compare_field' :'billed_amt', 'compare_field' :'billed_amt',
'compare_ref_field' :'amount', 'compare_ref_field' :'export_amount',
'target_dt' :'Sales Order Item', 'target_dt' :'Sales Order Item',
'join_field' :'so_detail' 'join_field' :'so_detail'
}) })
self.validate_qty({ self.validate_qty({
'source_dt' :'Sales Invoice Item', 'source_dt' :'Sales Invoice Item',
'compare_field' :'billed_amt', 'compare_field' :'billed_amt',
'compare_ref_field' :'amount', 'compare_ref_field' :'export_amount',
'target_dt' :'Delivery Note Item', 'target_dt' :'Delivery Note Item',
'join_field' :'dn_detail' 'join_field' :'dn_detail'
}, no_tolerance =1) }, no_tolerance =1)
@ -734,7 +734,7 @@ class StatusUpdater:
tolerance = self.get_tolerance_for(item['item_code']) 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) 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['max_allowed'] = flt(item[args['compare_ref_field']] * (100+tolerance)/100)
item['reduce_by'] = item[args['compare_field']] - item['max_allowed'] item['reduce_by'] = item[args['compare_field']] - item['max_allowed']
@ -764,12 +764,13 @@ class StatusUpdater:
if item: if item:
item = item[0] item = item[0]
item['idx'] = d.idx 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']]: 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) 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: elif no_tolerance:
item['reduce_by'] = item[args['compare_field']] - item[args['compare_ref_field']] item['reduce_by'] = item[args['compare_field']] - item[args['compare_ref_field']]
if item['reduce_by'] > .01:
msgprint(""" msgprint("""
Row #%(idx)s: Max %(compare_ref_field)s allowed for <b>Item %(item_code)s</b> against Row #%(idx)s: Max %(compare_ref_field)s allowed for <b>Item %(item_code)s</b> against
<b>%(parenttype)s %(parent)s</b> is <b>""" % item <b>%(parenttype)s %(parent)s</b> is <b>""" % item
@ -806,9 +807,9 @@ class StatusUpdater:
'target_dt' :'Sales Order Item', 'target_dt' :'Sales Order Item',
'target_parent_dt' :'Sales Order', 'target_parent_dt' :'Sales Order',
'target_parent_field' :'per_billed', 'target_parent_field' :'per_billed',
'target_ref_field' :'amount', 'target_ref_field' :'export_amount',
'source_dt' :'Sales Invoice Item', 'source_dt' :'Sales Invoice Item',
'source_field' :'amount', 'source_field' :'export_amount',
'join_field' :'so_detail', 'join_field' :'so_detail',
'percent_join_field' :'sales_order', 'percent_join_field' :'sales_order',
'status_field' :'billing_status', 'status_field' :'billing_status',
@ -820,9 +821,9 @@ class StatusUpdater:
'target_dt' :'Delivery Note Item', 'target_dt' :'Delivery Note Item',
'target_parent_dt' :'Delivery Note', 'target_parent_dt' :'Delivery Note',
'target_parent_field' :'per_billed', 'target_parent_field' :'per_billed',
'target_ref_field' :'amount', 'target_ref_field' :'export_amount',
'source_dt' :'Sales Invoice Item', 'source_dt' :'Sales Invoice Item',
'source_field' :'amount', 'source_field' :'export_amount',
'join_field' :'dn_detail', 'join_field' :'dn_detail',
'percent_join_field' :'delivery_note', 'percent_join_field' :'delivery_note',
'status_field' :'billing_status', 'status_field' :'billing_status',