diff --git a/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml b/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml
index 2c02be3..05de20d 100644
--- a/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml
+++ b/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml
@@ -4,6 +4,7 @@
+
diff --git a/netforce_clinic/models/labor_cost.py b/netforce_clinic/models/labor_cost.py
index eb68d21..b55bce8 100644
--- a/netforce_clinic/models/labor_cost.py
+++ b/netforce_clinic/models/labor_cost.py
@@ -194,12 +194,13 @@ class LaborCost(Model):
}))
if not obj.manual:
- var_pt=len(item.hd_cases)
+ var_pt=len([hdcase for hdcase in item.hd_cases if hdcase.state in ("waiting_payment", "paid")])
var_ptx=var_pt*(obj.var_k or 0)
total_bstr=total_b < 0 and "+%s"%(abs(total_b)) or "-%s"%total_b
var_x=0
if total_a:
- var_x=eval('(%s%s)/%s'%(var_ptx,total_bstr,total_a))
+ exp='(%s%s)/%s'%(var_ptx,total_bstr,total_a)
+ var_x=eval(exp)
for fline in formulars:
vals=fline[1]
fml=vals['formular'].replace("X","*%s")
diff --git a/netforce_clinic/models/labor_cost_line.py b/netforce_clinic/models/labor_cost_line.py
index ac5df70..0a7fd3c 100644
--- a/netforce_clinic/models/labor_cost_line.py
+++ b/netforce_clinic/models/labor_cost_line.py
@@ -19,6 +19,7 @@ class LaborCostLine(Model):
'department_id': dpt.id,
}
return res
+
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py
index 6e05c45..fadc007 100644
--- a/netforce_clinic/models/report_labor_cost.py
+++ b/netforce_clinic/models/report_labor_cost.py
@@ -176,6 +176,7 @@ class ReportLaborCost(Model):
'walkin_qty': 0,
'department_id': department.id,
'branch_id':department.branch_id.id,
+ 'cycle_id': cycle_id,
}
if staff.number=='walkin':
ddata[dpt_name]['walkin_qty']+=qty
@@ -185,14 +186,16 @@ class ReportLaborCost(Model):
if categ_name not in ctdata.keys():
ctdata[categ_name]={
'amount': 0,
+ 'cycle_id': cycle_id,
'categ_id': categ.id,
}
- ctdata[categ_name]['amount']+=line.pay_amount or 0
+ ctdata[categ_name]['amount']+=line.amount or 0
if dpt_name not in ndata.keys():
ndata[dpt_name]={
'hdcases': set(),
'department_id': department.id,
'branch_id': department.branch_id.id,
+ 'cycle_id': cycle_id,
}
for hdcase in citem.hd_cases:
if hdcase.state in ('waiting_payment','paid'):
@@ -204,15 +207,19 @@ class ReportLaborCost(Model):
total_amount+=amount
ctlines.append({
'name': categ_name,
- 'amount': amount,
+ 'amount': round(amount,0),
'branch_id': branch_id,
'categ_id': categ_id,
'department_id': department_id,
'staff_type': 'nurse',
+ 'cycle_id': cycle_id,
})
ctlines.append({
'name': 'รวม',
- 'amount': total_amount,
+ 'amount': round(total_amount,0),
+ 'cycle_id': cycle_id,
+ 'branch_id': branch_id,
+ 'department_id': department_id,
})
for dt_name,vals in ddata.items():
qty=vals['qty'] or 0
@@ -230,6 +237,7 @@ class ReportLaborCost(Model):
'department_id': dpt_id,
'branch_id': brch_id,
'staff_type': 'doctor',
+ 'cycle_id': cycle_id,
})
dlines=[{
'name': 'แพทย์',
@@ -248,9 +256,10 @@ class ReportLaborCost(Model):
'qty2': 0,
'total_qty':0,
'cost': 0,
- 'department_id': None,
- 'branch_id':None,
'staff_type': 'doctor',
+ 'cycle_id': cycle_id,
+ 'branch_id': branch_id,
+ 'department_id': department_id,
})
for dline in dlines[1:-1]:
dlines[-1]['qty']+=dline['qty'] or 0
@@ -281,6 +290,7 @@ class ReportLaborCost(Model):
'branch_id': brch_id,
'total': 0,
'staff_type': 'nurse',
+ 'cycle_id': cycle_id,
})
nlines=sorted(nlines, key=lambda x: x['name'])
nlines.append({
@@ -288,9 +298,10 @@ class ReportLaborCost(Model):
'qty': 0,
'cost': 0,
'total': 0,
- 'department_id': None,
- 'branch_id':None,
'staff_type': 'nurse',
+ 'cycle_id': cycle_id,
+ 'branch_id': branch_id,
+ 'department_id': department_id,
})
for nline in nlines[1:-1]:
nlines[-1]['qty']+=nline['qty'] or 0
diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py
index cb0c7fb..af5b61a 100644
--- a/netforce_clinic/models/report_labor_cost_summary.py
+++ b/netforce_clinic/models/report_labor_cost_summary.py
@@ -18,6 +18,7 @@ class ReportLaborCostSummary(Model):
'department_id': fields.Many2One("clinic.department","Department"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
'level_id': fields.Many2One("clinic.staff.level","Level"),
+ 'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
'categ_id': fields.Many2One("clinic.staff.categ","Category"),
'only_value': fields.Boolean("Only Amount"),
}
@@ -38,6 +39,7 @@ class ReportLaborCostSummary(Model):
date_to=defaults.get("date_to", self._get_date_to())
branch_id=defaults.get("branch_id")
categ_id=defaults.get("categ_id")
+ cycle_id=defaults.get("cycle_id")
if categ_id:
categ_id=int(categ_id)
if branch_id:
@@ -63,6 +65,7 @@ class ReportLaborCostSummary(Model):
'only_value': True,
'categ_id': categ_id,
'level_id': level_id,
+ 'cycle_id': cycle_id,
}
print('res ', res)
return res
@@ -78,6 +81,7 @@ class ReportLaborCostSummary(Model):
branch_id=defaults['branch_id']
categ_id=defaults['categ_id']
level_id=defaults['level_id']
+ cycle_id=defaults['cycle_id']
dom=[]
if ids:
obj=self.browse(ids)[0]
@@ -89,6 +93,7 @@ class ReportLaborCostSummary(Model):
categ_id=obj.categ_id.id
branch_id=obj.branch_id.id
department_id=obj.department_id.id
+ cycle_id=obj.cycle_id.id
only_value=obj.only_value
dom.append(['date','>=',date_from])
dom.append(['date','<=',date_to])
@@ -104,6 +109,8 @@ class ReportLaborCostSummary(Model):
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
if department_id:
dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
+ if cycle_id:
+ dom.append(['labor_cost_id.cycle_item_id.cycle_id','=',cycle_id])
staffs={}
citems={}
print('>> dom: ', dom)
@@ -114,7 +121,8 @@ class ReportLaborCostSummary(Model):
dpt=citem.department_id
qty=line.qty or 0 #XXX
total_hdcase+=qty
- amt=line.pay_amount or 0 #XXX
+ #amt=line.pay_amount or 0 #XXX
+ amt=line.amount or 0 #XXX
staff=line.staff_id
categ_name=''
categ_id=None
@@ -222,13 +230,14 @@ class ReportLaborCostSummary(Model):
total_qty=0
total_cost=0
for tline in total_lines:
+ tline['amt']=round(tline['amt'],0) or 0 #XXX
amt=tline['amt'] or 0
qty=tline['qty'] or 0
total+=amt
total_cost+=amt
total_qty+=qty
- total_lines.append({'amt': round(total,0)})
+ total_lines.append({'amt': round(total,0)}) #XXX
company_id=get_active_company()
comp=get_model("company").browse(company_id)
if staff_type!='doctor':
diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost.hbs
index 75c337d..493c946 100644
--- a/netforce_clinic/templates/report_labor_cost.hbs
+++ b/netforce_clinic/templates/report_labor_cost.hbs
@@ -1,8 +1,5 @@
-
- จาก {{date_from}} ถึง {{date_to}}
-
-
+
{{#ifeq report_type "detail"}}
@@ -102,7 +99,7 @@
{{cost}} |
{{else}}
- {{currency cost}}
+ {{currency cost}}
|
{{/if}}
{{/each}}
@@ -135,7 +132,7 @@
{{cost}} |
{{else}}
- {{currency cost}}
+ {{currency cost}}
|
{{/if}}
{{/each}}
@@ -148,7 +145,7 @@
{{name}} |
- {{currency amount}}
+ {{currency amount}}
|
{{/each}}