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