From 0a16631221dc08acd815e3f276677855ecfba3ef Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 13 Sep 2011 17:41:40 +0530 Subject: [PATCH 1/5] serial no added in mapper and considered mapping where amount=0 --- .../Delivery Note-Receivable Voucher.txt | 15 ++++++++++++--- .../Purchase Order-Payable Voucher.txt | 4 ++-- .../Purchase Receipt-Payable Voucher.txt | 2 +- .../Sales Order-Receivable Voucher.txt | 6 +++--- .../Delivery Note-Installation Note.txt | 16 ++++++++++++---- .../Purchase Order-Purchase Receipt.txt | 8 ++++---- .../Receivable Voucher-Delivery Note.txt | 11 ++++++++++- 7 files changed, 44 insertions(+), 18 deletions(-) diff --git a/accounts/DocType Mapper/Delivery Note-Receivable Voucher/Delivery Note-Receivable Voucher.txt b/accounts/DocType Mapper/Delivery Note-Receivable Voucher/Delivery Note-Receivable Voucher.txt index ee94be8e4d..40cdad38f2 100644 --- a/accounts/DocType Mapper/Delivery Note-Receivable Voucher/Delivery Note-Receivable Voucher.txt +++ b/accounts/DocType Mapper/Delivery Note-Receivable Voucher/Delivery Note-Receivable Voucher.txt @@ -5,7 +5,7 @@ { 'creation': '2010-08-08 17:09:34', 'docstatus': 0, - 'modified': '2011-09-13 13:23:44', + 'modified': '2011-09-13 17:35:54', 'modified_by': 'Administrator', 'owner': 'Administrator' }, @@ -47,7 +47,7 @@ # 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', 'match_id': 1, 'to_field': 'qty' @@ -125,6 +125,15 @@ 'to_field': 'incentives' }, + # Field Mapper Detail + { + 'doctype': 'Field Mapper Detail', + 'from_field': 'serial_no', + 'map': 'Yes', + 'match_id': 1, + 'to_field': 'serial_no' + }, + # Table Mapper Detail { 'doctype': 'Table Mapper Detail', @@ -142,7 +151,7 @@ 'match_id': 1, 'to_field': 'entries', '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 diff --git a/accounts/DocType Mapper/Purchase Order-Payable Voucher/Purchase Order-Payable Voucher.txt b/accounts/DocType Mapper/Purchase Order-Payable Voucher/Purchase Order-Payable Voucher.txt index 17b63634c5..61ee9b6d64 100644 --- a/accounts/DocType Mapper/Purchase Order-Payable Voucher/Purchase Order-Payable Voucher.txt +++ b/accounts/DocType Mapper/Purchase Order-Payable Voucher/Purchase Order-Payable Voucher.txt @@ -5,7 +5,7 @@ { 'creation': '2010-08-08 17:09:35', 'docstatus': 0, - 'modified': '2011-09-07 12:10:30', + 'modified': '2011-09-13 17:37:09', 'modified_by': 'Administrator', 'owner': 'Administrator' }, @@ -124,7 +124,7 @@ 'match_id': 1, 'to_field': 'entries', 'to_table': 'PV Detail', - 'validation_logic': 'ifnull(billed_qty,0) < qty' + 'validation_logic': 'ifnull(billed_qty,0) < qty and docstatus = 1' }, # Table Mapper Detail diff --git a/accounts/DocType Mapper/Purchase Receipt-Payable Voucher/Purchase Receipt-Payable Voucher.txt b/accounts/DocType Mapper/Purchase Receipt-Payable Voucher/Purchase Receipt-Payable Voucher.txt index d755954fc2..b2baa57c62 100644 --- a/accounts/DocType Mapper/Purchase Receipt-Payable Voucher/Purchase Receipt-Payable Voucher.txt +++ b/accounts/DocType Mapper/Purchase Receipt-Payable Voucher/Purchase Receipt-Payable Voucher.txt @@ -5,7 +5,7 @@ { 'creation': '2010-08-08 17:09:35', 'docstatus': 0, - 'modified': '2011-09-07 12:09:55', + 'modified': '2011-09-13 17:27:32', 'modified_by': 'Administrator', 'owner': 'Administrator' }, diff --git a/accounts/DocType Mapper/Sales Order-Receivable Voucher/Sales Order-Receivable Voucher.txt b/accounts/DocType Mapper/Sales Order-Receivable Voucher/Sales Order-Receivable Voucher.txt index 97b1cb2380..ebbdbcd0b5 100644 --- a/accounts/DocType Mapper/Sales Order-Receivable Voucher/Sales Order-Receivable Voucher.txt +++ b/accounts/DocType Mapper/Sales Order-Receivable Voucher/Sales Order-Receivable Voucher.txt @@ -5,7 +5,7 @@ { 'creation': '2010-08-08 17:09:36', 'docstatus': 0, - 'modified': '2011-09-13 13:23:04', + 'modified': '2011-09-13 17:36:31', 'modified_by': 'Administrator', 'owner': 'Administrator' }, @@ -57,7 +57,7 @@ # 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', 'match_id': 1, 'to_field': 'qty' @@ -153,7 +153,7 @@ 'match_id': 1, 'to_field': 'entries', '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 diff --git a/selling/DocType Mapper/Delivery Note-Installation Note/Delivery Note-Installation Note.txt b/selling/DocType Mapper/Delivery Note-Installation Note/Delivery Note-Installation Note.txt index 67abbdc3b0..e45c48767d 100644 --- a/selling/DocType Mapper/Delivery Note-Installation Note/Delivery Note-Installation Note.txt +++ b/selling/DocType Mapper/Delivery Note-Installation Note/Delivery Note-Installation Note.txt @@ -5,8 +5,8 @@ { 'creation': '2010-08-08 17:09:34', 'docstatus': 0, - 'modified': '2011-05-17 11:42:57', - 'modified_by': 'umair@iwebnotes.com', + 'modified': '2011-09-13 17:28:37', + 'modified_by': 'Administrator', 'owner': 'Administrator' }, @@ -31,7 +31,7 @@ # These values are common for all DocType Mapper { - 'doctype': 'DocType Mapper', + 'doctype': u'DocType Mapper', 'from_doctype': 'Delivery Note', 'module': 'Selling', 'name': '__common__', @@ -41,7 +41,7 @@ # DocType Mapper, Delivery Note-Installation Note { - 'doctype': 'DocType Mapper', + 'doctype': u'DocType Mapper', 'name': 'Delivery Note-Installation Note' }, @@ -111,6 +111,14 @@ '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 { 'doctype': 'Table Mapper Detail', diff --git a/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt b/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt index 54e272a54f..f561c157d9 100644 --- a/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt +++ b/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt @@ -5,8 +5,8 @@ { 'creation': '2010-08-08 17:09:35', 'docstatus': 0, - 'modified': '2011-05-13 12:42:57', - 'modified_by': 'umair@iwebnotes.com', + 'modified': '2011-09-13 17:26:55', + 'modified_by': 'Administrator', 'owner': 'Administrator' }, @@ -31,7 +31,7 @@ # These values are common for all DocType Mapper { - 'doctype': 'DocType Mapper', + 'doctype': u'DocType Mapper', 'from_doctype': 'Purchase Order', 'module': 'Stock', 'name': '__common__', @@ -41,7 +41,7 @@ # DocType Mapper, Purchase Order-Purchase Receipt { - 'doctype': 'DocType Mapper', + 'doctype': u'DocType Mapper', 'name': 'Purchase Order-Purchase Receipt' }, diff --git a/stock/DocType Mapper/Receivable Voucher-Delivery Note/Receivable Voucher-Delivery Note.txt b/stock/DocType Mapper/Receivable Voucher-Delivery Note/Receivable Voucher-Delivery Note.txt index 3fd88db1f4..74437311e0 100755 --- a/stock/DocType Mapper/Receivable Voucher-Delivery Note/Receivable Voucher-Delivery Note.txt +++ b/stock/DocType Mapper/Receivable Voucher-Delivery Note/Receivable Voucher-Delivery Note.txt @@ -5,7 +5,7 @@ { 'creation': '2010-12-15 08:39:22', 'docstatus': 0, - 'modified': '2011-09-07 12:08:19', + 'modified': '2011-09-13 17:26:01', 'modified_by': 'Administrator', 'owner': 'Administrator' }, @@ -107,6 +107,15 @@ 'to_field': 'naming_series' }, + # Field Mapper Detail + { + 'doctype': 'Field Mapper Detail', + 'from_field': 'serial_no', + 'map': 'Yes', + 'match_id': 1, + 'to_field': 'serial_no' + }, + # Table Mapper Detail { 'doctype': 'Table Mapper Detail', From 67127150aed28864ad73a85fa14ef69643229239 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 13 Sep 2011 17:56:27 +0530 Subject: [PATCH 2/5] reload mapper --- patches/patch.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index cee21311e3..fa3afca7cb 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 363 +last_patch = 364 #------------------------------------------- @@ -328,3 +328,12 @@ def execute(patch_no): for d in mappers: if d[0] and d[1]: 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]) From f2718d106460c6b10714b6e389a3c34024f9da37 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 14 Sep 2011 11:40:01 +0530 Subject: [PATCH 3/5] delievery billing status patch --- patches/delivery_billing_status_patch.py | 56 ++++++++++++++---------- patches/patch.py | 5 ++- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/patches/delivery_billing_status_patch.py b/patches/delivery_billing_status_patch.py index 2f9501398c..1fcd8bfdda 100644 --- a/patches/delivery_billing_status_patch.py +++ b/patches/delivery_billing_status_patch.py @@ -1,32 +1,43 @@ import webnotes 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 #--------------- def update_percent(): - so = sql("select name from `tabSales Order` where docstatus = 1") - for d in so: - sql(""" - update - `tabSales Order` - set - 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])) - + # calculate % billed based on item table + sql(""" update `tabSales Order` so + 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), + per_billed = (select sum(if(amount > ifnull(billed_amt, 0), billed_amt, amount))/sum(amount)*100 from `tabSales Order Detail` where parent = so.name), + modified = now() + where docstatus = 1 + """) + # update DN - # --------- - dn = sql("select name from `tabDelivery Note` where docstatus = 1") - for d in dn: - sql(""" - update - `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])) - + # --------- + sql(""" update `tabDelivery Note` 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), + modified = now() + where docstatus=1 + """) # update delivery/billing status #------------------------------- @@ -39,5 +50,6 @@ def update_status(): if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""") def run_patch(): + update_delivered_billed_qty() update_percent() update_status() diff --git a/patches/patch.py b/patches/patch.py index fa3afca7cb..ca289f1672 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 364 +last_patch = 365 #------------------------------------------- @@ -337,3 +337,6 @@ def execute(patch_no): 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() From c04e2f304873249a597a6e7efcf88bd893817417 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 14 Sep 2011 15:36:15 +0530 Subject: [PATCH 4/5] fixed issue in serial no warehouse sync validation --- stock/doctype/stock_ledger/stock_ledger.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py index dca975402c..f9725918a8 100644 --- a/stock/doctype/stock_ledger/stock_ledger.py +++ b/stock/doctype/stock_ledger/stock_ledger.py @@ -51,7 +51,8 @@ class DocType: # ----------------------------- def validate_serial_no_warehouse(self, obj, 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) for s in serial_nos: s = s.strip() @@ -60,8 +61,8 @@ class DocType: msgprint("Serial No %s does not exists"%s, raise_exception = 1) elif not sr_war[0][0]: msgprint("Warehouse not mentioned in the Serial No %s" % 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): - 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) + elif sr_war[0][0] != wh: + msgprint("Serial No : %s for Item : %s doesn't exists in Warehouse : %s" % (s, d.item_code, wh), raise_exception = 1) # ------------------------------------ From c3307c5eec9f4173f4ec5bd1a8f40b6a2b548abb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 14 Sep 2011 17:23:56 +0530 Subject: [PATCH 5/5] fixed issue: warehouse was getting blank on sales return cancel --- stock/doctype/stock_ledger/stock_ledger.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py index f9725918a8..ff6de7083d 100644 --- a/stock/doctype/stock_ledger/stock_ledger.py +++ b/stock/doctype/stock_ledger/stock_ledger.py @@ -134,8 +134,10 @@ class DocType: else: 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) - elif purpose in ['Material Transfer', 'Sales Return']: - 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)) + elif purpose == 'Material Transfer': + 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: 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)