From 1fcc52bbb66b52230f60331f4132110c3f1a0032 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Thu, 26 Mar 2015 14:55:16 +0700 Subject: [PATCH] report claim expense --- netforce_clinic/models/hd_case.py | 28 ++++++++++++++----- .../models/report_account_hd_case_summary.py | 3 +- .../report_account_hd_case_summary.hbs | 12 +++++--- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 7771914..608e930 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -74,6 +74,8 @@ class HDCase(Model): res={} 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 @@ -83,9 +85,9 @@ class HDCase(Model): dz=dlz.dialyzer_id dlz_id=dz.id prod=dz.product_id - #name=dz.name or "" - #name=name.split()[-1] - name=prod.description + name="" + if prod: + name=prod.description or "" dlz_name.append(name) dlz_use+=dlz.use_time or 0 dlz_max+=dlz.max_use_time or 0 @@ -101,7 +103,8 @@ class HDCase(Model): for dline in obj.dialyzers: dlz=dline.dialyzer_id prod=dlz.product_id - dlz_price+=prod.sale_price or 0 + if prod: + dlz_price+=prod.sale_price or 0 for line in obj.lines: amt=line.amount or 0 @@ -121,11 +124,20 @@ class HDCase(Model): elif categ.code=='FEE': fee+=amt*sign elif categ.code=='DLZ': - dlz_price+=prod.sale_price or 0 + if prod: + dlz_price+=prod.sale_price or 0 elif categ.code=="LAB": - lab+=amt + if reimbursable_ctx: + if reimbursable_ctx==line.reimbursable: + lab+=amt + else: + lab+=amt else: - misc+=amt + if reimbursable_ctx: + if reimbursable_ctx==line.reimbursable: + misc+=amt + else: + misc+=amt res[obj.id]={ 'epo': ','.join([n for n in names]), 'fee': fee, @@ -387,6 +399,8 @@ class HDCase(Model): line=get_data_path(data,path,parent=True) product_id=line.get('product_id') prod=get_model("product").browse(product_id) + if not prod: + return data if prod.can_sell: line['reimbursable']='no' else: diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py index 4ba990a..6c616c8 100644 --- a/netforce_clinic/models/report_account_hd_case_summary.py +++ b/netforce_clinic/models/report_account_hd_case_summary.py @@ -105,7 +105,8 @@ class ReportAccountHDCaseSummary(Model): dom.append(['product_id','=',product_id]) records={} cycles={} - for line in get_model("clinic.hd.case.line").search_browse(dom): + context['reimbursable']=reimbursable + 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("-") diff --git a/netforce_clinic/templates/report_account_hd_case_summary.hbs b/netforce_clinic/templates/report_account_hd_case_summary.hbs index 3f94c74..431a8db 100644 --- a/netforce_clinic/templates/report_account_hd_case_summary.hbs +++ b/netforce_clinic/templates/report_account_hd_case_summary.hbs @@ -38,7 +38,7 @@ สิทธิ์ Receipt# Invoice# - EPO + ชื่อยา ค่าฟอก ค่ายา Lab @@ -55,7 +55,7 @@ ID Card สิทธิ์ HCT% - EPO + ชื่อยา ค่าฟอก ค่ายา ค่าบริการฉีดยา @@ -80,14 +80,18 @@ {{idcard}} {{ptype}} {{pm_number}} - {{inv_number}} + + {{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}} + {{epo_name}} {{currency fee zero=""}} {{currency epo zero=""}} {{currency lab zero=""}} {{currency misc zero=""}} {{currency dlz_price zero=""}} - {{inv_ref}} + + {{view "link" string=inv_ref action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}} + {{#if pick_id}} {{view "link" string=pick_ref action="pick_out" action_options="mode=form" active_id=pick_id}}