diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py index 37d746d..4c751aa 100644 --- a/netforce_clinic/models/report_labor_cost.py +++ b/netforce_clinic/models/report_labor_cost.py @@ -73,7 +73,6 @@ class ReportLaborCost(Model): hdcases={} hdcase_obj=get_model("clinic.hd.case") dstates=dict(hdcase_obj._fields['state'].selection) - print('dom ', dom) for hdcase in hdcase_obj.search_browse(dom): dpt=hdcase.department_id state=hdcase.state or '' @@ -95,6 +94,9 @@ class ReportLaborCost(Model): dom=dom.replace("False","false") dom=dom.replace("True","true") return dom.replace("'","\"") + st=get_model('clinic.setting').browse(1) + vark=st.var_k or 0 + cost_per_case=st.cost_per_case or 0 lines=[] dom=[] dom.append(["date",">=",date_from]) @@ -136,6 +138,7 @@ class ReportLaborCost(Model): total_hdcase+=qty dlines=[] nlines=[] + ctlines=[] if report_type=='cross': dom=[ ['date','>=',date_from], @@ -144,8 +147,10 @@ class ReportLaborCost(Model): ] ddata={} ndata={} - for line in get_model('clinic.labor.cost.line').search_browse(dom): + ctdata={} + for line in get_model('clinic.labor.cost.line').search_browse(dom,order="department_id.name"): cost_id=line.labor_cost_id + categ_name=line.categ_id.name or "" citem=cost_id.cycle_item_id department=citem.department_id dpt_name=department.name or '' @@ -155,28 +160,81 @@ class ReportLaborCost(Model): ddata[dpt_name]=0 ddata[dpt_name]+=qty elif line.type=='nurse': + if categ_name not in ctdata.keys(): + ctdata[categ_name]=0 + ctdata[categ_name]+=line.pay_amount or 0 if dpt_name not in ndata.keys(): ndata[dpt_name]=set() for hdcase in citem.hd_cases: ndata[dpt_name].update({hdcase.id}) + total_amount=0 + for categ_name,amount in ctdata.items(): + total_amount+=amount + ctlines.append({ + 'name': categ_name, + 'amount': amount, + }) + ctlines.append({ + 'name': 'รวม', + 'amount': total_amount, + }) dlines.append({ 'name': 'แพทย์', 'qty': 'จำนวนครั้ง', + 'qty2': 'ไม่จ่ายแพทย์', + 'total_qty': 'รวมจำนวนครั้ง', + 'cost': 'เป็นยอดเงินรวม', + 'desc': True, }) for dt_name,qty in ddata.items(): + walkin=0 + cost=(walkin+qty)*cost_per_case dlines.append({ 'name': dt_name, 'qty': qty, + 'qty2': walkin, + 'total_qty': walkin+qty, + 'cost': cost, + 'total': 0, }) + dlines.append({ + 'name': 'รวม', + 'qty': 0, + 'qty2': 0, + 'total_qty':0, + 'cost': 0, + }) + for dline in dlines[1:-1]: + dlines[-1]['qty']+=dline['qty'] or 0 + dlines[-1]['qty2']+=dline['qty2'] or 0 + dlines[-1]['total_qty']+=dline['total_qty'] or 0 + dlines[-1]['cost']+=dline['cost'] or 0 + nlines.append({ 'name': 'พยาบาล', 'qty': 'จำนวนครั้ง', + 'cost': 'เป็นยอดเงินรวม', + 'total': 'รวม', + 'desc': True, }) for dt_name, hdcases in ndata.items(): + total_hdcase=len(hdcases) nlines.append({ 'name': dt_name, - 'qty': len(hdcases) + 'qty': total_hdcase, + 'cost': total_hdcase*vark, + 'total': 0, }) + nlines.append({ + 'name': 'รวม', + 'qty': 0, + 'cost': 0, + 'total': 0, + }) + for nline in nlines[1:-1]: + nlines[-1]['qty']+=nline['qty'] or 0 + nlines[-1]['cost']+=nline['cost'] or 0 + nlines[-1]['total']+=nline['total'] or 0 data={ 'company_name': '%s %s' % (company.name or "", sub_name), 'date': date, @@ -185,13 +243,12 @@ class ReportLaborCost(Model): 'lines': lines, 'dlines': dlines, 'nlines': nlines, + 'ctlines': ctlines, 'total_hdcase': total_hdcase, 'branch_id': branch_id, 'department_id': department_id, 'show_detail': show_detail, 'report_type': report_type, - #'ddata': ddata, - #'ndata': ndata, } return data diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost.hbs index 8bcb41f..f133bf7 100644 --- a/netforce_clinic/templates/report_labor_cost.hbs +++ b/netforce_clinic/templates/report_labor_cost.hbs @@ -1,9 +1,6 @@
-

- {{company_name}} -

- From {{date_from}} To {{date_to}} + จาก {{date_from}} ถึง {{date_to}}

{{#ifeq report_type "detail"}} @@ -64,12 +61,47 @@ {{#each dlines }} - {{name}} + {{#if desc}} + {{name}} + {{else}} + {{name}} + {{/if}} {{/each}} {{#each dlines }} - {{qty}} + {{#if desc}} + {{qty}} + {{else}} + {{currency qty}} + {{/if}} + {{/each}} + + + {{#each dlines }} + {{#if desc}} + {{qty2}} + {{else}} + {{currency qty2}} + {{/if}} + {{/each}} + + + {{#each dlines }} + {{#if desc}} + {{total_qty}} + {{else}} + {{currency total_qty}} + {{/if}} + {{/each}} + + + {{#each dlines }} + {{#if desc}} + {{cost}} + {{else}} + {{currency cost}} + {{/if}} {{/each}} @@ -78,14 +110,41 @@ {{#each nlines }} - {{name}} + {{#if desc}} + {{name}} + {{else}} + {{name}} + {{/if}} {{/each}} {{#each nlines }} - {{qty}} + {{#if desc}} + {{qty}} + {{else}} + {{currency qty}} + {{/if}} + {{/each}} + + + {{#each nlines }} + {{#if desc}} + {{cost}} + {{else}} + {{currency cost}} + {{/if}} {{/each}} + + + {{#each ctlines }} + + + + + {{/each}} + +
{{name}}{{currency amount}}
{{/ifeq}}