diff --git a/netforce_clinic/layouts/clinic_labor_cost_entry_form.xml b/netforce_clinic/layouts/clinic_labor_cost_entry_form.xml
index 9a97b90..50c04bc 100644
--- a/netforce_clinic/layouts/clinic_labor_cost_entry_form.xml
+++ b/netforce_clinic/layouts/clinic_labor_cost_entry_form.xml
@@ -21,10 +21,10 @@
-
+
-
+
@@ -35,10 +35,12 @@
-
+
+
+
-
+
diff --git a/netforce_clinic/layouts/clinic_report_staff_form.xml b/netforce_clinic/layouts/clinic_report_staff_form.xml
index 98dd688..a81e1fb 100644
--- a/netforce_clinic/layouts/clinic_report_staff_form.xml
+++ b/netforce_clinic/layouts/clinic_report_staff_form.xml
@@ -1,18 +1,32 @@
diff --git a/netforce_clinic/layouts/clinic_report_staff_list.xml b/netforce_clinic/layouts/clinic_report_staff_list.xml
index 4b46ab0..4b0078c 100644
--- a/netforce_clinic/layouts/clinic_report_staff_list.xml
+++ b/netforce_clinic/layouts/clinic_report_staff_list.xml
@@ -1,6 +1,5 @@
-
-
+
-
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 6549256..430a59f 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -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
diff --git a/netforce_clinic/models/labor_cost_entry.py b/netforce_clinic/models/labor_cost_entry.py
index 557ad0f..d41791f 100644
--- a/netforce_clinic/models/labor_cost_entry.py
+++ b/netforce_clinic/models/labor_cost_entry.py
@@ -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
diff --git a/netforce_clinic/models/labor_cost_entry_line.py b/netforce_clinic/models/labor_cost_entry_line.py
index ecd3813..66b8984 100644
--- a/netforce_clinic/models/labor_cost_entry_line.py
+++ b/netforce_clinic/models/labor_cost_entry_line.py
@@ -7,19 +7,38 @@ class LaborCostEntryLine(Model):
_name="clinic.labor.cost.entry.line"
_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"
diff --git a/netforce_clinic/models/report_staff.py b/netforce_clinic/models/report_staff.py
index f08f7fa..712f3e0 100644
--- a/netforce_clinic/models/report_staff.py
+++ b/netforce_clinic/models/report_staff.py
@@ -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):
@@ -39,5 +45,9 @@ class ReportStaff(Model):
def write(self,ids,vals,**kw):
super().write(ids,vals,**kw)
self.function_store(ids)
+
+ def get_data(self,context={}):
+ data={}
+ return data
ReportStaff.register()
diff --git a/netforce_clinic/models/report_staff_line.py b/netforce_clinic/models/report_staff_line.py
index 7542256..6ec6bc2 100644
--- a/netforce_clinic/models/report_staff_line.py
+++ b/netforce_clinic/models/report_staff_line.py
@@ -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()
diff --git a/netforce_clinic/models/report_staff_patient.py b/netforce_clinic/models/report_staff_patient.py
new file mode 100644
index 0000000..ed782ac
--- /dev/null
+++ b/netforce_clinic/models/report_staff_patient.py
@@ -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()
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index 65df73a..2bf1f7e 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -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