diff --git a/netforce_clinic/layouts/clinic_report_cycle_item.xml b/netforce_clinic/layouts/clinic_report_cycle_item.xml index 37d097b..0a46419 100644 --- a/netforce_clinic/layouts/clinic_report_cycle_item.xml +++ b/netforce_clinic/layouts/clinic_report_cycle_item.xml @@ -3,6 +3,7 @@ + diff --git a/netforce_clinic/layouts/clinic_user_form.xml b/netforce_clinic/layouts/clinic_user_form.xml index 77a1d24..9edff4c 100644 --- a/netforce_clinic/layouts/clinic_user_form.xml +++ b/netforce_clinic/layouts/clinic_user_form.xml @@ -3,7 +3,9 @@ - + + + diff --git a/netforce_clinic/models/base_user.py b/netforce_clinic/models/base_user.py index 8b403d2..f5e51eb 100644 --- a/netforce_clinic/models/base_user.py +++ b/netforce_clinic/models/base_user.py @@ -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() diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 608e930..1e36492 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -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), diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py index 6c616c8..5070ac0 100644 --- a/netforce_clinic/models/report_account_hd_case_summary.py +++ b/netforce_clinic/models/report_account_hd_case_summary.py @@ -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, diff --git a/netforce_clinic/models/report_cycle_item.py b/netforce_clinic/models/report_cycle_item.py index 2f7492c..6607d34 100644 --- a/netforce_clinic/models/report_cycle_item.py +++ b/netforce_clinic/models/report_cycle_item.py @@ -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 diff --git a/netforce_clinic/models/select_company.py b/netforce_clinic/models/select_company.py index 747d7f2..97e448b 100644 --- a/netforce_clinic/models/select_company.py +++ b/netforce_clinic/models/select_company.py @@ -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() diff --git a/netforce_clinic/templates/report_account_hd_case_summary.hbs b/netforce_clinic/templates/report_account_hd_case_summary.hbs index 431a8db..cfb8e7b 100644 --- a/netforce_clinic/templates/report_account_hd_case_summary.hbs +++ b/netforce_clinic/templates/report_account_hd_case_summary.hbs @@ -83,9 +83,9 @@ {{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}} - {{epo_name}} + {{mdc_name}} {{currency fee zero=""}} - {{currency epo zero=""}} + {{currency mdc zero=""}} {{currency lab zero=""}} {{currency misc zero=""}} {{currency dlz_price zero=""}} @@ -110,13 +110,18 @@ {{idcard}} {{ptype}} {{hct}} - {{epo_name}} + {{mdc_name}} {{currency fee zero=""}} - {{currency epo zero=""}} + {{currency mdc zero=""}} {{currency srv zero=""}} - - {{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}} - + {{#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}} + + {{else}} + + + {{/if}} {{#if pick_id}} {{view "link" string=pick_ref action="pick_out" action_options="mode=form" active_id=pick_id}} @@ -145,7 +150,7 @@ {{currency total_fee zero=""}} - {{currency total_epo zero=""}} + {{currency total_mdc zero=""}} {{currency total_lab zero=""}} {{currency total_misc zero=""}} {{currency total_dlz zero=""}} @@ -161,7 +166,7 @@ {{currency total_fee zero=""}} - {{currency total_epo zero=""}} + {{currency total_mdc zero=""}} {{currency total_srv zero=""}} diff --git a/netforce_clinic/templates/report_cycle_item.hbs b/netforce_clinic/templates/report_cycle_item.hbs index fdba8dd..d7016e9 100644 --- a/netforce_clinic/templates/report_cycle_item.hbs +++ b/netforce_clinic/templates/report_cycle_item.hbs @@ -33,7 +33,7 @@ {{dname}} {{tname}} {{fee}} - {{epo}} + {{mdc}} {{dlz_name}} {{dlz_use}} View