added repair_all_bin fn
This commit is contained in:
parent
211b04a011
commit
edddabd4f0
@ -23,6 +23,8 @@ class DocType:
|
|||||||
self.doclist = doclist
|
self.doclist = doclist
|
||||||
self.msg = []
|
self.msg = []
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
def get_count_for_reposting(self, args):
|
def get_count_for_reposting(self, args):
|
||||||
args = eval(args)
|
args = eval(args)
|
||||||
if args['check'] == 'Bin':
|
if args['check'] == 'Bin':
|
||||||
@ -39,6 +41,7 @@ class DocType:
|
|||||||
|
|
||||||
return [d[0] for d in sql("select name from `tabAccount` ")]
|
return [d[0] for d in sql("select name from `tabAccount` ")]
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
def get_bin_qty(self, wh, item):
|
def get_bin_qty(self, wh, item):
|
||||||
# get actual_qty
|
# get actual_qty
|
||||||
act_qty = sql("select ifnull(actual_qty, 0) from `tabBin` where warehouse = '%s' and item_code = '%s'" % (wh, item))
|
act_qty = sql("select ifnull(actual_qty, 0) from `tabBin` where warehouse = '%s' and item_code = '%s'" % (wh, item))
|
||||||
@ -52,6 +55,7 @@ class DocType:
|
|||||||
ord_qty = sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.received_qty, 0), (ifnull(t2.qty, 0) - ifnull(t2.received_qty, 0)) * ifnull(t2.conversion_factor, 0) , 0) ) from `tabPurchase Order` t1, `tabPO Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s'" % (wh, item))
|
ord_qty = sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.received_qty, 0), (ifnull(t2.qty, 0) - ifnull(t2.received_qty, 0)) * ifnull(t2.conversion_factor, 0) , 0) ) from `tabPurchase Order` t1, `tabPO Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s'" % (wh, item))
|
||||||
ord_qty = ord_qty and flt(ord_qty[0][0]) or 0
|
ord_qty = ord_qty and flt(ord_qty[0][0]) or 0
|
||||||
|
|
||||||
|
|
||||||
# get reserved_qty
|
# get reserved_qty
|
||||||
res_qty =sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.delivered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.delivered_qty, 0) , 0) ) from `tabSales Order` t1, `tabSales Order Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.reserved_warehouse = '%s' and t2.item_code = '%s' " % (wh, item))
|
res_qty =sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.delivered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.delivered_qty, 0) , 0) ) from `tabSales Order` t1, `tabSales Order Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.reserved_warehouse = '%s' and t2.item_code = '%s' " % (wh, item))
|
||||||
res_qty = res_qty and flt(res_qty[0][0]) or 0
|
res_qty = res_qty and flt(res_qty[0][0]) or 0
|
||||||
@ -62,6 +66,7 @@ class DocType:
|
|||||||
|
|
||||||
return {'actual_qty': act_qty, 'indented_qty': ind_qty, 'ordered_qty': ord_qty, 'reserved_qty': res_qty, 'planned_qty': plan_qty }
|
return {'actual_qty': act_qty, 'indented_qty': ind_qty, 'ordered_qty': ord_qty, 'reserved_qty': res_qty, 'planned_qty': plan_qty }
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
def check_bin_qty(self, bin_obj, qty_dict):
|
def check_bin_qty(self, bin_obj, qty_dict):
|
||||||
label_dict = {'actual_qty': 'Actual Qty', 'indented_qty': 'Indent Qty', 'ordered_qty': 'Ordered Qty', 'reserved_qty': 'Reserved Qty', 'planned_qty': 'Planned Qty'}
|
label_dict = {'actual_qty': 'Actual Qty', 'indented_qty': 'Indent Qty', 'ordered_qty': 'Ordered Qty', 'reserved_qty': 'Reserved Qty', 'planned_qty': 'Planned Qty'}
|
||||||
for f in qty_dict:
|
for f in qty_dict:
|
||||||
@ -75,6 +80,8 @@ class DocType:
|
|||||||
msgprint('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
|
msgprint('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
|
||||||
self.msg.append('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
|
self.msg.append('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
def repair_bin(self, bin):
|
def repair_bin(self, bin):
|
||||||
import webnotes
|
import webnotes
|
||||||
bin_obj = get_obj('Bin',bin)
|
bin_obj = get_obj('Bin',bin)
|
||||||
@ -99,6 +106,19 @@ class DocType:
|
|||||||
msgprint('<div style="color: RED"> Handle Item %s and Warehouse %s seprately. </div> <div style="color: RED"> ERROR: %s</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, str(webnotes.utils.getTraceback())))
|
msgprint('<div style="color: RED"> Handle Item %s and Warehouse %s seprately. </div> <div style="color: RED"> ERROR: %s</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, str(webnotes.utils.getTraceback())))
|
||||||
self.msg.append('<div style="color: RED"> ERROR: %s</div>' % (str(webnotes.utils.getTraceback())))
|
self.msg.append('<div style="color: RED"> ERROR: %s</div>' % (str(webnotes.utils.getTraceback())))
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
def repair_all_bins(self):
|
||||||
|
bins = sql("select name from tabBin")
|
||||||
|
cnt = 0
|
||||||
|
for bin in bins[0]:
|
||||||
|
if cnt % 20 == 0:
|
||||||
|
sql("commit")
|
||||||
|
sql("start transaction")
|
||||||
|
cnt += 1
|
||||||
|
|
||||||
|
self.repair_bin(bin)
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
def repair_opening_bal(self, d, acc_obj, past_yr, fiscal_yr):
|
def repair_opening_bal(self, d, acc_obj, past_yr, fiscal_yr):
|
||||||
# check opening balance
|
# check opening balance
|
||||||
opbal = sql("select balance from `tabAccount Balance` where account=%s and period = %s", (acc_obj.doc.name, past_yr))
|
opbal = sql("select balance from `tabAccount Balance` where account=%s and period = %s", (acc_obj.doc.name, past_yr))
|
||||||
@ -107,6 +127,8 @@ class DocType:
|
|||||||
self.msg.append('<div style="color: RED"> Difference found in Opening of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.opening), opbal and flt(opbal[0][0]) or 0))
|
self.msg.append('<div style="color: RED"> Difference found in Opening of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.opening), opbal and flt(opbal[0][0]) or 0))
|
||||||
sql("update `tabAccount Balance` set opening = '%s' where period = '%s' and account = '%s' " % (opbal and flt(opbal[0][0]) or 0, fiscal_yr, acc_obj.doc.name))
|
sql("update `tabAccount Balance` set opening = '%s' where period = '%s' and account = '%s' " % (opbal and flt(opbal[0][0]) or 0, fiscal_yr, acc_obj.doc.name))
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
def repair_bal(self, d, acc_obj, fiscal_yr):
|
def repair_bal(self, d, acc_obj, fiscal_yr):
|
||||||
# check balances
|
# check balances
|
||||||
ysd = get_value('Fiscal Year', fiscal_yr, 'year_start_date')
|
ysd = get_value('Fiscal Year', fiscal_yr, 'year_start_date')
|
||||||
@ -116,6 +138,8 @@ class DocType:
|
|||||||
self.msg.append('<div style="color: RED"> Difference found in Balance of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.balance), flt(bal)))
|
self.msg.append('<div style="color: RED"> Difference found in Balance of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.balance), flt(bal)))
|
||||||
sql("update `tabAccount Balance` set balance = '%s' where period = '%s' and account = '%s' " % (bal, d.period, acc_obj.doc.name))
|
sql("update `tabAccount Balance` set balance = '%s' where period = '%s' and account = '%s' " % (bal, d.period, acc_obj.doc.name))
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
def repair_acc_bal(self, acc, past_yr = '' , fiscal_yr = ''):
|
def repair_acc_bal(self, acc, past_yr = '' , fiscal_yr = ''):
|
||||||
# get account obj
|
# get account obj
|
||||||
acc_obj = get_obj('Account', acc, with_children = 1)
|
acc_obj = get_obj('Account', acc, with_children = 1)
|
||||||
@ -140,6 +164,8 @@ class DocType:
|
|||||||
|
|
||||||
return self.msg
|
return self.msg
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
def send_mail(self, args):
|
def send_mail(self, args):
|
||||||
args = eval(args)
|
args = eval(args)
|
||||||
self.msg, subject = args['msg'], args['subject']
|
self.msg, subject = args['msg'], args['subject']
|
||||||
@ -153,4 +179,4 @@ In Account := %s User := %s has Reposted %s and following was found:-
|
|||||||
|
|
||||||
""" % (get_value('Control Panel', None,'account_id'), session['user'], subject, '\n'.join(self.msg))
|
""" % (get_value('Control Panel', None,'account_id'), session['user'], subject, '\n'.join(self.msg))
|
||||||
|
|
||||||
sendmail(['saumil@iwebnotes.com','nabin@iwebnotes.com'], subject='Repair of ' + cstr(subject), parts = [('text/plain', email_msg)])
|
sendmail(['support@iwebnotes.com'], subject='Repair of ' + cstr(subject), parts = [('text/plain', email_msg)])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user