report labor cost

conv_bal
watcha.h@almacom.co.th 2015-04-07 13:14:25 +07:00
parent 39fa93e8da
commit b7bf99819c
9 changed files with 59 additions and 26 deletions

View File

@ -10,6 +10,7 @@
<field name="qty" onchange="onchange_vals" help="Number of HD Case"/>
<field name="rate" onchange="onchange_vals"/>
<field name="amount"/>
<field name="pay_amount"/>
</tab>
<tab string="Computation">
<field name="labor_cost_id"/>

View File

@ -4,4 +4,5 @@
<field name="staff_id"/>
<field name="type"/>
<field name="amount"/>
<field name="pay_amount"/>
</list>

View File

@ -3,6 +3,5 @@
<field name="var_pt"/>
<field name="total_dcost"/>
<field name="total_ncost"/>
<!--<field name="total_stcost"/>-->
<field name="total"/>
</list>

View File

@ -75,7 +75,11 @@ class HDCase(Model):
user_id=get_active_user()
set_active_user(1)
reimbursable_ctx=context.get('reimbursable')
no=0
for obj in self.browse(ids):
if not obj.doctor_id:
print('obj.date ', obj.date)
no+=1
dlz_use=0
dlz_max=0
dlz_name=[]
@ -153,6 +157,7 @@ class HDCase(Model):
'dlz_use': dlz_use,
'dlz_max': dlz_max,
}
print('no ', no)
set_active_user(user_id)
return res

View File

@ -80,7 +80,7 @@ class LaborCost(Model):
return res
_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_pt': fields.Integer("PT", 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
staff_total={}
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
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
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
if not staffs and dwalkin:
staff=dwalkin
staff_total[staff.id]={
'base': 0,
'type': staff.type,
'categ_id': staff.categ_id.id,
'level_id': staff.level_id.id,
'qty': 0,
}
base=cost_per_case
staff_total[staff.id]['base']=base
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():
base=value['base']

View File

@ -19,6 +19,13 @@ class LaborCostLine(Model):
'department_id': dpt.id,
}
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={
"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"),
'rate': fields.Float("Rate",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),
'description': fields.Char("Description"),
'company_id': fields.Many2One('company','Company'),

View File

@ -94,7 +94,6 @@ class ReportLaborCost(Model):
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]]
@ -104,7 +103,6 @@ class ReportLaborCost(Model):
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({
@ -127,6 +125,10 @@ class ReportLaborCost(Model):
elif branch_id:
branch=get_model("clinic.branch").browse(branch_id)
sub_name="(%s)" % branch.name or ""
total_hdcase=0
for line in lines:
qty=line['qty'] or 0
total_hdcase+=qty
data={
'company_name': '%s %s' % (company.name or "", sub_name),
'date': date,

View File

@ -89,7 +89,7 @@ class ReportLaborCostDetail(Model):
if not date:
continue
dpt=citem.department_id
amt=line.amount or 0
amt=line.pay_amount or 0 #XXX
staff=line.staff_id
qty=0
if staff.type=='doctor':

View File

@ -99,13 +99,14 @@ class ReportLaborCostSummary(Model):
citems={}
print('dom ', dom)
total_hdcase=0
x=set()
for line in get_model("clinic.labor.cost.line").search_browse(dom):
lcost=line.labor_cost_id
citem=lcost.cycle_item_id
dpt=citem.department_id
qty=line.qty or 0 #XXX
total_hdcase+=qty
amt=line.amount or 0
amt=line.pay_amount or 0 #XXX
staff=line.staff_id
categ_name=''
categ_id=None
@ -145,7 +146,10 @@ 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 ('waiting_payment', 'paid')])
qty=0
for hdcase in citem.hd_cases:
if hdcase.state in ('waiting_payment', 'paid'):
qty+=1
citems[citem.id]=qty
lines=[]
dom=[]