labor cost

conv_bal
watcha.h 2015-02-02 17:35:47 +07:00
parent e35b55736b
commit f3d340b744
10 changed files with 141 additions and 35 deletions

View File

@ -21,10 +21,10 @@
<field name="staff_id"/>
<field name="department_id"/>
<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="amount"/>
<field name="report_staff_id"/>
<field name="report_staff_id" readonly="1"/>
</list>
</field>
<field name="dcost" string="Total" span="3" offset="9"/>
@ -35,10 +35,12 @@
<field name="staff_id"/>
<field name="department_id"/>
<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="amount"/>
<field name="report_staff_id"/>
<field name="report_staff_id2"/>
</list>
</field>
<field name="ncost" string="Total" span="3" offset="9"/>

View File

@ -1,18 +1,32 @@
<form model="clinic.report.staff">
<head>
<button string="Print" icon="print"/>
<button string="Options" dropdown="1">
<item string="TODO"/>
</button>
<button string="Print" icon="print" action="report_staff_print"/>
</head>
<group form_layout="stacked">
<field name="date_from" span="3"/>
<field name="date_to" span="3"/>
<field name="staff_id" span="3"/>
<field name="entry_id" required="1" span="3"/>
<field name="date_from" required="1" 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>
<field name="lines" nolabel="1">
<group attrs='{"invisible":[["staff_type","=","nurse"]]}'>
<field name="lines" nolabel="2">
<list>
<field name="date"/>
<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>

View File

@ -1,6 +1,5 @@
<list model="clinic.report.staff">
<field name="date_from"/>
<field name="date_to"/>
<field name="entry_id"/>
<field name="staff_id"/>
<field name="hdcase_total"/>
<field name="staff_type"/>
</list>

View File

@ -65,6 +65,7 @@ from . import report_recent_patient
from . import report_discontinue_patient
from . import report_staff
from . import report_staff_line
from . import report_staff_patient
from . import report_staff_fee
from . import report_staff_fee_detail
from . import report_staff_fee_sum

View File

@ -49,7 +49,7 @@ class LaborCostEntry(Model):
"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']]),
"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),
'note': fields.Text("Note"),
'company_id': fields.Many2One("company","Company"),
@ -67,7 +67,6 @@ class LaborCostEntry(Model):
return "%s-%s-%s"%(year,month,total_day)
_defaults={
'state': 'draft',
'name': '/',
'date': lambda *a: time.strftime("%Y-%m-%d"),
'date_from': _get_date_from,
@ -116,14 +115,14 @@ class LaborCostEntry(Model):
'date_from': obj.date_from,
'date_to': obj.date_to,
'staff_id': staff.id,
'entry_id': obj.id,
'staff_type': staff.type,
}),
'items': set(),
}
# create staff report
staffs[staff.id]['qty']+=qty
staffs[staff.id]['amt']+=amt
staffs[staff.id]['items'].update({citem.id})
lines=[]
timenow=time.strftime("%Y-%m-%d")
for staff_id, vals in staffs.items():
@ -132,24 +131,37 @@ class LaborCostEntry(Model):
state=vals['state']
report_staff_id=vals['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()
pids=set()
for item in get_model("clinic.cycle.item").browse(vals['items']):
if vals['staff_type']=='nurse':
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:
for hd_case in item.hd_cases:
doctor_id=hd_case.doctor_id.id
if staff_id==doctor_id:
hids.update({hd_case.id})
#pids.update({hd_case.patient_id.id})
rlines=[]
for hid in list(hids):
rlines.append(('create',{
'hd_case_id': hid,
'amount': amt/qty, #XXX
}))
plines=[]
for pid in list(pids):
plines.append(('create',{
'patient_id': pid,
}))
report_staff.write({
'lines': rlines,
'patients': plines,
})
#####
@ -199,9 +211,17 @@ class LaborCostEntry(Model):
def update_amount(self,context={}):
data=context['data']
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']
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
def onchange_date(self,context={}):
@ -217,7 +237,15 @@ class LaborCostEntry(Model):
data=context['data']
path=context['path']
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)
return data

View File

@ -8,18 +8,37 @@ class LaborCostEntryLine(Model):
_string="Labor Cost Entry Line"
_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={
'entry_id': fields.Many2One("clinic.labor.cost.entry","Entry",required=True,on_delete="cascade"),
'staff_id': fields.Many2One("clinic.staff","Staff",required=True),
'date': fields.Date("Date"),
'qty': fields.Integer("#HDCase"),
'qty': fields.Integer("#Cycle"), #Cycle Item XXX
'rate': fields.Float("Rate Avg."),
'amount': fields.Float("Amount"),
'company_id': fields.Many2One("company","Company"),
'department_id': fields.Many2One("clinic.department","Department"),
"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),
'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"

View File

@ -16,19 +16,25 @@ class ReportStaff(Model):
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
total=len(obj.lines)
htotal=len(obj.lines)
ptotal=len(obj.patients)
res[obj.id]={
'hdcase_total': total,
'hdcase_total': htotal,
'patient_total': ptotal,
}
return res
_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),
'date_from': fields.Date("From"),
'date_from': fields.Date("From",search=True),
'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"),
'patients': fields.One2Many("clinic.report.staff.patient","report_staff_id","Patient Lines"),
}
def create(self,vals,**kw):
@ -40,4 +46,8 @@ class ReportStaff(Model):
super().write(ids,vals,**kw)
self.function_store(ids)
def get_data(self,context={}):
data={}
return data
ReportStaff.register()

View File

@ -3,9 +3,22 @@ from netforce.model import Model, fields
class ReportStaffLine(Model):
_name='clinic.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={
'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"),
'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()

View File

@ -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()

View File

@ -2,12 +2,18 @@ todo:
- accounting
- labor cost
- report ***
- nurse
- max cycle
- doctor
- total hd case
- invoice line -> account -> credit
- debit from hd case setting
- if user select product by them self
- credit <= product -> tab -> accounting -> sale -> sale account
- debit <= 1. contact -> tab accounting -> account receiaveble , 2. finacial setting -> account receiable
- sale medicine
- matching payment
- patient
- link vascular access to patient profile and copy to hd case after confirm on visit -> ok