improve account report (claim/no claim)
parent
72b440b69c
commit
c5205f35c2
|
@ -3,6 +3,7 @@
|
|||
<field name="date_from" onchange="onchange_datefrom" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="cycle_id" span="2"/>
|
||||
<field name="ptype_id" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_type" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
<group span="6" columns="1">
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
<separator string="Clinic"/>
|
||||
<field name="department_profile_id"/>
|
||||
<field name="old_profile_id"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="auto_load_dpt"/>
|
||||
<!--<field name="branch_id"/>-->
|
||||
<!--<field name="department_id"/>-->
|
||||
<field name="select_branch"/>
|
||||
</field>
|
||||
</inherit>
|
||||
|
|
|
@ -8,6 +8,10 @@ class User(Model):
|
|||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'old_profile_id': fields.Many2One('profile', "Old Profile"),
|
||||
'select_branch': fields.Boolean("Can Change Branch"),
|
||||
'auto_load_dpt': fields.Boolean("Auto Load Branch & Department"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'auto_load_dpt': True,
|
||||
}
|
||||
|
||||
User.register()
|
||||
|
|
|
@ -75,7 +75,6 @@ class HDCase(Model):
|
|||
user_id=get_active_user()
|
||||
set_active_user(1)
|
||||
reimbursable_ctx=context.get('reimbursable')
|
||||
print('reimbursable_ctx ', reimbursable_ctx)
|
||||
for obj in self.browse(ids):
|
||||
dlz_use=0
|
||||
dlz_max=0
|
||||
|
@ -92,40 +91,43 @@ class HDCase(Model):
|
|||
dlz_use+=dlz.use_time or 0
|
||||
dlz_max+=dlz.max_use_time or 0
|
||||
dlz_name=','.join([dlz for dlz in dlz_name])
|
||||
names=[]
|
||||
epo_names=[]
|
||||
mdc_names=[]
|
||||
fee=0
|
||||
lab=0
|
||||
misc=0
|
||||
dlz_price=0
|
||||
#sign=1
|
||||
#if obj.state=='waiting_payment':
|
||||
#sign=-1
|
||||
for dline in obj.dialyzers:
|
||||
dlz=dline.dialyzer_id
|
||||
prod=dlz.product_id
|
||||
if prod:
|
||||
dlz_price+=prod.sale_price or 0
|
||||
|
||||
mdc=0
|
||||
for line in obj.lines:
|
||||
amt=line.amount or 0
|
||||
prod=line.product_id
|
||||
categ=line.product_categ_id
|
||||
if categ and prod:
|
||||
#if categ and prod and line.reimbursable=='yes':
|
||||
sign=1
|
||||
if line.reimbursable=='yes':
|
||||
sign=-1
|
||||
if categ.parent_id:
|
||||
if categ.parent_id.code=='MDC':
|
||||
name=prod.name or ""
|
||||
name=name.split("-")
|
||||
name=name[0].title()
|
||||
if reimbursable_ctx:
|
||||
if reimbursable_ctx==line.reimbursable:
|
||||
mdc+=amt
|
||||
mdc_names.append(name or "")
|
||||
else:
|
||||
mdc+=amt
|
||||
mdc_names.append(name or "")
|
||||
if categ.code=='EPO':
|
||||
name=prod.name or ""
|
||||
name=name.split("-")
|
||||
if name:
|
||||
name=name[0].title()
|
||||
names.append(name)
|
||||
epo_names.append(name)
|
||||
elif categ.code=='FEE':
|
||||
fee+=amt*sign
|
||||
elif categ.code=='DLZ':
|
||||
if prod:
|
||||
dlz_price+=prod.sale_price or 0
|
||||
dlz_price+=amt
|
||||
elif categ.code=="LAB":
|
||||
if reimbursable_ctx:
|
||||
if reimbursable_ctx==line.reimbursable:
|
||||
|
@ -139,10 +141,12 @@ class HDCase(Model):
|
|||
else:
|
||||
misc+=amt
|
||||
res[obj.id]={
|
||||
'epo': ','.join([n for n in names]),
|
||||
'epo': ','.join([n for n in epo_names]),
|
||||
'fee': fee,
|
||||
'lab': lab,
|
||||
'misc': misc,
|
||||
'mdc': mdc,
|
||||
'mdc_name': ','.join([n for n in mdc_names]),
|
||||
'dlz_id': dlz_id,
|
||||
'dlz_price': dlz_price,
|
||||
'dlz_name': dlz_name,
|
||||
|
@ -196,7 +200,9 @@ class HDCase(Model):
|
|||
"dlz_price": fields.Float("DZ",function="_get_expense",function_multi=True),
|
||||
"dlz_use": fields.Float("DZ Use",function="_get_expense",function_multi=True),
|
||||
"dlz_max": fields.Float("DZ Max",function="_get_expense",function_multi=True),
|
||||
"dlz_id": fields.Float("DZ ID",function="_get_expense",function_multi=True),
|
||||
"dlz_id": fields.Integer("DZ ID",function="_get_expense",function_multi=True),
|
||||
"mdc": fields.Float("MDC",function="_get_expense",function_multi=True),
|
||||
"mdc_name": fields.Float("MDC Name",function="_get_expense",function_multi=True),
|
||||
'sickbed_id': fields.Many2One("clinic.sickbed",'Sickbed'),
|
||||
"ref": fields.Char("Ref",search=True),
|
||||
"time_start": fields.DateTime("Start Time",required=True),
|
||||
|
|
|
@ -83,7 +83,7 @@ class ReportAccountHDCaseSummary(Model):
|
|||
date_to=obj.date_to
|
||||
ptype_id=obj.ptype_id.id
|
||||
cycle_id=obj.cycle_id.id
|
||||
reimbursable=obj.reimbursable
|
||||
reimbursable=obj.reimbursable or ""
|
||||
product_id=obj.product_id.id
|
||||
dom=[
|
||||
['hd_case_id.date','>=', date_from],
|
||||
|
@ -109,9 +109,6 @@ class ReportAccountHDCaseSummary(Model):
|
|||
for line in get_model("clinic.hd.case.line").search_browse(dom,context=context):
|
||||
hdcase=line.hd_case_id
|
||||
items={}
|
||||
mdc_name=(hdcase.epo or "").split("-")
|
||||
if mdc_name:
|
||||
mdc_name=mdc_name[0].title()
|
||||
amt=line.amount or 0
|
||||
categ=line.product_categ_id
|
||||
code=(categ.code or "").lower()
|
||||
|
@ -121,13 +118,31 @@ class ReportAccountHDCaseSummary(Model):
|
|||
'amount': amt,
|
||||
})
|
||||
pm_number=','.join([pm.number for pm in hdcase.payments if pm.number])
|
||||
prods={
|
||||
'yes': [],
|
||||
'no': [],
|
||||
'': [],
|
||||
}
|
||||
#get the right invoice
|
||||
for line in hdcase.lines:
|
||||
prod=line.product_id
|
||||
reim=line.reimbursable
|
||||
if prod:
|
||||
prods[reim].append(prod.id)
|
||||
inv_number=""
|
||||
inv_ref=""
|
||||
inv_id=None
|
||||
for inv in hdcase.invoices:
|
||||
inv_number+=inv.number or ""
|
||||
inv_ref+=inv.ref or ""
|
||||
inv_id=inv.id
|
||||
inv_prods=[]
|
||||
for line in inv.lines:
|
||||
prod=line.product_id
|
||||
if prod:
|
||||
if prod.id in prods[reimbursable]:
|
||||
inv_prods.append(prod.id)
|
||||
if prods[reimbursable]==inv_prods:
|
||||
inv_number+=inv.number or ""
|
||||
inv_ref+=inv.ref or ""
|
||||
inv_id=inv.id
|
||||
pick_ref=""
|
||||
pick_id=None
|
||||
for pick in hdcase.pickings:
|
||||
|
@ -161,9 +176,10 @@ class ReportAccountHDCaseSummary(Model):
|
|||
'pm_number': pm_number and pm_number or "-",
|
||||
'inv_number': inv_number and inv_number or "-",
|
||||
'inv_id': inv_id,
|
||||
'mdc_name': mdc_name,
|
||||
'mdc': hdcase.mdc,
|
||||
'mdc_name': hdcase.mdc_name,
|
||||
'dlz_name': hdcase.dlz_name,
|
||||
'dlz_id': hdcase.dlz_id.id,
|
||||
'dlz_id': hdcase.dlz_id and hdcase.dlz_id or 0,
|
||||
'dlz_price': hdcase.dlz_price or 0,
|
||||
'lab': hdcase.lab,
|
||||
'misc': hdcase.misc,
|
||||
|
|
|
@ -16,6 +16,7 @@ class ReportCycleItem(Model):
|
|||
"date_from": fields.Date("From", required=True),
|
||||
"date_to": fields.Date("To", required=True),
|
||||
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
||||
"ptype_id": fields.Many2One("clinic.patient.type","Patient Type"),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
}
|
||||
|
@ -27,6 +28,7 @@ class ReportCycleItem(Model):
|
|||
date_from=defaults.get('date_from','%s-%s-01'%(year,month))
|
||||
date_to=defaults.get('date_to','%s-%s-01'%(year,month))
|
||||
branch_id=defaults.get('branch_id')
|
||||
ptype_id=defaults.get('ptype_id')
|
||||
department_id=defaults.get('department_id')
|
||||
res=get_model('select.company').get_select()
|
||||
if res:
|
||||
|
@ -55,6 +57,7 @@ class ReportCycleItem(Model):
|
|||
date_to=defaults.get("date_to")
|
||||
branch_id=defaults.get("branch_id")
|
||||
department_id=defaults.get("department_id")
|
||||
ptype_id=defaults.get("ptype_id")
|
||||
month=date_from.split("-")[1]
|
||||
cycle_id=None
|
||||
if ids:
|
||||
|
@ -65,6 +68,7 @@ class ReportCycleItem(Model):
|
|||
branch_id=obj.branch_id.id
|
||||
department_id=obj.department_id.id
|
||||
cycle_id=obj.cycle_id.id
|
||||
ptype_id=obj.ptype_id.id
|
||||
# new patient of this month
|
||||
dom=[]
|
||||
dom.append(['date','>=',date_from])
|
||||
|
@ -88,6 +92,8 @@ class ReportCycleItem(Model):
|
|||
for hdcase in citem.hd_cases:
|
||||
patient=hdcase.patient_id
|
||||
ptype=patient.type_id
|
||||
if ptype_id and ptype_id!=ptype.id:
|
||||
continue
|
||||
doctor=hdcase.doctor_id
|
||||
cycle=hdcase.cycle_id
|
||||
dpt=hdcase.department_id
|
||||
|
@ -109,7 +115,9 @@ class ReportCycleItem(Model):
|
|||
'dname': doctor.name or "",
|
||||
'date': hdcase.date,
|
||||
'epo': hdcase.epo,
|
||||
'fee': abs(hdcase.fee), #XXX
|
||||
'mdc': hdcase.mdc,
|
||||
'mdc_name': hdcase.mdc_name,
|
||||
'fee': abs(hdcase.fee),
|
||||
'dlz_name': hdcase.dlz_name,
|
||||
'dlz_use': dlz_use,
|
||||
'dlz_id': hdcase.dlz_id,
|
||||
|
@ -138,8 +146,10 @@ class ReportCycleItem(Model):
|
|||
index=0
|
||||
old=[]
|
||||
total_fee=0
|
||||
total_mdc=0
|
||||
for line in sorted(lines,key=lambda x:(x['date'],x['cseq'])):
|
||||
total_fee+=line.get("fee",0)
|
||||
total_mdc+=line.get("mdc",0)
|
||||
cid=line['cid']
|
||||
if not cid in old:
|
||||
old.append(cid)
|
||||
|
@ -160,6 +170,7 @@ class ReportCycleItem(Model):
|
|||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
'total_fee': total_fee,
|
||||
'total_mdc': total_mdc,
|
||||
}
|
||||
return data
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ class SelectCompany(Model):
|
|||
'branch_id': branch.id,
|
||||
})
|
||||
else:
|
||||
print("xxx ")
|
||||
user.write({
|
||||
'branch_id': None,
|
||||
})
|
||||
|
@ -215,25 +216,27 @@ class SelectCompany(Model):
|
|||
department_id=None
|
||||
branch_id=None
|
||||
user=get_model("base.user").browse(user_id)
|
||||
auto_load_dpt=user.auto_load_dpt or False
|
||||
dpt=user.department_id
|
||||
res={
|
||||
'department_id': None,
|
||||
'branch_id': None,
|
||||
}
|
||||
if not dpt:
|
||||
dpts=user.department_profile_id.departments
|
||||
if dpts:
|
||||
res={
|
||||
'department_ids': [dpt.id for dpt in dpts],
|
||||
'branch_id': dpts[0].branch_id.id, #XXX
|
||||
}
|
||||
else:
|
||||
department_id=dpt.id
|
||||
branch_id=dpt.branch_id.id
|
||||
res={
|
||||
'department_id': department_id,
|
||||
'branch_id': branch_id,
|
||||
}
|
||||
if auto_load_dpt:
|
||||
if not dpt:
|
||||
dpts=user.department_profile_id.departments
|
||||
if dpts:
|
||||
res.update({
|
||||
'department_ids': [dpt.id for dpt in dpts],
|
||||
'branch_id': dpts[0].branch_id.id, #XXX
|
||||
})
|
||||
else:
|
||||
department_id=dpt.id
|
||||
branch_id=dpt.branch_id.id
|
||||
res.update({
|
||||
'department_id': department_id,
|
||||
'branch_id': branch_id,
|
||||
})
|
||||
return res
|
||||
|
||||
SelectCompany.register()
|
||||
|
|
|
@ -83,9 +83,9 @@
|
|||
<td>
|
||||
{{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
|
||||
</td>
|
||||
<td>{{epo_name}}</td>
|
||||
<td>{{mdc_name}}</td>
|
||||
<td>{{currency fee zero=""}}</td>
|
||||
<td>{{currency epo zero=""}}</td>
|
||||
<td>{{currency mdc zero=""}}</td>
|
||||
<td>{{currency lab zero=""}}</td>
|
||||
<td>{{currency misc zero=""}}</td>
|
||||
<td>{{currency dlz_price zero=""}}</td>
|
||||
|
@ -110,13 +110,18 @@
|
|||
<td style="width:20%">{{idcard}}</td>
|
||||
<td>{{ptype}}</td>
|
||||
<td>{{hct}}</td>
|
||||
<td>{{epo_name}}</td>
|
||||
<td>{{mdc_name}}</td>
|
||||
<td>{{currency fee zero=""}}</td>
|
||||
<td>{{currency epo zero=""}}</td>
|
||||
<td>{{currency mdc zero=""}}</td>
|
||||
<td>{{currency srv zero=""}}</td>
|
||||
<td>
|
||||
{{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
|
||||
</td>
|
||||
{{#if inv_id}}
|
||||
<td>
|
||||
{{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
|
||||
</td>
|
||||
{{else}}
|
||||
<td>
|
||||
</td>
|
||||
{{/if}}
|
||||
<td>
|
||||
{{#if pick_id}}
|
||||
{{view "link" string=pick_ref action="pick_out" action_options="mode=form" active_id=pick_id}}
|
||||
|
@ -145,7 +150,7 @@
|
|||
<th></th>
|
||||
<th></th>
|
||||
<th>{{currency total_fee zero=""}}</th>
|
||||
<th>{{currency total_epo zero=""}}</th>
|
||||
<th>{{currency total_mdc zero=""}}</th>
|
||||
<th>{{currency total_lab zero=""}}</th>
|
||||
<th>{{currency total_misc zero=""}}</th>
|
||||
<th>{{currency total_dlz zero=""}}</th>
|
||||
|
@ -161,7 +166,7 @@
|
|||
<th></th>
|
||||
<th></th>
|
||||
<th>{{currency total_fee zero=""}}</th>
|
||||
<th>{{currency total_epo zero=""}}</th>
|
||||
<th>{{currency total_mdc zero=""}}</th>
|
||||
<th>{{currency total_srv zero=""}}</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<td><a href="/ui#name=clinic_staff&active_id={{did}}&mode=form">{{dname}}</a></td>
|
||||
<td><a href="/ui#name=clinic_patient_type&active_id={{tid}}&mode=form">{{tname}}</a></td>
|
||||
<td style="text-align:right">{{fee}}</td>
|
||||
<td>{{epo}}</td>
|
||||
<td>{{mdc}}</td>
|
||||
<td><a href="/ui#name=clinic_dialyzer&active_id={{dlz_id}}&mode=form">{{dlz_name}}</a></td>
|
||||
<td>{{dlz_use}}</td>
|
||||
<td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">View</a></td>
|
||||
|
|
Loading…
Reference in New Issue