Browse Source

Audit repor index error fix

master
venkataakhil 11 months ago
parent
commit
5959a39765
  1. 48
      smart_service/transactions/report/audit_report/audit_report.py

48
smart_service/transactions/report/audit_report/audit_report.py

@ -46,11 +46,10 @@ def get_data(filters):
filter_data = filters.variant_mapping filter_data = filters.variant_mapping
if filter_data != None and len(data) > 0: if filter_data != None and len(data) > 0:
validation_flag, data = modify_data(data, filter_data) validation_flag, data = modify_data(data, filter_data)
if validation_flag: if validation_flag:
return data return data
else: else:
frappe.log_error('Audit report',str(data)) return []
return []
return data return data
@ -99,11 +98,13 @@ def modify_data(data_input, filter_parent):
for j in ss_map_append: for j in ss_map_append:
val = j['procedure_name'] val = j['procedure_name']
proc = j['procedure'] proc = j['procedure']
proc_map, proc_size = get_parent_map(ss_map[val], 'procedure_name') proc_map, proc_size = get_parent_map(
ss_map[val], 'procedure_name')
proc_values_dic = append_to_dic3( proc_values_dic = append_to_dic3(
proc_map, proc_size, j, indent=3, header=0, procedure=proc) proc_map, proc_size, j, indent=3, header=0, procedure=proc)
proc_length = status_length_append(proc_values_dic, 'Procedure') proc_length = status_length_append(
proc_values_dic, 'Procedure')
j['active_status'] = j['active_status'] + ' / ' + proc_length j['active_status'] = j['active_status'] + ' / ' + proc_length
list1.append(j) list1.append(j)
@ -112,20 +113,22 @@ def modify_data(data_input, filter_parent):
proc_map[pm], 'step_name') proc_map[pm], 'step_name')
step_length = status_length_append(steps_size, 'Step') step_length = status_length_append(steps_size, 'Step')
list1.append({'procedure_name': pm, 'indent': 3, 'header': 0, list1.append({'procedure_name': pm, 'indent': 3, 'header': 0,
'active_status': step_length, 'modified': ''}) 'active_status': step_length, 'modified': ''})
for sl in step_list: for sl in step_list:
list1.append({'procedure_name': sl, 'indent': 4, list1.append({'procedure_name': sl, 'indent': 4,
'header': 0, 'active_status': '', 'modified': ''}) 'header': 0, 'active_status': '', 'modified': ''})
for ss in step_list[sl]: for ss in step_list[sl]:
ss.update({'procedure_name': ss['content_type']}) ss.update({'procedure_name': ss['content_type']})
list1.append(ss) list1.append(ss)
append_data = add_duplicate_data(list1) append_data = add_duplicate_data(list1)
append_data = remove_duplicate_and_header(append_data) append_data = remove_duplicate_and_header(append_data)
# frappe.msgprint(str(append_data))
return True, append_data return True, append_data
except Exception as e: except Exception as e:
frappe.log_error('Audit report_modify ',str(e)) frappe.log_error('Audit report', frappe.get_traceback())
return False, str(e) False, None
def append_to_dic1(map_data, indent, header): def append_to_dic1(map_data, indent, header):
map_data_append = [] map_data_append = []
@ -231,20 +234,21 @@ def append_to_dic3(map_data, proc_size, j, indent, header, procedure):
for cus in range(len(custom_lang)): for cus in range(len(custom_lang)):
if len(list1[cus]) > 0: if len(list1[cus]) > 0:
if i<len(list1[cus]):
# frappe.msgprint(str(list1[cus]))
if list1[cus][i][0] == 1:
dic1['{}_active_status'.format(custom_lang[cus]['lang_code'])] = str(
list1[cus][i][0]) + " Step"
else:
dic1['{}_active_status'.format(custom_lang[cus]['lang_code'])] = str(
list1[cus][i][0]) + " Steps"
if list1[cus][i][0] == 1: # Append modified date
dic1['{}_active_status'.format(custom_lang[cus]['lang_code'])] = str( dic1['{}_modified'.format(
list1[cus][i][0]) + " Step" custom_lang[cus]['lang_code'])] = list1[cus][i][1]
else:
dic1['{}_active_status'.format(custom_lang[cus]['lang_code'])] = str(
list1[cus][i][0]) + " Steps"
# Append modified date
dic1['{}_modified'.format(
custom_lang[cus]['lang_code'])] = list1[cus][i][1]
dic2.update(dic1) dic2.update(dic1)
proc_dict.update(dic1) proc_dict.update(dic1)
i += 1 i += 1
map_data_append.append(proc_dict) map_data_append.append(proc_dict)
return map_data_append return map_data_append

Loading…
Cancel
Save