fix account report
parent
b79cfd015e
commit
5091739cec
|
@ -110,27 +110,28 @@ class ReportAccountHDCaseSummary(Model):
|
||||||
records={}
|
records={}
|
||||||
cycles={}
|
cycles={}
|
||||||
context['reimbursable']=reimbursable
|
context['reimbursable']=reimbursable
|
||||||
|
categ_prods=[]
|
||||||
|
for cat_prod in get_model("product.categ").search_read([],['code']):
|
||||||
|
code=(cat_prod['code'] or "").lower()
|
||||||
|
categ_prods.append(code)
|
||||||
for line in get_model("clinic.hd.case.line").search_browse(dom,context=context):
|
for line in get_model("clinic.hd.case.line").search_browse(dom,context=context):
|
||||||
hdcase=line.hd_case_id
|
hdcase=line.hd_case_id
|
||||||
items={}
|
pm_numbers=[]
|
||||||
amt=line.amount or 0
|
pm_id=None
|
||||||
categ=line.product_categ_id
|
for pm in hdcase.payments:
|
||||||
code=(categ.code or "").lower()
|
if pm.number:
|
||||||
if not code in items.keys():
|
pm_numbers.append(pm.number)
|
||||||
items[code]=[]
|
pm_id=pm.id #XXX
|
||||||
items[code].append({
|
pm_number=','.join([pnum for pnum in pm_numbers])
|
||||||
'amount': amt,
|
|
||||||
})
|
|
||||||
pm_number=','.join([pm.number for pm in hdcase.payments if pm.number])
|
|
||||||
prods={
|
prods={
|
||||||
'yes': [],
|
'yes': [],
|
||||||
'no': [],
|
'no': [],
|
||||||
'': [],
|
'': [],
|
||||||
}
|
}
|
||||||
#get the right invoice
|
#get the right invoice
|
||||||
for line in hdcase.lines:
|
for hline in hdcase.lines:
|
||||||
prod=line.product_id
|
prod=hline.product_id
|
||||||
reim=line.reimbursable
|
reim=hline.reimbursable
|
||||||
if prod:
|
if prod:
|
||||||
prods[reim].append(prod.id)
|
prods[reim].append(prod.id)
|
||||||
inv_number=""
|
inv_number=""
|
||||||
|
@ -138,8 +139,8 @@ class ReportAccountHDCaseSummary(Model):
|
||||||
inv_id=None
|
inv_id=None
|
||||||
for inv in hdcase.invoices:
|
for inv in hdcase.invoices:
|
||||||
inv_prods=[]
|
inv_prods=[]
|
||||||
for line in inv.lines:
|
for inv_line in inv.lines:
|
||||||
prod=line.product_id
|
prod=inv_line.product_id
|
||||||
if prod:
|
if prod:
|
||||||
if prod.id in prods[reimbursable]:
|
if prod.id in prods[reimbursable]:
|
||||||
inv_prods.append(prod.id)
|
inv_prods.append(prod.id)
|
||||||
|
@ -158,15 +159,15 @@ class ReportAccountHDCaseSummary(Model):
|
||||||
cycle_item=hdcase.cycle_item_id
|
cycle_item=hdcase.cycle_item_id
|
||||||
if cycle.id not in cycles.keys():
|
if cycle.id not in cycles.keys():
|
||||||
cycles[cycle.id]=[]
|
cycles[cycle.id]=[]
|
||||||
for line in cycle_item.lines:
|
for cline in cycle_item.lines:
|
||||||
nurse=line.nurse_id
|
nurse=cline.nurse_id
|
||||||
cycles[cycle.id].append(nurse.name)
|
cycles[cycle.id].append(nurse.name)
|
||||||
vals={
|
vals={
|
||||||
'hdcase_id': hdcase.id,
|
'hdcase_id': hdcase.id,
|
||||||
'number': hdcase.number or "",
|
'number': hdcase.number or "",
|
||||||
'date': hdcase.date,
|
'date': hdcase.date,
|
||||||
'hct': hdcase.hct or 0,
|
'hct': hdcase.hct or 0,
|
||||||
'epo_name': hdcase.epo or 0,
|
'epo_name': hdcase.epo or "",
|
||||||
'ptype': ptype.name or "",
|
'ptype': ptype.name or "",
|
||||||
'ptype_color': ptype.color or "default",
|
'ptype_color': ptype.color or "default",
|
||||||
'dname': hdcase.doctor_id.name or "",
|
'dname': hdcase.doctor_id.name or "",
|
||||||
|
@ -177,39 +178,43 @@ class ReportAccountHDCaseSummary(Model):
|
||||||
'idcard': patient.card_no or "",
|
'idcard': patient.card_no or "",
|
||||||
'cseq': cycle.sequence or 0,
|
'cseq': cycle.sequence or 0,
|
||||||
'cycle_item_id': cycle_item.id,
|
'cycle_item_id': cycle_item.id,
|
||||||
'pm_number': pm_number and pm_number or "-",
|
'pm_number': pm_number and pm_number or "",
|
||||||
'inv_number': inv_number and inv_number or "-",
|
'pm_id': pm_id,
|
||||||
|
'inv_number': inv_number and inv_number or "",
|
||||||
'inv_id': inv_id,
|
'inv_id': inv_id,
|
||||||
'mdc': hdcase.mdc,
|
|
||||||
'mdc_name': hdcase.mdc_name,
|
'mdc_name': hdcase.mdc_name,
|
||||||
'dlz_name': hdcase.dlz_name,
|
'dlz_name': hdcase.dlz_name,
|
||||||
'dlz_id': hdcase.dlz_id and hdcase.dlz_id or 0,
|
'dlz_id': hdcase.dlz_id and hdcase.dlz_id or 0,
|
||||||
'dlz_price': hdcase.dlz_price,
|
'inv_ref': inv_ref and inv_ref or "",
|
||||||
'lab': hdcase.lab,
|
'pick_ref': pick_ref and pick_ref or "",
|
||||||
'misc': hdcase.misc,
|
|
||||||
'inv_ref': inv_ref and inv_ref or "-",
|
|
||||||
'pick_ref': pick_ref and pick_ref or "-",
|
|
||||||
'pick_id': pick_id,
|
'pick_id': pick_id,
|
||||||
}
|
}
|
||||||
for code, item in items.items():
|
|
||||||
vals.update({
|
|
||||||
code: sum([t['amount'] for t in item])
|
|
||||||
})
|
|
||||||
# merge 1 line of number
|
# merge 1 line of number
|
||||||
number=vals['number']
|
hdcase_id=vals['hdcase_id']
|
||||||
if number not in records.keys():
|
if not records.get(hdcase_id):
|
||||||
records[number]=vals
|
for categ_prod in categ_prods:
|
||||||
#FIXME please check
|
vals[categ_prod]=0
|
||||||
#else:
|
vals['misc']=0
|
||||||
#for code, item in items.items():
|
records[hdcase_id]=vals
|
||||||
#if vals.get(code):
|
amt=line.amount or 0
|
||||||
#if not records[number].get(code):
|
categ=line.product_categ_id
|
||||||
#records[number][code]=0
|
if categ:
|
||||||
#records[number][code]+=vals[code]
|
code=(categ.code or "").lower()
|
||||||
#records[number]['lab']+=vals['lab']
|
if code:
|
||||||
#records[number]['misc']+=vals['misc']
|
code=code.replace("epo","mdc") #XXX
|
||||||
|
records[hdcase_id][code]+=amt
|
||||||
|
else:
|
||||||
|
if categ.parent_id:
|
||||||
|
code=categ.parent_id.code or ''
|
||||||
|
if code:
|
||||||
|
code=code.lower()
|
||||||
|
records[hdcase_id][code]+=amt
|
||||||
|
else:
|
||||||
|
records[hdcase_id]['misc']+=amt
|
||||||
|
else:
|
||||||
|
records[hdcase_id]['misc']+=amt
|
||||||
lines=[]
|
lines=[]
|
||||||
for hdnumber, vals in records.items():
|
for hdcase_id, vals in records.items():
|
||||||
lines.append(vals)
|
lines.append(vals)
|
||||||
company_name=company.name or ""
|
company_name=company.name or ""
|
||||||
if department_id:
|
if department_id:
|
||||||
|
|
Binary file not shown.
|
@ -79,9 +79,15 @@
|
||||||
<td style="width:20%">{{hn}}</td>
|
<td style="width:20%">{{hn}}</td>
|
||||||
<td style="width:20%">{{idcard}}</td>
|
<td style="width:20%">{{idcard}}</td>
|
||||||
<td>{{ptype}}</td>
|
<td>{{ptype}}</td>
|
||||||
<td>{{pm_number}}</td>
|
|
||||||
<td>
|
<td>
|
||||||
|
{{#if pm_id}}
|
||||||
|
{{view "link" string=pm_number action="payment" action_options="mode=form" active_id=pm_id}}
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{#if inv_id}}
|
||||||
{{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
|
{{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
|
||||||
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td>{{mdc_name}}</td>
|
<td>{{mdc_name}}</td>
|
||||||
<td>{{currency fee zero=""}}</td>
|
<td>{{currency fee zero=""}}</td>
|
||||||
|
@ -90,13 +96,13 @@
|
||||||
<td>{{currency misc zero=""}}</td>
|
<td>{{currency misc zero=""}}</td>
|
||||||
<td>{{currency dlz_price zero=""}}</td>
|
<td>{{currency dlz_price zero=""}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
{{#if inv_id}}
|
||||||
{{view "link" string=inv_ref action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
|
{{view "link" string=inv_ref action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
|
||||||
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{#if pick_id}}
|
{{#if pick_id}}
|
||||||
{{view "link" string=pick_ref action="pick_out" action_options="mode=form" active_id=pick_id}}
|
{{view "link" string=pick_ref action="pick_out" action_options="mode=form" active_id=pick_id}}
|
||||||
{{else}}
|
|
||||||
-
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
Loading…
Reference in New Issue