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