labor cost report
parent
b88bf1b337
commit
4b51b8be9d
|
@ -32,7 +32,7 @@ class ReportLaborCost(Model):
|
||||||
defaults=context.get("defaults",{})
|
defaults=context.get("defaults",{})
|
||||||
date_from=defaults.get("date_from", self._get_date_from())
|
date_from=defaults.get("date_from", self._get_date_from())
|
||||||
date_to=defaults.get("date_to", self._get_date_to())
|
date_to=defaults.get("date_to", self._get_date_to())
|
||||||
report_type=defaults.get("report_type","detail")
|
report_type=defaults.get("report_type","cross")
|
||||||
print('defaults ', defaults)
|
print('defaults ', defaults)
|
||||||
res={
|
res={
|
||||||
'date': time.strftime("%Y-%m-%d"),
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
|
@ -150,29 +150,47 @@ class ReportLaborCost(Model):
|
||||||
ctdata={}
|
ctdata={}
|
||||||
for line in get_model('clinic.labor.cost.line').search_browse(dom,order="department_id.name"):
|
for line in get_model('clinic.labor.cost.line').search_browse(dom,order="department_id.name"):
|
||||||
cost_id=line.labor_cost_id
|
cost_id=line.labor_cost_id
|
||||||
categ_name=line.categ_id.name or ""
|
categ=line.categ_id
|
||||||
|
categ_name=categ.name or "unknow"
|
||||||
citem=cost_id.cycle_item_id
|
citem=cost_id.cycle_item_id
|
||||||
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
|
||||||
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]=0
|
ddata[dpt_name]={
|
||||||
ddata[dpt_name]+=qty
|
'qty': 0,
|
||||||
|
'department_id': department.id,
|
||||||
|
'branch_id':department.branch_id.id,
|
||||||
|
}
|
||||||
|
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]=0
|
ctdata[categ_name]={
|
||||||
ctdata[categ_name]+=line.pay_amount or 0
|
'amount': 0,
|
||||||
|
'categ_id': categ.id,
|
||||||
|
}
|
||||||
|
ctdata[categ_name]['amount']+=line.pay_amount or 0
|
||||||
if dpt_name not in ndata.keys():
|
if dpt_name not in ndata.keys():
|
||||||
ndata[dpt_name]=set()
|
ndata[dpt_name]={
|
||||||
|
'hdcases': set(),
|
||||||
|
'department_id': department.id,
|
||||||
|
'branch_id':department.branch_id.id,
|
||||||
|
}
|
||||||
for hdcase in citem.hd_cases:
|
for hdcase in citem.hd_cases:
|
||||||
ndata[dpt_name].update({hdcase.id})
|
ndata[dpt_name]['hdcases'].update({hdcase.id})
|
||||||
total_amount=0
|
total_amount=0
|
||||||
for categ_name,amount in ctdata.items():
|
for categ_name,vals in ctdata.items():
|
||||||
|
amount=vals['amount'] or 0
|
||||||
|
categ_id=vals['categ_id']
|
||||||
total_amount+=amount
|
total_amount+=amount
|
||||||
ctlines.append({
|
ctlines.append({
|
||||||
'name': categ_name,
|
'name': categ_name,
|
||||||
'amount': amount,
|
'amount': amount,
|
||||||
|
'branch_id': branch_id,
|
||||||
|
'categ_id': categ_id,
|
||||||
|
'department_id': department_id,
|
||||||
|
'staff_type': 'nurse',
|
||||||
})
|
})
|
||||||
ctlines.append({
|
ctlines.append({
|
||||||
'name': 'รวม',
|
'name': 'รวม',
|
||||||
|
@ -185,8 +203,14 @@ class ReportLaborCost(Model):
|
||||||
'total_qty': 'รวมจำนวนครั้ง',
|
'total_qty': 'รวมจำนวนครั้ง',
|
||||||
'cost': 'เป็นยอดเงินรวม',
|
'cost': 'เป็นยอดเงินรวม',
|
||||||
'desc': True,
|
'desc': True,
|
||||||
|
'department_id': None,
|
||||||
|
'branch_id':None,
|
||||||
|
'staff_type': 'doctor',
|
||||||
})
|
})
|
||||||
for dt_name,qty in ddata.items():
|
for dt_name,vals in ddata.items():
|
||||||
|
qty=vals['qty'] or 0
|
||||||
|
department_id=vals['department_id']
|
||||||
|
branch_id=vals['branch_id']
|
||||||
walkin=0
|
walkin=0
|
||||||
cost=(walkin+qty)*cost_per_case
|
cost=(walkin+qty)*cost_per_case
|
||||||
dlines.append({
|
dlines.append({
|
||||||
|
@ -196,6 +220,9 @@ class ReportLaborCost(Model):
|
||||||
'total_qty': walkin+qty,
|
'total_qty': walkin+qty,
|
||||||
'cost': cost,
|
'cost': cost,
|
||||||
'total': 0,
|
'total': 0,
|
||||||
|
'department_id': department_id,
|
||||||
|
'branch_id': branch_id,
|
||||||
|
'staff_type': 'doctor',
|
||||||
})
|
})
|
||||||
dlines.append({
|
dlines.append({
|
||||||
'name': 'รวม',
|
'name': 'รวม',
|
||||||
|
@ -203,6 +230,9 @@ class ReportLaborCost(Model):
|
||||||
'qty2': 0,
|
'qty2': 0,
|
||||||
'total_qty':0,
|
'total_qty':0,
|
||||||
'cost': 0,
|
'cost': 0,
|
||||||
|
'department_id': None,
|
||||||
|
'branch_id':None,
|
||||||
|
'staff_type': 'doctor',
|
||||||
})
|
})
|
||||||
for dline in dlines[1:-1]:
|
for dline in dlines[1:-1]:
|
||||||
dlines[-1]['qty']+=dline['qty'] or 0
|
dlines[-1]['qty']+=dline['qty'] or 0
|
||||||
|
@ -215,21 +245,33 @@ class ReportLaborCost(Model):
|
||||||
'qty': 'จำนวนครั้ง',
|
'qty': 'จำนวนครั้ง',
|
||||||
'cost': 'เป็นยอดเงินรวม',
|
'cost': 'เป็นยอดเงินรวม',
|
||||||
'total': 'รวม',
|
'total': 'รวม',
|
||||||
|
'department_id': None,
|
||||||
|
'branch_id': None,
|
||||||
'desc': True,
|
'desc': True,
|
||||||
|
'staff_type': 'nurse',
|
||||||
})
|
})
|
||||||
for dt_name, hdcases in ndata.items():
|
for dt_name, vals in ndata.items():
|
||||||
|
hdcases=vals['hdcases']
|
||||||
|
department_id=vals['department_id']
|
||||||
|
branch_id=vals['branch_id']
|
||||||
total_hdcase=len(hdcases)
|
total_hdcase=len(hdcases)
|
||||||
nlines.append({
|
nlines.append({
|
||||||
'name': dt_name,
|
'name': dt_name,
|
||||||
'qty': total_hdcase,
|
'qty': total_hdcase,
|
||||||
'cost': total_hdcase*vark,
|
'cost': total_hdcase*vark,
|
||||||
|
'department_id': department_id,
|
||||||
|
'branch_id': branch_id,
|
||||||
'total': 0,
|
'total': 0,
|
||||||
|
'staff_type': 'nurse',
|
||||||
})
|
})
|
||||||
nlines.append({
|
nlines.append({
|
||||||
'name': 'รวม',
|
'name': 'รวม',
|
||||||
'qty': 0,
|
'qty': 0,
|
||||||
'cost': 0,
|
'cost': 0,
|
||||||
'total': 0,
|
'total': 0,
|
||||||
|
'department_id': None,
|
||||||
|
'branch_id':None,
|
||||||
|
'staff_type': 'nurse',
|
||||||
})
|
})
|
||||||
for nline in nlines[1:-1]:
|
for nline in nlines[1:-1]:
|
||||||
nlines[-1]['qty']+=nline['qty'] or 0
|
nlines[-1]['qty']+=nline['qty'] or 0
|
||||||
|
|
|
@ -37,6 +37,9 @@ class ReportLaborCostSummary(Model):
|
||||||
date_from=defaults.get("date_from", self._get_date_from())
|
date_from=defaults.get("date_from", self._get_date_from())
|
||||||
date_to=defaults.get("date_to", self._get_date_to())
|
date_to=defaults.get("date_to", self._get_date_to())
|
||||||
branch_id=defaults.get("branch_id")
|
branch_id=defaults.get("branch_id")
|
||||||
|
categ_id=defaults.get("categ_id")
|
||||||
|
if categ_id:
|
||||||
|
categ_id=int(categ_id)
|
||||||
if branch_id:
|
if branch_id:
|
||||||
branch_id=int(branch_id)
|
branch_id=int(branch_id)
|
||||||
department_id=defaults.get("department_id")
|
department_id=defaults.get("department_id")
|
||||||
|
@ -46,15 +49,20 @@ class ReportLaborCostSummary(Model):
|
||||||
if staff_id:
|
if staff_id:
|
||||||
staff_id=int(staff_id)
|
staff_id=int(staff_id)
|
||||||
staff_type=defaults.get("staff_type","doctor")
|
staff_type=defaults.get("staff_type","doctor")
|
||||||
|
level_id=defaults.get("level_id")
|
||||||
|
if level_id:
|
||||||
|
level_id=int(level_id)
|
||||||
res={
|
res={
|
||||||
'date': date,
|
'date': date,
|
||||||
'date_from': date_from,
|
'date_from': date_from,
|
||||||
'date_to': date_to,
|
'date_to': date_to,
|
||||||
'staff_type': staff_type,
|
'staff_type': staff_type,
|
||||||
'staff_id': staff_id and staff_id or None,
|
'staff_id': staff_id and staff_id or None,
|
||||||
'department_id': department_id,
|
'department_id': department_id or None,
|
||||||
'branch_id': branch_id,
|
'branch_id': branch_id or None,
|
||||||
'only_value': True,
|
'only_value': True,
|
||||||
|
'categ_id': categ_id,
|
||||||
|
'level_id': level_id,
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -67,8 +75,8 @@ class ReportLaborCostSummary(Model):
|
||||||
only_value=defaults['only_value']
|
only_value=defaults['only_value']
|
||||||
department_id=defaults['department_id']
|
department_id=defaults['department_id']
|
||||||
branch_id=defaults['branch_id']
|
branch_id=defaults['branch_id']
|
||||||
level_id=None
|
categ_id=defaults['categ_id']
|
||||||
categ_id=None
|
level_id=defaults['level_id']
|
||||||
dom=[]
|
dom=[]
|
||||||
if ids:
|
if ids:
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
@ -97,7 +105,7 @@ class ReportLaborCostSummary(Model):
|
||||||
dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
|
dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
|
||||||
staffs={}
|
staffs={}
|
||||||
citems={}
|
citems={}
|
||||||
print('dom ', dom)
|
print('>> dom: ', dom)
|
||||||
total_hdcase=0
|
total_hdcase=0
|
||||||
for line in get_model("clinic.labor.cost.line").search_browse(dom):
|
for line in get_model("clinic.labor.cost.line").search_browse(dom):
|
||||||
lcost=line.labor_cost_id
|
lcost=line.labor_cost_id
|
||||||
|
|
|
@ -100,7 +100,9 @@
|
||||||
{{#if desc}}
|
{{#if desc}}
|
||||||
<th style="text-align:left;width:10%">{{cost}}</th>
|
<th style="text-align:left;width:10%">{{cost}}</th>
|
||||||
{{else}}
|
{{else}}
|
||||||
<td style="text-align:right">{{currency cost}}</td>
|
<td style="text-align:right">
|
||||||
|
<a href="#name=clinic_report_labor_cost_summary&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.staff_type={{staff_type}}">{{currency cost}}</a>
|
||||||
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -131,7 +133,9 @@
|
||||||
{{#if desc}}
|
{{#if desc}}
|
||||||
<th>{{cost}}</th>
|
<th>{{cost}}</th>
|
||||||
{{else}}
|
{{else}}
|
||||||
<td style="text-align:right">{{currency cost}}</td>
|
<td style="text-align:right">
|
||||||
|
<a href="#name=clinic_report_labor_cost_summary&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.staff_type={{staff_type}}">{{currency cost}}</a>
|
||||||
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -142,7 +146,9 @@
|
||||||
{{#each ctlines }}
|
{{#each ctlines }}
|
||||||
<tr>
|
<tr>
|
||||||
<th style="text-align:left;width:14%">{{name}}</th>
|
<th style="text-align:left;width:14%">{{name}}</th>
|
||||||
<td style="text-align:right">{{currency amount}}</td>
|
<td style="text-align:right">
|
||||||
|
<a href="#name=clinic_report_labor_cost_summary&defaults.categ_id={{categ_id}}&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.staff_type={{staff_type}}">{{currency amount}}</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue