report labor cost
							parent
							
								
									f7349c2542
								
							
						
					
					
						commit
						9b65b7cc36
					
				| 
						 | 
					@ -11,8 +11,8 @@
 | 
				
			||||||
            <header string="REPORTS"/>
 | 
					            <header string="REPORTS"/>
 | 
				
			||||||
            <item string="HD Case Expense" action="clinic_report_account_hd_case_summary"/>
 | 
					            <item string="HD Case Expense" action="clinic_report_account_hd_case_summary"/>
 | 
				
			||||||
            <item string="RD Shop Expense" action="clinic_report_account_shop"/>
 | 
					            <item string="RD Shop Expense" action="clinic_report_account_shop"/>
 | 
				
			||||||
            <!--<item string="Labor Cost" action="clinic_report_labor_cost"/>-->
 | 
					            <item string="Labor Cost" action="clinic_report_labor_cost"/>
 | 
				
			||||||
            <item string="Labor Cost Summary" action="clinic_report_labor_cost_summary"/>
 | 
					            <!--<item string="Labor Cost Summary" action="clinic_report_labor_cost_summary"/>-->
 | 
				
			||||||
            <!--<item string="Labor Cost Detail" action="clinic_report_labor_cost_detail"/>-->
 | 
					            <!--<item string="Labor Cost Detail" action="clinic_report_labor_cost_detail"/>-->
 | 
				
			||||||
            <!--<item string="Labor Cost Sub Detail" action="clinic_report_labor_cost_sub_detail"/>-->
 | 
					            <!--<item string="Labor Cost Sub Detail" action="clinic_report_labor_cost_sub_detail"/>-->
 | 
				
			||||||
            <!--<item string="Labor Cost Daily" action="clinic_report_labor_cost_daily"/>-->
 | 
					            <!--<item string="Labor Cost Daily" action="clinic_report_labor_cost_daily"/>-->
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,29 +56,32 @@ class ReportLaborCost(Model):
 | 
				
			||||||
        dom.append(['date','>=',date_from])
 | 
					        dom.append(['date','>=',date_from])
 | 
				
			||||||
        dom.append(['date','<=',date_to])
 | 
					        dom.append(['date','<=',date_to])
 | 
				
			||||||
        if branch_id:
 | 
					        if branch_id:
 | 
				
			||||||
            dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
 | 
					            dom.append(['branch_id','=',branch_id])
 | 
				
			||||||
        if department_id:
 | 
					        if department_id:
 | 
				
			||||||
            dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
 | 
					            dom.append(['department_id','=',department_id])
 | 
				
			||||||
        print('dom ', dom)
 | 
					        print('dom ', dom)
 | 
				
			||||||
 | 
					        hdcases={}
 | 
				
			||||||
 | 
					        for hdcase in get_model("clinic.hd.case").search_browse(dom):
 | 
				
			||||||
 | 
					            dpt=hdcase.department_id
 | 
				
			||||||
 | 
					            if dpt.id not in hdcases.keys():
 | 
				
			||||||
 | 
					                hdcases[dpt.id]={
 | 
				
			||||||
 | 
					                    'name': dpt.name,
 | 
				
			||||||
 | 
					                    'department_id': dpt.id,
 | 
				
			||||||
 | 
					                    'branch_id': dpt.branch_id.id,
 | 
				
			||||||
 | 
					                    'qty':0,
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            hdcases[dpt.id]['qty']+=1
 | 
				
			||||||
        lines=[] 
 | 
					        lines=[] 
 | 
				
			||||||
        citems={}
 | 
					 | 
				
			||||||
        for line in get_model("clinic.labor.cost.line").search_browse(dom):
 | 
					 | 
				
			||||||
            #print('xx')
 | 
					 | 
				
			||||||
            lcost=line.labor_cost_id
 | 
					 | 
				
			||||||
            citem=lcost.cycle_item_id
 | 
					 | 
				
			||||||
            dpt=citem.department_id
 | 
					 | 
				
			||||||
            qty=line.qty or 0 #XXX
 | 
					 | 
				
			||||||
            print(citem.id)
 | 
					 | 
				
			||||||
            import pdb; pdb.set_trace()
 | 
					 | 
				
			||||||
            if not citem.id  not in list(citems.keys()):
 | 
					 | 
				
			||||||
                print("zzz")
 | 
					 | 
				
			||||||
                citems[citem.id]=citem
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        total_hdcase=0
 | 
					        total_hdcase=0
 | 
				
			||||||
        for citem_id, citem in citems.items():
 | 
					        for dpt_id, vals in hdcases.items():
 | 
				
			||||||
            for hdcase in citem.hd_cases:
 | 
					            qty=vals['qty'] or 0
 | 
				
			||||||
                if hdcase.state in ('completed','waitting_payment','paid'):
 | 
					            total_hdcase+=qty
 | 
				
			||||||
                    total_hdcase+=1
 | 
					            lines.append({
 | 
				
			||||||
 | 
					                'name': vals['name'],
 | 
				
			||||||
 | 
					                'branch_id': vals['branch_id'],
 | 
				
			||||||
 | 
					                'department_id': vals['department_id'],
 | 
				
			||||||
 | 
					                'qty': qty,
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
        sub_name=''
 | 
					        sub_name=''
 | 
				
			||||||
        if department_id:
 | 
					        if department_id:
 | 
				
			||||||
            dpt=get_model("clinic.department").browse(department_id)
 | 
					            dpt=get_model("clinic.department").browse(department_id)
 | 
				
			||||||
| 
						 | 
					@ -86,6 +89,7 @@ class ReportLaborCost(Model):
 | 
				
			||||||
        elif branch_id:
 | 
					        elif branch_id:
 | 
				
			||||||
            branch=get_model("clinic.branch").browse(branch_id)
 | 
					            branch=get_model("clinic.branch").browse(branch_id)
 | 
				
			||||||
            sub_name="(%s)" % branch.name or ""
 | 
					            sub_name="(%s)" % branch.name or ""
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        data={
 | 
					        data={
 | 
				
			||||||
            'company_name': '%s %s' % (company.name or "", sub_name),
 | 
					            'company_name': '%s %s' % (company.name or "", sub_name),
 | 
				
			||||||
            'date_from': date_from,
 | 
					            'date_from': date_from,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,15 +35,18 @@ class ReportLaborCostSummary(Model):
 | 
				
			||||||
        defaults=context.get("defaults",{})
 | 
					        defaults=context.get("defaults",{})
 | 
				
			||||||
        date_from=defaults.get("date_from", self._get_date_from())
 | 
					        date_from=defaults.get("date_from", self._get_date_from())
 | 
				
			||||||
        date_to=defaults.get("date_to", self._get_date_to())
 | 
					        date_to=defaults.get("date_to", self._get_date_to())
 | 
				
			||||||
 | 
					        branch_id=int(defaults.get("branch_id","0"))
 | 
				
			||||||
 | 
					        department_id=int(defaults.get("department_id","0"))
 | 
				
			||||||
        staff_type=defaults.get("staff_type","doctor")
 | 
					        staff_type=defaults.get("staff_type","doctor")
 | 
				
			||||||
        staff_id=int(defaults.get('staff_id', "0"))
 | 
					        staff_id=int(defaults.get('staff_id', "0"))
 | 
				
			||||||
        print('defaults ', defaults)
 | 
					 | 
				
			||||||
        res={
 | 
					        res={
 | 
				
			||||||
            'date': time.strftime("%Y-%m-%d"),
 | 
					            'date': time.strftime("%Y-%m-%d"),
 | 
				
			||||||
            'date_from': date_from,
 | 
					            'date_from': date_from,
 | 
				
			||||||
            'date_to': date_to,
 | 
					            'date_to': date_to,
 | 
				
			||||||
            'staff_type': staff_type,
 | 
					            'staff_type': staff_type,
 | 
				
			||||||
            'staff_id': staff_id and staff_id or None,
 | 
					            'staff_id': staff_id and staff_id or None,
 | 
				
			||||||
 | 
					            'department_id': department_id,
 | 
				
			||||||
 | 
					            'branch_id': branch_id,
 | 
				
			||||||
            'only_value': True,
 | 
					            'only_value': True,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return res
 | 
					        return res
 | 
				
			||||||
| 
						 | 
					@ -55,10 +58,10 @@ class ReportLaborCostSummary(Model):
 | 
				
			||||||
        staff_id=defaults['staff_id']
 | 
					        staff_id=defaults['staff_id']
 | 
				
			||||||
        staff_type=defaults['staff_type']
 | 
					        staff_type=defaults['staff_type']
 | 
				
			||||||
        only_value=defaults['only_value']
 | 
					        only_value=defaults['only_value']
 | 
				
			||||||
 | 
					        department_id=defaults['department_id']
 | 
				
			||||||
 | 
					        branch_id=defaults['branch_id']
 | 
				
			||||||
        level_id=None
 | 
					        level_id=None
 | 
				
			||||||
        categ_id=None
 | 
					        categ_id=None
 | 
				
			||||||
        branch_id=None
 | 
					 | 
				
			||||||
        department_id=None
 | 
					 | 
				
			||||||
        dom=[]
 | 
					        dom=[]
 | 
				
			||||||
        if ids:
 | 
					        if ids:
 | 
				
			||||||
            obj=self.browse(ids)[0]
 | 
					            obj=self.browse(ids)[0]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,17 +8,23 @@
 | 
				
			||||||
</center>
 | 
					</center>
 | 
				
			||||||
<table class="table table-condensed table-striped">
 | 
					<table class="table table-condensed table-striped">
 | 
				
			||||||
    <thead>
 | 
					    <thead>
 | 
				
			||||||
 | 
					        <th>ชั้น</th>
 | 
				
			||||||
 | 
					        <th style="text-align:right">จำนวน HD Case</th>
 | 
				
			||||||
    </thead>
 | 
					    </thead>
 | 
				
			||||||
    <tbody>
 | 
					    <tbody>
 | 
				
			||||||
        {{#each lines }}
 | 
					        {{#each lines }}
 | 
				
			||||||
                <tr>
 | 
					                <tr>
 | 
				
			||||||
                    <td></td>
 | 
					                    <td>
 | 
				
			||||||
 | 
					                        {{name}}
 | 
				
			||||||
 | 
					                    </td>
 | 
				
			||||||
 | 
					                    <td style="text-align:right">
 | 
				
			||||||
 | 
					                        <a href="#name=clinic_report_labor_cost_summary&defaults.date_from={{../date_from}}&defaults.date_to={{../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}">{{currency  qty}}</a>
 | 
				
			||||||
 | 
					                    </td>
 | 
				
			||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
        {{/each}}
 | 
					        {{/each}}
 | 
				
			||||||
    </tbody>
 | 
					    </tbody>
 | 
				
			||||||
    <tfoot>
 | 
					    <tfoot>
 | 
				
			||||||
 | 
					        <th>Total</th>
 | 
				
			||||||
 | 
					        <th style="text-align:right">{{currency total_hdcase}}</th>
 | 
				
			||||||
    </tfoot>
 | 
					    </tfoot>
 | 
				
			||||||
</table>
 | 
					</table>
 | 
				
			||||||
<p>
 | 
					 | 
				
			||||||
    {{total_hdcase}}
 | 
					 | 
				
			||||||
</p>
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue