reformat report
parent
a881dfadda
commit
c93b40dfc8
|
@ -142,7 +142,7 @@ class LaborCost(Model):
|
|||
nurse=line.nurse_id
|
||||
level=line.level_id or nurse.level_id
|
||||
if not level:
|
||||
raise Exception("Please specify level for %s"%nurse.name)
|
||||
raise Exception("Please specify level %s for %s"%(nurse.name,item.name))
|
||||
levels[level.id]['total']+=1
|
||||
|
||||
st_levels={}
|
||||
|
|
|
@ -216,8 +216,7 @@ class ReportLaborCost(Model):
|
|||
for categ_name,vals in ctdata.items():
|
||||
amount=vals['amount'] or 0
|
||||
categ_id=vals['categ_id']
|
||||
total_amount+=amount
|
||||
ctlines.append({
|
||||
ct_vals={
|
||||
'name': categ_name,
|
||||
'amount': round(amount,0),
|
||||
'branch_id': branch_id,
|
||||
|
@ -225,7 +224,9 @@ class ReportLaborCost(Model):
|
|||
'department_id': department_id,
|
||||
'staff_type': 'nurse',
|
||||
'cycle_id': cycle_id,
|
||||
})
|
||||
}
|
||||
total_amount+=ct_vals['amount']
|
||||
ctlines.append(ct_vals)
|
||||
ctlines.append({
|
||||
'name': 'รวม',
|
||||
'amount': round(total_amount,0),
|
||||
|
@ -354,17 +355,29 @@ class ReportLaborCost(Model):
|
|||
nlines[-1]['cost']+=nline['cost'] or 0
|
||||
nlines[-1]['total']+=nline['total'] or 0
|
||||
|
||||
def conv2line(keys=[],lines=[]):
|
||||
def con2float(r):
|
||||
if type(r)==type(''):
|
||||
return r
|
||||
return "{0:,.2f}".format(r)
|
||||
|
||||
def v2h(keys=[],lines=[]):
|
||||
lines2=[]
|
||||
for key in keys:
|
||||
no=0
|
||||
vals={}
|
||||
vals={'desc': False}
|
||||
if key=='name':
|
||||
vals['desc']=True
|
||||
for line in lines:
|
||||
vals[no]=line[key]
|
||||
vals[no]=con2float(line[key])
|
||||
no+=1
|
||||
lines2.append(vals)
|
||||
return lines2
|
||||
|
||||
def reformat(lines=[]):
|
||||
for line in lines:
|
||||
line['amount']=con2float(line['amount'])
|
||||
return lines
|
||||
|
||||
data={
|
||||
'company_name': '%s %s' % (company.name or "", sub_name),
|
||||
'date': date,
|
||||
|
@ -372,25 +385,17 @@ class ReportLaborCost(Model):
|
|||
'date_to': date_to,
|
||||
'lines': lines,
|
||||
'dlines': dlines,
|
||||
'dlines2': conv2line(['name','qty','qty2','total_qty','cost'],dlines),
|
||||
'dlines2': v2h(['name','qty','qty2','total_qty','cost'],dlines),
|
||||
'nlines': nlines,
|
||||
'nlines2': [],
|
||||
'nlines2': v2h(['name','qty','cost'],nlines),
|
||||
'ctlines': ctlines,
|
||||
'ctlines2': reformat(ctlines),
|
||||
'total_hdcase': total_hdcase,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
'show_detail': show_detail,
|
||||
'report_type': report_type,
|
||||
}
|
||||
|
||||
for key in ('name', 'qty', 'cost'):
|
||||
no=0
|
||||
vals={}
|
||||
for nline in data['nlines']:
|
||||
vals[no]=nline[key]
|
||||
no+=1
|
||||
data['nlines2'].append(vals)
|
||||
|
||||
return data
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
|
|
|
@ -115,9 +115,14 @@ class ReportLaborCostSummary(Model):
|
|||
dom.append(['labor_cost_id.cycle_item_id.cycle_id','=',cycle_id])
|
||||
staffs={}
|
||||
citems={}
|
||||
|
||||
def int2ths(r):
|
||||
if type(r)==type(''):
|
||||
return r
|
||||
return "{0:,.0f}".format(r)
|
||||
|
||||
print('--> dom: ', dom)
|
||||
total_hdcase=0
|
||||
|
||||
for line in get_model("clinic.labor.cost.line").search_browse(dom):
|
||||
lcost=line.labor_cost_id
|
||||
citem=lcost.cycle_item_id
|
||||
|
@ -263,6 +268,7 @@ class ReportLaborCostSummary(Model):
|
|||
line['no']=no
|
||||
nlines.append(line)
|
||||
no+=1
|
||||
|
||||
data={
|
||||
'title': title,
|
||||
'date_from': date_from,
|
||||
|
@ -272,12 +278,41 @@ class ReportLaborCostSummary(Model):
|
|||
'comp_span': len(dpts),
|
||||
'lines': nlines,
|
||||
'total_lines': total_lines,
|
||||
'total_hdcase': total_hdcase or 0,
|
||||
'total_hdcase': int2ths(total_hdcase) or 0,
|
||||
'total_cost': round(total_cost,0) or 0,
|
||||
'staff_type': staff_type,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
'dpts_txt': [{0: '#', 1: 'รหัส', 2: 'ชื่อ-สกุล',}],
|
||||
}
|
||||
items=[]
|
||||
vals={}
|
||||
no=0
|
||||
dpt_len=len(data['dpts_txt'][0])
|
||||
for dpt in dpts:
|
||||
data['dpts_txt'][0][no+dpt_len]=dpt['name']
|
||||
vals[no]=0
|
||||
no+=1
|
||||
count=1
|
||||
for i in range(len(data['lines'])):
|
||||
line=data['lines'][i]
|
||||
item_vals=vals.copy()
|
||||
item_vals['no']=count
|
||||
item_vals['number']=line['number']
|
||||
item_vals['staff_name']=line['staff_name']
|
||||
no=0
|
||||
for sub_line in line['sub_lines']:
|
||||
item_vals['item%s'%no]=sub_line['amt']
|
||||
no+=1
|
||||
item_vals['total']=line['total']
|
||||
items.append(item_vals)
|
||||
count+=1
|
||||
data['items']=items
|
||||
data['total_lines_txt']=[{}]
|
||||
no=0
|
||||
for tline in data['total_lines']:
|
||||
data['total_lines_txt'][0]['item%s'%no]=tline['amt']
|
||||
no+=1
|
||||
return data
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -157,7 +157,7 @@
|
|||
<tr>
|
||||
<th style="text-align:left;width:14%">{{name}}</th>
|
||||
<td style="text-align:right">
|
||||
<a href="#name=clinic_report_labor_cost_summary&defaults.categ_id={{categ_id}}&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.staff_type=nurse&defaults.cycle_id={{cycle_id}}">{{currency amount}}</a>
|
||||
<a href="#name=clinic_report_labor_cost_summary&defaults.categ_id={{categ_id}}&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.staff_type=nurse&defaults.cycle_id={{cycle_id}}">{{amount}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
|
Loading…
Reference in New Issue