- Information: State Accept 'Finish Treatment', 'Waiting Payment', 'Paid'.
+ Information: State Accept 'Waiting Payment', 'Paid'.
diff --git a/netforce_clinic/layouts/clinic_cycle_item_list.xml b/netforce_clinic/layouts/clinic_cycle_item_list.xml
index a48de9f..9992919 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_list.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_list.xml
@@ -7,6 +7,7 @@
+
diff --git a/netforce_clinic/models/compute_labor_cost.py b/netforce_clinic/models/compute_labor_cost.py
index d2240cc..75cf803 100644
--- a/netforce_clinic/models/compute_labor_cost.py
+++ b/netforce_clinic/models/compute_labor_cost.py
@@ -3,7 +3,6 @@ from calendar import monthrange
from netforce.model import Model,fields,get_model
-
class ComputeLaborCost(Model):
_name="clinic.compute.labor.cost"
_string="Compute Labor Cost"
@@ -66,4 +65,9 @@ class ComputeLaborCost(Model):
data['date_to']="%s-%s-%s"%(year,month,total_day)
return data
+ def onchange_branch(self,context={}):
+ data=context['data']
+ data['department_id']=None
+ return data
+
ComputeLaborCost.register()
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index 4feeebf..3c96062 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -27,8 +27,10 @@ class CycleItem(Model):
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
+ pt_total=len([hdcase for hdcase in obj.hd_cases if hdcase.state in ('waiting_payment','paid')])
res[obj.id]={
'nurse_total': len(obj.lines),
+ 'pt_total': pt_total,
}
return res
@@ -48,6 +50,7 @@ class CycleItem(Model):
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
"state": fields.Selection([("draft","Draft"),('pending','Pending'),("validated","Validated")],"Status",required=True),
'nurse_total': fields.Integer("Nurses",function="_get_all",function_multi=True),
+ 'pt_total': fields.Integer("Patients",function="_get_all",function_multi=True),
'note': fields.Text("Note"),
}
@@ -104,8 +107,8 @@ class CycleItem(Model):
state=hdcase.state
if state=='cancelled':
continue
- if state not in ('completed','waiting_payment','paid'):
- raise Exception('Invalidate cycle item %s: HD Case %s is not completed' % (obj.name, hdcase.patient_id.name))
+ if state not in ('waiting_payment','paid'):
+ raise Exception('Invalidate cycle item %s: Can not validate HD Case %s (State not accept)' % (obj.name, hdcase.patient_id.name))
for obj_id in ids:
lcost_ids=get_model("clinic.labor.cost").search([['cycle_item_id','=',obj_id]])
labor_cost=get_model("clinic.labor.cost")
diff --git a/netforce_clinic/models/labor_cost.py b/netforce_clinic/models/labor_cost.py
index cfb6469..a7ec28a 100644
--- a/netforce_clinic/models/labor_cost.py
+++ b/netforce_clinic/models/labor_cost.py
@@ -24,7 +24,7 @@ class LaborCost(Model):
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
- hd_cases=obj.cycle_item_id.hd_cases or []
+ hd_cases=[hdcase for hdcase in obj.cycle_item_id.hd_cases if hdcase.state in ('waiting_payment','paid')] or []
total_case=len(hd_cases)
total_a,total_b=0,0
total=0.0
@@ -272,13 +272,12 @@ class LaborCost(Model):
'level_id': level_id,
}
- #TODO UPDATE COST : like cycle daily
item=obj.cycle_item_id
lines=[]
# cost's nurses
for line in item.lines:
nurse=line.nurse_id
- level=line.level_id
+ level=line.level_id or nurse.level_id
vals=levels.get(level.id)
rate,amt,qty=0.0,0.0,0
level_id=level.id
@@ -306,6 +305,8 @@ class LaborCost(Model):
for staff in get_model("clinic.staff").search_browse([['number','=','walkin']]):
dwalkin=staff
for hd_case in item.hd_cases:
+ if hd_case.state not in ('waiting_payment','paid'):
+ continue
staffs=hd_case.staffs
for ps in staffs:
staff=ps.staff_id or dwalkin
diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py
index 7fe6f59..66f939b 100644
--- a/netforce_clinic/models/report_labor_cost.py
+++ b/netforce_clinic/models/report_labor_cost.py
@@ -59,6 +59,7 @@ class ReportLaborCost(Model):
show_detail=obj.show_detail
dom.append(['date','>=',date_from])
dom.append(['date','<=',date_to])
+ dom.append(['cycle_item_id.state','=', 'validated'])
if branch_id:
dom.append(['branch_id','=',branch_id])
if department_id:
@@ -67,6 +68,7 @@ class ReportLaborCost(Model):
hdcases={}
hdcase_obj=get_model("clinic.hd.case")
dstates=dict(hdcase_obj._fields['state'].selection)
+ print('dom ', dom)
for hdcase in hdcase_obj.search_browse(dom):
dpt=hdcase.department_id
state=hdcase.state or ''
@@ -78,7 +80,9 @@ class ReportLaborCost(Model):
'qty':0,
'state':{},
}
- hdcases[dpt.id]['qty']+=1
+ #total for each department
+ if state in ('waiting_payment','paid'):
+ hdcases[dpt.id]['qty']+=1
if not hdcases[dpt.id]['state'].get(state):
hdcases[dpt.id]['state'][state]=0
hdcases[dpt.id]['state'][state]+=1
@@ -94,17 +98,21 @@ class ReportLaborCost(Model):
for dpt_id, vals in hdcases.items():
sub_lines=[]
dom2=[['department_id','=',dpt_id]]
+ qty=vals['qty'] or 0
for state, sqty in vals['state'].items():
+ ok=False
dom3=[['state','=',state]] # last domain
+ if state in ('waiting_payment','paid'):
+ ok=True
+ total_hdcase+=qty
dom4=dom+dom2+dom3
state=dstates[state]
sub_lines.append({
'name': state,
'qty': sqty,
+ 'ok': ok,
'action_options': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom4)),
})
- qty=vals['qty'] or 0
- total_hdcase+=qty
lines.append({
'name': vals['name'],
'branch_id': vals['branch_id'],
diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py
index bfee4d9..17d1e20 100644
--- a/netforce_clinic/models/report_labor_cost_summary.py
+++ b/netforce_clinic/models/report_labor_cost_summary.py
@@ -99,7 +99,6 @@ class ReportLaborCostSummary(Model):
citems={}
print('dom ', dom)
total_hdcase=0
- states={}
for line in get_model("clinic.labor.cost.line").search_browse(dom):
lcost=line.labor_cost_id
citem=lcost.cycle_item_id
@@ -113,6 +112,7 @@ class ReportLaborCostSummary(Model):
categ=staff.categ_id
level_name=''
if not staff:
+ print('no staff', qty, amt)
continue
if level_id and staff.level_id.id !=level_id:
continue
@@ -145,16 +145,8 @@ class ReportLaborCostSummary(Model):
staffs[staff.name][dpt.name]['qty']+=qty
if not citems.get(citem.id):
- #qty=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('completed', 'waiting_payment', 'paid')])
- qty=0
- for hdcase in citem.hd_cases:
- qty+=1
- #if hdcase.state not in states.keys():
- #states[hdcase.state]=0
- #states[hdcase.state]+=1
+ qty=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('waiting_payment', 'paid')])
citems[citem.id]=qty
- #for state,vals in states.items():
- #print(state, vals)
lines=[]
dom=[]
if branch_id:
@@ -227,7 +219,6 @@ class ReportLaborCostSummary(Model):
total_lines.append({'amt': round(total,0)})
company_id=get_active_company()
comp=get_model("company").browse(company_id)
-
if staff_type!='doctor':
total_hdcase=0
for k,hdcase_qty in citems.items():
diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost.hbs
index 8b64038..4a17efb 100644
--- a/netforce_clinic/templates/report_labor_cost.hbs
+++ b/netforce_clinic/templates/report_labor_cost.hbs
@@ -21,26 +21,30 @@