diff --git a/netforce_clinic/layouts/clinic_cycle_dialy_form.xml b/netforce_clinic/layouts/clinic_cycle_dialy_form.xml
index 4355c93..6b8abb0 100644
--- a/netforce_clinic/layouts/clinic_cycle_dialy_form.xml
+++ b/netforce_clinic/layouts/clinic_cycle_dialy_form.xml
@@ -12,14 +12,20 @@
+
-
+
+
+
diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml
index 4f812d6..e88c1cc 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_form.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml
@@ -2,7 +2,8 @@
diff --git a/netforce_clinic/models/cycle_dialy.py b/netforce_clinic/models/cycle_dialy.py
index 9e21a4b..1e61d69 100644
--- a/netforce_clinic/models/cycle_dialy.py
+++ b/netforce_clinic/models/cycle_dialy.py
@@ -12,7 +12,7 @@ class CycleDialy(Model):
for obj in self.browse(ids):
total=0.0
for line in obj.lines:
- total+=(line.paid_amount or 0)
+ total+=(line.amount or 0)
res[obj.id]={
'total': total,
}
diff --git a/netforce_clinic/models/cycle_dialy_line.py b/netforce_clinic/models/cycle_dialy_line.py
index 26ed390..5ce20e4 100644
--- a/netforce_clinic/models/cycle_dialy_line.py
+++ b/netforce_clinic/models/cycle_dialy_line.py
@@ -9,7 +9,10 @@ class CycleDialyLine(Model):
"cycle_dialy_id": fields.Many2One("clinic.cycle.dialy","Cycle Dialy"),
'cycle_id': fields.Many2One("clinic.cycle", "Cycle"),
'personal_id': fields.Many2One("clinic.personal", "Personal"),
- 'paid_amount': fields.Float("Paid Amount"),
+ 'level_id': fields.Many2One("clinic.personal.level", "Level"),
+ 'qty': fields.Integer("Qty"),
+ 'rate': fields.Float("Rate"),
+ 'amount': fields.Float("Amount"),
'company_id': fields.Many2One("company","Company"),
"type": fields.Selection([("doctor","Doctor"),('nurse','Nurse'),("personal","Personal")],"Type",required=True),
}
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index 1b744e1..bbf9bcb 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -129,8 +129,10 @@ class CycleItem(Model):
lines.append(('create',{
'cycle_id': obj.cycle_id.id,
'personal_id': nurse.id,
- 'paid_amount': levels[level.id] or 0.0,
+ 'level_id': nurse.level_id.id,
+ 'rate': levels[level.id] or 0.0,
'type': 'nurse',
+ 'qty': 1,
}))
# cost's doctor
@@ -147,17 +149,24 @@ class CycleItem(Model):
if not personal_total.get(personal.id):
personal_total[personal.id]={
'base': 0,
+ 'level_id': personal.level_id.id,
'type': ps.type,
+ 'qty': 0,
}
- personal_total[personal.id]['base']+=base
+ personal_total[personal.id]['base']=base
+ personal_total[personal.id]['qty']+=1
for doctor_id, value in personal_total.items():
base=value['base']
type=value['type']
+ qty=value['qty']
+ level_id=value['level_id']
lines.append(('create',{
'cycle_id': obj.cycle_id.id,
'personal_id': doctor_id,
- 'paid_amount': base,
+ 'level_id': level_id,
+ 'rate': base,
+ 'qty': qty,
'type': type,
}))
@@ -174,15 +183,22 @@ class CycleItem(Model):
mode,vals=line
cycle_id=vals['cycle_id']
personal_id=vals['personal_id']
- paid_amount=vals['paid_amount'] or 0
+ #amount=vals['amount'] or 0
+ rate=vals['rate'] or 0
+ qty=vals['qty'] or 0
+ amount=qty*rate
key=(cycle_id,personal_id)
if not key in glines.keys():
glines[key]={
- 'paid_amount': paid_amount,
+ 'amount': amount,
'type': vals['type'],
+ 'level_id': vals['level_id'],
+ 'rate': rate,
+ 'qty': qty,
}
continue
- glines[key]['paid_amount']+=paid_amount
+ glines[key]['amount']+=amount
+ glines[key]['qty']+=qty
lines=[]
for key,vals in glines.items():
@@ -286,7 +302,9 @@ class CycleItem(Model):
var_pt=len(obj.hd_cases)
var_ptx=var_pt*(obj.var_k or 0)
total_bstr=total_b < 0 and "+%s"%(abs(total_b)) or "-%s"%total_b
- var_x=eval('(%s%s)/%s'%(var_ptx,total_bstr,total_a))
+ var_x=0
+ if total_a:
+ var_x=eval('(%s%s)/%s'%(var_ptx,total_bstr,total_a))
for line in lines:
vals=line[1]
fml=vals['formular'].replace("X","*%s")
@@ -377,5 +395,35 @@ class CycleItem(Model):
'active_id': schedule_id,
}
}
+
+ def load_nurse_from_schedule(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ #TODO check cycle number & date from schedule
+ schedules=get_model("clinic.schedule").search_browse([['date','=',obj.date]])
+ nurses=[]
+ for schedule in schedules:
+ for line in schedule.lines:
+ cycle=line.cycle_id
+ if obj.cycle_id.id==cycle.id:
+ nurse=line.nurse_id
+ level=line.level_id
+ nurses.append(('create',{
+ 'nurse_id': nurse.id,
+ 'level_id': level.id,
+ }))
+ for nurse in obj.nurses:
+ nurse.delete()
+ obj.write({
+ 'nurses': nurses,
+ })
+
+ return {
+ 'next': {
+ 'name': 'clinic_cycle_item',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash': 'Load nurse from schedule to cycle item successfully',
+ }
CycleItem.register()