From 62c044f070bcdf375c7a82f11a89ffffd768c85c Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Thu, 23 Apr 2015 16:30:20 +0700 Subject: [PATCH] fix --- netforce_clinic/models/cycle_item.py | 9 ++++++++ netforce_clinic/models/hd_case.py | 10 ++++++++ netforce_clinic/models/labor_cost.py | 23 ++++++++++--------- netforce_clinic/models/matching_hdcase.py | 2 +- netforce_clinic/models/report_labor_cost.py | 5 ++-- .../models/report_thai_wht_certif.py | 3 ++- 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py index 3c96062..e259a68 100644 --- a/netforce_clinic/models/cycle_item.py +++ b/netforce_clinic/models/cycle_item.py @@ -103,6 +103,15 @@ class CycleItem(Model): def validate(self,ids,context={}): obj=self.browse(ids)[0] + #prevent duplicate nurse + ns={} + for line in obj.lines: + nurse=line.nurse_id + if not ns.get(nurse.id): + ns[nurse.id]=1 + else: + raise Exception("Duplicate %s"%nurse.name) + for hdcase in obj.hd_cases: state=hdcase.state if state=='cancelled': diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 2c25ca8..bd753cf 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -1475,6 +1475,16 @@ class HDCase(Model): self.function_store(ids) super().write(ids,vals,**kw) obj=self.browse(ids)[0] + # prevent duplicate doctor + print('obj.state ', obj.state) + if obj.state in ('waiting_payment', 'paid'): + st={} + for lstaff in obj.staffs: + staff=lstaff.staff_id + if not st.get(staff.id): + st[staff.id]=1 + else: + raise Exception("Douplicate %s"%staff.name) self.check_hct(obj) def approve(self,ids,context={}): diff --git a/netforce_clinic/models/labor_cost.py b/netforce_clinic/models/labor_cost.py index c610734..eb68d21 100644 --- a/netforce_clinic/models/labor_cost.py +++ b/netforce_clinic/models/labor_cost.py @@ -311,18 +311,19 @@ class LaborCost(Model): if hd_case.state not in ('waiting_payment','paid'): continue staffs=hd_case.staffs - if not staffs and dwalkin: - staff=dwalkin - staff_total[staff.id]={ - 'base': 0, - 'type': staff.type, - 'categ_id': staff.categ_id.id, - 'level_id': staff.level_id.id, - 'qty': 0, - } + doctor_id=hd_case.doctor_id + if not doctor_id and dwalkin: + if not staff_total.get(dwalkin.id): + staff_total[dwalkin.id]={ + 'base': 0, + 'type': dwalkin.type, + 'categ_id': dwalkin.categ_id.id, + 'level_id': dwalkin.level_id.id, + 'qty': 0, + } base=cost_per_case - staff_total[staff.id]['base']=base - staff_total[staff.id]['qty']+=1 + staff_total[dwalkin.id]['base']=base + staff_total[dwalkin.id]['qty']+=1 else: for ps in staffs: staff=ps.staff_id or dwalkin diff --git a/netforce_clinic/models/matching_hdcase.py b/netforce_clinic/models/matching_hdcase.py index 88f4b7c..1244b18 100644 --- a/netforce_clinic/models/matching_hdcase.py +++ b/netforce_clinic/models/matching_hdcase.py @@ -313,7 +313,7 @@ class MatchingHDCase(Model): if date_from==date_to: date=date_from data={ - 'lines': lines, + 'lines': sorted(lines,key=lambda x: x.get('date')), 'date_from': date_from, 'date_to': date_to, 'date': date, diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py index 9e4bea0..e954e69 100644 --- a/netforce_clinic/models/report_labor_cost.py +++ b/netforce_clinic/models/report_labor_cost.py @@ -184,10 +184,11 @@ class ReportLaborCost(Model): ndata[dpt_name]={ 'hdcases': set(), 'department_id': department.id, - 'branch_id':department.branch_id.id, + 'branch_id': department.branch_id.id, } for hdcase in citem.hd_cases: - ndata[dpt_name]['hdcases'].update({hdcase.id}) + if hdcase.state in ('waiting_payment','paid'): + ndata[dpt_name]['hdcases'].update({hdcase.id}) total_amount=0 for categ_name,vals in ctdata.items(): amount=vals['amount'] or 0 diff --git a/netforce_clinic/models/report_thai_wht_certif.py b/netforce_clinic/models/report_thai_wht_certif.py index 8f6ceb7..518cb19 100644 --- a/netforce_clinic/models/report_thai_wht_certif.py +++ b/netforce_clinic/models/report_thai_wht_certif.py @@ -56,8 +56,9 @@ class ReportThaiWHTCertif(Model): else: if contact_type!=comp.contact_type: raise Exception("Different WHT contact types for same payment") - print('sequence ', comp.sequence) exp_code=comp.sequence or "5" + exp_code=exp_code.replace(".","_") + print('sequence ', exp_code) #if comp.exp_type=="salary": #exp_code="1" #elif comp.exp_type=="commission":