report labor cost

conv_bal
watcha.h@almacom.co.th 2015-04-08 22:48:21 +07:00
parent b4724e98b8
commit b88bf1b337
2 changed files with 129 additions and 13 deletions

View File

@ -73,7 +73,6 @@ class ReportLaborCost(Model):
hdcases={}
hdcase_obj=get_model("clinic.hd.case")
dstates=dict(hdcase_obj._fields['state'].selection)
print('dom ', dom)
for hdcase in hdcase_obj.search_browse(dom):
dpt=hdcase.department_id
state=hdcase.state or ''
@ -95,6 +94,9 @@ class ReportLaborCost(Model):
dom=dom.replace("False","false")
dom=dom.replace("True","true")
return dom.replace("'","\"")
st=get_model('clinic.setting').browse(1)
vark=st.var_k or 0
cost_per_case=st.cost_per_case or 0
lines=[]
dom=[]
dom.append(["date",">=",date_from])
@ -136,6 +138,7 @@ class ReportLaborCost(Model):
total_hdcase+=qty
dlines=[]
nlines=[]
ctlines=[]
if report_type=='cross':
dom=[
['date','>=',date_from],
@ -144,8 +147,10 @@ class ReportLaborCost(Model):
]
ddata={}
ndata={}
for line in get_model('clinic.labor.cost.line').search_browse(dom):
ctdata={}
for line in get_model('clinic.labor.cost.line').search_browse(dom,order="department_id.name"):
cost_id=line.labor_cost_id
categ_name=line.categ_id.name or ""
citem=cost_id.cycle_item_id
department=citem.department_id
dpt_name=department.name or ''
@ -155,28 +160,81 @@ class ReportLaborCost(Model):
ddata[dpt_name]=0
ddata[dpt_name]+=qty
elif line.type=='nurse':
if categ_name not in ctdata.keys():
ctdata[categ_name]=0
ctdata[categ_name]+=line.pay_amount or 0
if dpt_name not in ndata.keys():
ndata[dpt_name]=set()
for hdcase in citem.hd_cases:
ndata[dpt_name].update({hdcase.id})
total_amount=0
for categ_name,amount in ctdata.items():
total_amount+=amount
ctlines.append({
'name': categ_name,
'amount': amount,
})
ctlines.append({
'name': 'รวม',
'amount': total_amount,
})
dlines.append({
'name': 'แพทย์',
'qty': 'จำนวนครั้ง',
'qty2': 'ไม่จ่ายแพทย์',
'total_qty': 'รวมจำนวนครั้ง',
'cost': 'เป็นยอดเงินรวม',
'desc': True,
})
for dt_name,qty in ddata.items():
walkin=0
cost=(walkin+qty)*cost_per_case
dlines.append({
'name': dt_name,
'qty': qty,
'qty2': walkin,
'total_qty': walkin+qty,
'cost': cost,
'total': 0,
})
dlines.append({
'name': 'รวม',
'qty': 0,
'qty2': 0,
'total_qty':0,
'cost': 0,
})
for dline in dlines[1:-1]:
dlines[-1]['qty']+=dline['qty'] or 0
dlines[-1]['qty2']+=dline['qty2'] or 0
dlines[-1]['total_qty']+=dline['total_qty'] or 0
dlines[-1]['cost']+=dline['cost'] or 0
nlines.append({
'name': 'พยาบาล',
'qty': 'จำนวนครั้ง',
'cost': 'เป็นยอดเงินรวม',
'total': 'รวม',
'desc': True,
})
for dt_name, hdcases in ndata.items():
total_hdcase=len(hdcases)
nlines.append({
'name': dt_name,
'qty': len(hdcases)
'qty': total_hdcase,
'cost': total_hdcase*vark,
'total': 0,
})
nlines.append({
'name': 'รวม',
'qty': 0,
'cost': 0,
'total': 0,
})
for nline in nlines[1:-1]:
nlines[-1]['qty']+=nline['qty'] or 0
nlines[-1]['cost']+=nline['cost'] or 0
nlines[-1]['total']+=nline['total'] or 0
data={
'company_name': '%s %s' % (company.name or "", sub_name),
'date': date,
@ -185,13 +243,12 @@ class ReportLaborCost(Model):
'lines': lines,
'dlines': dlines,
'nlines': nlines,
'ctlines': ctlines,
'total_hdcase': total_hdcase,
'branch_id': branch_id,
'department_id': department_id,
'show_detail': show_detail,
'report_type': report_type,
#'ddata': ddata,
#'ndata': ndata,
}
return data

View File

@ -1,9 +1,6 @@
<center>
<h3>
{{company_name}}
</h3>
<h4>
From {{date_from}} To {{date_to}}
จาก {{date_from}} ถึง {{date_to}}
</h4>
</center>
{{#ifeq report_type "detail"}}
@ -64,12 +61,47 @@
<tbody style="text-align:center">
<tr>
{{#each dlines }}
<th style="text-align:center;width:10%">{{name}}</th>
{{#if desc}}
<th style="text-align:left;width:10%">{{name}}</th>
{{else}}
<th style="text-align:center;width:10%">{{name}}</th>
{{/if}}
{{/each}}
</tr>
<tr>
{{#each dlines }}
<td>{{qty}}</td>
{{#if desc}}
<th style="text-align:left;width:10%">{{qty}}</th>
{{else}}
<td style="text-align:right">{{currency qty}}</td>
{{/if}}
{{/each}}
</tr>
<tr>
{{#each dlines }}
{{#if desc}}
<th style="text-align:left;width:10%">{{qty2}}</th>
{{else}}
<td style="text-align:right">{{currency qty2}}</td>
{{/if}}
{{/each}}
</tr>
<tr>
{{#each dlines }}
{{#if desc}}
<th style="text-align:left;width:10%">{{total_qty}}</th>
{{else}}
<td style="text-align:right">{{currency total_qty}}</td>
{{/if}}
{{/each}}
</tr>
<tr>
{{#each dlines }}
{{#if desc}}
<th style="text-align:left;width:10%">{{cost}}</th>
{{else}}
<td style="text-align:right">{{currency cost}}</td>
{{/if}}
{{/each}}
</tr>
</tbody>
@ -78,14 +110,41 @@
<tbody style="text-align:center">
<tr>
{{#each nlines }}
<th style="text-align:center;width:10%">{{name}}</th>
{{#if desc}}
<th style="text-align:left;width:10%">{{name}}</th>
{{else}}
<th style="text-align:center;width:10%">{{name}}</th>
{{/if}}
{{/each}}
</tr>
<tr>
{{#each nlines }}
<td>{{qty}}</td>
{{#if desc}}
<th>{{qty}}</th>
{{else}}
<td style="text-align:right">{{currency qty}}</td>
{{/if}}
{{/each}}
</tr>
<tr>
{{#each nlines }}
{{#if desc}}
<th>{{cost}}</th>
{{else}}
<td style="text-align:right">{{currency cost}}</td>
{{/if}}
{{/each}}
</tr>
</tbody>
</table>
<table class="table table-bordered">
<tbody style="text-align:center">
{{#each ctlines }}
<tr>
<th style="text-align:left;width:14%">{{name}}</th>
<td style="text-align:right">{{currency amount}}</td>
</tr>
{{/each}}
</tbody>
</table>
{{/ifeq}}