report overtime
							parent
							
								
									e710105b26
								
							
						
					
					
						commit
						9276d1aa6c
					
				| 
						 | 
					@ -1,9 +1,10 @@
 | 
				
			||||||
<form model="clinic.compute.labor.cost" title="Compute Labor Cost">
 | 
					<form model="clinic.compute.labor.cost" title="Compute Labor Cost">
 | 
				
			||||||
    <field name="date" span="2" mode="month" onchange="onchange_date"/>
 | 
					<!--<field name="date" span="2" mode="month" onchange="onchange_date"/>-->
 | 
				
			||||||
    <field name="date_from" span="2"/>
 | 
					    <field name="period_id" domain='[["state","=","open"]]' onchange="onchange_period" span="4"/>
 | 
				
			||||||
    <field name="date_to" span="2"/>
 | 
					    <field name="date_from" span="4"/>
 | 
				
			||||||
    <field name="branch_id" onchange='onchange_branch' span="3"/>
 | 
					    <field name="date_to" span="4"/>
 | 
				
			||||||
    <field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
 | 
					    <field name="branch_id" onchange='onchange_branch' span="4"/>
 | 
				
			||||||
 | 
					    <field name="department_id" domain='[["branch_id","=",branch_id]]' span="4"/>
 | 
				
			||||||
    <foot replace="1">
 | 
					    <foot replace="1">
 | 
				
			||||||
        <button string="Compute" method="compute" icon="repeat" type="default"/>
 | 
					        <button string="Compute" method="compute" icon="repeat" type="default"/>
 | 
				
			||||||
    </foot>
 | 
					    </foot>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ class ComputeLaborCost(Model):
 | 
				
			||||||
    _transient=True
 | 
					    _transient=True
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    _fields={
 | 
					    _fields={
 | 
				
			||||||
 | 
					        "period_id": fields.Many2One("clinic.period.line","Period"),
 | 
				
			||||||
        "date": fields.Date("Month"),
 | 
					        "date": fields.Date("Month"),
 | 
				
			||||||
        "date_from": fields.Date("From", required=True),
 | 
					        "date_from": fields.Date("From", required=True),
 | 
				
			||||||
        "date_to": fields.Date("To", required=True),
 | 
					        "date_to": fields.Date("To", required=True),
 | 
				
			||||||
| 
						 | 
					@ -25,11 +26,25 @@ class ComputeLaborCost(Model):
 | 
				
			||||||
        weekday, total_day=monthrange(int(year), int(month))
 | 
					        weekday, total_day=monthrange(int(year), int(month))
 | 
				
			||||||
        return "%s-%s-%s"%(year,month,total_day)
 | 
					        return "%s-%s-%s"%(year,month,total_day)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _defaults={
 | 
					    def default_get(self,field_names=None,context={},**kw):
 | 
				
			||||||
        'date': lambda *a: time.strftime("%Y-%m-%d"),
 | 
					        defaults=context.get("defaults",{})
 | 
				
			||||||
        'date_from': _get_date_from,
 | 
					        date_from=defaults.get("date_from", self._get_date_from())
 | 
				
			||||||
        'date_to': _get_date_to,
 | 
					        date_to=defaults.get("date_to", self._get_date_to())
 | 
				
			||||||
 | 
					        yearnow=date_from.split("-")[0]
 | 
				
			||||||
 | 
					        for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
 | 
				
			||||||
 | 
					            for line in period.lines:
 | 
				
			||||||
 | 
					                if line.state=='open':
 | 
				
			||||||
 | 
					                    period_id=line.id
 | 
				
			||||||
 | 
					                    date_from=line.date_start
 | 
				
			||||||
 | 
					                    date_to=line.date_stop
 | 
				
			||||||
 | 
					                    break
 | 
				
			||||||
 | 
					        res={
 | 
				
			||||||
 | 
					            'period_id': period_id,
 | 
				
			||||||
 | 
					            'date': time.strftime("%Y-%m-%d"),
 | 
				
			||||||
 | 
					            'date_from': date_from,
 | 
				
			||||||
 | 
					            'date_to': date_to,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        return res
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def compute(self,ids,context={}):
 | 
					    def compute(self,ids,context={}):
 | 
				
			||||||
        obj=self.browse(ids)[0]
 | 
					        obj=self.browse(ids)[0]
 | 
				
			||||||
| 
						 | 
					@ -70,4 +85,12 @@ class ComputeLaborCost(Model):
 | 
				
			||||||
        data['department_id']=None
 | 
					        data['department_id']=None
 | 
				
			||||||
        return data
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def onchange_period(self,context={}):   
 | 
				
			||||||
 | 
					        data=context['data']
 | 
				
			||||||
 | 
					        period_id=data['period_id']
 | 
				
			||||||
 | 
					        period=get_model('clinic.period.line').browse(period_id)
 | 
				
			||||||
 | 
					        data['date_from']=period.date_start
 | 
				
			||||||
 | 
					        data['date_to']=period.date_stop
 | 
				
			||||||
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ComputeLaborCost.register()
 | 
					ComputeLaborCost.register()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -104,6 +104,12 @@ class ReportLaborCostOverTime(Model):
 | 
				
			||||||
            dom=dom.replace("False","false")
 | 
					            dom=dom.replace("False","false")
 | 
				
			||||||
            dom=dom.replace("True","true")
 | 
					            dom=dom.replace("True","true")
 | 
				
			||||||
            return dom.replace("'","\"")
 | 
					            return dom.replace("'","\"")
 | 
				
			||||||
 | 
					        def int2ths(r):
 | 
				
			||||||
 | 
					            if type(r)==type(''):
 | 
				
			||||||
 | 
					                return r
 | 
				
			||||||
 | 
					            if not r:
 | 
				
			||||||
 | 
					                return ""
 | 
				
			||||||
 | 
					            return "{0:,.2f}".format(r) 
 | 
				
			||||||
        lines=[]
 | 
					        lines=[]
 | 
				
			||||||
        snames=sorted(staffs.keys()) #sort by staff name
 | 
					        snames=sorted(staffs.keys()) #sort by staff name
 | 
				
			||||||
        no=1
 | 
					        no=1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -29,14 +29,11 @@
 | 
				
			||||||
                    <td style="text-align:right;">
 | 
					                    <td style="text-align:right;">
 | 
				
			||||||
                        <a href="#name=clinic_report_labor_cost_summary&defaults.date_from={{../date_from}}&defaults.date_to={{../date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}">{{currency amount zero=""}}</a>
 | 
					                        <a href="#name=clinic_report_labor_cost_summary&defaults.date_from={{../date_from}}&defaults.date_to={{../date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}">{{currency amount zero=""}}</a>
 | 
				
			||||||
                    </td>
 | 
					                    </td>
 | 
				
			||||||
                    <td style="text-align:right;">{{max_cycle}}</td>
 | 
					                    <td style="text-align:right;">{{currency max_cycle zero=""}}</td>
 | 
				
			||||||
                    <td style="text-align:right;">
 | 
					                    <td style="text-align:right;">
 | 
				
			||||||
                        {{view "link" string=cycle_qty action="clinic_labor_cost_item" action_options=action_options}}
 | 
					                        {{view "link" string=cycle_qty action="clinic_labor_cost_item" action_options=action_options}}
 | 
				
			||||||
                    </td>
 | 
					                    </td>
 | 
				
			||||||
                    <!--
 | 
					                    <td style="text-align:right;">{{currency ot_qty zero=""}}</th>
 | 
				
			||||||
                    <td style="text-align:right;">{{cycle_qty}}</th>
 | 
					 | 
				
			||||||
                    -->
 | 
					 | 
				
			||||||
                    <td style="text-align:right;">{{ot_qty}}</th>
 | 
					 | 
				
			||||||
                    <td style="text-align:right;">{{currency ot_per_cycle zero=""}}</th>
 | 
					                    <td style="text-align:right;">{{currency ot_per_cycle zero=""}}</th>
 | 
				
			||||||
                    <td style="text-align:right;color:orange">{{currency ot_amount zero=""}}</th>
 | 
					                    <td style="text-align:right;color:orange">{{currency ot_amount zero=""}}</th>
 | 
				
			||||||
                    <td style="text-align:right;color:blue">{{currency staff_wage zero=""}}</th>
 | 
					                    <td style="text-align:right;color:blue">{{currency staff_wage zero=""}}</th>
 | 
				
			||||||
| 
						 | 
					@ -51,9 +48,9 @@
 | 
				
			||||||
        <th></th>
 | 
					        <th></th>
 | 
				
			||||||
        <th>รวม</th>
 | 
					        <th>รวม</th>
 | 
				
			||||||
        <th style="text-align:right">{{currency total_amount zero=""}}</th>
 | 
					        <th style="text-align:right">{{currency total_amount zero=""}}</th>
 | 
				
			||||||
        <th style="text-align:right">{{total_max_cycle}}</th>
 | 
					        <th style="text-align:right">{{currency total_max_cycle zero=""}}</th>
 | 
				
			||||||
        <th style="text-align:right">{{total_cycle_qty}}</th>
 | 
					        <th style="text-align:right">{{currency total_cycle_qty zero=""}}</th>
 | 
				
			||||||
        <th style="text-align:right">{{total_ot_qty}}</th>
 | 
					        <th style="text-align:right">{{currency total_ot_qty zero=""}}</th>
 | 
				
			||||||
        <th style="text-align:right">{{currency total_ot_per_cycle zero=""}}</th>
 | 
					        <th style="text-align:right">{{currency total_ot_per_cycle zero=""}}</th>
 | 
				
			||||||
        <th style="text-align:right">{{currency total_ot_amount zero=""}}</th>
 | 
					        <th style="text-align:right">{{currency total_ot_amount zero=""}}</th>
 | 
				
			||||||
        <th style="text-align:right">{{currency total_wage zero=""}}</th>
 | 
					        <th style="text-align:right">{{currency total_wage zero=""}}</th>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue