fix compute labor cost
parent
bc73ddec5a
commit
1ae0f40d5c
|
@ -4,6 +4,7 @@
|
|||
<field name="date_to" required="1" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_branch" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
<field name="cycle_id" span="2"/>
|
||||
<field name="staff_type" onchange="onchange_type" span="2"/>
|
||||
<field name="staff_id" domain='[["type","=",staff_type]]' span="2"/>
|
||||
<field name="categ_id" domain='[["type","=","nurse"]]' span="2"/>
|
||||
|
|
|
@ -194,12 +194,13 @@ class LaborCost(Model):
|
|||
}))
|
||||
|
||||
if not obj.manual:
|
||||
var_pt=len(item.hd_cases)
|
||||
var_pt=len([hdcase for hdcase in item.hd_cases if hdcase.state in ("waiting_payment", "paid")])
|
||||
var_ptx=var_pt*(obj.var_k or 0)
|
||||
total_bstr=total_b < 0 and "+%s"%(abs(total_b)) or "-%s"%total_b
|
||||
var_x=0
|
||||
if total_a:
|
||||
var_x=eval('(%s%s)/%s'%(var_ptx,total_bstr,total_a))
|
||||
exp='(%s%s)/%s'%(var_ptx,total_bstr,total_a)
|
||||
var_x=eval(exp)
|
||||
for fline in formulars:
|
||||
vals=fline[1]
|
||||
fml=vals['formular'].replace("X","*%s")
|
||||
|
|
|
@ -19,6 +19,7 @@ class LaborCostLine(Model):
|
|||
'department_id': dpt.id,
|
||||
}
|
||||
return res
|
||||
|
||||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
|
|
|
@ -176,6 +176,7 @@ class ReportLaborCost(Model):
|
|||
'walkin_qty': 0,
|
||||
'department_id': department.id,
|
||||
'branch_id':department.branch_id.id,
|
||||
'cycle_id': cycle_id,
|
||||
}
|
||||
if staff.number=='walkin':
|
||||
ddata[dpt_name]['walkin_qty']+=qty
|
||||
|
@ -185,14 +186,16 @@ class ReportLaborCost(Model):
|
|||
if categ_name not in ctdata.keys():
|
||||
ctdata[categ_name]={
|
||||
'amount': 0,
|
||||
'cycle_id': cycle_id,
|
||||
'categ_id': categ.id,
|
||||
}
|
||||
ctdata[categ_name]['amount']+=line.pay_amount or 0
|
||||
ctdata[categ_name]['amount']+=line.amount or 0
|
||||
if dpt_name not in ndata.keys():
|
||||
ndata[dpt_name]={
|
||||
'hdcases': set(),
|
||||
'department_id': department.id,
|
||||
'branch_id': department.branch_id.id,
|
||||
'cycle_id': cycle_id,
|
||||
}
|
||||
for hdcase in citem.hd_cases:
|
||||
if hdcase.state in ('waiting_payment','paid'):
|
||||
|
@ -204,15 +207,19 @@ class ReportLaborCost(Model):
|
|||
total_amount+=amount
|
||||
ctlines.append({
|
||||
'name': categ_name,
|
||||
'amount': amount,
|
||||
'amount': round(amount,0),
|
||||
'branch_id': branch_id,
|
||||
'categ_id': categ_id,
|
||||
'department_id': department_id,
|
||||
'staff_type': 'nurse',
|
||||
'cycle_id': cycle_id,
|
||||
})
|
||||
ctlines.append({
|
||||
'name': 'รวม',
|
||||
'amount': total_amount,
|
||||
'amount': round(total_amount,0),
|
||||
'cycle_id': cycle_id,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
})
|
||||
for dt_name,vals in ddata.items():
|
||||
qty=vals['qty'] or 0
|
||||
|
@ -230,6 +237,7 @@ class ReportLaborCost(Model):
|
|||
'department_id': dpt_id,
|
||||
'branch_id': brch_id,
|
||||
'staff_type': 'doctor',
|
||||
'cycle_id': cycle_id,
|
||||
})
|
||||
dlines=[{
|
||||
'name': 'แพทย์',
|
||||
|
@ -248,9 +256,10 @@ class ReportLaborCost(Model):
|
|||
'qty2': 0,
|
||||
'total_qty':0,
|
||||
'cost': 0,
|
||||
'department_id': None,
|
||||
'branch_id':None,
|
||||
'staff_type': 'doctor',
|
||||
'cycle_id': cycle_id,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
})
|
||||
for dline in dlines[1:-1]:
|
||||
dlines[-1]['qty']+=dline['qty'] or 0
|
||||
|
@ -281,6 +290,7 @@ class ReportLaborCost(Model):
|
|||
'branch_id': brch_id,
|
||||
'total': 0,
|
||||
'staff_type': 'nurse',
|
||||
'cycle_id': cycle_id,
|
||||
})
|
||||
nlines=sorted(nlines, key=lambda x: x['name'])
|
||||
nlines.append({
|
||||
|
@ -288,9 +298,10 @@ class ReportLaborCost(Model):
|
|||
'qty': 0,
|
||||
'cost': 0,
|
||||
'total': 0,
|
||||
'department_id': None,
|
||||
'branch_id':None,
|
||||
'staff_type': 'nurse',
|
||||
'cycle_id': cycle_id,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
})
|
||||
for nline in nlines[1:-1]:
|
||||
nlines[-1]['qty']+=nline['qty'] or 0
|
||||
|
|
|
@ -18,6 +18,7 @@ class ReportLaborCostSummary(Model):
|
|||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'level_id': fields.Many2One("clinic.staff.level","Level"),
|
||||
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
|
||||
'categ_id': fields.Many2One("clinic.staff.categ","Category"),
|
||||
'only_value': fields.Boolean("Only Amount"),
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ class ReportLaborCostSummary(Model):
|
|||
date_to=defaults.get("date_to", self._get_date_to())
|
||||
branch_id=defaults.get("branch_id")
|
||||
categ_id=defaults.get("categ_id")
|
||||
cycle_id=defaults.get("cycle_id")
|
||||
if categ_id:
|
||||
categ_id=int(categ_id)
|
||||
if branch_id:
|
||||
|
@ -63,6 +65,7 @@ class ReportLaborCostSummary(Model):
|
|||
'only_value': True,
|
||||
'categ_id': categ_id,
|
||||
'level_id': level_id,
|
||||
'cycle_id': cycle_id,
|
||||
}
|
||||
print('res ', res)
|
||||
return res
|
||||
|
@ -78,6 +81,7 @@ class ReportLaborCostSummary(Model):
|
|||
branch_id=defaults['branch_id']
|
||||
categ_id=defaults['categ_id']
|
||||
level_id=defaults['level_id']
|
||||
cycle_id=defaults['cycle_id']
|
||||
dom=[]
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
|
@ -89,6 +93,7 @@ class ReportLaborCostSummary(Model):
|
|||
categ_id=obj.categ_id.id
|
||||
branch_id=obj.branch_id.id
|
||||
department_id=obj.department_id.id
|
||||
cycle_id=obj.cycle_id.id
|
||||
only_value=obj.only_value
|
||||
dom.append(['date','>=',date_from])
|
||||
dom.append(['date','<=',date_to])
|
||||
|
@ -104,6 +109,8 @@ class ReportLaborCostSummary(Model):
|
|||
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
|
||||
if cycle_id:
|
||||
dom.append(['labor_cost_id.cycle_item_id.cycle_id','=',cycle_id])
|
||||
staffs={}
|
||||
citems={}
|
||||
print('>> dom: ', dom)
|
||||
|
@ -114,7 +121,8 @@ class ReportLaborCostSummary(Model):
|
|||
dpt=citem.department_id
|
||||
qty=line.qty or 0 #XXX
|
||||
total_hdcase+=qty
|
||||
amt=line.pay_amount or 0 #XXX
|
||||
#amt=line.pay_amount or 0 #XXX
|
||||
amt=line.amount or 0 #XXX
|
||||
staff=line.staff_id
|
||||
categ_name=''
|
||||
categ_id=None
|
||||
|
@ -222,13 +230,14 @@ class ReportLaborCostSummary(Model):
|
|||
total_qty=0
|
||||
total_cost=0
|
||||
for tline in total_lines:
|
||||
tline['amt']=round(tline['amt'],0) or 0 #XXX
|
||||
amt=tline['amt'] or 0
|
||||
qty=tline['qty'] or 0
|
||||
total+=amt
|
||||
total_cost+=amt
|
||||
total_qty+=qty
|
||||
|
||||
total_lines.append({'amt': round(total,0)})
|
||||
total_lines.append({'amt': round(total,0)}) #XXX
|
||||
company_id=get_active_company()
|
||||
comp=get_model("company").browse(company_id)
|
||||
if staff_type!='doctor':
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<center>
|
||||
<h4>
|
||||
จาก {{date_from}} ถึง {{date_to}}
|
||||
|
||||
</h4>
|
||||
<br/>
|
||||
</center>
|
||||
{{#ifeq report_type "detail"}}
|
||||
<table class="table table-condensed table-striped">
|
||||
|
@ -36,14 +33,14 @@
|
|||
Subtotal
|
||||
</th>
|
||||
<th style="text-align:right">
|
||||
<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>
|
||||
<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}}&defaults.cycle_id={{cycle_id}}">{{currency qty}}</a>
|
||||
</th>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<td>{{name}}</td>
|
||||
<td style="text-align:right">
|
||||
<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>
|
||||
<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}}&defaults.cycle_id={{cycle_id}}">{{currency qty}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
@ -52,7 +49,7 @@
|
|||
<tfoot>
|
||||
<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>
|
||||
<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}}&defaults.cycle_id={{cycle_id}}">{{currency total_hdcase}}</a>
|
||||
</th>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
@ -102,7 +99,7 @@
|
|||
<th style="text-align:left;width:10%">{{cost}}</th>
|
||||
{{else}}
|
||||
<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}}&defaults.staff_type={{staff_type}}">{{currency cost}}</a>
|
||||
<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}}&defaults.staff_type={{staff_type}}&defaults.cycle_id={{cycle_id}}">{{currency cost}}</a>
|
||||
</td>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
@ -135,7 +132,7 @@
|
|||
<th>{{cost}}</th>
|
||||
{{else}}
|
||||
<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}}&defaults.staff_type={{staff_type}}">{{currency cost}}</a>
|
||||
<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}}&defaults.staff_type={{staff_type}}&defaults.cycle_id={{cycle_id}}">{{currency cost}}</a>
|
||||
</td>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
@ -148,7 +145,7 @@
|
|||
<tr>
|
||||
<th style="text-align:left;width:14%">{{name}}</th>
|
||||
<td style="text-align:right">
|
||||
<a href="#name=clinic_report_labor_cost_summary&defaults.categ_id={{categ_id}}&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.staff_type=nurse">{{currency amount}}</a>
|
||||
<a href="#name=clinic_report_labor_cost_summary&defaults.categ_id={{categ_id}}&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.staff_type=nurse&defaults.cycle_id={{cycle_id}}">{{currency amount}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
|
Loading…
Reference in New Issue