From 556262f9cc71befec611d65e98dfd935a38bfc65 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 3 Mar 2015 06:11:37 +0700 Subject: [PATCH] report labor cost sub detail --- .../clinic_report_labor_cost_sub_detail.xml | 8 + .../layouts/clinic_account_menu.xml | 1 + .../clinic_report_labor_cost_sub_detail.xml | 8 + netforce_clinic/models/__init__.py | 1 + .../models/report_labor_cost_detail.py | 14 +- .../models/report_labor_cost_sub_detail.py | 147 ++++++++++++++++++ .../reports/report_labor_cost_sub_detail.xlsx | Bin 0 -> 6828 bytes .../templates/report_labor_cost_detail.hbs | 8 +- .../report_labor_cost_sub_detail.hbs | 34 ++++ netforce_clinic/todo.txt | 10 +- 10 files changed, 221 insertions(+), 10 deletions(-) create mode 100644 netforce_clinic/actions/clinic_report_labor_cost_sub_detail.xml create mode 100644 netforce_clinic/layouts/clinic_report_labor_cost_sub_detail.xml create mode 100644 netforce_clinic/models/report_labor_cost_sub_detail.py create mode 100644 netforce_clinic/reports/report_labor_cost_sub_detail.xlsx create mode 100644 netforce_clinic/templates/report_labor_cost_sub_detail.hbs diff --git a/netforce_clinic/actions/clinic_report_labor_cost_sub_detail.xml b/netforce_clinic/actions/clinic_report_labor_cost_sub_detail.xml new file mode 100644 index 0000000..75c3dee --- /dev/null +++ b/netforce_clinic/actions/clinic_report_labor_cost_sub_detail.xml @@ -0,0 +1,8 @@ + + Report Labor Cost Sub Detail + report + clinic.report.labor.cost.sub.detail + report_labor_cost_sub_detail + report_labor_cost_sub_detail + account_menu + diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml index 12fd036..9030a1a 100644 --- a/netforce_clinic/layouts/clinic_account_menu.xml +++ b/netforce_clinic/layouts/clinic_account_menu.xml @@ -9,6 +9,7 @@
+ diff --git a/netforce_clinic/layouts/clinic_report_labor_cost_sub_detail.xml b/netforce_clinic/layouts/clinic_report_labor_cost_sub_detail.xml new file mode 100644 index 0000000..a076092 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_labor_cost_sub_detail.xml @@ -0,0 +1,8 @@ +
+ + + + + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 8059be5..41689fa 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -77,6 +77,7 @@ from . import report_staff_fee_sum from . import report_payment_matching from . import report_labor_cost_summary from . import report_labor_cost_detail +from . import report_labor_cost_sub_detail from . import report_labor_cost_daily from . import report_labor_cost_overtime from . import branch diff --git a/netforce_clinic/models/report_labor_cost_detail.py b/netforce_clinic/models/report_labor_cost_detail.py index 0681dd6..dc04859 100644 --- a/netforce_clinic/models/report_labor_cost_detail.py +++ b/netforce_clinic/models/report_labor_cost_detail.py @@ -56,12 +56,11 @@ class ReportLaborCostDetail(Model): defaults=self.default_get(context=context) date_from=defaults.get("date_from") date_to=defaults.get("date_to") - staff_type=defaults.get("staff_type") + staff_type=defaults.get("type") staff_id=defaults.get("staff_id") department_id=defaults.get("department_id") dom=[] if ids: - print("get from ids") obj=self.browse(ids)[0] date_from=obj.date_from date_to=obj.date_to @@ -127,6 +126,14 @@ class ReportLaborCostDetail(Model): dates[date][dpt.name]['qty']+=qty lines=[] dpts=get_model("clinic.department").search_read([],['name']) + # link to sub detail + for dpt in dpts: + dpt.update({ + 'staff_id': staff_id, + 'staff_type': staff_type, + 'date_from': date_from, + 'date_to': date_to, + }) dpts=sorted(dpts, key=lambda b: b['name']) no=1 dlines=sorted(dates.keys()) #sort by staff name @@ -192,6 +199,9 @@ class ReportLaborCostDetail(Model): staff_name=staff.name or '' data={ 'staff_name': staff_name, + 'staff_id': staff_id, + 'staff_type': staff_type, + 'department_id': "0", #XXX 'date_from': date_from, 'date_to': date_to, 'dpts': dpts, diff --git a/netforce_clinic/models/report_labor_cost_sub_detail.py b/netforce_clinic/models/report_labor_cost_sub_detail.py new file mode 100644 index 0000000..3b25562 --- /dev/null +++ b/netforce_clinic/models/report_labor_cost_sub_detail.py @@ -0,0 +1,147 @@ +import time +from calendar import monthrange + +from netforce.model import Model,fields,get_model +from netforce.access import get_active_company + +class ReportLaborCostSubDetail(Model): + _name="clinic.report.labor.cost.sub.detail" + _string="Report Labor Cost Sub Detail" + _transient=True + + _fields={ + "date": fields.Date("Month"), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), + 'department_id': fields.Many2One("clinic.department","Department"), + 'staff_id': fields.Many2One("clinic.staff","Staff"), + "staff_type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"), + 'department_id': fields.Many2One("clinic.department","Department"), + } + + def _get_date_from(self,context={}): + year,month=time.strftime("%Y-%m").split("-") + return '%s-%s-01'%(year,month) + + def _get_date_to(self,context={}): + year,month,day=time.strftime("%Y-%m-%d").split("-") + weekday, total_day=monthrange(int(year), int(month)) + return "%s-%s-%s"%(year,month,total_day) + + def default_get(self,field_names=None,context={},**kw): + defaults=context.get("defaults",{}) + date_from=defaults.get("date_from") + if not date_from: + date_from=self._get_date_from() + date_to=defaults.get("date_to") + if not date_to: + date_to=self._get_date_to() + staff_type=defaults.get("staff_type","doctor") + staff_id=int(defaults.get('staff_id', "0")) + department_id=int(defaults.get('department_id', "0")) + res={ + 'date': time.strftime("%Y-%m-%d"), + 'date_from': date_from, + 'date_to': date_to, + 'staff_type': staff_type, + 'staff_id': staff_id and staff_id or None, + 'department_id': department_id and department_id or None, + } + print('res ', res) + return res + + def get_report_data(self,ids,context={}): + company_id=get_active_company() + comp=get_model("company").browse(company_id) + defaults=self.default_get(context=context) + date_from=defaults.get("date_from") + date_to=defaults.get("date_to") + staff_type=defaults.get("staff_type") + staff_id=defaults.get("staff_id") + department_id=defaults.get("department_id") + staff_name='' + dom=[] + if ids: + obj=self.browse(ids)[0] + date_from=obj.date_from + date_to=obj.date_to + staff_id=obj.staff_id.id + staff_name=obj.staff_id.name or "" + staff_type=obj.staff_type + department_id=obj.department_id.id + dom.append(['date','>=',date_from]) + dom.append(['date','<=',date_to]) + if staff_id and staff_type=='doctor': + dom.append(['staff_id','=',staff_id]) + elif staff_id and staff_type=='nurse': + pass + if staff_type: + dom.append(['type','=',staff_type]) + if department_id: + dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id]) + if not staff_id: + return {} + def replace_quote(dom=""): + return dom.replace("'","\"") + lines=[] + amount_total=0 + for line in get_model("clinic.labor.cost.line").search_browse(dom): + lcost=line.labor_cost_id + citem=lcost.cycle_item_id + date=citem.date + dpt=citem.department_id + amount=line.amount or 0 + qty=line.qty or 0 + if qty: + amount=amount/qty + for hdcase in citem.hd_cases: + patient=hdcase.patient_id + doctor=hdcase.doctor_id + vals={ + 'date': date, + 'patient_name': patient.name or "", + 'department_name': dpt.name or "", + 'amount': amount, + } + if staff_type=='doctor' and doctor.id==staff_id: + lines.append(vals) + amount_total+=amount + elif staff_type=='nurse': + lines.append(vals) + amount_total+=amount + else: + pass + slines=[] + no=1 + for line in sorted(lines,key=lambda x: (x['date'], x['department_name'])): + line['no']=no + slines.append(line) + no+=1 + + data={ + 'staff_name': staff_name, + 'staff_id': staff_id, + 'staff_type': staff_type, + 'date_from': date_from, + 'date_to': date_to, + 'comp_name': comp.name or 0, + 'lines': slines, + 'amount_total': amount_total, + } + return data + + def onchange_date(self,context={}): + data=context['data'] + date=data['date'] + year,month,day=date.split("-") + weekday, total_day=monthrange(int(year), int(month)) + data['date_from']="%s-%s-01"%(year,month) + data['date_to']="%s-%s-%s"%(year,month,total_day) + return data + + def onchange_type(self,context={}): + data=context['data'] + data['staff_id']=None + return data + +ReportLaborCostSubDetail.register() diff --git a/netforce_clinic/reports/report_labor_cost_sub_detail.xlsx b/netforce_clinic/reports/report_labor_cost_sub_detail.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..ea852c3f316fea001dc14b3676ab138c7a626ca7 GIT binary patch literal 6828 zcmeHLWmr`0+9gFgq(iz97#bu5lscDgsA$AUckkXs;%KszL;9t#;lIs5HqIVA z+=%bW#Bn85072v-7!v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=nsN27zCtfqUYYf5GUW=n5kcYM|C5Xb2w?jv; z9T|lf>1UY#YnqJ+^Z&hmiS~aV_-ne02)ln41^iNf9ew}a=hq+$kp=%O8Mr{f`}}D# z{Ck&QH<$n3B^!Rzf70cT2<-PRe?1pXtUvAY$F}tMF2CAJgya5MRd9m=pUeO8-@kYG z)vX}x=g(Th``0}FX-0n^{HwMj49(9Pg9|$1^8d0ozYqOY{Se~+vligI{Cz3-ee|yc yM=0daI)}sXuhIY1%io9p`j#S8;Ad%){;4KtD5Jx}Pb4I4_-7dYt_+hQ&i)5mPJk-_ literal 0 HcmV?d00001 diff --git a/netforce_clinic/templates/report_labor_cost_detail.hbs b/netforce_clinic/templates/report_labor_cost_detail.hbs index aba60a7..3895a5f 100644 --- a/netforce_clinic/templates/report_labor_cost_detail.hbs +++ b/netforce_clinic/templates/report_labor_cost_detail.hbs @@ -6,14 +6,18 @@ - {{comp_name}} + + {{comp_name}} + # วันที่ {{#each dpts}} - {{name}} + + {{name}} + {{/each}} รวม diff --git a/netforce_clinic/templates/report_labor_cost_sub_detail.hbs b/netforce_clinic/templates/report_labor_cost_sub_detail.hbs new file mode 100644 index 0000000..054538f --- /dev/null +++ b/netforce_clinic/templates/report_labor_cost_sub_detail.hbs @@ -0,0 +1,34 @@ +

+{{#if lines}} + + + + + + + + + + + + {{#each lines }} + + + + + + {{/each}} + + + + + + + + +
#DatePatientDepartmentAmount
{{no}} + {{date}} + {{patient_name}}{{department_name}}{{currency amount zero=""}}
รวม{{currency amount_total zero=""}}
+{{else}} + No items to show +{{/if}} diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index f9ca269..971fb8b 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,20 +1,18 @@ todo: + - report k. boy (sub detail) + - change by department +=============================== + - compute labor cost - update level -> ok - set patient_id with domain state=='admit' -> ok - convbal -> not yet (wait yui) -> ok but have to update memo - post 10,000 invoices per one time -> ask david patient & staff - split name -> not yet staff have multi department -> added but set have to set permission - many2many - show epo(yes) in list of hd case ->ok matching payment > ok create contact from staff -> ok script to clear invoice -> ok - - -