report labor cost
parent
5aa69ef411
commit
39fa93e8da
|
@ -2,7 +2,7 @@
|
|||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="branch_id" span="3"/>
|
||||
<field name="branch_id" onchange='onchange_branch' span="3"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
|
||||
<foot replace="1">
|
||||
<button string="Compute" method="compute" icon="repeat" type="default"/>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<template>
|
||||
<div>
|
||||
<p></p>
|
||||
<b>Information: </b>State Accept <b style="color:green">'Finish Treatment', 'Waiting Payment', 'Paid'.</b></div>
|
||||
<b>Information: </b>State Accept <b style="color:green">'Waiting Payment', 'Paid'.</b></div>
|
||||
</template>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<field name="branch_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="nurse_total"/>
|
||||
<field name="pt_total"/>
|
||||
<field name="user_id"/>
|
||||
<field name="date_validate"/>
|
||||
<field name="note"/>
|
||||
|
|
|
@ -3,7 +3,6 @@ from calendar import monthrange
|
|||
|
||||
from netforce.model import Model,fields,get_model
|
||||
|
||||
|
||||
class ComputeLaborCost(Model):
|
||||
_name="clinic.compute.labor.cost"
|
||||
_string="Compute Labor Cost"
|
||||
|
@ -66,4 +65,9 @@ class ComputeLaborCost(Model):
|
|||
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||
return data
|
||||
|
||||
def onchange_branch(self,context={}):
|
||||
data=context['data']
|
||||
data['department_id']=None
|
||||
return data
|
||||
|
||||
ComputeLaborCost.register()
|
||||
|
|
|
@ -27,8 +27,10 @@ class CycleItem(Model):
|
|||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
pt_total=len([hdcase for hdcase in obj.hd_cases if hdcase.state in ('waiting_payment','paid')])
|
||||
res[obj.id]={
|
||||
'nurse_total': len(obj.lines),
|
||||
'pt_total': pt_total,
|
||||
}
|
||||
return res
|
||||
|
||||
|
@ -48,6 +50,7 @@ class CycleItem(Model):
|
|||
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
|
||||
"state": fields.Selection([("draft","Draft"),('pending','Pending'),("validated","Validated")],"Status",required=True),
|
||||
'nurse_total': fields.Integer("Nurses",function="_get_all",function_multi=True),
|
||||
'pt_total': fields.Integer("Patients",function="_get_all",function_multi=True),
|
||||
'note': fields.Text("Note"),
|
||||
}
|
||||
|
||||
|
@ -104,8 +107,8 @@ class CycleItem(Model):
|
|||
state=hdcase.state
|
||||
if state=='cancelled':
|
||||
continue
|
||||
if state not in ('completed','waiting_payment','paid'):
|
||||
raise Exception('Invalidate cycle item %s: HD Case %s is not completed' % (obj.name, hdcase.patient_id.name))
|
||||
if state not in ('waiting_payment','paid'):
|
||||
raise Exception('Invalidate cycle item %s: Can not validate HD Case %s (State not accept)' % (obj.name, hdcase.patient_id.name))
|
||||
for obj_id in ids:
|
||||
lcost_ids=get_model("clinic.labor.cost").search([['cycle_item_id','=',obj_id]])
|
||||
labor_cost=get_model("clinic.labor.cost")
|
||||
|
|
|
@ -24,7 +24,7 @@ class LaborCost(Model):
|
|||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
hd_cases=obj.cycle_item_id.hd_cases or []
|
||||
hd_cases=[hdcase for hdcase in obj.cycle_item_id.hd_cases if hdcase.state in ('waiting_payment','paid')] or []
|
||||
total_case=len(hd_cases)
|
||||
total_a,total_b=0,0
|
||||
total=0.0
|
||||
|
@ -272,13 +272,12 @@ class LaborCost(Model):
|
|||
'level_id': level_id,
|
||||
}
|
||||
|
||||
#TODO UPDATE COST : like cycle daily
|
||||
item=obj.cycle_item_id
|
||||
lines=[]
|
||||
# cost's nurses
|
||||
for line in item.lines:
|
||||
nurse=line.nurse_id
|
||||
level=line.level_id
|
||||
level=line.level_id or nurse.level_id
|
||||
vals=levels.get(level.id)
|
||||
rate,amt,qty=0.0,0.0,0
|
||||
level_id=level.id
|
||||
|
@ -306,6 +305,8 @@ class LaborCost(Model):
|
|||
for staff in get_model("clinic.staff").search_browse([['number','=','walkin']]):
|
||||
dwalkin=staff
|
||||
for hd_case in item.hd_cases:
|
||||
if hd_case.state not in ('waiting_payment','paid'):
|
||||
continue
|
||||
staffs=hd_case.staffs
|
||||
for ps in staffs:
|
||||
staff=ps.staff_id or dwalkin
|
||||
|
|
|
@ -59,6 +59,7 @@ class ReportLaborCost(Model):
|
|||
show_detail=obj.show_detail
|
||||
dom.append(['date','>=',date_from])
|
||||
dom.append(['date','<=',date_to])
|
||||
dom.append(['cycle_item_id.state','=', 'validated'])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
|
@ -67,6 +68,7 @@ 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 ''
|
||||
|
@ -78,7 +80,9 @@ class ReportLaborCost(Model):
|
|||
'qty':0,
|
||||
'state':{},
|
||||
}
|
||||
hdcases[dpt.id]['qty']+=1
|
||||
#total for each department
|
||||
if state in ('waiting_payment','paid'):
|
||||
hdcases[dpt.id]['qty']+=1
|
||||
if not hdcases[dpt.id]['state'].get(state):
|
||||
hdcases[dpt.id]['state'][state]=0
|
||||
hdcases[dpt.id]['state'][state]+=1
|
||||
|
@ -94,17 +98,21 @@ class ReportLaborCost(Model):
|
|||
for dpt_id, vals in hdcases.items():
|
||||
sub_lines=[]
|
||||
dom2=[['department_id','=',dpt_id]]
|
||||
qty=vals['qty'] or 0
|
||||
for state, sqty in vals['state'].items():
|
||||
ok=False
|
||||
dom3=[['state','=',state]] # last domain
|
||||
if state in ('waiting_payment','paid'):
|
||||
ok=True
|
||||
total_hdcase+=qty
|
||||
dom4=dom+dom2+dom3
|
||||
state=dstates[state]
|
||||
sub_lines.append({
|
||||
'name': state,
|
||||
'qty': sqty,
|
||||
'ok': ok,
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom4)),
|
||||
})
|
||||
qty=vals['qty'] or 0
|
||||
total_hdcase+=qty
|
||||
lines.append({
|
||||
'name': vals['name'],
|
||||
'branch_id': vals['branch_id'],
|
||||
|
|
|
@ -99,7 +99,6 @@ class ReportLaborCostSummary(Model):
|
|||
citems={}
|
||||
print('dom ', dom)
|
||||
total_hdcase=0
|
||||
states={}
|
||||
for line in get_model("clinic.labor.cost.line").search_browse(dom):
|
||||
lcost=line.labor_cost_id
|
||||
citem=lcost.cycle_item_id
|
||||
|
@ -113,6 +112,7 @@ class ReportLaborCostSummary(Model):
|
|||
categ=staff.categ_id
|
||||
level_name=''
|
||||
if not staff:
|
||||
print('no staff', qty, amt)
|
||||
continue
|
||||
if level_id and staff.level_id.id !=level_id:
|
||||
continue
|
||||
|
@ -145,16 +145,8 @@ class ReportLaborCostSummary(Model):
|
|||
staffs[staff.name][dpt.name]['qty']+=qty
|
||||
|
||||
if not citems.get(citem.id):
|
||||
#qty=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('completed', 'waiting_payment', 'paid')])
|
||||
qty=0
|
||||
for hdcase in citem.hd_cases:
|
||||
qty+=1
|
||||
#if hdcase.state not in states.keys():
|
||||
#states[hdcase.state]=0
|
||||
#states[hdcase.state]+=1
|
||||
qty=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('waiting_payment', 'paid')])
|
||||
citems[citem.id]=qty
|
||||
#for state,vals in states.items():
|
||||
#print(state, vals)
|
||||
lines=[]
|
||||
dom=[]
|
||||
if branch_id:
|
||||
|
@ -227,7 +219,6 @@ class ReportLaborCostSummary(Model):
|
|||
total_lines.append({'amt': round(total,0)})
|
||||
company_id=get_active_company()
|
||||
comp=get_model("company").browse(company_id)
|
||||
|
||||
if staff_type!='doctor':
|
||||
total_hdcase=0
|
||||
for k,hdcase_qty in citems.items():
|
||||
|
|
|
@ -21,26 +21,30 @@
|
|||
<th></th>
|
||||
</tr>
|
||||
{{#each sub_lines}}
|
||||
<tr>
|
||||
<td style="text-align:right">{{name}}</td>
|
||||
{{#if ok}}
|
||||
<tr style="color:green;">
|
||||
{{else}}
|
||||
<tr>
|
||||
{{/if}}
|
||||
<td> {{name}}</td>
|
||||
<td style="text-align:right">
|
||||
{{view "link" string=qty action="clinic_hd_case" action_options=action_options}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
<tr>
|
||||
<th style="text-align:right">
|
||||
Subtotal
|
||||
<th>
|
||||
Subtotal
|
||||
</th>
|
||||
<th style="text-align:right">
|
||||
<a href="#name=clinic_report_labor_cost_summary&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}">{{currency qty}}</a>
|
||||
<a target="_blank" href="#name=clinic_report_labor_cost_summary&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}">{{currency qty}}</a>
|
||||
</th>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<td>{{name}}</td>
|
||||
<td style="text-align:right">
|
||||
<a href="#name=clinic_report_labor_cost_summary&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}">{{currency qty}}</a>
|
||||
<a target="_blank" href="#name=clinic_report_labor_cost_summary&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}">{{currency qty}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in New Issue