From dd2a844d142b3d6bde4d28c6816b18e0f27a4457 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Tue, 28 Apr 2015 17:11:02 +0700 Subject: [PATCH] improve --- .../clinic_report_labor_cost_detail.xml | 2 + .../models/report_labor_cost_daily.py | 6 +++ .../models/report_labor_cost_detail.py | 46 +++++++++++++++---- .../templates/report_labor_cost_daily.hbs | 12 ++--- .../templates/report_labor_cost_detail.hbs | 19 +++++++- 5 files changed, 69 insertions(+), 16 deletions(-) diff --git a/netforce_clinic/layouts/clinic_report_labor_cost_detail.xml b/netforce_clinic/layouts/clinic_report_labor_cost_detail.xml index 602c81f..b38bebf 100644 --- a/netforce_clinic/layouts/clinic_report_labor_cost_detail.xml +++ b/netforce_clinic/layouts/clinic_report_labor_cost_detail.xml @@ -6,4 +6,6 @@ + + diff --git a/netforce_clinic/models/report_labor_cost_daily.py b/netforce_clinic/models/report_labor_cost_daily.py index 320877d..adc7a4f 100644 --- a/netforce_clinic/models/report_labor_cost_daily.py +++ b/netforce_clinic/models/report_labor_cost_daily.py @@ -69,6 +69,8 @@ class ReportLaborCostDaily(Model): amt=line.amount or 0 if staff_type=='doctor': for hdcase in citem.hd_cases: + if hdcase.state not in ("waiting_payment","paid"): + continue doctor=hdcase.doctor_id pt_type=hdcase.patient_type_id pt=hdcase.patient_id @@ -76,6 +78,7 @@ class ReportLaborCostDaily(Model): lines.append({ 'hd_case_number': hdcase.number or '', 'hd_case_id': hdcase.id or '', + 'date': hdcase.date or '', 'no': no, 'hn': pt.number, 'patient_id': pt.id, @@ -91,6 +94,8 @@ class ReportLaborCostDaily(Model): elif staff_type=='nurse': print("nurse ") for hdcase in citem.hd_cases: + if hdcase.state not in ("waiting_payment","paid"): + continue doctor=hdcase.doctor_id pt_type=hdcase.patient_type_id pt=hdcase.patient_id @@ -98,6 +103,7 @@ class ReportLaborCostDaily(Model): 'no': no, 'cycle_item_name': citem.name or '', 'cycle_item_id': citem.id, + 'date': citem.date, 'hn': pt.number, 'patient_id': pt.id, 'patient_type_name': pt_type.name or '', diff --git a/netforce_clinic/models/report_labor_cost_detail.py b/netforce_clinic/models/report_labor_cost_detail.py index 57a6280..8c549f2 100644 --- a/netforce_clinic/models/report_labor_cost_detail.py +++ b/netforce_clinic/models/report_labor_cost_detail.py @@ -18,6 +18,8 @@ class ReportLaborCostDetail(Model): "type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"), 'department_id': fields.Many2One("clinic.department","Department"), 'branch_id': fields.Many2One("clinic.branch","Branch"), + 'cycle_id': fields.Many2One("clinic.cycle","Cycle"), + 'categ_id': fields.Many2One("clinic.staff.categ","Category"), } def _get_date_from(self,context={}): @@ -32,6 +34,12 @@ class ReportLaborCostDetail(Model): def default_get(self,field_names=None,context={},**kw): defaults=context.get("defaults",{}) date_from=defaults.get("date_from") + cycle_id=defaults.get("cycle_id") + if cycle_id: + cycle_id=int(cycle_id) + categ_id=defaults.get("categ_id") + if categ_id: + categ_id=int(categ_id) if not date_from: date_from=self._get_date_from() date_to=defaults.get("date_to") @@ -39,7 +47,6 @@ class ReportLaborCostDetail(Model): date_to=self._get_date_to() staff_type=defaults.get("staff_type","doctor") staff_id=int(defaults.get('staff_id', "0")) - print('defaults ', defaults) department_id=defaults.get('department_id') if department_id: department_id=int(department_id) @@ -49,15 +56,19 @@ class ReportLaborCostDetail(Model): if not branch_id and department_id: dpt=get_model('clinic.department').browse(department_id) branch_id=dpt.branch_id.id + print('defaults ', defaults) res={ 'date': time.strftime("%Y-%m-%d"), 'date_from': date_from, 'date_to': date_to, 'type': staff_type, - 'staff_id': staff_id and staff_id or None, - 'department_id': department_id and department_id or None, - 'branch_id': branch_id, + 'staff_id': staff_id or None, + 'department_id': department_id or None, + 'branch_id': branch_id or None, + 'cycle_id': cycle_id or None, + 'categ_id': categ_id or None, } + print('res ', res) return res def get_report_data(self,ids,context={}): @@ -70,6 +81,8 @@ class ReportLaborCostDetail(Model): staff_id=defaults.get("staff_id") department_id=defaults.get("department_id") branch_id=defaults.get("branch_id") + cycle_id=defaults.get("cycle_id") or None + categ_id=defaults.get("categ_id") or None dom=[] if ids: obj=self.browse(ids)[0] @@ -79,6 +92,8 @@ class ReportLaborCostDetail(Model): staff_type=obj.type department_id=obj.department_id.id branch_id=obj.branch_id.id + cycle_id=obj.cycle_id.id + categ_id=obj.categ_id.id dom.append(['date','>=',date_from]) dom.append(['date','<=',date_to]) if staff_id: @@ -89,12 +104,16 @@ class ReportLaborCostDetail(Model): dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id]) if branch_id: dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id]) - + if cycle_id: + 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 {} + #if not staff_id: + #return {} dates={} for line in get_model("clinic.labor.cost.line").search_browse(dom): lcost=line.labor_cost_id @@ -103,7 +122,8 @@ class ReportLaborCostDetail(Model): if not date: continue dpt=citem.department_id - amt=line.pay_amount or 0 #XXX + #amt=line.pay_amount or 0 #XXX + amt=line.amount or 0 #XXX staff=line.staff_id qty=0 if staff.type=='doctor': @@ -112,13 +132,14 @@ class ReportLaborCostDetail(Model): if staff.id==doctor_id: qty+=1 elif staff.type=='nurse': - qty=len(citem.hd_cases) or 0 # qty of patient + qty=citem.pt_total or 0 # qty of patient else: pass if not dates.get(date): dates[date]={ 'labor_cost_id': lcost.id, 'staff_id': staff.id, + 'staff_name': staff.name or "", 'staff_type': staff.type, dpt.name: { 'amt': 0, @@ -130,6 +151,7 @@ class ReportLaborCostDetail(Model): dates[date].update({ 'labor_cost_id': lcost.id, 'staff_id': staff.id, + 'staff_name': staff.name or '', 'staff_type': staff.type, dpt.name: { 'amt': 0, @@ -173,6 +195,7 @@ class ReportLaborCostDetail(Model): vals=dates[kdate] lvals={ 'no': no, + 'staff_name': vals.get('staff_name') or "", 'date': kdate, 'staff_type': vals.get("staff_type"), 'staff_id': vals.get("staff_id"), @@ -229,7 +252,11 @@ class ReportLaborCostDetail(Model): if staff_id: staff=get_model("clinic.staff").browse(staff_id) staff_name=staff.name or '' + show_name=True + if staff_id: + show_name=False data={ + 'show_name': show_name, 'staff_name': staff_name, 'staff_id': staff_id, 'staff_type': staff_type, @@ -244,6 +271,7 @@ class ReportLaborCostDetail(Model): 'dpt_lines': dpt_lines, 'show_all': show_count <=1 and True or False, } + print('.... ', data['show_name']) return data def onchange_date(self,context={}): diff --git a/netforce_clinic/templates/report_labor_cost_daily.hbs b/netforce_clinic/templates/report_labor_cost_daily.hbs index 6c0ac99..0c06db1 100644 --- a/netforce_clinic/templates/report_labor_cost_daily.hbs +++ b/netforce_clinic/templates/report_labor_cost_daily.hbs @@ -8,13 +8,13 @@ HDCase {{/ifeq}} {{#ifeq staff_type "nurse"}} - Cycle Item + Date {{/ifeq}} + Cycle + Department HN Patient Type - Cycle - Department @@ -28,14 +28,14 @@ {{/ifeq}} {{#ifeq ../staff_type "nurse"}} - {{view "link" string=cycle_item_name action="clinic_cycle_item" action_options="mode=form" active_id=cycle_item_id}} + {{view "link" string=date action="clinic_cycle_item" action_options="mode=form" active_id=cycle_item_id}} {{/ifeq}} + {{cycle_name}} + {{dpt_name}} {{hn}} {{patient_name}} {{patient_type_name}} - {{cycle_name}} - {{dpt_name}} {{/each}} diff --git a/netforce_clinic/templates/report_labor_cost_detail.hbs b/netforce_clinic/templates/report_labor_cost_detail.hbs index 381e4a7..3f6ac8e 100644 --- a/netforce_clinic/templates/report_labor_cost_detail.hbs +++ b/netforce_clinic/templates/report_labor_cost_detail.hbs @@ -5,7 +5,9 @@ - + {{#if ../show_name}} + + {{/if}} {{#if show_all}} {{comp_name}} @@ -14,10 +16,14 @@ {{/if}} + # วันที่ + {{#if ../show_name}} + Staff + {{/if}} {{#each dpts}} {{#if show_link}} @@ -38,6 +44,9 @@ + {{#if ../show_name}} + + {{/if}} {{#each dpts}} {{qty_text}} @@ -54,6 +63,11 @@ {{date}} + {{#if ../show_name}} + + {{staff_name}} + + {{/if}} {{#each sub_lines}} {{currency qty zero=""}} @@ -74,6 +88,9 @@ รวม + {{#if show_name}} + + {{/if}} {{#each dpt_lines}} {{qty}} {{currency amt zero=""}}