'Validates qty at row level'

def validate_qty(self):

    self.tolerance = {}
    self.global_tolerance = None
    for args in self.status_updater:
        if (u'target_ref_field' not in args):
            continue
        for d in self.get_all_children():
            if ((d.doctype == args[u'source_dt']) and d.get(args[u'join_field'])):
                args[u'name'] = d.get(args[u'join_field'])
                item = frappe.db.sql(u'select    item_code,    `{target_ref_field}`,\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB `{target_field}`,    parenttype,    parent    from    `tab{target_dt}`\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB where    `{target_ref_field}`    <    `{target_field}`\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB and    name=%s    and    docstatus=1'.format(**args), args[u'name'], as_dict=1)
                if item:
                    item = item[0]
                    item[u'idx'] = d.idx
                    item[u'target_ref_field'] = args[u'target_ref_field'].replace(u'_', u'    ')
                    if args.get(u'no_tolerance'):
                        item[u'reduce_by'] = (item[args[u'target_field']] - item[args[u'target_ref_field']])
                        if (item[u'reduce_by'] > 0.01):
                            self.limits_crossed_error(args, item)
                    elif item[args[u'target_ref_field']]:
                        self.check_overflow_with_tolerance(item, args)
