report labor cost sub detail
parent
a727a26344
commit
556262f9cc
|
@ -0,0 +1,8 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Report Labor Cost Sub Detail</field>
|
||||||
|
<field name="view_cls">report</field>
|
||||||
|
<field name="model">clinic.report.labor.cost.sub.detail</field>
|
||||||
|
<field name="report_template">report_labor_cost_sub_detail</field>
|
||||||
|
<field name="report_template_xls">report_labor_cost_sub_detail</field>
|
||||||
|
<field name="menu">account_menu</field>
|
||||||
|
</action>
|
|
@ -9,6 +9,7 @@
|
||||||
<header string="REPORTS"/>
|
<header string="REPORTS"/>
|
||||||
<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 Daily" action="clinic_report_labor_cost_daily"/>
|
<item string="Labor Cost Daily" action="clinic_report_labor_cost_daily"/>
|
||||||
<item string="Labor Cost Overtime" action="clinic_report_labor_cost_overtime"/>
|
<item string="Labor Cost Overtime" action="clinic_report_labor_cost_overtime"/>
|
||||||
<divider/>
|
<divider/>
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<form model="clinic.report.labor.cost.sub.detail">
|
||||||
|
<field name="date" mode="month" onchange="onchange_date" span="2"/>
|
||||||
|
<field name="date_from" required="1" span="2"/>
|
||||||
|
<field name="date_to" required="1" span="2"/>
|
||||||
|
<field name="staff_type" onchange="onchange_type" span="2"/>
|
||||||
|
<field name="staff_id" domain='[["type","=",type]]' span="2"/>
|
||||||
|
<field name="department_id" span="2"/>
|
||||||
|
</form>
|
|
@ -77,6 +77,7 @@ from . import report_staff_fee_sum
|
||||||
from . import report_payment_matching
|
from . import report_payment_matching
|
||||||
from . import report_labor_cost_summary
|
from . import report_labor_cost_summary
|
||||||
from . import report_labor_cost_detail
|
from . import report_labor_cost_detail
|
||||||
|
from . import report_labor_cost_sub_detail
|
||||||
from . import report_labor_cost_daily
|
from . import report_labor_cost_daily
|
||||||
from . import report_labor_cost_overtime
|
from . import report_labor_cost_overtime
|
||||||
from . import branch
|
from . import branch
|
||||||
|
|
|
@ -56,12 +56,11 @@ class ReportLaborCostDetail(Model):
|
||||||
defaults=self.default_get(context=context)
|
defaults=self.default_get(context=context)
|
||||||
date_from=defaults.get("date_from")
|
date_from=defaults.get("date_from")
|
||||||
date_to=defaults.get("date_to")
|
date_to=defaults.get("date_to")
|
||||||
staff_type=defaults.get("staff_type")
|
staff_type=defaults.get("type")
|
||||||
staff_id=defaults.get("staff_id")
|
staff_id=defaults.get("staff_id")
|
||||||
department_id=defaults.get("department_id")
|
department_id=defaults.get("department_id")
|
||||||
dom=[]
|
dom=[]
|
||||||
if ids:
|
if ids:
|
||||||
print("get from ids")
|
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
date_from=obj.date_from
|
date_from=obj.date_from
|
||||||
date_to=obj.date_to
|
date_to=obj.date_to
|
||||||
|
@ -127,6 +126,14 @@ class ReportLaborCostDetail(Model):
|
||||||
dates[date][dpt.name]['qty']+=qty
|
dates[date][dpt.name]['qty']+=qty
|
||||||
lines=[]
|
lines=[]
|
||||||
dpts=get_model("clinic.department").search_read([],['name'])
|
dpts=get_model("clinic.department").search_read([],['name'])
|
||||||
|
# link to sub detail
|
||||||
|
for dpt in dpts:
|
||||||
|
dpt.update({
|
||||||
|
'staff_id': staff_id,
|
||||||
|
'staff_type': staff_type,
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
})
|
||||||
dpts=sorted(dpts, key=lambda b: b['name'])
|
dpts=sorted(dpts, key=lambda b: b['name'])
|
||||||
no=1
|
no=1
|
||||||
dlines=sorted(dates.keys()) #sort by staff name
|
dlines=sorted(dates.keys()) #sort by staff name
|
||||||
|
@ -192,6 +199,9 @@ class ReportLaborCostDetail(Model):
|
||||||
staff_name=staff.name or ''
|
staff_name=staff.name or ''
|
||||||
data={
|
data={
|
||||||
'staff_name': staff_name,
|
'staff_name': staff_name,
|
||||||
|
'staff_id': staff_id,
|
||||||
|
'staff_type': staff_type,
|
||||||
|
'department_id': "0", #XXX
|
||||||
'date_from': date_from,
|
'date_from': date_from,
|
||||||
'date_to': date_to,
|
'date_to': date_to,
|
||||||
'dpts': dpts,
|
'dpts': dpts,
|
||||||
|
|
|
@ -0,0 +1,147 @@
|
||||||
|
import time
|
||||||
|
from calendar import monthrange
|
||||||
|
|
||||||
|
from netforce.model import Model,fields,get_model
|
||||||
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
|
class ReportLaborCostSubDetail(Model):
|
||||||
|
_name="clinic.report.labor.cost.sub.detail"
|
||||||
|
_string="Report Labor Cost Sub Detail"
|
||||||
|
_transient=True
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
"date": fields.Date("Month"),
|
||||||
|
"date_from": fields.Date("From", required=True),
|
||||||
|
"date_to": fields.Date("To", required=True),
|
||||||
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
|
'staff_id': fields.Many2One("clinic.staff","Staff"),
|
||||||
|
"staff_type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"),
|
||||||
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
|
}
|
||||||
|
|
||||||
|
def _get_date_from(self,context={}):
|
||||||
|
year,month=time.strftime("%Y-%m").split("-")
|
||||||
|
return '%s-%s-01'%(year,month)
|
||||||
|
|
||||||
|
def _get_date_to(self,context={}):
|
||||||
|
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
||||||
|
weekday, total_day=monthrange(int(year), int(month))
|
||||||
|
return "%s-%s-%s"%(year,month,total_day)
|
||||||
|
|
||||||
|
def default_get(self,field_names=None,context={},**kw):
|
||||||
|
defaults=context.get("defaults",{})
|
||||||
|
date_from=defaults.get("date_from")
|
||||||
|
if not date_from:
|
||||||
|
date_from=self._get_date_from()
|
||||||
|
date_to=defaults.get("date_to")
|
||||||
|
if not date_to:
|
||||||
|
date_to=self._get_date_to()
|
||||||
|
staff_type=defaults.get("staff_type","doctor")
|
||||||
|
staff_id=int(defaults.get('staff_id', "0"))
|
||||||
|
department_id=int(defaults.get('department_id', "0"))
|
||||||
|
res={
|
||||||
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
'staff_type': staff_type,
|
||||||
|
'staff_id': staff_id and staff_id or None,
|
||||||
|
'department_id': department_id and department_id or None,
|
||||||
|
}
|
||||||
|
print('res ', res)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def get_report_data(self,ids,context={}):
|
||||||
|
company_id=get_active_company()
|
||||||
|
comp=get_model("company").browse(company_id)
|
||||||
|
defaults=self.default_get(context=context)
|
||||||
|
date_from=defaults.get("date_from")
|
||||||
|
date_to=defaults.get("date_to")
|
||||||
|
staff_type=defaults.get("staff_type")
|
||||||
|
staff_id=defaults.get("staff_id")
|
||||||
|
department_id=defaults.get("department_id")
|
||||||
|
staff_name=''
|
||||||
|
dom=[]
|
||||||
|
if ids:
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
date_from=obj.date_from
|
||||||
|
date_to=obj.date_to
|
||||||
|
staff_id=obj.staff_id.id
|
||||||
|
staff_name=obj.staff_id.name or ""
|
||||||
|
staff_type=obj.staff_type
|
||||||
|
department_id=obj.department_id.id
|
||||||
|
dom.append(['date','>=',date_from])
|
||||||
|
dom.append(['date','<=',date_to])
|
||||||
|
if staff_id and staff_type=='doctor':
|
||||||
|
dom.append(['staff_id','=',staff_id])
|
||||||
|
elif staff_id and staff_type=='nurse':
|
||||||
|
pass
|
||||||
|
if staff_type:
|
||||||
|
dom.append(['type','=',staff_type])
|
||||||
|
if department_id:
|
||||||
|
dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
|
||||||
|
if not staff_id:
|
||||||
|
return {}
|
||||||
|
def replace_quote(dom=""):
|
||||||
|
return dom.replace("'","\"")
|
||||||
|
lines=[]
|
||||||
|
amount_total=0
|
||||||
|
for line in get_model("clinic.labor.cost.line").search_browse(dom):
|
||||||
|
lcost=line.labor_cost_id
|
||||||
|
citem=lcost.cycle_item_id
|
||||||
|
date=citem.date
|
||||||
|
dpt=citem.department_id
|
||||||
|
amount=line.amount or 0
|
||||||
|
qty=line.qty or 0
|
||||||
|
if qty:
|
||||||
|
amount=amount/qty
|
||||||
|
for hdcase in citem.hd_cases:
|
||||||
|
patient=hdcase.patient_id
|
||||||
|
doctor=hdcase.doctor_id
|
||||||
|
vals={
|
||||||
|
'date': date,
|
||||||
|
'patient_name': patient.name or "",
|
||||||
|
'department_name': dpt.name or "",
|
||||||
|
'amount': amount,
|
||||||
|
}
|
||||||
|
if staff_type=='doctor' and doctor.id==staff_id:
|
||||||
|
lines.append(vals)
|
||||||
|
amount_total+=amount
|
||||||
|
elif staff_type=='nurse':
|
||||||
|
lines.append(vals)
|
||||||
|
amount_total+=amount
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
slines=[]
|
||||||
|
no=1
|
||||||
|
for line in sorted(lines,key=lambda x: (x['date'], x['department_name'])):
|
||||||
|
line['no']=no
|
||||||
|
slines.append(line)
|
||||||
|
no+=1
|
||||||
|
|
||||||
|
data={
|
||||||
|
'staff_name': staff_name,
|
||||||
|
'staff_id': staff_id,
|
||||||
|
'staff_type': staff_type,
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
'comp_name': comp.name or 0,
|
||||||
|
'lines': slines,
|
||||||
|
'amount_total': amount_total,
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
|
||||||
|
def onchange_date(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
date=data['date']
|
||||||
|
year,month,day=date.split("-")
|
||||||
|
weekday, total_day=monthrange(int(year), int(month))
|
||||||
|
data['date_from']="%s-%s-01"%(year,month)
|
||||||
|
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def onchange_type(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
data['staff_id']=None
|
||||||
|
return data
|
||||||
|
|
||||||
|
ReportLaborCostSubDetail.register()
|
Binary file not shown.
|
@ -6,14 +6,18 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th style="text-align:center" colspan="{{comp_span}}">{{comp_name}}</th>
|
<th style="text-align:center" colspan="{{comp_span}}">
|
||||||
|
<a href="#name=clinic_report_labor_cost_sub_detail&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.department_id={{department_id}}">{{comp_name}}</a>
|
||||||
|
</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th rowspan="2">#</th>
|
<th rowspan="2">#</th>
|
||||||
<th rowspan="2">วันที่</th>
|
<th rowspan="2">วันที่</th>
|
||||||
{{#each dpts}}
|
{{#each dpts}}
|
||||||
<th rowspan="2" colspan="2" style="text-align:center">{{name}}</th>
|
<th rowspan="2" colspan="2" style="text-align:center">
|
||||||
|
<a href="#name=clinic_report_labor_cost_sub_detail&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.department_id={{id}}">{{name}}</a>
|
||||||
|
</th>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<th rowspan="2" colspan="2" style="text-align:center;">รวม</th>
|
<th rowspan="2" colspan="2" style="text-align:center;">รวม</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<p></p>
|
||||||
|
{{#if lines}}
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="text-align:center">#</th>
|
||||||
|
<th style="text-align:center">Date</th>
|
||||||
|
<th style="text-align:center">Patient</th>
|
||||||
|
<th style="text-align:center">Department</th>
|
||||||
|
<th style="text-align:center">Amount</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each lines }}
|
||||||
|
<tr>
|
||||||
|
<td>{{no}}</th>
|
||||||
|
<td>{{date}}</th>
|
||||||
|
<td>{{patient_name}}</td>
|
||||||
|
<td>{{department_name}}</td>
|
||||||
|
<td style="text-align:right;">{{currency amount zero=""}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th>รวม</th>
|
||||||
|
<th style="text-align:right;">{{currency amount_total zero=""}}</th>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
{{else}}
|
||||||
|
No items to show
|
||||||
|
{{/if}}
|
|
@ -1,20 +1,18 @@
|
||||||
todo:
|
todo:
|
||||||
|
- report k. boy (sub detail)
|
||||||
|
- change by department
|
||||||
|
===============================
|
||||||
|
|
||||||
- compute labor cost
|
- compute labor cost
|
||||||
- update level -> ok
|
- update level -> ok
|
||||||
- set patient_id with domain state=='admit' -> ok
|
- set patient_id with domain state=='admit' -> ok
|
||||||
|
|
||||||
convbal -> not yet (wait yui) -> ok but have to update memo
|
convbal -> not yet (wait yui) -> ok but have to update memo
|
||||||
|
|
||||||
post 10,000 invoices per one time -> ask david
|
post 10,000 invoices per one time -> ask david
|
||||||
patient & staff
|
patient & staff
|
||||||
- split name -> not yet
|
- split name -> not yet
|
||||||
staff have multi department -> added but set have to set permission
|
staff have multi department -> added but set have to set permission
|
||||||
- many2many
|
- many2many
|
||||||
|
|
||||||
show epo(yes) in list of hd case ->ok
|
show epo(yes) in list of hd case ->ok
|
||||||
matching payment > ok
|
matching payment > ok
|
||||||
create contact from staff -> ok
|
create contact from staff -> ok
|
||||||
script to clear invoice -> ok
|
script to clear invoice -> ok
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue