labor cost summary
							parent
							
								
									016bfd85b5
								
							
						
					
					
						commit
						3d17dbcd72
					
				| 
						 | 
					@ -2,6 +2,8 @@
 | 
				
			||||||
    <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="date_from" span="2"/>
 | 
				
			||||||
    <field name="date_to" span="2"/>
 | 
					    <field name="date_to" span="2"/>
 | 
				
			||||||
 | 
					    <field name="branch_id" span="3"/>
 | 
				
			||||||
 | 
					    <field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
 | 
				
			||||||
    <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>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,8 @@ class ComputeLaborCost(Model):
 | 
				
			||||||
        "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),
 | 
				
			||||||
 | 
					        'branch_id': fields.Many2One("clinic.branch","Branch"),
 | 
				
			||||||
 | 
					        'department_id': fields.Many2One("clinic.department","Department"),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _get_date_from(self,context={}):
 | 
					    def _get_date_from(self,context={}):
 | 
				
			||||||
| 
						 | 
					@ -35,8 +37,15 @@ class ComputeLaborCost(Model):
 | 
				
			||||||
        dom=[]
 | 
					        dom=[]
 | 
				
			||||||
        dom.append(['date','>=', obj.date_from])
 | 
					        dom.append(['date','>=', obj.date_from])
 | 
				
			||||||
        dom.append(['date','<=', obj.date_to])
 | 
					        dom.append(['date','<=', obj.date_to])
 | 
				
			||||||
 | 
					        if obj.branch_id:
 | 
				
			||||||
 | 
					            dom.append(['branch_id','=',obj.branch_id.id])
 | 
				
			||||||
 | 
					        if obj.department_id:
 | 
				
			||||||
 | 
					            dom.append(['department_id','=',obj.department_id.id])
 | 
				
			||||||
        for lcost in get_model("clinic.labor.cost").search_browse(dom):
 | 
					        for lcost in get_model("clinic.labor.cost").search_browse(dom):
 | 
				
			||||||
            print("compute %s ....", lcost.cycle_item_id.name)
 | 
					            print("compute %s ....", lcost.cycle_item_id.name)
 | 
				
			||||||
 | 
					            #item=lcost.cycle_item_id
 | 
				
			||||||
 | 
					            #item.to_draft()
 | 
				
			||||||
 | 
					            #item.validate()
 | 
				
			||||||
            lcost.compute()
 | 
					            lcost.compute()
 | 
				
			||||||
        print("Done!")
 | 
					        print("Done!")
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,10 +69,10 @@ class LaborCost(Model):
 | 
				
			||||||
                'var_fml3': '(%s%s)/%s'%(var_ptx,total_bstr,total_a),
 | 
					                'var_fml3': '(%s%s)/%s'%(var_ptx,total_bstr,total_a),
 | 
				
			||||||
                'var_x': round(var_x,2),
 | 
					                'var_x': round(var_x,2),
 | 
				
			||||||
                'total': total,
 | 
					                'total': total,
 | 
				
			||||||
                'total_formular': total_formular,
 | 
					                'total_formular': round(total_formular,0),
 | 
				
			||||||
                'total_ncost': total_ncost,
 | 
					                'total_ncost': round(total_ncost,0),
 | 
				
			||||||
                'total_nqty': total_nqty,
 | 
					                'total_nqty': total_nqty,
 | 
				
			||||||
                'total_dcost': total_dcost,
 | 
					                'total_dcost': round(total_dcost,0),
 | 
				
			||||||
                'total_dqty': total_dqty,
 | 
					                'total_dqty': total_dqty,
 | 
				
			||||||
                'total_stcost': total_stcost,
 | 
					                'total_stcost': total_stcost,
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -205,19 +205,15 @@ class ReportLaborCostSummary(Model):
 | 
				
			||||||
            total_cost+=amt
 | 
					            total_cost+=amt
 | 
				
			||||||
            total_qty+=qty
 | 
					            total_qty+=qty
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        total_lines.append({'amt': total})
 | 
					        total_lines.append({'amt': round(total,0)})
 | 
				
			||||||
        company_id=get_active_company()
 | 
					        company_id=get_active_company()
 | 
				
			||||||
        comp=get_model("company").browse(company_id)
 | 
					        comp=get_model("company").browse(company_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #staff_type=staff_type or staff.type #XXX
 | 
					 | 
				
			||||||
        print("staff_type ", staff_type)
 | 
					 | 
				
			||||||
        if staff_type!='doctor':
 | 
					        if staff_type!='doctor':
 | 
				
			||||||
            total_hdcase=0
 | 
					            total_hdcase=0
 | 
				
			||||||
            for k,hdcase_qty in citems.items():
 | 
					            for k,hdcase_qty in citems.items():
 | 
				
			||||||
                total_hdcase+=hdcase_qty
 | 
					                total_hdcase+=hdcase_qty
 | 
				
			||||||
            print("total_hdcase ", total_hdcase)
 | 
					        # run no
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # reset no
 | 
					 | 
				
			||||||
        nlines=[]
 | 
					        nlines=[]
 | 
				
			||||||
        no=1
 | 
					        no=1
 | 
				
			||||||
        for line in sorted(lines, key=lambda x: x['number']):
 | 
					        for line in sorted(lines, key=lambda x: x['number']):
 | 
				
			||||||
| 
						 | 
					@ -234,7 +230,7 @@ class ReportLaborCostSummary(Model):
 | 
				
			||||||
            'lines': nlines,
 | 
					            'lines': nlines,
 | 
				
			||||||
            'total_lines': total_lines,
 | 
					            'total_lines': total_lines,
 | 
				
			||||||
            'total_hdcase': total_hdcase or 0,
 | 
					            'total_hdcase': total_hdcase or 0,
 | 
				
			||||||
            'total_cost': total_cost or 0,
 | 
					            'total_cost': round(total_cost,0) or 0,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return data
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,7 @@
 | 
				
			||||||
                    <th style="text-align:right">{{name}}</th>
 | 
					                    <th style="text-align:right">{{name}}</th>
 | 
				
			||||||
                {{/each}}
 | 
					                {{/each}}
 | 
				
			||||||
            </th>
 | 
					            </th>
 | 
				
			||||||
            <th rowspan="2" style="text-align:right;">รายได้</th>
 | 
					            <th rowspan="2" style="text-align:right;">รวม</th>
 | 
				
			||||||
        </tr>
 | 
					        </tr>
 | 
				
			||||||
    </thead>
 | 
					    </thead>
 | 
				
			||||||
    <tbody>
 | 
					    <tbody>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue