From 765a9884edeb695b3b4ace0e6531ebb8b13f2899 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Thu, 18 Feb 2016 21:24:47 +0700 Subject: [PATCH] wrong summary total mecical for each round --- netforce_clinic/models/hd_case.py | 7 +++++++ netforce_clinic/models/report_cycle_item.py | 16 +++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 9fdcdbd..71228f2 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -111,6 +111,7 @@ class HDCase(Model): dlz_price=0 srv=0 mdc=0 + mdc_items={} for line in obj.lines: amt=line.amount or 0 prod=line.product_id @@ -129,8 +130,12 @@ class HDCase(Model): else: mdc+=amt mdc_names.append(prod_name or "") + mdc_items.setdefault(prod_name,0) + mdc_items[prod_name]=line.qty if categ.code=='EPO': epo_names.append(prod_name.title()) + mdc_items.setdefault(prod_name,0) + mdc_items[prod_name]=line.qty elif categ.code=='IVR': iron_names.append(prod_name.title()) elif categ.code=='FEE': @@ -154,6 +159,7 @@ class HDCase(Model): res[obj.id]={ 'epo': ','.join([n for n in epo_names]), 'mdc_name': ','.join([n for n in mdc_names]), + 'mdc_items': str(mdc_items), 'iron_name': ','.join([n for n in iron_names]), 'fee': fee, 'lab': lab, @@ -222,6 +228,7 @@ class HDCase(Model): "mdc": fields.Float("MDC",function="_get_expense",function_multi=True), "srv": fields.Float("Service",function="_get_expense",function_multi=True), "mdc_name": fields.Float("MDC Name",function="_get_expense",function_multi=True), + "mdc_items": fields.Float("MDC Items",function="_get_expense",function_multi=True), "iron_name": fields.Float("Iron Name",function="_get_expense",function_multi=True), 'sickbed_id': fields.Many2One("clinic.sickbed",'Sickbed'), "ref": fields.Char("Ref",search=True), diff --git a/netforce_clinic/models/report_cycle_item.py b/netforce_clinic/models/report_cycle_item.py index 3e030d1..ebf89a2 100644 --- a/netforce_clinic/models/report_cycle_item.py +++ b/netforce_clinic/models/report_cycle_item.py @@ -147,6 +147,7 @@ class ReportCycleItem(Model): total_epo=0 total_ivr=0 + for line in hdcase.lines: prod=line.product_id if prod.categ_id: @@ -171,6 +172,7 @@ class ReportCycleItem(Model): 'hdcase_number': reformat_number(hdcase.number), 'hdcase_id': hdcase.id, 'mdc_name': hdcase.mdc_name or hdcase.epo, + 'mdc_items': hdcase.mdc_items, 'iron_name': hdcase.iron_name or '', 'fee': abs(hdcase.fee), 'dlz_name': hdcase.dlz_name, @@ -224,12 +226,16 @@ class ReportCycleItem(Model): if x['cseq']==line['cseq'] and x['date']==date: sub_fee+=x['fee'] or 0 sub_mdc+=x['mdc'] or 0 - if not epos.get(x['mdc_name']): - epos[x['mdc_name']]=0 - if not epos.get(x['iron_name']): - epos[x['iron_name']]=0 + x_name=x['mdc_name'] + epos.setdefault(x_name,0) + epos.setdefault(x['iron_name'],0) epos[x['iron_name']]+=x['total_ivr'] or 0 #XXX - epos[x['mdc_name']]+=x['total_epo'] or 0 + if ',' in x_name: + del epos[x_name] + for k,v in eval(x['mdc_items']).items(): + epos[k]=v + else: + epos[x_name]+=x['total_epo'] or 0 count+=1 line['date_txt']=line['date'] line['cseq_txt']=line['cseq']