diff --git a/netforce_clinic/models/report_labor_cost_detail.py b/netforce_clinic/models/report_labor_cost_detail.py index 58acb1c..4c0638a 100644 --- a/netforce_clinic/models/report_labor_cost_detail.py +++ b/netforce_clinic/models/report_labor_cost_detail.py @@ -108,12 +108,8 @@ class ReportLaborCostDetail(Model): dom.append(['cycle_id','=',cycle_id]) if categ_id: dom.append(['staff_id.categ_id','=',categ_id]) - print('dom ', dom) def replace_quote(dom=""): return dom.replace("'","\"") - #prevent to load more data - #if not staff_id: - #return {} dates={} for line in get_model("clinic.labor.cost.line").search_browse(dom): lcost=line.labor_cost_id @@ -122,8 +118,7 @@ class ReportLaborCostDetail(Model): if not date: continue dpt=citem.department_id - #amt=line.pay_amount or 0 #XXX - amt=line.amount or 0 #XXX + amt=line.amount or 0 staff=line.staff_id qty=0 if staff.type=='doctor': @@ -277,8 +272,43 @@ class ReportLaborCostDetail(Model): 'dpt_lines': dpt_lines, 'show_all': show_count <=1 and True or False, } - print('department_id ', department_id) - print('branch_id ', branch_id) + data['dpts_txt']=[{0: '#', 1: 'วันที่'}] + vals={} + no=0 + dpt_len=len(data['dpts_txt'][0]) + for dpt in dpts: + data['dpts_txt'][0][no+dpt_len]=dpt['name'] + vals[no]=0 + no+=1 + count=1 + items=[] + def int2ths(r): + if type(r)==type(''): + return r + if not r: + return "" + return "{0:,.2f}".format(r) + for i in range(len(data['lines'])): + line=data['lines'][i] + item_vals=vals.copy() + item_vals['no']=count + item_vals['date']=line['date'] + no=0 + for sub_line in line['sub_lines']: + item_vals['item%s_qty'%no]=int2ths(sub_line['qty']) + item_vals['item%s_amt'%no]=int2ths(sub_line['amt']) + no+=1 + item_vals['total_qty']=int2ths(line['total_qty']) + item_vals['total_amt']=int2ths(line['total_amt']) + items.append(item_vals) + count+=1 + data['items']=items + data['total_lines_txt']=[{}] + no=0 + for tline in data['dpt_lines']: + data['total_lines_txt'][0]['item%s_qty'%no]=int2ths(tline['qty']) + data['total_lines_txt'][0]['item%s_amt'%no]=int2ths(tline['amt']) + no+=1 return data def onchange_date(self,context={}): diff --git a/netforce_clinic/models/report_labor_cost_sub_detail.py b/netforce_clinic/models/report_labor_cost_sub_detail.py index 7b648e1..9e0d5b9 100644 --- a/netforce_clinic/models/report_labor_cost_sub_detail.py +++ b/netforce_clinic/models/report_labor_cost_sub_detail.py @@ -38,10 +38,10 @@ class ReportLaborCostSubDetail(Model): date_to=self._get_date_to() staff_type=defaults.get("staff_type","doctor") staff_id=int(defaults.get('staff_id', "0")) - department_id=defaults.get('department_id') + department_id=defaults.get('department_id',None) if department_id: department_id=int(department_id) - branch_id=defaults.get('branch_id') + branch_id=defaults.get('branch_id',None) if branch_id: branch_id=int(branch_id) if not branch_id and department_id: @@ -56,6 +56,7 @@ class ReportLaborCostSubDetail(Model): 'department_id': department_id, 'branch_id': branch_id, } + print('res ', res) return res def get_report_data(self,ids,context={}): @@ -66,8 +67,8 @@ class ReportLaborCostSubDetail(Model): date_to=defaults.get("date_to") staff_type=defaults.get("staff_type") staff_id=defaults.get("staff_id") - branch_id=defaults.get("branch_id") - department_id=defaults.get("department_id") + branch_id=defaults.get("branch_id",None) + department_id=defaults.get("department_id",None) staff_name='' dom=[] if ids: diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py index c3d2cad..d34bc66 100644 --- a/netforce_clinic/models/report_labor_cost_summary.py +++ b/netforce_clinic/models/report_labor_cost_summary.py @@ -120,8 +120,6 @@ class ReportLaborCostSummary(Model): if type(r)==type(''): return r return "{0:,.0f}".format(r) - - print('--> dom: ', dom) total_hdcase=0 for line in get_model("clinic.labor.cost.line").search_browse(dom): lcost=line.labor_cost_id @@ -283,8 +281,10 @@ class ReportLaborCostSummary(Model): 'staff_type': staff_type, 'branch_id': branch_id, 'department_id': department_id, - 'dpts_txt': [{0: '#', 1: 'รหัส', 2: 'ชื่อ-สกุล',}], } + + # for report xlsx + data['dpts_txt']=[{0: '#', 1: 'รหัส', 2: 'ชื่อ-สกุล',}] items=[] vals={} no=0 diff --git a/netforce_clinic/reports/report_labor_cost_detail.xlsx b/netforce_clinic/reports/report_labor_cost_detail.xlsx index fccee4c..c16264f 100644 Binary files a/netforce_clinic/reports/report_labor_cost_detail.xlsx and b/netforce_clinic/reports/report_labor_cost_detail.xlsx differ diff --git a/netforce_clinic/reports/report_labor_cost_sub_detail.xlsx b/netforce_clinic/reports/report_labor_cost_sub_detail.xlsx index ea852c3..24cfb0a 100644 Binary files a/netforce_clinic/reports/report_labor_cost_sub_detail.xlsx and b/netforce_clinic/reports/report_labor_cost_sub_detail.xlsx differ diff --git a/netforce_clinic/reports/report_labor_cost_summary.xlsx b/netforce_clinic/reports/report_labor_cost_summary.xlsx index 1d4e986..9a17351 100644 Binary files a/netforce_clinic/reports/report_labor_cost_summary.xlsx and b/netforce_clinic/reports/report_labor_cost_summary.xlsx differ diff --git a/netforce_clinic/templates/report_labor_cost_detail.hbs b/netforce_clinic/templates/report_labor_cost_detail.hbs index 9ad3efe..559c288 100644 --- a/netforce_clinic/templates/report_labor_cost_detail.hbs +++ b/netforce_clinic/templates/report_labor_cost_detail.hbs @@ -10,7 +10,15 @@ {{/if}} {{#if show_all}} - {{comp_name}} + {{#if department_id}} + {{comp_name}} + {{else}} + {{#if branch_id}} + {{comp_name}} + {{else}} + {{comp_name}} + {{/if}} + {{/if}} {{else}} {{comp_name}} {{/if}}