merged from master

This commit is contained in:
Rushabh Mehta
2011-09-15 12:55:25 +05:30
10 changed files with 87 additions and 97 deletions

View File

@@ -5,7 +5,7 @@
{ {
'creation': '2010-08-08 17:09:34', 'creation': '2010-08-08 17:09:34',
'docstatus': 0, 'docstatus': 0,
'modified': '2011-09-14 12:36:24', 'modified': '2011-09-13 17:35:54',
'modified_by': 'Administrator', 'modified_by': 'Administrator',
'owner': 'Administrator' 'owner': 'Administrator'
}, },
@@ -47,7 +47,7 @@
# Field Mapper Detail # Field Mapper Detail
{ {
'doctype': 'Field Mapper Detail', 'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt)) / flt(obj.basic_rate)', 'from_field': 'eval: obj.basic_rate and (flt(obj.amount) - flt(obj.billed_amt)) / flt(obj.basic_rate) or obj.qty',
'map': 'Yes', 'map': 'Yes',
'match_id': 1, 'match_id': 1,
'to_field': 'qty' 'to_field': 'qty'
@@ -128,28 +128,10 @@
# Field Mapper Detail # Field Mapper Detail
{ {
'doctype': 'Field Mapper Detail', 'doctype': 'Field Mapper Detail',
'from_field': 'eval: flt(obj.qty) - flt(obj.billed_qty)', 'from_field': 'serial_no',
'map': 'Yes', 'map': 'Yes',
'match_id': 1, 'match_id': 1,
'to_field': 'qty' 'to_field': 'serial_no'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.basic_rate)',
'map': 'Yes',
'match_id': 1,
'to_field': 'amount'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.export_rate)',
'map': 'Yes',
'match_id': 1,
'to_field': 'export_amount'
}, },
# Table Mapper Detail # Table Mapper Detail
@@ -169,7 +151,7 @@
'match_id': 1, 'match_id': 1,
'to_field': 'entries', 'to_field': 'entries',
'to_table': 'RV Detail', 'to_table': 'RV Detail',
'validation_logic': 'amount > ifnull(billed_amt, 0) and docstatus = 1' 'validation_logic': '(ifnull(amount, 0) = 0 or amount > ifnull(billed_amt, 0)) and docstatus = 1'
}, },
# Table Mapper Detail # Table Mapper Detail

View File

@@ -5,7 +5,7 @@
{ {
'creation': '2010-08-08 17:09:35', 'creation': '2010-08-08 17:09:35',
'docstatus': 0, 'docstatus': 0,
'modified': '2011-09-14 12:36:24', 'modified': '2011-09-13 17:37:09',
'modified_by': 'Administrator', 'modified_by': 'Administrator',
'owner': 'Administrator' 'owner': 'Administrator'
}, },
@@ -124,7 +124,7 @@
'match_id': 1, 'match_id': 1,
'to_field': 'entries', 'to_field': 'entries',
'to_table': 'PV Detail', 'to_table': 'PV Detail',
'validation_logic': 'ifnull(billed_qty,0) < qty' 'validation_logic': 'ifnull(billed_qty,0) < qty and docstatus = 1'
}, },
# Table Mapper Detail # Table Mapper Detail

View File

@@ -5,7 +5,7 @@
{ {
'creation': '2010-08-08 17:09:35', 'creation': '2010-08-08 17:09:35',
'docstatus': 0, 'docstatus': 0,
'modified': '2011-09-14 12:36:24', 'modified': '2011-09-13 17:27:32',
'modified_by': 'Administrator', 'modified_by': 'Administrator',
'owner': 'Administrator' 'owner': 'Administrator'
}, },

View File

@@ -5,7 +5,7 @@
{ {
'creation': '2010-08-08 17:09:36', 'creation': '2010-08-08 17:09:36',
'docstatus': 0, 'docstatus': 0,
'modified': '2011-09-14 12:36:25', 'modified': '2011-09-13 17:36:31',
'modified_by': 'Administrator', 'modified_by': 'Administrator',
'owner': 'Administrator' 'owner': 'Administrator'
}, },
@@ -57,7 +57,7 @@
# Field Mapper Detail # Field Mapper Detail
{ {
'doctype': 'Field Mapper Detail', 'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt))/flt(obj.basic_rate)', 'from_field': 'eval: obj.basic_rate and (flt(obj.amount) - flt(obj.billed_amt))/flt(obj.basic_rate) or obj.qty',
'map': 'Yes', 'map': 'Yes',
'match_id': 1, 'match_id': 1,
'to_field': 'qty' 'to_field': 'qty'
@@ -136,33 +136,6 @@
'to_field': 'incentives' 'to_field': 'incentives'
}, },
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: flt(obj.qty) - flt(obj.billed_qty)',
'map': 'Yes',
'match_id': 1,
'to_field': 'qty'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.basic_rate)',
'map': 'Yes',
'match_id': 1,
'to_field': 'amount'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.export_rate)',
'map': 'Yes',
'match_id': 1,
'to_field': 'export_amount'
},
# Table Mapper Detail # Table Mapper Detail
{ {
'doctype': 'Table Mapper Detail', 'doctype': 'Table Mapper Detail',
@@ -180,7 +153,7 @@
'match_id': 1, 'match_id': 1,
'to_field': 'entries', 'to_field': 'entries',
'to_table': 'RV Detail', 'to_table': 'RV Detail',
'validation_logic': 'docstatus = 1' 'validation_logic': '(ifnull(amount, 0) = 0 or amount > ifnull(billed_amt, 0)) and docstatus = 1'
}, },
# Table Mapper Detail # Table Mapper Detail

View File

@@ -1,32 +1,43 @@
import webnotes import webnotes
sql = webnotes.conn.sql sql = webnotes.conn.sql
test=1
# Update SO and DN Detail
#--------------------------
def update_delivered_billed_qty():
# update billed amt in item table in so and dn
sql(""" update `tabSales Order Detail` so
set billed_amt = (select sum(amount) from `tabRV Detail` where `so_detail`= so.name and docstatus=1 and parent not like 'old%%'),
delivered_qty = (select sum(qty) from `tabDelivery Note Detail` where `prevdoc_detail_docname`= so.name and docstatus=1 and parent not like 'old%%'),
modified = now()
where docstatus = 1
""")
sql(""" update `tabDelivery Note Detail` dn
set billed_amt = (select sum(amount) from `tabRV Detail` where `dn_detail`= dn.name and docstatus=1 and parent not like 'old%%'),
modified = now()
where docstatus = 1
""")
# update SO # update SO
#--------------- #---------------
def update_percent(): def update_percent():
so = sql("select name from `tabSales Order` where docstatus = 1") # calculate % billed based on item table
for d in so: sql(""" update `tabSales Order` so
sql(""" set per_delivered = (select sum(if(qty > ifnull(delivered_qty, 0), delivered_qty, qty))/sum(qty)*100 from `tabSales Order Detail` where parent=so.name),
update per_billed = (select sum(if(amount > ifnull(billed_amt, 0), billed_amt, amount))/sum(amount)*100 from `tabSales Order Detail` where parent = so.name),
`tabSales Order` modified = now()
set where docstatus = 1
per_delivered = (select sum(if(qty > ifnull(delivered_qty, 0), delivered_qty, qty))/sum(qty)*100 from `tabSales Order Detail` where parent='%s'), """)
per_billed = (select sum(if(qty > ifnull(billed_qty, 0), billed_qty, qty))/sum(qty)*100 from `tabSales Order Detail` where parent='%s')
where
name='%s'""" % (d[0], d[0], d[0]))
# update DN # update DN
# --------- # ---------
dn = sql("select name from `tabDelivery Note` where docstatus = 1") sql(""" update `tabDelivery Note` dn
for d in dn: set per_billed = (select sum(if(amount > ifnull(billed_amt, 0), billed_amt, amount))/sum(amount)*100 from `tabDelivery Note Detail` where parent = dn.name),
sql(""" modified = now()
update where docstatus=1
`tabDelivery Note` """)
set
per_billed = (select sum(if(qty > ifnull(billed_qty, 0), billed_qty, qty))/sum(qty)*100 from `tabDelivery Note Detail` where parent='%s')
where
name='%s'""" % (d[0], d[0]))
# update delivery/billing status # update delivery/billing status
#------------------------------- #-------------------------------
@@ -39,5 +50,6 @@ def update_status():
if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""") if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
def run_patch(): def run_patch():
update_delivered_billed_qty()
update_percent() update_percent()
update_status() update_status()

View File

@@ -1,7 +1,7 @@
# REMEMBER to update this # REMEMBER to update this
# ======================== # ========================
last_patch = 363 last_patch = 365
#------------------------------------------- #-------------------------------------------
@@ -328,3 +328,15 @@ def execute(patch_no):
for d in mappers: for d in mappers:
if d[0] and d[1]: if d[0] and d[1]:
reload_doc(d[1].lower(), 'DocType Mapper', d[0]) reload_doc(d[1].lower(), 'DocType Mapper', d[0])
elif patch_no == 364:
sql("""delete from `tabField Mapper Detail`
where to_field in ('qty', 'amount', 'export_amount')
and parent in ('Sales Order-Receivable Voucher', 'Delivery Note-Receivable Voucher')
""")
mappers = sql("select name, module from `tabDocType Mapper`")
for d in mappers:
if d[0] and d[1]:
reload_doc(d[1].lower(), 'DocType Mapper', d[0])
elif patch_no == 365:
from patches.delivery_billing_status_patch import run_patch
run_patch()

View File

@@ -5,8 +5,8 @@
{ {
'creation': '2010-08-08 17:09:34', 'creation': '2010-08-08 17:09:34',
'docstatus': 0, 'docstatus': 0,
'modified': '2011-05-17 11:42:57', 'modified': '2011-09-13 17:28:37',
'modified_by': 'umair@iwebnotes.com', 'modified_by': 'Administrator',
'owner': 'Administrator' 'owner': 'Administrator'
}, },
@@ -31,7 +31,7 @@
# These values are common for all DocType Mapper # These values are common for all DocType Mapper
{ {
'doctype': 'DocType Mapper', 'doctype': u'DocType Mapper',
'from_doctype': 'Delivery Note', 'from_doctype': 'Delivery Note',
'module': 'Selling', 'module': 'Selling',
'name': '__common__', 'name': '__common__',
@@ -41,7 +41,7 @@
# DocType Mapper, Delivery Note-Installation Note # DocType Mapper, Delivery Note-Installation Note
{ {
'doctype': 'DocType Mapper', 'doctype': u'DocType Mapper',
'name': 'Delivery Note-Installation Note' 'name': 'Delivery Note-Installation Note'
}, },
@@ -111,6 +111,14 @@
'to_field': 'prevdoc_date' 'to_field': 'prevdoc_date'
}, },
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'serial_no',
'match_id': 1,
'to_field': 'serial_no'
},
# Table Mapper Detail # Table Mapper Detail
{ {
'doctype': 'Table Mapper Detail', 'doctype': 'Table Mapper Detail',

View File

@@ -5,8 +5,8 @@
{ {
'creation': '2010-08-08 17:09:35', 'creation': '2010-08-08 17:09:35',
'docstatus': 0, 'docstatus': 0,
'modified': '2011-05-13 12:42:57', 'modified': '2011-09-13 17:26:55',
'modified_by': 'umair@iwebnotes.com', 'modified_by': 'Administrator',
'owner': 'Administrator' 'owner': 'Administrator'
}, },
@@ -31,7 +31,7 @@
# These values are common for all DocType Mapper # These values are common for all DocType Mapper
{ {
'doctype': 'DocType Mapper', 'doctype': u'DocType Mapper',
'from_doctype': 'Purchase Order', 'from_doctype': 'Purchase Order',
'module': 'Stock', 'module': 'Stock',
'name': '__common__', 'name': '__common__',
@@ -41,7 +41,7 @@
# DocType Mapper, Purchase Order-Purchase Receipt # DocType Mapper, Purchase Order-Purchase Receipt
{ {
'doctype': 'DocType Mapper', 'doctype': u'DocType Mapper',
'name': 'Purchase Order-Purchase Receipt' 'name': 'Purchase Order-Purchase Receipt'
}, },

View File

@@ -3,9 +3,9 @@
# These values are common in all dictionaries # These values are common in all dictionaries
{ {
'creation': '2010-12-14 17:56:41', 'creation': '2010-12-15 08:39:22',
'docstatus': 0, 'docstatus': 0,
'modified': '2011-09-14 12:36:24', 'modified': '2011-09-13 17:26:01',
'modified_by': 'Administrator', 'modified_by': 'Administrator',
'owner': 'Administrator' 'owner': 'Administrator'
}, },
@@ -110,10 +110,10 @@
# Field Mapper Detail # Field Mapper Detail
{ {
'doctype': 'Field Mapper Detail', 'doctype': 'Field Mapper Detail',
'from_field': 'customer_address', 'from_field': 'serial_no',
'map': 'Yes', 'map': 'Yes',
'match_id': 0, 'match_id': 1,
'to_field': 'delivery_address' 'to_field': 'serial_no'
}, },
# Table Mapper Detail # Table Mapper Detail

View File

@@ -51,7 +51,8 @@ class DocType:
# ----------------------------- # -----------------------------
def validate_serial_no_warehouse(self, obj, fname): def validate_serial_no_warehouse(self, obj, fname):
for d in getlist(obj.doclist, fname): for d in getlist(obj.doclist, fname):
if d.serial_no: wh = d.warehouse or d.s_warehouse
if d.serial_no and wh:
serial_nos = self.get_sr_no_list(d.serial_no) serial_nos = self.get_sr_no_list(d.serial_no)
for s in serial_nos: for s in serial_nos:
s = s.strip() s = s.strip()
@@ -60,8 +61,8 @@ class DocType:
msgprint("Serial No %s does not exists"%s, raise_exception = 1) msgprint("Serial No %s does not exists"%s, raise_exception = 1)
elif not sr_war[0][0]: elif not sr_war[0][0]:
msgprint("Warehouse not mentioned in the Serial No <b>%s</b>" % s, raise_exception = 1) msgprint("Warehouse not mentioned in the Serial No <b>%s</b>" % s, raise_exception = 1)
elif (d.warehouse and sr_war[0][0] != d.warehouse) or (d.s_warehouse and sr_war[0][0] != d.s_warehouse): elif sr_war[0][0] != wh:
msgprint("Serial No : %s for Item : %s doesn't exists in Warehouse : %s" % (s, d.item_code, d.warehouse or d.s_warehouse), raise_exception = 1) msgprint("Serial No : %s for Item : %s doesn't exists in Warehouse : %s" % (s, d.item_code, wh), raise_exception = 1)
# ------------------------------------ # ------------------------------------
@@ -133,8 +134,10 @@ class DocType:
else: else:
if exists and exists[0][1] == 'Delivered' and exists[0][2] != 2: if exists and exists[0][1] == 'Delivered' and exists[0][2] != 2:
msgprint("Serial No: %s is already delivered, you can not cancel the document." % serial_no, raise_exception=1) msgprint("Serial No: %s is already delivered, you can not cancel the document." % serial_no, raise_exception=1)
elif purpose in ['Material Transfer', 'Sales Return']: elif purpose == 'Material Transfer':
sql("update `tabSerial No` set status = '%s', purchase_document_type = '', purchase_document_no = '', warehouse = '%s' where name = '%s'" % (purpose == 'Material Transfer' and 'In Store' or 'Delivered', d.s_warehouse, serial_no)) sql("update `tabSerial No` set status = 'In Store', purchase_document_type = '', purchase_document_no = '', warehouse = '%s' where name = '%s'" % (d.s_warehouse, serial_no))
elif purpose == 'Sales Return':
sql("update `tabSerial No` set status = 'Delivered', purchase_document_type = '', purchase_document_no = '' where name = '%s'" % serial_no)
else: else:
sql("update `tabSerial No` set docstatus = 2, status = 'Not in Use', purchase_document_type = '', purchase_document_no = '', purchase_date = '', purchase_rate = '', supplier = null, supplier_name = '', supplier_address = '', warehouse = '' where name = '%s'" % serial_no) sql("update `tabSerial No` set docstatus = 2, status = 'Not in Use', purchase_document_type = '', purchase_document_no = '', purchase_date = '', purchase_rate = '', supplier = null, supplier_name = '', supplier_address = '', warehouse = '' where name = '%s'" % serial_no)