labor cost
parent
e35b55736b
commit
f3d340b744
|
@ -21,10 +21,10 @@
|
||||||
<field name="staff_id"/>
|
<field name="staff_id"/>
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<field name="qty" onchange="onchange_line"/>
|
<field name="qty" string="Qty" onchange="onchange_line"/>
|
||||||
<field name="rate" onchange="onchange_line"/>
|
<field name="rate" onchange="onchange_line"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
<field name="report_staff_id"/>
|
<field name="report_staff_id" readonly="1"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
<field name="dcost" string="Total" span="3" offset="9"/>
|
<field name="dcost" string="Total" span="3" offset="9"/>
|
||||||
|
@ -35,10 +35,12 @@
|
||||||
<field name="staff_id"/>
|
<field name="staff_id"/>
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<field name="qty" string="PT" onchange="onchange_line"/>
|
<field name="max_cycle" />
|
||||||
|
<field name="qty" onchange="onchange_line"/>
|
||||||
|
<field name="over_cycle" />
|
||||||
<field name="rate" onchange="onchange_line"/>
|
<field name="rate" onchange="onchange_line"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
<field name="report_staff_id"/>
|
<field name="report_staff_id2"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
<field name="ncost" string="Total" span="3" offset="9"/>
|
<field name="ncost" string="Total" span="3" offset="9"/>
|
||||||
|
|
|
@ -1,18 +1,32 @@
|
||||||
<form model="clinic.report.staff">
|
<form model="clinic.report.staff">
|
||||||
<head>
|
<head>
|
||||||
<button string="Print" icon="print"/>
|
<button string="Print" icon="print" action="report_staff_print"/>
|
||||||
<button string="Options" dropdown="1">
|
|
||||||
<item string="TODO"/>
|
|
||||||
</button>
|
|
||||||
</head>
|
</head>
|
||||||
<group form_layout="stacked">
|
<group form_layout="stacked">
|
||||||
<field name="date_from" span="3"/>
|
<field name="entry_id" required="1" span="3"/>
|
||||||
<field name="date_to" span="3"/>
|
<field name="date_from" required="1" span="3"/>
|
||||||
<field name="staff_id" span="3"/>
|
<field name="date_to" required="1" span="3"/>
|
||||||
|
<field name="staff_id" required="1" span="3"/>
|
||||||
|
<field name="staff_type" invisible="1" span="3"/>
|
||||||
</group>
|
</group>
|
||||||
<field name="lines" nolabel="1">
|
<group attrs='{"invisible":[["staff_type","=","nurse"]]}'>
|
||||||
<list>
|
<field name="lines" nolabel="2">
|
||||||
<field name="hd_case_id"/>
|
<list>
|
||||||
</list>
|
<field name="date"/>
|
||||||
</field>
|
<field name="hd_case_id"/>
|
||||||
|
<field name="patient_id"/>
|
||||||
|
<field name="amount"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</group>
|
||||||
|
<group attrs='{"invisible":[["staff_type","=","doctor"]]}'>
|
||||||
|
<field name="patients" nolabel="1">
|
||||||
|
<list>
|
||||||
|
<field name="patient_id"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</group>
|
||||||
|
<foot>
|
||||||
|
<!--<button string="Compute" method="compute" icon="repeat"/>-->
|
||||||
|
</foot>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<list model="clinic.report.staff">
|
<list model="clinic.report.staff">
|
||||||
<field name="date_from"/>
|
<field name="entry_id"/>
|
||||||
<field name="date_to"/>
|
|
||||||
<field name="staff_id"/>
|
<field name="staff_id"/>
|
||||||
<field name="hdcase_total"/>
|
<field name="staff_type"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -65,6 +65,7 @@ from . import report_recent_patient
|
||||||
from . import report_discontinue_patient
|
from . import report_discontinue_patient
|
||||||
from . import report_staff
|
from . import report_staff
|
||||||
from . import report_staff_line
|
from . import report_staff_line
|
||||||
|
from . import report_staff_patient
|
||||||
from . import report_staff_fee
|
from . import report_staff_fee
|
||||||
from . import report_staff_fee_detail
|
from . import report_staff_fee_detail
|
||||||
from . import report_staff_fee_sum
|
from . import report_staff_fee_sum
|
||||||
|
|
|
@ -49,7 +49,7 @@ class LaborCostEntry(Model):
|
||||||
"lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Lines"),
|
"lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Lines"),
|
||||||
"nurse_lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Nurse Lines",domain=[['type','=','nurse']]),
|
"nurse_lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Nurse Lines",domain=[['type','=','nurse']]),
|
||||||
"doctor_lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Doctor Lines",domain=[['type','=','doctor']]),
|
"doctor_lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Doctor Lines",domain=[['type','=','doctor']]),
|
||||||
'state': fields.Selection([['draft','Draft'],['approved','Approved']],"State"),
|
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
|
||||||
'user_id': fields.Many2One("base.user","Approver",search=True),
|
'user_id': fields.Many2One("base.user","Approver",search=True),
|
||||||
'note': fields.Text("Note"),
|
'note': fields.Text("Note"),
|
||||||
'company_id': fields.Many2One("company","Company"),
|
'company_id': fields.Many2One("company","Company"),
|
||||||
|
@ -67,7 +67,6 @@ class LaborCostEntry(Model):
|
||||||
return "%s-%s-%s"%(year,month,total_day)
|
return "%s-%s-%s"%(year,month,total_day)
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'state': 'draft',
|
|
||||||
'name': '/',
|
'name': '/',
|
||||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||||
'date_from': _get_date_from,
|
'date_from': _get_date_from,
|
||||||
|
@ -116,14 +115,14 @@ class LaborCostEntry(Model):
|
||||||
'date_from': obj.date_from,
|
'date_from': obj.date_from,
|
||||||
'date_to': obj.date_to,
|
'date_to': obj.date_to,
|
||||||
'staff_id': staff.id,
|
'staff_id': staff.id,
|
||||||
|
'entry_id': obj.id,
|
||||||
|
'staff_type': staff.type,
|
||||||
}),
|
}),
|
||||||
'items': set(),
|
'items': set(),
|
||||||
}
|
}
|
||||||
# create staff report
|
|
||||||
staffs[staff.id]['qty']+=qty
|
staffs[staff.id]['qty']+=qty
|
||||||
staffs[staff.id]['amt']+=amt
|
staffs[staff.id]['amt']+=amt
|
||||||
staffs[staff.id]['items'].update({citem.id})
|
staffs[staff.id]['items'].update({citem.id})
|
||||||
|
|
||||||
lines=[]
|
lines=[]
|
||||||
timenow=time.strftime("%Y-%m-%d")
|
timenow=time.strftime("%Y-%m-%d")
|
||||||
for staff_id, vals in staffs.items():
|
for staff_id, vals in staffs.items():
|
||||||
|
@ -132,24 +131,37 @@ class LaborCostEntry(Model):
|
||||||
state=vals['state']
|
state=vals['state']
|
||||||
report_staff_id=vals['report_staff_id']
|
report_staff_id=vals['report_staff_id']
|
||||||
report_staff=get_model("clinic.report.staff").browse(report_staff_id)
|
report_staff=get_model("clinic.report.staff").browse(report_staff_id)
|
||||||
# find hd case for each staff
|
|
||||||
|
# Find hd case for each staff
|
||||||
hids=set()
|
hids=set()
|
||||||
|
pids=set()
|
||||||
for item in get_model("clinic.cycle.item").browse(vals['items']):
|
for item in get_model("clinic.cycle.item").browse(vals['items']):
|
||||||
if vals['staff_type']=='nurse':
|
if vals['staff_type']=='nurse':
|
||||||
for hd_case in item.hd_cases:
|
for hd_case in item.hd_cases:
|
||||||
hids.update({hd_case.id})
|
#hids.update({hd_case.id})
|
||||||
|
pids.update({hd_case.patient_id.id})
|
||||||
else:
|
else:
|
||||||
for hd_case in item.hd_cases:
|
for hd_case in item.hd_cases:
|
||||||
doctor_id=hd_case.doctor_id.id
|
doctor_id=hd_case.doctor_id.id
|
||||||
if staff_id==doctor_id:
|
if staff_id==doctor_id:
|
||||||
hids.update({hd_case.id})
|
hids.update({hd_case.id})
|
||||||
|
#pids.update({hd_case.patient_id.id})
|
||||||
rlines=[]
|
rlines=[]
|
||||||
for hid in list(hids):
|
for hid in list(hids):
|
||||||
rlines.append(('create',{
|
rlines.append(('create',{
|
||||||
'hd_case_id': hid,
|
'hd_case_id': hid,
|
||||||
|
'amount': amt/qty, #XXX
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
plines=[]
|
||||||
|
for pid in list(pids):
|
||||||
|
plines.append(('create',{
|
||||||
|
'patient_id': pid,
|
||||||
|
}))
|
||||||
|
|
||||||
report_staff.write({
|
report_staff.write({
|
||||||
'lines': rlines,
|
'lines': rlines,
|
||||||
|
'patients': plines,
|
||||||
})
|
})
|
||||||
#####
|
#####
|
||||||
|
|
||||||
|
@ -199,9 +211,17 @@ class LaborCostEntry(Model):
|
||||||
def update_amount(self,context={}):
|
def update_amount(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
total_amt=0.0
|
total_amt=0.0
|
||||||
for line in data['lines']:
|
total_damt=0.0
|
||||||
|
total_namt=0.0
|
||||||
|
for line in data['doctor_lines']:
|
||||||
total_amt+=line['amount']
|
total_amt+=line['amount']
|
||||||
data['total_amt']=total_amt
|
total_damt+=line['amount']
|
||||||
|
for line in data['nurse_lines']:
|
||||||
|
total_amt+=line['amount']
|
||||||
|
total_namt+=line['amount']
|
||||||
|
data['total']=total_amt
|
||||||
|
data['dcost']=total_damt
|
||||||
|
data['ncost']=total_namt
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_date(self,context={}):
|
def onchange_date(self,context={}):
|
||||||
|
@ -217,7 +237,15 @@ class LaborCostEntry(Model):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
path=context['path']
|
path=context['path']
|
||||||
line=get_data_path(data,path,parent=True)
|
line=get_data_path(data,path,parent=True)
|
||||||
line['amount']=(line['qty'] or 0) * (line['rate'] or 0.0)
|
cmax=line['max_cycle'] or 0
|
||||||
|
qty=line['qty'] or 0
|
||||||
|
rate=line['rate'] or 0
|
||||||
|
over=min(0,cmax-qty)
|
||||||
|
print('xx ', cmax, qty, over)
|
||||||
|
if cmax<=0:
|
||||||
|
over=0
|
||||||
|
line['amount']=qty*rate
|
||||||
|
line['over_cycle']=over
|
||||||
data=self.update_amount(context)
|
data=self.update_amount(context)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,38 @@ class LaborCostEntryLine(Model):
|
||||||
_name="clinic.labor.cost.entry.line"
|
_name="clinic.labor.cost.entry.line"
|
||||||
_string="Labor Cost Entry Line"
|
_string="Labor Cost Entry Line"
|
||||||
_multi_company=True
|
_multi_company=True
|
||||||
|
|
||||||
|
def _get_all(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
staff=obj.staff_id
|
||||||
|
cmax=staff.max_cycle or 0
|
||||||
|
qty=obj.qty or 0
|
||||||
|
over=min(0,cmax-qty)
|
||||||
|
if not cmax: #XXX
|
||||||
|
over=0
|
||||||
|
res[obj.id]={
|
||||||
|
'max_cycle': cmax,
|
||||||
|
'over_cycle': over,
|
||||||
|
'report_staff_id2': obj.report_staff_id.id, #XXX show PT
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'entry_id': fields.Many2One("clinic.labor.cost.entry","Entry",required=True,on_delete="cascade"),
|
'entry_id': fields.Many2One("clinic.labor.cost.entry","Entry",required=True,on_delete="cascade"),
|
||||||
'staff_id': fields.Many2One("clinic.staff","Staff",required=True),
|
'staff_id': fields.Many2One("clinic.staff","Staff",required=True),
|
||||||
'date': fields.Date("Date"),
|
'date': fields.Date("Date"),
|
||||||
'qty': fields.Integer("#HDCase"),
|
'qty': fields.Integer("#Cycle"), #Cycle Item XXX
|
||||||
'rate': fields.Float("Rate Avg."),
|
'rate': fields.Float("Rate Avg."),
|
||||||
'amount': fields.Float("Amount"),
|
'amount': fields.Float("Amount"),
|
||||||
'company_id': fields.Many2One("company","Company"),
|
'company_id': fields.Many2One("company","Company"),
|
||||||
'department_id': fields.Many2One("clinic.department","Department"),
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type"),
|
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type"),
|
||||||
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
|
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
|
||||||
'report_staff_id': fields.Many2One("clinic.report.staff","#"),
|
'report_staff_id': fields.Many2One("clinic.report.staff","#HDCase"),
|
||||||
|
'max_cycle': fields.Integer("Max Cycle", function="_get_all",function_multi=True),
|
||||||
|
'over_cycle': fields.Integer("Over Cycle", function="_get_all",function_multi=True),
|
||||||
|
'report_staff_id2': fields.Many2One("clinic.report.staff","#PT",function="_get_all",function_multi=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_order="type"
|
_order="type"
|
||||||
|
|
|
@ -16,19 +16,25 @@ class ReportStaff(Model):
|
||||||
def _get_all(self,ids,context={}):
|
def _get_all(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
total=len(obj.lines)
|
htotal=len(obj.lines)
|
||||||
|
ptotal=len(obj.patients)
|
||||||
res[obj.id]={
|
res[obj.id]={
|
||||||
'hdcase_total': total,
|
'hdcase_total': htotal,
|
||||||
|
'patient_total': ptotal,
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'staff_id': fields.Many2One("clinic.staff",'Staff'),
|
'entry_id': fields.Many2One("clinic.labor.cost.entry",'Labor Cost Entry',search=True),
|
||||||
|
'staff_id': fields.Many2One("clinic.staff",'Staff',search=True),
|
||||||
|
"staff_type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type",search=True),
|
||||||
'name': fields.Char("Name", function="_get_store",function_multi=True,store=True),
|
'name': fields.Char("Name", function="_get_store",function_multi=True,store=True),
|
||||||
'date_from': fields.Date("From"),
|
'date_from': fields.Date("From",search=True),
|
||||||
'date_to': fields.Date("To"),
|
'date_to': fields.Date("To"),
|
||||||
'hdcase_total': fields.Char("Total", function="_get_all",function_multi=True),
|
'hdcase_total': fields.Char("HDCase Total", function="_get_all",function_multi=True),
|
||||||
|
'patient_total': fields.Char("Patient Total", function="_get_all",function_multi=True),
|
||||||
'lines': fields.One2Many("clinic.report.staff.line","report_staff_id","Lines"),
|
'lines': fields.One2Many("clinic.report.staff.line","report_staff_id","Lines"),
|
||||||
|
'patients': fields.One2Many("clinic.report.staff.patient","report_staff_id","Patient Lines"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def create(self,vals,**kw):
|
def create(self,vals,**kw):
|
||||||
|
@ -39,5 +45,9 @@ class ReportStaff(Model):
|
||||||
def write(self,ids,vals,**kw):
|
def write(self,ids,vals,**kw):
|
||||||
super().write(ids,vals,**kw)
|
super().write(ids,vals,**kw)
|
||||||
self.function_store(ids)
|
self.function_store(ids)
|
||||||
|
|
||||||
|
def get_data(self,context={}):
|
||||||
|
data={}
|
||||||
|
return data
|
||||||
|
|
||||||
ReportStaff.register()
|
ReportStaff.register()
|
||||||
|
|
|
@ -3,9 +3,22 @@ from netforce.model import Model, fields
|
||||||
class ReportStaffLine(Model):
|
class ReportStaffLine(Model):
|
||||||
_name='clinic.report.staff.line'
|
_name='clinic.report.staff.line'
|
||||||
_string="Report Staff Line"
|
_string="Report Staff Line"
|
||||||
|
|
||||||
|
def _get_all(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
res[obj.id]={
|
||||||
|
'date': obj.hd_case_id.date,
|
||||||
|
'patient_id': obj.hd_case_id.patient_id.id,
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'report_staff_id': fields.Many2One("clinic.report.staff","Report Staff", required=True, on_delete="cascade"),
|
'report_staff_id': fields.Many2One("clinic.report.staff","Report Staff", required=True, on_delete="cascade"),
|
||||||
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"),
|
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"),
|
||||||
|
'date': fields.Date("Date",function="_get_all", function_multi=True),
|
||||||
|
'patient_id': fields.Many2One("clinic.patient","Patient",function="_get_all",function_multi=True),
|
||||||
|
'amount': fields.Float("Amount"),
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportStaffLine.register()
|
ReportStaffLine.register()
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
|
||||||
|
class ReportStaffPatient(Model):
|
||||||
|
_name='clinic.report.staff.patient'
|
||||||
|
_string="Report Staff Patient"
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
'report_staff_id': fields.Many2One("clinic.report.staff","Report Staff", required=True, on_delete="cascade"),
|
||||||
|
'patient_id': fields.Many2One("clinic.patient","Patient"),
|
||||||
|
'date': fields.Date("Date"),
|
||||||
|
'amount': fields.Float("Amount"),
|
||||||
|
}
|
||||||
|
|
||||||
|
ReportStaffPatient.register()
|
|
@ -2,12 +2,18 @@ todo:
|
||||||
- accounting
|
- accounting
|
||||||
- labor cost
|
- labor cost
|
||||||
- report ***
|
- report ***
|
||||||
|
- nurse
|
||||||
|
- max cycle
|
||||||
|
- doctor
|
||||||
|
- total hd case
|
||||||
- invoice line -> account -> credit
|
- invoice line -> account -> credit
|
||||||
- debit from hd case setting
|
- debit from hd case setting
|
||||||
- if user select product by them self
|
- if user select product by them self
|
||||||
- credit <= product -> tab -> accounting -> sale -> sale account
|
- credit <= product -> tab -> accounting -> sale -> sale account
|
||||||
- debit <= 1. contact -> tab accounting -> account receiaveble , 2. finacial setting -> account receiable
|
- debit <= 1. contact -> tab accounting -> account receiaveble , 2. finacial setting -> account receiable
|
||||||
- sale medicine
|
- sale medicine
|
||||||
|
- matching payment
|
||||||
|
|
||||||
|
|
||||||
- patient
|
- patient
|
||||||
- link vascular access to patient profile and copy to hd case after confirm on visit -> ok
|
- link vascular access to patient profile and copy to hd case after confirm on visit -> ok
|
||||||
|
|
Loading…
Reference in New Issue