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