diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py index 5070ac0..48731d7 100644 --- a/netforce_clinic/models/report_account_hd_case_summary.py +++ b/netforce_clinic/models/report_account_hd_case_summary.py @@ -180,7 +180,7 @@ class ReportAccountHDCaseSummary(Model): 'mdc_name': hdcase.mdc_name, 'dlz_name': hdcase.dlz_name, 'dlz_id': hdcase.dlz_id and hdcase.dlz_id or 0, - 'dlz_price': hdcase.dlz_price or 0, + 'dlz_price': hdcase.dlz_price or 1, 'lab': hdcase.lab, 'misc': hdcase.misc, 'inv_ref': inv_ref and inv_ref or "-", @@ -207,6 +207,18 @@ class ReportAccountHDCaseSummary(Model): lines=[] for hdnumber, vals in records.items(): lines.append(vals) + print("#1 ", len(lines)) + #get data from rd shop + if reimbursable=='no': + ctx={ + 'date_from': date_from, + 'date_to': date_to, + 'branch_id': branch_id, + 'department_id': department_id, + } + shop_lines=get_model('clinic.shop').get_shop_data(context=ctx)['records'] + lines+=shop_lines + print("#2 ", len(lines)) company_name=company.name or "" if department_id: company_name+=' (%s)'%get_model('clinic.department').browse(department_id).name or "" @@ -218,6 +230,7 @@ class ReportAccountHDCaseSummary(Model): total_lab=0 total_dlz=0 total_misc=0 + total_mdc=0 slines=[] no=1 ptypes={} @@ -234,6 +247,7 @@ class ReportAccountHDCaseSummary(Model): total_fee+=line.get('fee',0) total_srv+=line.get('srv',0) total_epo+=line.get('epo',0) + total_mdc+=line.get('mdc',0) total_lab+=line.get('lab',0) total_misc+=line.get('misc',0) total_dlz+=line.get('dlz_price',0) @@ -245,10 +259,11 @@ class ReportAccountHDCaseSummary(Model): index=0 else: index+=1 - cres=cycles[cid] - line['nurse']='' - if index < len(cres): - line['nurse']=cres[index] + if not line.get('is_shop'): + cres=cycles[cid] + line['nurse']='' + if index < len(cres): + line['nurse']=cres[index] slines.append(line) no+=1 types=[] @@ -273,6 +288,7 @@ class ReportAccountHDCaseSummary(Model): 'total_fee': total_fee, 'total_srv': total_srv, 'total_epo': total_epo, + 'total_mdc': total_mdc, 'total_lab': total_lab, 'total_misc': total_misc, 'total_dlz': total_dlz, @@ -288,6 +304,7 @@ class ReportAccountHDCaseSummary(Model): data['title']='Report - Claim' else: data['title']='Report - No Claim' + data['title']='' #XXX return data def onchange_date(self,context={}): diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py index a25b16e..b015843 100644 --- a/netforce_clinic/models/shop.py +++ b/netforce_clinic/models/shop.py @@ -808,5 +808,111 @@ class Shop(Model): obj.write({ 'state': 'cancelled', }) + + def get_shop_data(self,context={}): + records=[] + dom=[ + ['date','>=',context['date_from']], + ['date','<=',context['date_to']], + ['state','not in',['draft','cancelled']], + ] + branch_id=context.get('branch_id') + if branch_id: + dom.append([ + 'branch_id','=',branch_id, + ]) + department_id=context.get('department_id') + if department_id: + dom.append([ + 'department_id','=',department_id, + ]) + print('#shop.dom' , dom) + for shop in get_model("clinic.shop").search_browse(dom): + patient=shop.patient_id + pm_id=None + pm_number="" + for pm in shop.payments: + pm_id=pm.id + pm_number=pm.number + inv_id=None + inv_number="" + inv_ref="" + for inv in shop.invoices: + inv_id=inv.id + inv_number=inv.number + inv_ref=inv.ref + pick_id=None + pick_number='' + for pick in shop.pickings: + pick_id=pick.id + pick_number=pick.number + for line in shop.lines: + prod=line.product_id + categ=line.categ_id + amount=line.amount or 0 + mdc=0 + lab=0 + misc=0 + fee=0 + dlz_price=0 + mdc_names=[] + if categ.parent_id: + if categ.parent_id.code=='MDC': + mdc+=amount + name=prod.name or "" + name=name.split("-") + name=name[0].title() + mdc_names.append(name) + else: + misc+=amount + continue + if categ.code=='DLZ': + dlz_price+=amount + elif categ.code=='FEE': + fee+=amount + elif categ.code=='LAB': + lab+=amount + else: + misc+=amount + vals={ + 'is_shop': True, + 'hdcase_id': None, + 'number': None, #XXX + 'date': shop.date, + 'hct': 0, + 'epo_name': "", + 'ptype': "Shop", #XXX + 'ptype_color': "warning", + 'dname': "", + 'cycle': "", + 'cid': 0, #XXX + 'pname': patient.name or "", + 'hn': patient.hn or "", + 'idcard': patient.card_no or "", + 'cseq': 0, + 'cycle_item_id': "", + 'pm_id': pm_id, + 'pm_number': pm_number, + 'inv_number': inv_number, + 'inv_id': inv_number, + 'inv_ref': inv_ref, + 'fee': fee, + 'mdc': mdc, + 'mdc_name': ','.join([n for n in mdc_names]), + 'dlz_name': "", #XXX + 'dlz_id': "", + 'dlz_price': dlz_price, + 'lab': lab, + 'misc': misc, + 'pick_ref': pick_number, + 'pick_id': pick_id, + 'reimbursable': 'no', + } + records.append(vals) + data={ + 'records': records, + } + print('total records: ',len(records)) + return data Shop.register()