report labor cost
parent
39fa93e8da
commit
b7bf99819c
|
@ -10,6 +10,7 @@
|
||||||
<field name="qty" onchange="onchange_vals" help="Number of HD Case"/>
|
<field name="qty" onchange="onchange_vals" help="Number of HD Case"/>
|
||||||
<field name="rate" onchange="onchange_vals"/>
|
<field name="rate" onchange="onchange_vals"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
|
<field name="pay_amount"/>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Computation">
|
<tab string="Computation">
|
||||||
<field name="labor_cost_id"/>
|
<field name="labor_cost_id"/>
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
<field name="staff_id"/>
|
<field name="staff_id"/>
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
|
<field name="pay_amount"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -3,6 +3,5 @@
|
||||||
<field name="var_pt"/>
|
<field name="var_pt"/>
|
||||||
<field name="total_dcost"/>
|
<field name="total_dcost"/>
|
||||||
<field name="total_ncost"/>
|
<field name="total_ncost"/>
|
||||||
<!--<field name="total_stcost"/>-->
|
|
||||||
<field name="total"/>
|
<field name="total"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -75,7 +75,11 @@ class HDCase(Model):
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
set_active_user(1)
|
set_active_user(1)
|
||||||
reimbursable_ctx=context.get('reimbursable')
|
reimbursable_ctx=context.get('reimbursable')
|
||||||
|
no=0
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
|
if not obj.doctor_id:
|
||||||
|
print('obj.date ', obj.date)
|
||||||
|
no+=1
|
||||||
dlz_use=0
|
dlz_use=0
|
||||||
dlz_max=0
|
dlz_max=0
|
||||||
dlz_name=[]
|
dlz_name=[]
|
||||||
|
@ -153,6 +157,7 @@ class HDCase(Model):
|
||||||
'dlz_use': dlz_use,
|
'dlz_use': dlz_use,
|
||||||
'dlz_max': dlz_max,
|
'dlz_max': dlz_max,
|
||||||
}
|
}
|
||||||
|
print('no ', no)
|
||||||
set_active_user(user_id)
|
set_active_user(user_id)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ class LaborCost(Model):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"cycle_item_id": fields.Many2One("clinic.cycle.item","Cycle Item",required=True,search=True),
|
"cycle_item_id": fields.Many2One("clinic.cycle.item","Cycle Item",required=True),
|
||||||
'var_k': fields.Float("K"),
|
'var_k': fields.Float("K"),
|
||||||
'var_pt': fields.Integer("PT", function="_get_all",function_multi=True),
|
'var_pt': fields.Integer("PT", function="_get_all",function_multi=True),
|
||||||
'var_ptx': fields.Char("PT x K:", function="_get_all",function_multi=True),
|
'var_ptx': fields.Char("PT x K:", function="_get_all",function_multi=True),
|
||||||
|
@ -302,32 +302,45 @@ class LaborCost(Model):
|
||||||
cost_per_case=obj.cost_per_case or st.cost_per_case or 0
|
cost_per_case=obj.cost_per_case or st.cost_per_case or 0
|
||||||
staff_total={}
|
staff_total={}
|
||||||
dwalkin=None
|
dwalkin=None
|
||||||
for staff in get_model("clinic.staff").search_browse([['number','=','walkin']]):
|
for staff in get_model("clinic.staff").search_browse([['number','=','walkin'],['type','=','doctor']]):
|
||||||
dwalkin=staff
|
dwalkin=staff
|
||||||
for hd_case in item.hd_cases:
|
for hd_case in item.hd_cases:
|
||||||
if hd_case.state not in ('waiting_payment','paid'):
|
if hd_case.state not in ('waiting_payment','paid'):
|
||||||
continue
|
continue
|
||||||
staffs=hd_case.staffs
|
staffs=hd_case.staffs
|
||||||
for ps in staffs:
|
if not staffs and dwalkin:
|
||||||
staff=ps.staff_id or dwalkin
|
staff=dwalkin
|
||||||
if not staff:
|
staff_total[staff.id]={
|
||||||
continue
|
'base': 0,
|
||||||
base=staff.base
|
'type': staff.type,
|
||||||
if not base:
|
'categ_id': staff.categ_id.id,
|
||||||
base=cost_per_case
|
'level_id': staff.level_id.id,
|
||||||
if not staff_total.get(staff.id):
|
'qty': 0,
|
||||||
staff_total[staff.id]={
|
}
|
||||||
'base': 0,
|
base=cost_per_case
|
||||||
'type': staff.type,
|
|
||||||
'categ_id': staff.categ_id.id,
|
|
||||||
'level_id': staff.level_id.id,
|
|
||||||
'qty': 0,
|
|
||||||
}
|
|
||||||
if staff.type!='doctor':
|
|
||||||
base=0
|
|
||||||
staff_total[staff.id]['description']=hd_case.number
|
|
||||||
staff_total[staff.id]['base']=base
|
staff_total[staff.id]['base']=base
|
||||||
staff_total[staff.id]['qty']+=1
|
staff_total[staff.id]['qty']+=1
|
||||||
|
else:
|
||||||
|
for ps in staffs:
|
||||||
|
staff=ps.staff_id or dwalkin
|
||||||
|
if not staff:
|
||||||
|
continue
|
||||||
|
base=staff.base
|
||||||
|
if not base:
|
||||||
|
base=cost_per_case
|
||||||
|
if not staff_total.get(staff.id):
|
||||||
|
staff_total[staff.id]={
|
||||||
|
'base': 0,
|
||||||
|
'type': staff.type,
|
||||||
|
'categ_id': staff.categ_id.id,
|
||||||
|
'level_id': staff.level_id.id,
|
||||||
|
'qty': 0,
|
||||||
|
}
|
||||||
|
if staff.type!='doctor':
|
||||||
|
base=0
|
||||||
|
staff_total[staff.id]['description']=hd_case.number
|
||||||
|
staff_total[staff.id]['base']=base
|
||||||
|
staff_total[staff.id]['qty']+=1
|
||||||
|
|
||||||
for doctor_id, value in staff_total.items():
|
for doctor_id, value in staff_total.items():
|
||||||
base=value['base']
|
base=value['base']
|
||||||
|
|
|
@ -19,6 +19,13 @@ class LaborCostLine(Model):
|
||||||
'department_id': dpt.id,
|
'department_id': dpt.id,
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
def _get_all(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
res[obj.id]={
|
||||||
|
'pay_amount': round(obj.amount,0),
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"labor_cost_id": fields.Many2One("clinic.labor.cost","Labor Cost",required=True,on_delete="cascade"),
|
"labor_cost_id": fields.Many2One("clinic.labor.cost","Labor Cost",required=True,on_delete="cascade"),
|
||||||
|
@ -29,6 +36,7 @@ class LaborCostLine(Model):
|
||||||
'qty': fields.Integer("Qty"),
|
'qty': fields.Integer("Qty"),
|
||||||
'rate': fields.Float("Rate",scale=2),
|
'rate': fields.Float("Rate",scale=2),
|
||||||
'amount': fields.Float("Amount",scale=2),
|
'amount': fields.Float("Amount",scale=2),
|
||||||
|
'pay_amount': fields.Float("Pay Amount",function="_get_all",function_multi=True),
|
||||||
'date': fields.Date("Date",search=True),
|
'date': fields.Date("Date",search=True),
|
||||||
'description': fields.Char("Description"),
|
'description': fields.Char("Description"),
|
||||||
'company_id': fields.Many2One('company','Company'),
|
'company_id': fields.Many2One('company','Company'),
|
||||||
|
|
|
@ -94,7 +94,6 @@ class ReportLaborCost(Model):
|
||||||
dom=[]
|
dom=[]
|
||||||
dom.append(["date",">=",date_from])
|
dom.append(["date",">=",date_from])
|
||||||
dom.append(["date","<=",date_to])
|
dom.append(["date","<=",date_to])
|
||||||
total_hdcase=0
|
|
||||||
for dpt_id, vals in hdcases.items():
|
for dpt_id, vals in hdcases.items():
|
||||||
sub_lines=[]
|
sub_lines=[]
|
||||||
dom2=[['department_id','=',dpt_id]]
|
dom2=[['department_id','=',dpt_id]]
|
||||||
|
@ -104,7 +103,6 @@ class ReportLaborCost(Model):
|
||||||
dom3=[['state','=',state]] # last domain
|
dom3=[['state','=',state]] # last domain
|
||||||
if state in ('waiting_payment','paid'):
|
if state in ('waiting_payment','paid'):
|
||||||
ok=True
|
ok=True
|
||||||
total_hdcase+=qty
|
|
||||||
dom4=dom+dom2+dom3
|
dom4=dom+dom2+dom3
|
||||||
state=dstates[state]
|
state=dstates[state]
|
||||||
sub_lines.append({
|
sub_lines.append({
|
||||||
|
@ -127,6 +125,10 @@ class ReportLaborCost(Model):
|
||||||
elif branch_id:
|
elif branch_id:
|
||||||
branch=get_model("clinic.branch").browse(branch_id)
|
branch=get_model("clinic.branch").browse(branch_id)
|
||||||
sub_name="(%s)" % branch.name or ""
|
sub_name="(%s)" % branch.name or ""
|
||||||
|
total_hdcase=0
|
||||||
|
for line in lines:
|
||||||
|
qty=line['qty'] or 0
|
||||||
|
total_hdcase+=qty
|
||||||
data={
|
data={
|
||||||
'company_name': '%s %s' % (company.name or "", sub_name),
|
'company_name': '%s %s' % (company.name or "", sub_name),
|
||||||
'date': date,
|
'date': date,
|
||||||
|
|
|
@ -89,7 +89,7 @@ class ReportLaborCostDetail(Model):
|
||||||
if not date:
|
if not date:
|
||||||
continue
|
continue
|
||||||
dpt=citem.department_id
|
dpt=citem.department_id
|
||||||
amt=line.amount or 0
|
amt=line.pay_amount or 0 #XXX
|
||||||
staff=line.staff_id
|
staff=line.staff_id
|
||||||
qty=0
|
qty=0
|
||||||
if staff.type=='doctor':
|
if staff.type=='doctor':
|
||||||
|
|
|
@ -99,13 +99,14 @@ class ReportLaborCostSummary(Model):
|
||||||
citems={}
|
citems={}
|
||||||
print('dom ', dom)
|
print('dom ', dom)
|
||||||
total_hdcase=0
|
total_hdcase=0
|
||||||
|
x=set()
|
||||||
for line in get_model("clinic.labor.cost.line").search_browse(dom):
|
for line in get_model("clinic.labor.cost.line").search_browse(dom):
|
||||||
lcost=line.labor_cost_id
|
lcost=line.labor_cost_id
|
||||||
citem=lcost.cycle_item_id
|
citem=lcost.cycle_item_id
|
||||||
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.amount or 0
|
amt=line.pay_amount or 0 #XXX
|
||||||
staff=line.staff_id
|
staff=line.staff_id
|
||||||
categ_name=''
|
categ_name=''
|
||||||
categ_id=None
|
categ_id=None
|
||||||
|
@ -145,7 +146,10 @@ class ReportLaborCostSummary(Model):
|
||||||
staffs[staff.name][dpt.name]['qty']+=qty
|
staffs[staff.name][dpt.name]['qty']+=qty
|
||||||
|
|
||||||
if not citems.get(citem.id):
|
if not citems.get(citem.id):
|
||||||
qty=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('waiting_payment', 'paid')])
|
qty=0
|
||||||
|
for hdcase in citem.hd_cases:
|
||||||
|
if hdcase.state in ('waiting_payment', 'paid'):
|
||||||
|
qty+=1
|
||||||
citems[citem.id]=qty
|
citems[citem.id]=qty
|
||||||
lines=[]
|
lines=[]
|
||||||
dom=[]
|
dom=[]
|
||||||
|
|
Loading…
Reference in New Issue