From 217047f577f56c823a2848b8f3486f5a53edcb14 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Fri, 1 May 2015 07:57:31 +0700 Subject: [PATCH] improve report --- netforce_clinic/models/report_labor_cost.py | 19 ++++++---- .../models/report_labor_cost_staff.py | 35 ++++++++++++++++--- netforce_clinic/models/setting.py | 6 ++++ .../templates/report_labor_cost.hbs | 8 +++-- .../templates/report_labor_cost_staff.hbs | 10 ++++++ 5 files changed, 66 insertions(+), 12 deletions(-) diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py index 23cdcb8..3c257d2 100644 --- a/netforce_clinic/models/report_labor_cost.py +++ b/netforce_clinic/models/report_labor_cost.py @@ -239,12 +239,13 @@ class ReportLaborCost(Model): dom3=dom1+[['walkin','=',False]] dlines.append({ 'name': dt_name, - 'qty': "{0:.2f}".format(round(qty,2)), - 'qty2': "{0:.2f}".format(round(walkin_qty,2)), + 'qty': "{0:,.2f}".format(round(qty,2)), + 'qty2': "{0:,.2f}".format(round(walkin_qty,2)), 'walkin_qty': walkin_qty, - 'option_qty': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom3)), - 'option_qty2': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom2)), 'total_qty': walkin_qty+qty, + 'date': date, + 'date_from': date_from, + 'date_to': date_to, 'cost': cost, 'total': 0, 'department_id': dpt_id, @@ -262,6 +263,9 @@ class ReportLaborCost(Model): 'department_id': None, 'branch_id':None, 'staff_type': 'doctor', + 'date': date, + 'date_from': date_from, + 'date_to': date_to, }]+sorted(dlines,key=lambda x: x['name']) dom4=[ ['date','>=',date_from], @@ -284,6 +288,9 @@ class ReportLaborCost(Model): 'cycle_id': cycle_id, 'branch_id': branch_id, 'department_id': department_id, + 'date': date, + 'date_from': date_from, + 'date_to': date_to, 'option_qty': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom4)), 'option_qty2': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom5)), }) @@ -293,8 +300,8 @@ class ReportLaborCost(Model): dlines[-1]['total_qty']+=dline['total_qty'] or 0 dlines[-1]['cost']+=dline['cost'] or 0 dlines[-1]['walkin_qty']+=float(dline['qty2']) or 0 - dlines[-1]['qty']="{0:.2f}".format(round(dlines[-1]['qty'],2)) #total - dlines[-1]['qty2']="{0:.2f}".format(round(dlines[-1]['qty2'],2)) #total + dlines[-1]['qty']="{0:,.2f}".format(round(dlines[-1]['qty'],2)) #total + dlines[-1]['qty2']="{0:,.2f}".format(round(dlines[-1]['qty2'],2)) #total nlines.append({ 'name': 'พยาบาล', diff --git a/netforce_clinic/models/report_labor_cost_staff.py b/netforce_clinic/models/report_labor_cost_staff.py index e1ab90c..dfd9f79 100644 --- a/netforce_clinic/models/report_labor_cost_staff.py +++ b/netforce_clinic/models/report_labor_cost_staff.py @@ -34,12 +34,24 @@ class ReportLaborCostStaff(Model): date_from=defaults.get("date_from", self._get_date_from()) date_to=defaults.get("date_to", self._get_date_to()) walkin=defaults.get("walkin", False) + department_id=defaults.get("department_id") or None + if department_id: + department_id=int(department_id) + branch_id=defaults.get("branch_id") or None + if branch_id: + branch_id=int(branch_id) + if walkin and walkin=='False': + walkin=False + else: + walkin=True print('defaults ', defaults) res={ 'date': time.strftime("%Y-%m-%d"), 'date_from': date_from, 'date_to': date_to, 'walkin': walkin, + 'department_id': department_id, + 'branch_id': branch_id, } return res @@ -71,23 +83,38 @@ class ReportLaborCostStaff(Model): if cycle_id: dom.append(['hd_case_id.cycle_id','=',cycle_id]) lines=[] + print('dom ', dom) for sline in get_model("clinic.hd.case.staff").search_browse(dom): hdcase=sline.hd_case_id staff=sline.staff_id - if walkin and staff: - continue + patient=hdcase.patient_id + if walkin: + if staff and staff.number!='walkin': + continue + else: + if staff.number=='walkin': + continue lines.append({ 'id': sline.id, 'date': sline.date, 'number': hdcase.number or '', 'staff_name': staff.name or '', - 'staff_id': staff.id or '', + 'staff_id': staff.id or None, + 'patient_id': patient.id or None, + 'patient_name': patient.name or None, 'department_name': sline.department_id.name or '', + 'date': sline.date, }) + nlines=[] + no=1 + for line in sorted(lines,key=lambda x: (x['date'],x['number'])): + line['no']=no + nlines.append(line) + no+=1 data={ 'date_from': date_from, 'date_to': date_to, - 'lines': lines, + 'lines': nlines, } return data diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 8a7cdf2..d150b92 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -161,6 +161,12 @@ class ClinicSetting(Model): if user_id !=1: print("Only admin!!") return + for sline in get_model("clinic.hd.case.staff").search_browse([]): + hdcase=sline.hd_case_id + sline.write({ + 'date': hdcase.date, + }) + print('update ', sline.id, hdcase.date) #obj=self.browse(ids)[0] #obj.del_duplicate_staff() #obj.merge_staff() diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost.hbs index 3b4c7dd..00b5437 100644 --- a/netforce_clinic/templates/report_labor_cost.hbs +++ b/netforce_clinic/templates/report_labor_cost.hbs @@ -72,7 +72,9 @@ {{qty}} {{else}} - {{view "link" string=qty action="clinic_report_labor_cost_staff" action_options=option_qty}} + + {{qty}} + {{/if}} {{/each}} @@ -84,7 +86,9 @@ {{else}} {{#if walkin_qty}} - {{view "link" string=qty2 action="clinic_report_labor_cost_staff" action_options=option_qty2}} + + {{qty2}} + {{else}} 0.00 {{/if}} diff --git a/netforce_clinic/templates/report_labor_cost_staff.hbs b/netforce_clinic/templates/report_labor_cost_staff.hbs index 35f1d5f..4d21bb3 100644 --- a/netforce_clinic/templates/report_labor_cost_staff.hbs +++ b/netforce_clinic/templates/report_labor_cost_staff.hbs @@ -3,20 +3,28 @@ + + + {{#each lines}} + + + @@ -27,6 +35,8 @@ + +
#Date HDCase DoctorPatient Department
{{no}}{{date}} {{view "link" string=number action="clinic_hd_case_staff" action_options="mode=form" active_id=id}} {{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}} + {{view "link" string=patient_name action="clinic_patient" action_options="mode=form" active_id=patient_id}} + {{department_name}}