diff --git a/netforce_clinic/layouts/clinic_labor_cost_line_form.xml b/netforce_clinic/layouts/clinic_labor_cost_line_form.xml
index f63f7d2..1964a69 100644
--- a/netforce_clinic/layouts/clinic_labor_cost_line_form.xml
+++ b/netforce_clinic/layouts/clinic_labor_cost_line_form.xml
@@ -10,6 +10,7 @@
+
diff --git a/netforce_clinic/layouts/clinic_labor_cost_line_list.xml b/netforce_clinic/layouts/clinic_labor_cost_line_list.xml
index 42ea8d9..c81842d 100644
--- a/netforce_clinic/layouts/clinic_labor_cost_line_list.xml
+++ b/netforce_clinic/layouts/clinic_labor_cost_line_list.xml
@@ -4,4 +4,5 @@
+
diff --git a/netforce_clinic/layouts/clinic_labor_cost_list.xml b/netforce_clinic/layouts/clinic_labor_cost_list.xml
index e1ecbb8..0c8c05d 100644
--- a/netforce_clinic/layouts/clinic_labor_cost_list.xml
+++ b/netforce_clinic/layouts/clinic_labor_cost_list.xml
@@ -3,6 +3,5 @@
-
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index 39465ce..678706d 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -75,7 +75,11 @@ class HDCase(Model):
user_id=get_active_user()
set_active_user(1)
reimbursable_ctx=context.get('reimbursable')
+ no=0
for obj in self.browse(ids):
+ if not obj.doctor_id:
+ print('obj.date ', obj.date)
+ no+=1
dlz_use=0
dlz_max=0
dlz_name=[]
@@ -153,6 +157,7 @@ class HDCase(Model):
'dlz_use': dlz_use,
'dlz_max': dlz_max,
}
+ print('no ', no)
set_active_user(user_id)
return res
diff --git a/netforce_clinic/models/labor_cost.py b/netforce_clinic/models/labor_cost.py
index a7ec28a..3f9aa35 100644
--- a/netforce_clinic/models/labor_cost.py
+++ b/netforce_clinic/models/labor_cost.py
@@ -80,7 +80,7 @@ class LaborCost(Model):
return res
_fields={
- "cycle_item_id": fields.Many2One("clinic.cycle.item","Cycle Item",required=True,search=True),
+ "cycle_item_id": fields.Many2One("clinic.cycle.item","Cycle Item",required=True),
'var_k': fields.Float("K"),
'var_pt': fields.Integer("PT", function="_get_all",function_multi=True),
'var_ptx': fields.Char("PT x K:", function="_get_all",function_multi=True),
@@ -302,32 +302,45 @@ class LaborCost(Model):
cost_per_case=obj.cost_per_case or st.cost_per_case or 0
staff_total={}
dwalkin=None
- for staff in get_model("clinic.staff").search_browse([['number','=','walkin']]):
+ for staff in get_model("clinic.staff").search_browse([['number','=','walkin'],['type','=','doctor']]):
dwalkin=staff
for hd_case in item.hd_cases:
if hd_case.state not in ('waiting_payment','paid'):
continue
staffs=hd_case.staffs
- for ps in staffs:
- staff=ps.staff_id or dwalkin
- if not staff:
- continue
- base=staff.base
- if not base:
- base=cost_per_case
- if not staff_total.get(staff.id):
- staff_total[staff.id]={
- 'base': 0,
- 'type': staff.type,
- 'categ_id': staff.categ_id.id,
- 'level_id': staff.level_id.id,
- 'qty': 0,
- }
- if staff.type!='doctor':
- base=0
- staff_total[staff.id]['description']=hd_case.number
+ 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,
+ }
+ base=cost_per_case
staff_total[staff.id]['base']=base
staff_total[staff.id]['qty']+=1
+ else:
+ for ps in staffs:
+ staff=ps.staff_id or dwalkin
+ if not staff:
+ continue
+ base=staff.base
+ if not base:
+ base=cost_per_case
+ if not staff_total.get(staff.id):
+ staff_total[staff.id]={
+ 'base': 0,
+ 'type': staff.type,
+ 'categ_id': staff.categ_id.id,
+ 'level_id': staff.level_id.id,
+ 'qty': 0,
+ }
+ if staff.type!='doctor':
+ base=0
+ staff_total[staff.id]['description']=hd_case.number
+ staff_total[staff.id]['base']=base
+ staff_total[staff.id]['qty']+=1
for doctor_id, value in staff_total.items():
base=value['base']
diff --git a/netforce_clinic/models/labor_cost_line.py b/netforce_clinic/models/labor_cost_line.py
index 21d947e..ac5df70 100644
--- a/netforce_clinic/models/labor_cost_line.py
+++ b/netforce_clinic/models/labor_cost_line.py
@@ -19,6 +19,13 @@ class LaborCostLine(Model):
'department_id': dpt.id,
}
return res
+ def _get_all(self,ids,context={}):
+ res={}
+ for obj in self.browse(ids):
+ res[obj.id]={
+ 'pay_amount': round(obj.amount,0),
+ }
+ return res
_fields={
"labor_cost_id": fields.Many2One("clinic.labor.cost","Labor Cost",required=True,on_delete="cascade"),
@@ -29,6 +36,7 @@ class LaborCostLine(Model):
'qty': fields.Integer("Qty"),
'rate': fields.Float("Rate",scale=2),
'amount': fields.Float("Amount",scale=2),
+ 'pay_amount': fields.Float("Pay Amount",function="_get_all",function_multi=True),
'date': fields.Date("Date",search=True),
'description': fields.Char("Description"),
'company_id': fields.Many2One('company','Company'),
diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py
index 66f939b..34541e3 100644
--- a/netforce_clinic/models/report_labor_cost.py
+++ b/netforce_clinic/models/report_labor_cost.py
@@ -94,7 +94,6 @@ class ReportLaborCost(Model):
dom=[]
dom.append(["date",">=",date_from])
dom.append(["date","<=",date_to])
- total_hdcase=0
for dpt_id, vals in hdcases.items():
sub_lines=[]
dom2=[['department_id','=',dpt_id]]
@@ -104,7 +103,6 @@ class ReportLaborCost(Model):
dom3=[['state','=',state]] # last domain
if state in ('waiting_payment','paid'):
ok=True
- total_hdcase+=qty
dom4=dom+dom2+dom3
state=dstates[state]
sub_lines.append({
@@ -127,6 +125,10 @@ class ReportLaborCost(Model):
elif branch_id:
branch=get_model("clinic.branch").browse(branch_id)
sub_name="(%s)" % branch.name or ""
+ total_hdcase=0
+ for line in lines:
+ qty=line['qty'] or 0
+ total_hdcase+=qty
data={
'company_name': '%s %s' % (company.name or "", sub_name),
'date': date,
diff --git a/netforce_clinic/models/report_labor_cost_detail.py b/netforce_clinic/models/report_labor_cost_detail.py
index 2102eb7..27a52ec 100644
--- a/netforce_clinic/models/report_labor_cost_detail.py
+++ b/netforce_clinic/models/report_labor_cost_detail.py
@@ -89,7 +89,7 @@ class ReportLaborCostDetail(Model):
if not date:
continue
dpt=citem.department_id
- amt=line.amount or 0
+ amt=line.pay_amount or 0 #XXX
staff=line.staff_id
qty=0
if staff.type=='doctor':
diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py
index 17d1e20..d258e7e 100644
--- a/netforce_clinic/models/report_labor_cost_summary.py
+++ b/netforce_clinic/models/report_labor_cost_summary.py
@@ -99,13 +99,14 @@ class ReportLaborCostSummary(Model):
citems={}
print('dom ', dom)
total_hdcase=0
+ x=set()
for line in get_model("clinic.labor.cost.line").search_browse(dom):
lcost=line.labor_cost_id
citem=lcost.cycle_item_id
dpt=citem.department_id
qty=line.qty or 0 #XXX
total_hdcase+=qty
- amt=line.amount or 0
+ amt=line.pay_amount or 0 #XXX
staff=line.staff_id
categ_name=''
categ_id=None
@@ -145,7 +146,10 @@ class ReportLaborCostSummary(Model):
staffs[staff.name][dpt.name]['qty']+=qty
if not citems.get(citem.id):
- qty=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('waiting_payment', 'paid')])
+ qty=0
+ for hdcase in citem.hd_cases:
+ if hdcase.state in ('waiting_payment', 'paid'):
+ qty+=1
citems[citem.id]=qty
lines=[]
dom=[]