diff --git a/netforce_clinic/actions/clinic_report_labor_cost_staff.xml b/netforce_clinic/actions/clinic_report_labor_cost_staff.xml new file mode 100644 index 0000000..2e0a93d --- /dev/null +++ b/netforce_clinic/actions/clinic_report_labor_cost_staff.xml @@ -0,0 +1,8 @@ + + Report Labor Cost Staff + report + clinic.report.labor.cost.staff + report_labor_cost_staff + report_labor_cost_staff + account_menu + diff --git a/netforce_clinic/layouts/clinic_report_hd_case_summary.xml b/netforce_clinic/layouts/clinic_report_hd_case_summary.xml index ce1f391..e7949c1 100644 --- a/netforce_clinic/layouts/clinic_report_hd_case_summary.xml +++ b/netforce_clinic/layouts/clinic_report_hd_case_summary.xml @@ -2,7 +2,7 @@ - - - + + + diff --git a/netforce_clinic/layouts/clinic_report_labor_cost_staff.xml b/netforce_clinic/layouts/clinic_report_labor_cost_staff.xml new file mode 100644 index 0000000..95897a7 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_labor_cost_staff.xml @@ -0,0 +1,9 @@ +
+ + + + + + + + diff --git a/netforce_clinic/layouts/clinic_report_medical_detail.xml b/netforce_clinic/layouts/clinic_report_medical_detail.xml index 3eb7701..1b80654 100644 --- a/netforce_clinic/layouts/clinic_report_medical_detail.xml +++ b/netforce_clinic/layouts/clinic_report_medical_detail.xml @@ -6,6 +6,7 @@ + diff --git a/netforce_clinic/layouts/clinic_report_medical_summary.xml b/netforce_clinic/layouts/clinic_report_medical_summary.xml index bfd0bf0..c389457 100644 --- a/netforce_clinic/layouts/clinic_report_medical_summary.xml +++ b/netforce_clinic/layouts/clinic_report_medical_summary.xml @@ -5,4 +5,5 @@ + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index b797965..1db6984 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -82,6 +82,7 @@ from . import report_staff_fee_detail from . import report_staff_fee_sum from . import report_payment_matching from . import report_labor_cost +from . import report_labor_cost_staff from . import report_labor_cost_summary from . import report_labor_cost_detail from . import report_labor_cost_sub_detail diff --git a/netforce_clinic/models/report_hd_case_summary.py b/netforce_clinic/models/report_hd_case_summary.py index 4d8dbff..2cece3b 100644 --- a/netforce_clinic/models/report_hd_case_summary.py +++ b/netforce_clinic/models/report_hd_case_summary.py @@ -19,6 +19,7 @@ class ReportHDCaseSummary(Model): "date_to": fields.Date("To", required=True), 'branch_id': fields.Many2One("clinic.branch","Branch"), 'department_id': fields.Many2One("clinic.department","Departments"), + 'report_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"Report Type"), } def _get_date_from(self,context={}): @@ -49,6 +50,7 @@ class ReportHDCaseSummary(Model): 'date_to': _get_date_to, 'branch_id': _get_branch, 'department_id': _get_department, + 'report_type': 'completed', } def get_report_data(self,ids,context={}): @@ -63,6 +65,7 @@ class ReportHDCaseSummary(Model): date_to=defaults.get('date_to',date) branch_id=defaults.get("branch_id",None) department_id=defaults.get("department_id",None) + report_type=defaults.get('report_type','completed') if branch_id: branch_id=branch_id[0] if department_id: @@ -80,7 +83,7 @@ class ReportHDCaseSummary(Model): year=int(date[0:4]) date_from=obj.date_from date_to=obj.date_to - + report_type=obj.report_type or 'completed' prev_year=year next_year=year prev_month=crr_month-1 @@ -111,13 +114,17 @@ class ReportHDCaseSummary(Model): dom=[] dom.append(["date",">=",date_from]) dom.append(["date","<=",date_to]) - dom.append(["state","in",["completed","waiting_payment","paid"]]) + if report_type=='completed': + dom.append(["state","in",["waiting_payment","paid"]]) + else: + dom.append(["state","not in",["waiting_payment","paid"]]) #dom.append(['patient_id.walkin','=','no']) if branch_id: dom.append(['branch_id','=',branch_id]) if department_id: dom.append(['department_id','=',department_id]) crr_total=len(get_model("clinic.hd.case").search(dom)) + print('---> dom ', dom) items={} items['topic%s'%count]={ 'month': month_str, @@ -261,12 +268,15 @@ class ReportHDCaseSummary(Model): line['unit']=unit lines.append(line) index+=1 + if report_type=='not_completed': + lines[0]['topic']='%s (ไม่สำเร็จ)'%lines[0]['topic'] context['defaults']={ 'date': date, 'date_from': date_from, 'date_to': date_to, 'branch_id': branch_id, 'department_id': department_id, + 'report_type': report_type, } medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context) @@ -279,6 +289,7 @@ class ReportHDCaseSummary(Model): branch=get_model("clinic.branch").browse(branch_id) sub_name="(%s)" % branch.name or "" data={ + 'report_type': report_type, 'branch_id': branch_id, 'department_id': department_id, 'date_from': date_from, diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py index 6ed865f..23cdcb8 100644 --- a/netforce_clinic/models/report_labor_cost.py +++ b/netforce_clinic/models/report_labor_cost.py @@ -234,10 +234,9 @@ class ReportLaborCost(Model): ['branch_id','=',brch_id], ['date','>=',date_from], ['date','<=',date_to], - ['state','in',['waiting_payment','paid']], ] - dom2=dom1+[['doctor_id2.number','=','']] - dom3=dom1+[['doctor_id2.number','!=','']] + dom2=dom1+[['walkin','=',True]] + dom3=dom1+[['walkin','=',False]] dlines.append({ 'name': dt_name, 'qty': "{0:.2f}".format(round(qty,2)), @@ -267,14 +266,13 @@ class ReportLaborCost(Model): dom4=[ ['date','>=',date_from], ['date','<=',date_to], - ['state','in',['waiting_payment','paid']], - ['doctor_id2.number','!=',''], + ['walkin','=',False], ] if department_id: dom4.append(['department_id','=',department_id]) if branch_id: dom4.append(['branch_id','=',branch_id]) - dom5=dom4+[['doctor_id2.number','=','']] + dom5=dom4+[['walkin','=',True]] dlines.append({ 'name': 'รวม', 'qty': 0, diff --git a/netforce_clinic/models/report_labor_cost_staff.py b/netforce_clinic/models/report_labor_cost_staff.py new file mode 100644 index 0000000..e1ab90c --- /dev/null +++ b/netforce_clinic/models/report_labor_cost_staff.py @@ -0,0 +1,113 @@ +import time +from calendar import monthrange + +from netforce.model import Model,fields,get_model + +class ReportLaborCostStaff(Model): + _name="clinic.report.labor.cost.staff" + _string="Report Labor Cost Staff" + _transient=True + + _fields={ + "date": fields.Date("Month"), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), + "branch_id": fields.Many2One("clinic.branch","Branch"), + "cycle_id": fields.Many2One("clinic.cycle","Cycle"), + "department_id": fields.Many2One("clinic.department","Department"), + 'walkin': fields.Boolean("Walkin"), + } + + def _get_date_from(self,context={}): + year,month,day=time.strftime("%Y-%m-%d").split("-") + #return '%s-%s-01'%(year,month) + return '%s-%s-%s'%(year,month,day) + + 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) + return "%s-%s-%s"%(year,month,day) + + def default_get(self,field_names=None,context={},**kw): + defaults=context.get("defaults",{}) + 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) + print('defaults ', defaults) + res={ + 'date': time.strftime("%Y-%m-%d"), + 'date_from': date_from, + 'date_to': date_to, + 'walkin': walkin, + } + return res + + def get_report_data(self,ids,context={}): + defaults=self.default_get(context=context) + date_from=defaults['date_from'] + date_to=defaults['date_to'] + branch_id=defaults.get("branch_id") + department_id=defaults.get("department_id") + cycle_id=defaults.get("cycle_id") + walkin=defaults.get("walkin") + print('walkin ', walkin) + dom=[] + if ids: + obj=self.browse(ids)[0] + date_from=obj.date_from + date_to=obj.date_to + branch_id=obj.branch_id.id + department_id=obj.department_id.id + cycle_id=obj.cycle_id.id + walkin=obj.walkin + dom.append(['date','>=',date_from]) + dom.append(['date','<=',date_to]) + dom.append(['hd_case_id.state','in',['waiting_payment','paid']]) + if branch_id: + dom.append(['hd_case_id.branch_id','=',branch_id]) + if department_id: + dom.append(['hd_case_id.department_id','=',department_id]) + if cycle_id: + dom.append(['hd_case_id.cycle_id','=',cycle_id]) + lines=[] + 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 + lines.append({ + 'id': sline.id, + 'date': sline.date, + 'number': hdcase.number or '', + 'staff_name': staff.name or '', + 'staff_id': staff.id or '', + 'department_name': sline.department_id.name or '', + }) + data={ + 'date_from': date_from, + 'date_to': date_to, + 'lines': lines, + } + 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_branch(self,context={}): + data=context['data'] + data['department_id']=None + return data + + def onchange_from(self,context={}): + data=context['data'] + data['date_to']=data['date_from'] + return data + +ReportLaborCostStaff.register() diff --git a/netforce_clinic/models/report_medical_detail.py b/netforce_clinic/models/report_medical_detail.py index ca9070a..60cf69b 100644 --- a/netforce_clinic/models/report_medical_detail.py +++ b/netforce_clinic/models/report_medical_detail.py @@ -18,6 +18,7 @@ class ReportMedicalDetail(Model): 'types': fields.Many2Many("clinic.patient.type","Types"), "branch_id": fields.Many2One("clinic.branch","Branch"), "department_id": fields.Many2One("clinic.department","Department"), + 'report_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"Report Type"), } # in case link from another report @@ -29,8 +30,9 @@ class ReportMedicalDetail(Model): date_from=defaults.get('date_from','%s-%s-01'%(year,month)) date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day)) categ_id=defaults.get('categ_id',None) + report_type=defaults.get('report_type',"completed") if not categ_id: - categ_ids=get_model("product.categ").search([['code','=','EPO']]) + categ_ids=get_model("product.categ").search([['code','=','MDC']]) if categ_ids: categ_id=categ_ids[0] branch_id=defaults.get('branch_id',None) @@ -54,7 +56,6 @@ class ReportMedicalDetail(Model): product_id=defaults.get("product_id",None) if product_id: product_id=int(product_id) - print('xx ',product_id) res={ 'date': date, 'date_from': date_from, @@ -64,7 +65,9 @@ class ReportMedicalDetail(Model): 'department_id': department_id, 'types': types, 'product_id': product_id, + 'report_type': report_type, } + print('report_type ', report_type) return res def get_report_data(self,ids,context={}): @@ -78,6 +81,7 @@ class ReportMedicalDetail(Model): department_id=defaults.get("department_id") product_id=defaults.get('product_id') types=defaults.get('types') + report_type=defaults.get('report_type','completed') if ids: obj=self.browse(ids)[0] prod_categ_id=obj.prod_categ_id.id @@ -88,6 +92,7 @@ class ReportMedicalDetail(Model): month=obj.date_from.split("-")[1] time_start=obj.date_from time_stop=obj.date_to + report_type=obj.report_type or 'completed' dom=[ ['hd_case_id.date','>=',time_start], ['hd_case_id.date','<=',time_stop], @@ -97,13 +102,17 @@ class ReportMedicalDetail(Model): if department_id: dom.append(['hd_case_id.department_id','=',department_id]) if prod_categ_id: - dom.append(['product_categ_id','=',prod_categ_id]) + dom.append(['product_categ_id.id','child_of',prod_categ_id]) if product_id: dom.append(['product_id','=',product_id]) if types and ids: dom.append(['hd_case_id.patient_type_id','in',[t.id for t in types]]) elif types: dom.append(['hd_case_id.patient_type_id','in',[t_id for t_id in types]]) + if report_type=='completed': + dom.append(["hd_case_id.state","in",["waiting_payment","paid"]]) + else: + dom.append(["hd_case_id.state","not in",["waiting_payment","paid"]]) lines=[] total_qty=0 for line in get_model('clinic.hd.case.line').search_browse(dom): diff --git a/netforce_clinic/models/report_medical_summary.py b/netforce_clinic/models/report_medical_summary.py index 577af77..4ee091e 100644 --- a/netforce_clinic/models/report_medical_summary.py +++ b/netforce_clinic/models/report_medical_summary.py @@ -17,6 +17,7 @@ class ReportMedicalSummary(Model): "prod_categ_id": fields.Many2One("product.categ","Category"), "branch_id": fields.Many2One("clinic.branch","Branch"), "department_id": fields.Many2One("clinic.department","Department"), + 'report_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"Report Type"), } # in case link from another report @@ -28,8 +29,9 @@ class ReportMedicalSummary(Model): date_from=defaults.get('date_from','%s-%s-01'%(year,month)) date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day)) categ_id=defaults.get('categ_id',None) + report_type=defaults.get('report_type',"completed") if not categ_id: - categ_ids=get_model("product.categ").search([['parent_id.code','=','MDC']]) + categ_ids=get_model("product.categ").search([['code','=','MDC']]) if categ_ids: categ_id=categ_ids[0] branch_id=defaults.get('branch_id',None) @@ -54,6 +56,7 @@ class ReportMedicalSummary(Model): 'prod_categ_id': categ_id, 'branch_id': branch_id, 'department_id': department_id, + 'report_type': report_type, } return res @@ -66,6 +69,7 @@ class ReportMedicalSummary(Model): prod_categ_id=defaults.get("prod_categ_id") branch_id=defaults.get("branch_id") department_id=defaults.get("department_id") + report_type=defaults.get("report_type","completed") if ids: obj=self.browse(ids)[0] prod_categ_id=obj.prod_categ_id.id @@ -74,17 +78,21 @@ class ReportMedicalSummary(Model): month=obj.date_from.split("-")[1] time_start=obj.date_from time_stop=obj.date_to - + report_type=obj.report_type or "completed" + print('report_type ---> ', report_type) products={} patient_types={t['id']: t['name'] for t in get_model('clinic.patient.type').search_read([[]],['name'],order="name")} dom=[] dom.append(['type','=','stock']) if prod_categ_id: - dom.append(['categ_id','=',prod_categ_id]) - print('dom ', dom) + dom.append(['categ_id.id','child_of',prod_categ_id]) + categ_ids=set() for prod in get_model("product").search_browse(dom): prod_code=prod.code or "" + categ=prod.categ_id + if categ and categ.parent_id: + categ_ids.update({categ.id}) products[prod_code]={} for patient_type_id,type_name in patient_types.items(): products[prod_code][patient_type_id]={ @@ -101,17 +109,24 @@ class ReportMedicalSummary(Model): dom.append(['branch_id','=',branch_id]) if department_id: dom.append(['department_id','=',department_id]) + if report_type=='completed': + dom.append(["state","in",["waiting_payment","paid"]]) + else: + dom.append(["state","not in",["waiting_payment","paid"]]) for hd_case in get_model('clinic.hd.case').search_browse(dom): patient_type_id=hd_case.patient_type_id.id for line in hd_case.lines: prod=line.product_id prod_code=prod.code or "" + categ=line.product_categ_id if not prod_code or not prod.active: continue - if line.type=='fee' or prod.type=='service': - continue - if prod_categ_id and prod_categ_id != prod.categ_id.id: + if categ and categ.id not in list(categ_ids): continue + #if line.type=='fee' or prod.type=='service': + #continue + #if prod_categ_id and prod_categ_id != prod.categ_id.id: + #continue products[prod_code][patient_type_id]['qty']+=line.qty lines=[] @@ -194,6 +209,7 @@ class ReportMedicalSummary(Model): 'lines': lines, 'month': month_str, 'year': year, + 'report_type': report_type, } return data diff --git a/netforce_clinic/models/visit_board.py b/netforce_clinic/models/visit_board.py index a109846..de85027 100644 --- a/netforce_clinic/models/visit_board.py +++ b/netforce_clinic/models/visit_board.py @@ -166,9 +166,11 @@ class VisitBoard(Model): hd_case_number=hd_case.number hd_case_state=hd_case.state if hd_case_state=='completed': - visit_color='#99ff99' + #visit_color='#99ff99' + visit_color='' elif hd_case_state=='in_progress': - visit_color='#f9e37d' + #visit_color='#f9e37d' + visit_color='' pass number=visit.number if number=='/': diff --git a/netforce_clinic/reports/report_labor_cost_staff.xlsx b/netforce_clinic/reports/report_labor_cost_staff.xlsx new file mode 100644 index 0000000..19d8ebb Binary files /dev/null and b/netforce_clinic/reports/report_labor_cost_staff.xlsx differ diff --git a/netforce_clinic/templates/report_hd_case_summary.hbs b/netforce_clinic/templates/report_hd_case_summary.hbs index eb1b76e..777a307 100644 --- a/netforce_clinic/templates/report_hd_case_summary.hbs +++ b/netforce_clinic/templates/report_hd_case_summary.hbs @@ -122,7 +122,7 @@
- รวมจำนวนยาที่ใช้ประจำเดือน + รวมจำนวนยาที่ใช้ประจำเดือน
@@ -140,7 +140,7 @@ {{#each sub_lines}} - {{qty}} + {{qty}} {{/each}} diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost.hbs index 359a2ca..3b4c7dd 100644 --- a/netforce_clinic/templates/report_labor_cost.hbs +++ b/netforce_clinic/templates/report_labor_cost.hbs @@ -72,7 +72,7 @@ {{qty}} {{else}} - {{view "link" string=qty action="clinic_hd_case" action_options=option_qty}} + {{view "link" string=qty action="clinic_report_labor_cost_staff" action_options=option_qty}} {{/if}} {{/each}} @@ -84,7 +84,7 @@ {{else}} {{#if walkin_qty}} - {{view "link" string=qty2 action="clinic_hd_case" action_options=option_qty2}} + {{view "link" string=qty2 action="clinic_report_labor_cost_staff" action_options=option_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 new file mode 100644 index 0000000..35f1d5f --- /dev/null +++ b/netforce_clinic/templates/report_labor_cost_staff.hbs @@ -0,0 +1,32 @@ +
+
+ + + + + + + + + + {{#each lines}} + + + + + + {{/each}} + + + + + + +
HDCaseDoctorDepartment
+ {{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}} + + {{department_name}} +
+