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