conv_bal
watcha.h@almacom.co.th 2015-04-09 12:10:50 +07:00
parent d508062f48
commit 1e61cafb39
1 changed files with 14 additions and 5 deletions

View File

@ -145,6 +145,10 @@ class ReportLaborCost(Model):
['date','<=',date_to],
['labor_cost_id.cycle_item_id.state','=','validated'],
]
if branch_id:
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])
ddata={}
ndata={}
ctdata={}
@ -156,14 +160,19 @@ class ReportLaborCost(Model):
department=citem.department_id
dpt_name=department.name or ''
qty=line.qty or 0
staff=line.staff_id
if line.type=='doctor':
if dpt_name not in ddata.keys():
ddata[dpt_name]={
'qty': 0,
'walkin_qty': 0,
'department_id': department.id,
'branch_id':department.branch_id.id,
}
ddata[dpt_name]['qty']+=qty
if staff.number=='walkin':
ddata[dpt_name]['walkin_qty']+=qty
else:
ddata[dpt_name]['qty']+=qty
elif line.type=='nurse':
if categ_name not in ctdata.keys():
ctdata[categ_name]={
@ -200,13 +209,13 @@ class ReportLaborCost(Model):
qty=vals['qty'] or 0
department_id=vals['department_id']
branch_id=vals['branch_id']
walkin=0
cost=(walkin+qty)*cost_per_case
walkin_qty=vals['walkin_qty']
cost=(walkin_qty+qty)*cost_per_case
dlines.append({
'name': dt_name,
'qty': qty,
'qty2': walkin,
'total_qty': walkin+qty,
'qty2': walkin_qty,
'total_qty': walkin_qty+qty,
'cost': cost,
'total': 0,
'department_id': department_id,