improve report

conv_bal
watcha.h@almacom.co.th 2015-05-01 07:57:31 +07:00
parent a6a48ebf3f
commit 217047f577
5 changed files with 66 additions and 12 deletions

View File

@ -239,12 +239,13 @@ class ReportLaborCost(Model):
dom3=dom1+[['walkin','=',False]]
dlines.append({
'name': dt_name,
'qty': "{0:.2f}".format(round(qty,2)),
'qty2': "{0:.2f}".format(round(walkin_qty,2)),
'qty': "{0:,.2f}".format(round(qty,2)),
'qty2': "{0:,.2f}".format(round(walkin_qty,2)),
'walkin_qty': walkin_qty,
'option_qty': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom3)),
'option_qty2': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom2)),
'total_qty': walkin_qty+qty,
'date': date,
'date_from': date_from,
'date_to': date_to,
'cost': cost,
'total': 0,
'department_id': dpt_id,
@ -262,6 +263,9 @@ class ReportLaborCost(Model):
'department_id': None,
'branch_id':None,
'staff_type': 'doctor',
'date': date,
'date_from': date_from,
'date_to': date_to,
}]+sorted(dlines,key=lambda x: x['name'])
dom4=[
['date','>=',date_from],
@ -284,6 +288,9 @@ class ReportLaborCost(Model):
'cycle_id': cycle_id,
'branch_id': branch_id,
'department_id': department_id,
'date': date,
'date_from': date_from,
'date_to': date_to,
'option_qty': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom4)),
'option_qty2': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom5)),
})
@ -293,8 +300,8 @@ class ReportLaborCost(Model):
dlines[-1]['total_qty']+=dline['total_qty'] or 0
dlines[-1]['cost']+=dline['cost'] or 0
dlines[-1]['walkin_qty']+=float(dline['qty2']) or 0
dlines[-1]['qty']="{0:.2f}".format(round(dlines[-1]['qty'],2)) #total
dlines[-1]['qty2']="{0:.2f}".format(round(dlines[-1]['qty2'],2)) #total
dlines[-1]['qty']="{0:,.2f}".format(round(dlines[-1]['qty'],2)) #total
dlines[-1]['qty2']="{0:,.2f}".format(round(dlines[-1]['qty2'],2)) #total
nlines.append({
'name': 'พยาบาล',

View File

@ -34,12 +34,24 @@ class ReportLaborCostStaff(Model):
date_from=defaults.get("date_from", self._get_date_from())
date_to=defaults.get("date_to", self._get_date_to())
walkin=defaults.get("walkin", False)
department_id=defaults.get("department_id") or None
if department_id:
department_id=int(department_id)
branch_id=defaults.get("branch_id") or None
if branch_id:
branch_id=int(branch_id)
if walkin and walkin=='False':
walkin=False
else:
walkin=True
print('defaults ', defaults)
res={
'date': time.strftime("%Y-%m-%d"),
'date_from': date_from,
'date_to': date_to,
'walkin': walkin,
'department_id': department_id,
'branch_id': branch_id,
}
return res
@ -71,23 +83,38 @@ class ReportLaborCostStaff(Model):
if cycle_id:
dom.append(['hd_case_id.cycle_id','=',cycle_id])
lines=[]
print('dom ', dom)
for sline in get_model("clinic.hd.case.staff").search_browse(dom):
hdcase=sline.hd_case_id
staff=sline.staff_id
if walkin and staff:
patient=hdcase.patient_id
if walkin:
if staff and staff.number!='walkin':
continue
else:
if staff.number=='walkin':
continue
lines.append({
'id': sline.id,
'date': sline.date,
'number': hdcase.number or '',
'staff_name': staff.name or '',
'staff_id': staff.id or '',
'staff_id': staff.id or None,
'patient_id': patient.id or None,
'patient_name': patient.name or None,
'department_name': sline.department_id.name or '',
'date': sline.date,
})
nlines=[]
no=1
for line in sorted(lines,key=lambda x: (x['date'],x['number'])):
line['no']=no
nlines.append(line)
no+=1
data={
'date_from': date_from,
'date_to': date_to,
'lines': lines,
'lines': nlines,
}
return data

View File

@ -161,6 +161,12 @@ class ClinicSetting(Model):
if user_id !=1:
print("Only admin!!")
return
for sline in get_model("clinic.hd.case.staff").search_browse([]):
hdcase=sline.hd_case_id
sline.write({
'date': hdcase.date,
})
print('update ', sline.id, hdcase.date)
#obj=self.browse(ids)[0]
#obj.del_duplicate_staff()
#obj.merge_staff()

View File

@ -72,7 +72,9 @@
<th style="text-align:left;width:10%">{{qty}}</th>
{{else}}
<td style="text-align:right">
{{view "link" string=qty action="clinic_report_labor_cost_staff" action_options=option_qty}}
<a href="/ui#name=clinic_report_labor_cost_staff&defaults.date={{date}}&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.walkin=False">
{{qty}}
</a>
</td>
{{/if}}
{{/each}}
@ -84,7 +86,9 @@
{{else}}
<td style="text-align:right">
{{#if walkin_qty}}
{{view "link" string=qty2 action="clinic_report_labor_cost_staff" action_options=option_qty2}}
<a href="/ui#name=clinic_report_labor_cost_staff&defaults.date={{date}}&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.walkin=false">
{{qty2}}
</a>
{{else}}
0.00
{{/if}}

View File

@ -3,20 +3,28 @@
<table class="table">
<thead class="scroll-header">
<tr>
<th>#</th>
<th>Date</th>
<th>HDCase</th>
<th>Doctor</th>
<th>Patient</th>
<th>Department</th>
</tr>
</thead>
<tbody>
{{#each lines}}
<tr>
<td>{{no}}</td>
<td>{{date}}</td>
<td>
{{view "link" string=number action="clinic_hd_case_staff" action_options="mode=form" active_id=id}}
</td>
<td>
{{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}}
</td>
<td>
{{view "link" string=patient_name action="clinic_patient" action_options="mode=form" active_id=patient_id}}
</td>
<td>
{{department_name}}
</td>
@ -27,6 +35,8 @@
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tfoot>
</table>