improve
parent
37b9ce4315
commit
dd2a844d14
|
@ -6,4 +6,6 @@
|
||||||
<field name="staff_id" domain='[["type","=",type]]' span="2"/>
|
<field name="staff_id" domain='[["type","=",type]]' span="2"/>
|
||||||
<field name="branch_id" span="2"/>
|
<field name="branch_id" span="2"/>
|
||||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||||
|
<field name="categ_id" span="2"/>
|
||||||
|
<field name="cycle_id" span="2"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -69,6 +69,8 @@ class ReportLaborCostDaily(Model):
|
||||||
amt=line.amount or 0
|
amt=line.amount or 0
|
||||||
if staff_type=='doctor':
|
if staff_type=='doctor':
|
||||||
for hdcase in citem.hd_cases:
|
for hdcase in citem.hd_cases:
|
||||||
|
if hdcase.state not in ("waiting_payment","paid"):
|
||||||
|
continue
|
||||||
doctor=hdcase.doctor_id
|
doctor=hdcase.doctor_id
|
||||||
pt_type=hdcase.patient_type_id
|
pt_type=hdcase.patient_type_id
|
||||||
pt=hdcase.patient_id
|
pt=hdcase.patient_id
|
||||||
|
@ -76,6 +78,7 @@ class ReportLaborCostDaily(Model):
|
||||||
lines.append({
|
lines.append({
|
||||||
'hd_case_number': hdcase.number or '',
|
'hd_case_number': hdcase.number or '',
|
||||||
'hd_case_id': hdcase.id or '',
|
'hd_case_id': hdcase.id or '',
|
||||||
|
'date': hdcase.date or '',
|
||||||
'no': no,
|
'no': no,
|
||||||
'hn': pt.number,
|
'hn': pt.number,
|
||||||
'patient_id': pt.id,
|
'patient_id': pt.id,
|
||||||
|
@ -91,6 +94,8 @@ class ReportLaborCostDaily(Model):
|
||||||
elif staff_type=='nurse':
|
elif staff_type=='nurse':
|
||||||
print("nurse ")
|
print("nurse ")
|
||||||
for hdcase in citem.hd_cases:
|
for hdcase in citem.hd_cases:
|
||||||
|
if hdcase.state not in ("waiting_payment","paid"):
|
||||||
|
continue
|
||||||
doctor=hdcase.doctor_id
|
doctor=hdcase.doctor_id
|
||||||
pt_type=hdcase.patient_type_id
|
pt_type=hdcase.patient_type_id
|
||||||
pt=hdcase.patient_id
|
pt=hdcase.patient_id
|
||||||
|
@ -98,6 +103,7 @@ class ReportLaborCostDaily(Model):
|
||||||
'no': no,
|
'no': no,
|
||||||
'cycle_item_name': citem.name or '',
|
'cycle_item_name': citem.name or '',
|
||||||
'cycle_item_id': citem.id,
|
'cycle_item_id': citem.id,
|
||||||
|
'date': citem.date,
|
||||||
'hn': pt.number,
|
'hn': pt.number,
|
||||||
'patient_id': pt.id,
|
'patient_id': pt.id,
|
||||||
'patient_type_name': pt_type.name or '',
|
'patient_type_name': pt_type.name or '',
|
||||||
|
|
|
@ -18,6 +18,8 @@ class ReportLaborCostDetail(Model):
|
||||||
"type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"),
|
"type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"),
|
||||||
'department_id': fields.Many2One("clinic.department","Department"),
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||||
|
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
|
||||||
|
'categ_id': fields.Many2One("clinic.staff.categ","Category"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_date_from(self,context={}):
|
def _get_date_from(self,context={}):
|
||||||
|
@ -32,6 +34,12 @@ class ReportLaborCostDetail(Model):
|
||||||
def default_get(self,field_names=None,context={},**kw):
|
def default_get(self,field_names=None,context={},**kw):
|
||||||
defaults=context.get("defaults",{})
|
defaults=context.get("defaults",{})
|
||||||
date_from=defaults.get("date_from")
|
date_from=defaults.get("date_from")
|
||||||
|
cycle_id=defaults.get("cycle_id")
|
||||||
|
if cycle_id:
|
||||||
|
cycle_id=int(cycle_id)
|
||||||
|
categ_id=defaults.get("categ_id")
|
||||||
|
if categ_id:
|
||||||
|
categ_id=int(categ_id)
|
||||||
if not date_from:
|
if not date_from:
|
||||||
date_from=self._get_date_from()
|
date_from=self._get_date_from()
|
||||||
date_to=defaults.get("date_to")
|
date_to=defaults.get("date_to")
|
||||||
|
@ -39,7 +47,6 @@ class ReportLaborCostDetail(Model):
|
||||||
date_to=self._get_date_to()
|
date_to=self._get_date_to()
|
||||||
staff_type=defaults.get("staff_type","doctor")
|
staff_type=defaults.get("staff_type","doctor")
|
||||||
staff_id=int(defaults.get('staff_id', "0"))
|
staff_id=int(defaults.get('staff_id', "0"))
|
||||||
print('defaults ', defaults)
|
|
||||||
department_id=defaults.get('department_id')
|
department_id=defaults.get('department_id')
|
||||||
if department_id:
|
if department_id:
|
||||||
department_id=int(department_id)
|
department_id=int(department_id)
|
||||||
|
@ -49,15 +56,19 @@ class ReportLaborCostDetail(Model):
|
||||||
if not branch_id and department_id:
|
if not branch_id and department_id:
|
||||||
dpt=get_model('clinic.department').browse(department_id)
|
dpt=get_model('clinic.department').browse(department_id)
|
||||||
branch_id=dpt.branch_id.id
|
branch_id=dpt.branch_id.id
|
||||||
|
print('defaults ', defaults)
|
||||||
res={
|
res={
|
||||||
'date': time.strftime("%Y-%m-%d"),
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
'date_from': date_from,
|
'date_from': date_from,
|
||||||
'date_to': date_to,
|
'date_to': date_to,
|
||||||
'type': staff_type,
|
'type': staff_type,
|
||||||
'staff_id': staff_id and staff_id or None,
|
'staff_id': staff_id or None,
|
||||||
'department_id': department_id and department_id or None,
|
'department_id': department_id or None,
|
||||||
'branch_id': branch_id,
|
'branch_id': branch_id or None,
|
||||||
|
'cycle_id': cycle_id or None,
|
||||||
|
'categ_id': categ_id or None,
|
||||||
}
|
}
|
||||||
|
print('res ', res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_report_data(self,ids,context={}):
|
def get_report_data(self,ids,context={}):
|
||||||
|
@ -70,6 +81,8 @@ class ReportLaborCostDetail(Model):
|
||||||
staff_id=defaults.get("staff_id")
|
staff_id=defaults.get("staff_id")
|
||||||
department_id=defaults.get("department_id")
|
department_id=defaults.get("department_id")
|
||||||
branch_id=defaults.get("branch_id")
|
branch_id=defaults.get("branch_id")
|
||||||
|
cycle_id=defaults.get("cycle_id") or None
|
||||||
|
categ_id=defaults.get("categ_id") or None
|
||||||
dom=[]
|
dom=[]
|
||||||
if ids:
|
if ids:
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
@ -79,6 +92,8 @@ class ReportLaborCostDetail(Model):
|
||||||
staff_type=obj.type
|
staff_type=obj.type
|
||||||
department_id=obj.department_id.id
|
department_id=obj.department_id.id
|
||||||
branch_id=obj.branch_id.id
|
branch_id=obj.branch_id.id
|
||||||
|
cycle_id=obj.cycle_id.id
|
||||||
|
categ_id=obj.categ_id.id
|
||||||
dom.append(['date','>=',date_from])
|
dom.append(['date','>=',date_from])
|
||||||
dom.append(['date','<=',date_to])
|
dom.append(['date','<=',date_to])
|
||||||
if staff_id:
|
if staff_id:
|
||||||
|
@ -89,12 +104,16 @@ class ReportLaborCostDetail(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])
|
||||||
if branch_id:
|
if branch_id:
|
||||||
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
|
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
|
||||||
|
if cycle_id:
|
||||||
|
dom.append(['cycle_id','=',cycle_id])
|
||||||
|
if categ_id:
|
||||||
|
dom.append(['staff_id.categ_id','=',categ_id])
|
||||||
|
print('dom ', dom)
|
||||||
def replace_quote(dom=""):
|
def replace_quote(dom=""):
|
||||||
return dom.replace("'","\"")
|
return dom.replace("'","\"")
|
||||||
#prevent to load more data
|
#prevent to load more data
|
||||||
if not staff_id:
|
#if not staff_id:
|
||||||
return {}
|
#return {}
|
||||||
dates={}
|
dates={}
|
||||||
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
|
||||||
|
@ -103,7 +122,8 @@ class ReportLaborCostDetail(Model):
|
||||||
if not date:
|
if not date:
|
||||||
continue
|
continue
|
||||||
dpt=citem.department_id
|
dpt=citem.department_id
|
||||||
amt=line.pay_amount or 0 #XXX
|
#amt=line.pay_amount or 0 #XXX
|
||||||
|
amt=line.amount or 0 #XXX
|
||||||
staff=line.staff_id
|
staff=line.staff_id
|
||||||
qty=0
|
qty=0
|
||||||
if staff.type=='doctor':
|
if staff.type=='doctor':
|
||||||
|
@ -112,13 +132,14 @@ class ReportLaborCostDetail(Model):
|
||||||
if staff.id==doctor_id:
|
if staff.id==doctor_id:
|
||||||
qty+=1
|
qty+=1
|
||||||
elif staff.type=='nurse':
|
elif staff.type=='nurse':
|
||||||
qty=len(citem.hd_cases) or 0 # qty of patient
|
qty=citem.pt_total or 0 # qty of patient
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
if not dates.get(date):
|
if not dates.get(date):
|
||||||
dates[date]={
|
dates[date]={
|
||||||
'labor_cost_id': lcost.id,
|
'labor_cost_id': lcost.id,
|
||||||
'staff_id': staff.id,
|
'staff_id': staff.id,
|
||||||
|
'staff_name': staff.name or "",
|
||||||
'staff_type': staff.type,
|
'staff_type': staff.type,
|
||||||
dpt.name: {
|
dpt.name: {
|
||||||
'amt': 0,
|
'amt': 0,
|
||||||
|
@ -130,6 +151,7 @@ class ReportLaborCostDetail(Model):
|
||||||
dates[date].update({
|
dates[date].update({
|
||||||
'labor_cost_id': lcost.id,
|
'labor_cost_id': lcost.id,
|
||||||
'staff_id': staff.id,
|
'staff_id': staff.id,
|
||||||
|
'staff_name': staff.name or '',
|
||||||
'staff_type': staff.type,
|
'staff_type': staff.type,
|
||||||
dpt.name: {
|
dpt.name: {
|
||||||
'amt': 0,
|
'amt': 0,
|
||||||
|
@ -173,6 +195,7 @@ class ReportLaborCostDetail(Model):
|
||||||
vals=dates[kdate]
|
vals=dates[kdate]
|
||||||
lvals={
|
lvals={
|
||||||
'no': no,
|
'no': no,
|
||||||
|
'staff_name': vals.get('staff_name') or "",
|
||||||
'date': kdate,
|
'date': kdate,
|
||||||
'staff_type': vals.get("staff_type"),
|
'staff_type': vals.get("staff_type"),
|
||||||
'staff_id': vals.get("staff_id"),
|
'staff_id': vals.get("staff_id"),
|
||||||
|
@ -229,7 +252,11 @@ class ReportLaborCostDetail(Model):
|
||||||
if staff_id:
|
if staff_id:
|
||||||
staff=get_model("clinic.staff").browse(staff_id)
|
staff=get_model("clinic.staff").browse(staff_id)
|
||||||
staff_name=staff.name or ''
|
staff_name=staff.name or ''
|
||||||
|
show_name=True
|
||||||
|
if staff_id:
|
||||||
|
show_name=False
|
||||||
data={
|
data={
|
||||||
|
'show_name': show_name,
|
||||||
'staff_name': staff_name,
|
'staff_name': staff_name,
|
||||||
'staff_id': staff_id,
|
'staff_id': staff_id,
|
||||||
'staff_type': staff_type,
|
'staff_type': staff_type,
|
||||||
|
@ -244,6 +271,7 @@ class ReportLaborCostDetail(Model):
|
||||||
'dpt_lines': dpt_lines,
|
'dpt_lines': dpt_lines,
|
||||||
'show_all': show_count <=1 and True or False,
|
'show_all': show_count <=1 and True or False,
|
||||||
}
|
}
|
||||||
|
print('.... ', data['show_name'])
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_date(self,context={}):
|
def onchange_date(self,context={}):
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
<th>HDCase</th>
|
<th>HDCase</th>
|
||||||
{{/ifeq}}
|
{{/ifeq}}
|
||||||
{{#ifeq staff_type "nurse"}}
|
{{#ifeq staff_type "nurse"}}
|
||||||
<th>Cycle Item</th>
|
<th>Date</th>
|
||||||
{{/ifeq}}
|
{{/ifeq}}
|
||||||
|
<th>Cycle</th>
|
||||||
|
<th>Department</th>
|
||||||
<th>HN</th>
|
<th>HN</th>
|
||||||
<th>Patient</th>
|
<th>Patient</th>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
<th>Cycle</th>
|
|
||||||
<th>Department</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -28,14 +28,14 @@
|
||||||
{{/ifeq}}
|
{{/ifeq}}
|
||||||
{{#ifeq ../staff_type "nurse"}}
|
{{#ifeq ../staff_type "nurse"}}
|
||||||
<td>
|
<td>
|
||||||
{{view "link" string=cycle_item_name action="clinic_cycle_item" action_options="mode=form" active_id=cycle_item_id}}
|
{{view "link" string=date action="clinic_cycle_item" action_options="mode=form" active_id=cycle_item_id}}
|
||||||
</td>
|
</td>
|
||||||
{{/ifeq}}
|
{{/ifeq}}
|
||||||
|
<td>{{cycle_name}}</td>
|
||||||
|
<td>{{dpt_name}}</td>
|
||||||
<td>{{hn}}</td>
|
<td>{{hn}}</td>
|
||||||
<td>{{patient_name}}</td>
|
<td>{{patient_name}}</td>
|
||||||
<td>{{patient_type_name}}</td>
|
<td>{{patient_type_name}}</td>
|
||||||
<td>{{cycle_name}}</td>
|
|
||||||
<td>{{dpt_name}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
{{#if ../show_name}}
|
||||||
<th></th>
|
<th></th>
|
||||||
|
{{/if}}
|
||||||
<th style="text-align:center" colspan="{{comp_span}}">
|
<th style="text-align:center" colspan="{{comp_span}}">
|
||||||
{{#if show_all}}
|
{{#if show_all}}
|
||||||
<a href="#name=clinic_report_labor_cost_sub_detail&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.department_id={{department_id}}">{{comp_name}}</a>
|
<a href="#name=clinic_report_labor_cost_sub_detail&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.department_id={{department_id}}">{{comp_name}}</a>
|
||||||
|
@ -14,10 +16,14 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</th>
|
</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th rowspan="2">#</th>
|
<th rowspan="2">#</th>
|
||||||
<th rowspan="2">วันที่</th>
|
<th rowspan="2">วันที่</th>
|
||||||
|
{{#if ../show_name}}
|
||||||
|
<th rowspan="2">Staff</th>
|
||||||
|
{{/if}}
|
||||||
{{#each dpts}}
|
{{#each dpts}}
|
||||||
<th rowspan="2" colspan="2" style="text-align:center">
|
<th rowspan="2" colspan="2" style="text-align:center">
|
||||||
{{#if show_link}}
|
{{#if show_link}}
|
||||||
|
@ -38,6 +44,9 @@
|
||||||
<tr></tr>
|
<tr></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th rowspan="2"></th>
|
<th rowspan="2"></th>
|
||||||
|
{{#if ../show_name}}
|
||||||
|
<th rowspan="2"></th>
|
||||||
|
{{/if}}
|
||||||
<th rowspan="2"></th>
|
<th rowspan="2"></th>
|
||||||
{{#each dpts}}
|
{{#each dpts}}
|
||||||
<th rowspan="2" style="text-align:center">{{qty_text}}</th>
|
<th rowspan="2" style="text-align:center">{{qty_text}}</th>
|
||||||
|
@ -54,6 +63,11 @@
|
||||||
<td>
|
<td>
|
||||||
<a href="#name=clinic_report_labor_cost_daily&defaults.date={{date}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}">{{date}}</a>
|
<a href="#name=clinic_report_labor_cost_daily&defaults.date={{date}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}">{{date}}</a>
|
||||||
</td>
|
</td>
|
||||||
|
{{#if ../show_name}}
|
||||||
|
<td>
|
||||||
|
{{staff_name}}
|
||||||
|
</td>
|
||||||
|
{{/if}}
|
||||||
{{#each sub_lines}}
|
{{#each sub_lines}}
|
||||||
<td style="text-align:right;">
|
<td style="text-align:right;">
|
||||||
<a href="#name=clinic_report_labor_cost_daily&defaults.date={{../date}}&defaults.staff_type={{../staff_type}}&defaults.staff_id={{../staff_id}}&defaults.department_id={{dpt_id}}">{{currency qty zero=""}}</a>
|
<a href="#name=clinic_report_labor_cost_daily&defaults.date={{../date}}&defaults.staff_type={{../staff_type}}&defaults.staff_id={{../staff_id}}&defaults.department_id={{dpt_id}}">{{currency qty zero=""}}</a>
|
||||||
|
@ -74,6 +88,9 @@
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<th>รวม</th>
|
<th>รวม</th>
|
||||||
<th style="text-align:right"></th>
|
<th style="text-align:right"></th>
|
||||||
|
{{#if show_name}}
|
||||||
|
<th style="text-align:right"></th>
|
||||||
|
{{/if}}
|
||||||
{{#each dpt_lines}}
|
{{#each dpt_lines}}
|
||||||
<th style="text-align:right;">{{qty}}</th>
|
<th style="text-align:right;">{{qty}}</th>
|
||||||
<th style="text-align:right;">{{currency amt zero=""}}</th>
|
<th style="text-align:right;">{{currency amt zero=""}}</th>
|
||||||
|
|
Loading…
Reference in New Issue