removed repair fn, fixes in reports

This commit is contained in:
Nabin Hait 2012-04-13 11:53:06 +05:30
parent a73b2965aa
commit e77164955b
9 changed files with 20 additions and 100 deletions

View File

@ -55,17 +55,6 @@ class DocType(TransactionBase):
'Purchase Order' : 'Purchase Order Item',
'Purchase Receipt' : 'Purchase Receipt Item'}
self.repair_percent_field = {
'ordered_qty' : 'per_ordered',
'received_qty': 'per_received',
'billed_qty' : 'per_billed'}
self.repair_fields = {
'Purchase Request Item' : ['ordered_qty'],
'Purchase Order Item' : ['received_qty', 'billed_qty'],
'Purchase Receipt Item': ['billed_qty']
}
self.next_dt_detail = {
'ordered_qty' : 'Purchase Order Item',
'billed_qty' : 'Purchase Invoice Item',
@ -563,64 +552,3 @@ class DocType(TransactionBase):
if d.prevdoc_doctype and d.prevdoc_docname:
dt = sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
d.prevdoc_date = dt and dt[0][0].strftime('%Y-%m-%d') or ''
#=================================================================================
# REPAIR OPTION
#=================================================================================
def get_next_dt_detail_qty(self, next_dt_detail, name, curr_dt, f):
get_qty = (curr_dt == 'Purchase Request') and 'qty * conversion_factor' or 'qty'
qty = sql("select sum(%s) from `tab%s` where %s = '%s' and docstatus = 1"% (get_qty, next_dt_detail, (f == 'billed_qty') and (curr_dt == 'Purchase Order' and 'po_detail' or 'pr_detail') or 'prevdoc_detail_docname', name))
return qty and flt(qty[0][0]) or 0
def repair_curr_qty_details(self, obj):
self.repair_fields_list, count, percent = self.repair_fields[obj.tname], {}, {}
# Check and Update Fields in Detail Table
for d in getlist(obj.doclist, obj.fname):
for f in self.repair_fields_list:
qty, update_qty = d.fields.get(f,0), self.get_next_dt_detail_qty(self.next_dt_detail[f], d.name, obj.doc.doctype, f)
# Check qty
if flt(qty) != flt(update_qty):
msgprint('<div style="color: RED"> Difference found in %s (Before : %s; After : %s) in %s of %s : %s in Row No : %s </div>' % (f, qty, update_qty, obj.tname, obj.doc.doctype, obj.doc.name, d.name))
self.msg.append('<div style="color: RED"> Difference found in %s (Before : %s; After : %s) in %s of %s : %s in Row No : %s</div>' % (f, qty, update_qty, obj.tname, obj.doc.doctype, obj.doc.name, d.name))
# update qty
#sql("update `tab%s` set %s = '%s' where name = '%s'"% (obj.tname, f, update_qty, d.name))
set(d, f, update_qty)
# Calculate percentage
if flt(d.qty) - flt(update_qty) <= 0:
percent[f] = percent.get(f, 0) + 100
else:
percent[f] = percent.get(f, 0) + (flt(update_qty)/flt(d.qty) * 100)
count[f] = count.get(f,0) + 1
return count, percent
def repair_curr_percent_detail(self, obj, count, percent):
import math
for f in self.repair_fields_list:
per_complete, update_per_complete = flt(obj.doc.fields.get(self.repair_percent_field[f], 0)), math.floor(flt(percent[f]) / flt(count[f]))
if flt(obj.doc.fields.get(self.repair_percent_field[f], 0)) != flt(update_per_complete):
msgprint('<div style="color: RED">Difference found in %s (Before : %s; After : %s) in %s : %s </div>' % (self.repair_percent_field[f], per_complete, update_per_complete, obj.doc.doctype, obj.doc.name))
self.msg.append('<div style="color: RED">Difference found in %s (Before : %s; After : %s) in %s : %s </div>' % (self.repair_percent_field[f], per_complete, update_per_complete, obj.doc.doctype, obj.doc.name))
#sql("update `tab%s` set %s = '%s' where name = '%s'" % (obj.doc.doctype, self.repair_percent_field[f], update_per_complete, obj.doc.name))
set(obj.doc, self.repair_percent_field[f], update_per_complete)
def send_mail(self, obj):
email_msg = """ Dear Administrator,
In Account := %s User := %s has Reposted %s : %s and following was found:-
%s
""" % (get_value('Control Panel', None,'account_id'), session['user'], obj.doc.doctype, obj.doc.name, '\n'.join(self.msg))
sendmail(['jai@webnotestech.com'], subject='Repair Option', parts = [('text/plain', email_msg)])
def repair_curr_doctype_details(self, obj):
count, percent = self.repair_curr_qty_details(obj)
self.repair_curr_percent_detail(obj, count, percent)
if self.msg: self.send_mail(obj)
msgprint('<div style="color: GREEN"> ' + cstr(obj.doc.doctype) + ' : ' + cstr(obj.doc.name) + ' has been checked' + cstr(self.msg and ' and repaired successfully.' or '. No changes Found.' + '</div>'))

View File

@ -363,8 +363,3 @@ class DocType(TransactionBase):
# **** Pull details from other charges master (Get Other Charges) ****
def get_purchase_tax_details(self):
return get_obj('Purchase Common').get_purchase_tax_details(self)
# Repair Purchase Order
# ===========================================
def repair_purchase_order(self):
get_obj('Purchase Common', 'Purchase Common').repair_curr_doctype_details(self)

View File

@ -231,9 +231,3 @@ class DocType:
# Step 5:=> Set Status
set(self.doc,'status','Cancelled')
# Repair Purchase Request
# ===========================================
def repair_indent(self):
get_obj('Purchase Common', 'Purchase Common').repair_curr_doctype_details(self)

View File

@ -3,24 +3,25 @@
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'creation': '2012-04-11 13:16:55',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified': '2012-04-13 11:15:06',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'Purchase Order\x01ID,Purchase Order\x01PO Date,Purchase Order\x01Grand Total,Purchase Order Item\x01Item Code,Purchase Order Item\x01Item Name,Purchase Order Item\x01Quantity,Purchase Order Item\x01Stock UOM,Purchase Order Item\x01Purchase Rate,Purchase Order Item\x01Amount,Purchase Order Item\x01Warehouse',
'columns': u'Purchase Order\x01ID,Purchase Order\x01Purchase Order Date,Purchase Order Item\x01Item Code,Purchase Order Item\x01Item Name,Purchase Order Item\x01Quantity,Purchase Order Item\x01Stock UOM,Purchase Order Item\x01Rate ,Purchase Order Item\x01Amount,Purchase Order\x01Net Total*,Purchase Order\x01Grand Total',
'criteria_name': u'Itemwise Purchase Details',
'doc_type': u'Purchase Order Item',
'doctype': 'Search Criteria',
'filters': u"{'Purchase Order\x01Saved':1,'Purchase Order\x01Submitted':1,'Purchase Order\x01Status':'','Purchase Order\x01Company Name':''}",
'filters': u'{"Purchase Order\\u0001Submitted":1,"Purchase Order\\u0001Status":[],"Purchase Order\\u0001Fiscal Year":[]}',
'module': u'Buying',
'name': '__common__',
'page_len': 50,
'parent_doc_type': u'Purchase Order',
'sort_by': u'`tabPurchase Order`.`name`',
'sort_by': u'`tabPurchase Order`.`transaction_date`',
'sort_order': u'DESC',
'standard': u'Yes'
},

View File

@ -48,6 +48,7 @@ def execute():
reload_doc(mod, 'DocType Mapper', ren_mapper[d])
delete_search_criteria()
change_report_module()
# reload custom search criteria
#for d in webnotes.conn.sql("""select name, module from
@ -126,7 +127,8 @@ def delete_search_criteria():
'delivery_notes', 'delivery_note_disabled', 'lead', 'lead_interested', 'lead_report',
'periodic_sales_summary', 'monthly_despatched_trend', 'sales', 'sales_order',
'sales_order1', 'sales_agentwise_commission', 'test_report',
'territory_wise_sales_-_target_vs_actual_')""")
'territory_wise_sales_-_target_vs_actual_',
'pending_po_items_to_bill1', 'pending_po_items_to_receive1')""")
webnotes.conn.sql("""
DELETE FROM `tabSearch Criteria`
@ -137,6 +139,11 @@ def delete_search_criteria():
AND IFNULL(standard, 'No') = 'Yes'
""")
def change_report_module():
reports = {'itemwise_receipt_details': 'Stock'}
for k in reports:
sql("update `tabSearch Criteria` set module = %s where name = %s", (reports[k], k))
def rename_in_db(ren_data, data_type, is_doctype):
for d in ren_data:
print colored('Renaming... ' + d + ' --> '+ ren_data[d], 'yellow')

View File

@ -466,8 +466,3 @@ class DocType(TransactionBase):
# **** Pull details from other charges master (Get Other Charges) ****
def get_purchase_tax_details(self):
return get_obj('Purchase Common').get_purchase_tax_details(self)
# Repair Purchase Order
# ===========================================
def repair_purchase_receipt(self):
get_obj('Purchase Common').repair_curr_doctype_details(self)

View File

@ -3,21 +3,21 @@
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'creation': '2012-04-11 13:16:55',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified': '2012-04-13 11:16:40',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'Purchase Receipt\x01ID,Purchase Receipt\x01Posting Date,Purchase Receipt Item\x01Item Code,Purchase Receipt Item\x01Item Name,Purchase Receipt Item\x01Accepted Quantity,Purchase Receipt Item\x01Rejected Quantity,Purchase Receipt Item\x01Accepted Warehouse,Purchase Receipt Item\x01Rejected Warehouse,Purchase Receipt Item\x01Amount',
'columns': u'Purchase Receipt\x01ID,Purchase Receipt\x01Posting Date,Purchase Receipt Item\x01Item Code,Purchase Receipt Item\x01Item Name,Purchase Receipt Item\x01Accepted Quantity,Purchase Receipt Item\x01Rejected Quantity,Purchase Receipt Item\x01UOM,Purchase Receipt Item\x01Accepted Warehouse,Purchase Receipt Item\x01Rejected Warehouse,Purchase Receipt Item\x01Amount',
'criteria_name': u'Itemwise Receipt Details',
'doc_type': u'Purchase Receipt Item',
'doctype': 'Search Criteria',
'filters': u"{'Purchase Receipt\x01Saved':1,'Purchase Receipt\x01Submitted':1,'Purchase Receipt\x01Status':'','Purchase Receipt\x01Fiscal Year':''}",
'module': u'Buying',
'filters': u'{"Purchase Receipt\\u0001Submitted":1,"Purchase Receipt\\u0001Status":[""],"Purchase Receipt\\u0001Fiscal Year":[""]}',
'module': u'Stock',
'name': '__common__',
'page_len': 50,
'parent_doc_type': u'Purchase Receipt',