report labor cost
parent
d4b3598a99
commit
d355abcda4
|
@ -295,7 +295,6 @@ class LaborCost(Model):
|
|||
'categ_id': nurse.categ_id.id,
|
||||
'rate': rate,
|
||||
'type': 'nurse',
|
||||
#'qty': qty,
|
||||
'qty': 1,
|
||||
}))
|
||||
|
||||
|
@ -303,10 +302,13 @@ class LaborCost(Model):
|
|||
st=get_model('clinic.setting').browse(1)
|
||||
cost_per_case=obj.cost_per_case or st.cost_per_case or 0
|
||||
staff_total={}
|
||||
dwalkin=None
|
||||
for staff in get_model("clinic.staff").search_browse([['number','=','walkin']]):
|
||||
dwalkin=staff
|
||||
for hd_case in item.hd_cases:
|
||||
staffs=hd_case.staffs
|
||||
for ps in staffs:
|
||||
staff=ps.staff_id
|
||||
staff=ps.staff_id or dwalkin
|
||||
if not staff:
|
||||
continue
|
||||
base=staff.base
|
||||
|
@ -317,7 +319,7 @@ class LaborCost(Model):
|
|||
'base': 0,
|
||||
'type': staff.type,
|
||||
'categ_id': staff.categ_id.id,
|
||||
'level_id': staff.level_id.id, #XXX
|
||||
'level_id': staff.level_id.id,
|
||||
'qty': 0,
|
||||
}
|
||||
if staff.type!='doctor':
|
||||
|
|
|
@ -310,10 +310,6 @@ class ReportHDCaseSummary(Model):
|
|||
data['department_id']=None
|
||||
return data
|
||||
|
||||
def get_report_data2(self,context={}):
|
||||
data={}
|
||||
return data
|
||||
|
||||
def run_report(self,ids,context={}):
|
||||
return {
|
||||
'next': {
|
||||
|
|
|
@ -44,8 +44,8 @@ class ReportLaborCost(Model):
|
|||
defaults=self.default_get(context=context)
|
||||
date_from=defaults['date_from']
|
||||
date_to=defaults['date_to']
|
||||
branch_id=None
|
||||
department_id=None
|
||||
branch_id=defaults.get("branch_id")
|
||||
department_id=defaults.get("department_id")
|
||||
dom=[]
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
|
@ -61,19 +61,44 @@ class ReportLaborCost(Model):
|
|||
dom.append(['department_id','=',department_id])
|
||||
date=date_from
|
||||
hdcases={}
|
||||
for hdcase in get_model("clinic.hd.case").search_browse(dom):
|
||||
hdcase_obj=get_model("clinic.hd.case")
|
||||
dstates=dict(hdcase_obj._fields['state'].selection)
|
||||
for hdcase in hdcase_obj.search_browse(dom):
|
||||
dpt=hdcase.department_id
|
||||
state=hdcase.state or ''
|
||||
if dpt.id not in hdcases.keys():
|
||||
hdcases[dpt.id]={
|
||||
'name': dpt.name,
|
||||
'department_id': dpt.id,
|
||||
'branch_id': dpt.branch_id.id,
|
||||
'qty':0,
|
||||
'state':{},
|
||||
}
|
||||
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
|
||||
def replace_quote(dom=""):
|
||||
dom=dom.replace("False","false")
|
||||
dom=dom.replace("True","true")
|
||||
return dom.replace("'","\"")
|
||||
lines=[]
|
||||
dom=[]
|
||||
dom.append(["date",">=",date_from])
|
||||
dom.append(["date","<=",date_to])
|
||||
total_hdcase=0
|
||||
for dpt_id, vals in hdcases.items():
|
||||
sub_lines=[]
|
||||
dom2=[['department_id','=',dpt_id]]
|
||||
for state, sqty in vals['state'].items():
|
||||
dom3=[['state','=',state]] # last domain
|
||||
dom4=dom+dom2+dom3
|
||||
state=dstates[state]
|
||||
sub_lines.append({
|
||||
'name': state,
|
||||
'qty': sqty,
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom4)),
|
||||
})
|
||||
qty=vals['qty'] or 0
|
||||
total_hdcase+=qty
|
||||
lines.append({
|
||||
|
@ -81,6 +106,7 @@ class ReportLaborCost(Model):
|
|||
'branch_id': vals['branch_id'],
|
||||
'department_id': vals['department_id'],
|
||||
'qty': qty,
|
||||
'sub_lines': sub_lines,
|
||||
})
|
||||
sub_name=''
|
||||
if department_id:
|
||||
|
@ -89,7 +115,6 @@ class ReportLaborCost(Model):
|
|||
elif branch_id:
|
||||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
sub_name="(%s)" % branch.name or ""
|
||||
print('>>>>>> :: ', date)
|
||||
data={
|
||||
'company_name': '%s %s' % (company.name or "", sub_name),
|
||||
'date': date,
|
||||
|
|
|
@ -34,7 +34,6 @@ class ReportLaborCostSummary(Model):
|
|||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
date=defaults.get("date", time.strftime("%Y-%m-%d"))
|
||||
print('date>>> ', date)
|
||||
date_from=defaults.get("date_from", self._get_date_from())
|
||||
date_to=defaults.get("date_to", self._get_date_to())
|
||||
branch_id=defaults.get("branch_id")
|
||||
|
@ -100,6 +99,7 @@ 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
|
||||
|
@ -145,8 +145,16 @@ 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=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
|
||||
citems[citem.id]=qty
|
||||
#for state,vals in states.items():
|
||||
#print(state, vals)
|
||||
lines=[]
|
||||
dom=[]
|
||||
if branch_id:
|
||||
|
|
|
@ -248,9 +248,6 @@ def date2thai(date, format='%(BY)s-%(m)s-%(d)s', lang='th_TH'):
|
|||
, 'd': int(day) # XXX remove zero
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def htmlcolor(r, g, b):
|
||||
#ex: htmlcolor(250,0,0) => '#fa0000'
|
||||
def _chkarg(a):
|
||||
|
|
|
@ -14,17 +14,31 @@
|
|||
<tbody>
|
||||
{{#each lines }}
|
||||
<tr>
|
||||
<td>
|
||||
<th>
|
||||
{{name}}
|
||||
</td>
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
{{#each sub_lines}}
|
||||
<tr>
|
||||
<td style="text-align:right">{{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>
|
||||
{{view "link" string=qty action="clinic_hd_case" action_options=action_options}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
<tr>
|
||||
<th style="text-align:right">
|
||||
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>
|
||||
</th>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<th>Total</th>
|
||||
<th>รวม</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 total_hdcase}}</a>
|
||||
</th>
|
||||
|
|
Loading…
Reference in New Issue