nurse fee detail
parent
8f5cd8a899
commit
a4683ca610
|
@ -1,4 +1,6 @@
|
||||||
import time
|
import time
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from calendar import monthrange
|
from calendar import monthrange
|
||||||
|
|
||||||
from netforce.model import Model,fields,get_model
|
from netforce.model import Model,fields,get_model
|
||||||
|
@ -50,24 +52,68 @@ class ReportNurseFeeSum(Model):
|
||||||
month=obj.date_from.split("-")[1]
|
month=obj.date_from.split("-")[1]
|
||||||
time_start=obj.date_from
|
time_start=obj.date_from
|
||||||
time_stop=obj.date_to
|
time_stop=obj.date_to
|
||||||
# new patient of this month
|
|
||||||
dom=[]
|
# generate list of date
|
||||||
dom.append(['resign_date','>=',time_start])
|
fmt='%Y-%m-%d'
|
||||||
dom.append(['resign_date','<=',time_stop])
|
start=datetime.strptime(time_start,fmt)
|
||||||
dom.append(['active','=',False])
|
stop=datetime.strptime(time_stop,fmt)
|
||||||
records=get_model('clinic.patient').search_browse(dom)
|
days=(stop-start).days
|
||||||
|
day_list=[]
|
||||||
|
for day in range(days+1):
|
||||||
|
dt=start+timedelta(days=day)
|
||||||
|
day_list.append(dt.strftime(fmt))
|
||||||
|
|
||||||
|
cols=[]
|
||||||
|
for date in day_list:
|
||||||
|
cols.append({'name': date[8:10]})
|
||||||
|
|
||||||
lines=[]
|
lines=[]
|
||||||
no=1
|
total_all={}
|
||||||
for record in records:
|
total_sum=0.0
|
||||||
lines.append({
|
for nurse in get_model("clinic.personal").search_browse([['type','=','nurse']]):
|
||||||
'no': no,
|
line={
|
||||||
'name': record.name or '',
|
'nurse_id': nurse.id,
|
||||||
'pid': record.id,
|
'nurse_name': nurse.name or '',
|
||||||
'note': record.note or '',
|
'sub_lines': [],
|
||||||
'resign_date': record.resign_date or '',
|
}
|
||||||
|
total_amt=0.0
|
||||||
|
for date in day_list:
|
||||||
|
if not total_all.get(date):
|
||||||
|
total_all[date]=0.0
|
||||||
|
dom=[]
|
||||||
|
dom.append(['date','=',date])
|
||||||
|
dom.append(['personal_id','=',nurse.id])
|
||||||
|
amt=0
|
||||||
|
results=get_model("clinic.cycle.dialy.line").search_read(dom,['amount','cycle_dialy_id'])
|
||||||
|
cycle_dialy_id=None
|
||||||
|
if results:
|
||||||
|
for result in results:
|
||||||
|
amt+=result['amount'] or 0.0
|
||||||
|
cycle_dialy_id=result['cycle_dialy_id'][0]
|
||||||
|
line['sub_lines'].append({
|
||||||
|
'cycle_dialy_id': cycle_dialy_id,
|
||||||
|
'amt': amt,
|
||||||
|
'last': False,
|
||||||
|
})
|
||||||
|
total_all[date]+=amt # all day
|
||||||
|
total_amt+=amt
|
||||||
|
# total of each nurse
|
||||||
|
line['sub_lines'].append({
|
||||||
|
'amt': round(total_amt,2),
|
||||||
|
'last': True,
|
||||||
})
|
})
|
||||||
no+=1
|
lines.append(line)
|
||||||
|
total_sum+=total_amt
|
||||||
|
|
||||||
|
total_lines=[]
|
||||||
|
for date in day_list:
|
||||||
|
total_lines.append({
|
||||||
|
'amt': total_all[date],
|
||||||
|
})
|
||||||
|
total_lines.append({
|
||||||
|
'amt': total_sum,
|
||||||
|
})
|
||||||
|
|
||||||
month_str=utils.MONTHS['th_TH'][int(month)]
|
month_str=utils.MONTHS['th_TH'][int(month)]
|
||||||
start=int(time_start[8:10])
|
start=int(time_start[8:10])
|
||||||
stop=int(time_stop[8:10])
|
stop=int(time_stop[8:10])
|
||||||
|
@ -75,7 +121,9 @@ class ReportNurseFeeSum(Model):
|
||||||
data={
|
data={
|
||||||
'company_name': company.name or "",
|
'company_name': company.name or "",
|
||||||
'parent_company_name': company.parent_id.name or "",
|
'parent_company_name': company.parent_id.name or "",
|
||||||
|
'cols': cols,
|
||||||
'lines': lines,
|
'lines': lines,
|
||||||
|
'total_lines': total_lines,
|
||||||
'month': month_str,
|
'month': month_str,
|
||||||
'from': time_start,
|
'from': time_start,
|
||||||
'to': time_stop,
|
'to': time_stop,
|
||||||
|
|
|
@ -14,24 +14,31 @@
|
||||||
{{#if lines}}
|
{{#if lines}}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<th>#</th>
|
<th style="text-align:left;">พยาบาล</th>
|
||||||
<th>วันที่</th>
|
{{#each cols}}
|
||||||
<th>ชื่อ</th>
|
<th style="text-align:right;">{{name}}</th>
|
||||||
<th>หมายเหตุ</th>
|
{{/each}}
|
||||||
|
<th style="text-align:right;">รวม</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#each lines}}
|
{{#each lines}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{no}}</td>
|
<td style="text-align:left;">{{nurse_name}}</td>
|
||||||
<td>{{resign_date}}</td>
|
{{#each sub_lines}}
|
||||||
<td>
|
{{#if last}}
|
||||||
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
<td style="text-align:right"><b>{{amt}}</b></td>
|
||||||
</td>
|
{{else}}
|
||||||
<td>{{note}}</td>
|
<td style="text-align:right">{{amt}}</td>
|
||||||
|
{{/if}}
|
||||||
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
|
<th>รวม</th>
|
||||||
|
{{#each total_lines}}
|
||||||
|
<th style="text-align:right">{{amt}}</th>
|
||||||
|
{{/each}}
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
Loading…
Reference in New Issue