diff --git a/netforce_clinic/actions/clinic_report_labor_cost.xml b/netforce_clinic/actions/clinic_report_labor_cost.xml
new file mode 100644
index 0000000..4cbd782
--- /dev/null
+++ b/netforce_clinic/actions/clinic_report_labor_cost.xml
@@ -0,0 +1,8 @@
+
+ Report Labor Cost
+ report
+ clinic.report.labor.cost
+ report_labor_cost
+ report_labor_cost
+ account_menu
+
diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml
index ed7f59e..cbe008b 100644
--- a/netforce_clinic/layouts/clinic_account_menu.xml
+++ b/netforce_clinic/layouts/clinic_account_menu.xml
@@ -9,6 +9,7 @@
+
diff --git a/netforce_clinic/layouts/clinic_report_labor_cost.xml b/netforce_clinic/layouts/clinic_report_labor_cost.xml
new file mode 100644
index 0000000..caaf794
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_report_labor_cost.xml
@@ -0,0 +1,7 @@
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 9d8f5fa..dcfd9fe 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -80,6 +80,7 @@ from . import report_staff_fee
from . import report_staff_fee_detail
from . import report_staff_fee_sum
from . import report_payment_matching
+from . import report_labor_cost
from . import report_labor_cost_summary
from . import report_labor_cost_detail
from . import report_labor_cost_sub_detail
diff --git a/netforce_clinic/models/matching_hdcase.py b/netforce_clinic/models/matching_hdcase.py
index f36c847..7beb6d7 100644
--- a/netforce_clinic/models/matching_hdcase.py
+++ b/netforce_clinic/models/matching_hdcase.py
@@ -100,7 +100,11 @@ class MatchingHDCase(Model):
#20: ' U '}
patients={}
- for pt in get_model("clinic.patient").search_read([],['name','hn_no','type_id']):
+ dom=[
+ ['dispose','=',False],
+ ['walkin','=','no'],
+ ]
+ for pt in get_model("clinic.patient").search_read(dom,['name','hn_no','type_id']):
hn=pt['hn_no']
patients[hn]={
'id': pt['id'],
@@ -121,7 +125,8 @@ class MatchingHDCase(Model):
hdcases2={}
for hdcase in get_model("clinic.hd.case").search_browse(dom):
date=hdcase.date
- hn=hdcase.patient_id.hn_no or 0
+ hn=hdcase.patient_id.hn_no or ""
+ hn=hn[0:7] #XXX K.Ekk explain on 03/04/2015 : 0-7 is main of hn
fee_amt=0
hct=hdcase.hct or "0"
hct=round(float(hct),2)
diff --git a/netforce_clinic/models/matching_payment.py b/netforce_clinic/models/matching_payment.py
index 86d6602..ca98446 100644
--- a/netforce_clinic/models/matching_payment.py
+++ b/netforce_clinic/models/matching_payment.py
@@ -171,6 +171,7 @@ class MatchingPayment(Model):
for invoice in invoices:
pname,hn,card_no='', '', ''
pname2=pname
+ hn=''
if invoice.related_id:
hdcase=invoice.related_id
patient=hdcase.patient_id
@@ -181,7 +182,7 @@ class MatchingPayment(Model):
pname=patient_names[pname]
pname2='%s %s'%(patient.first_name or "",patient.last_name or "")
card_no=patient.card_no or ""
- hn=patient.hn_no
+ hn=patient.hn_no or ""
elif invoice.ref:
pname=invoice.ref or ''
#XXX
@@ -193,6 +194,7 @@ class MatchingPayment(Model):
hn=pt.hn_no or ""
else:
pass
+ hn=hn[0:7] #XXX
fee,epo,srv=0, 0, 0
due_amount=0
for inv_line in invoice.lines:
diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py
new file mode 100644
index 0000000..b1ad915
--- /dev/null
+++ b/netforce_clinic/models/report_labor_cost.py
@@ -0,0 +1,112 @@
+import time
+from calendar import monthrange
+
+from netforce.model import Model,fields,get_model
+from netforce.access import get_active_company
+
+class ReportLaborCost(Model):
+ _name="clinic.report.labor.cost"
+ _string="Report Labor Cost"
+ _transient=True
+
+ _fields={
+ "date": fields.Date("Month"),
+ "date_from": fields.Date("From", required=True),
+ "date_to": fields.Date("To", required=True),
+ "branch_id": fields.Many2One("clinic.branch","Branch"),
+ "department_id": fields.Many2One("clinic.department","Department"),
+ }
+
+ def _get_date_from(self,context={}):
+ year,month=time.strftime("%Y-%m").split("-")
+ return '%s-%s-01'%(year,month)
+
+ def _get_date_to(self,context={}):
+ year,month,day=time.strftime("%Y-%m-%d").split("-")
+ weekday, total_day=monthrange(int(year), int(month))
+ return "%s-%s-%s"%(year,month,total_day)
+
+ def default_get(self,field_names=None,context={},**kw):
+ defaults=context.get("defaults",{})
+ date_from=defaults.get("date_from", self._get_date_from())
+ date_to=defaults.get("date_to", self._get_date_to())
+ print('defaults ', defaults)
+ res={
+ 'date': time.strftime("%Y-%m-%d"),
+ 'date_from': date_from,
+ 'date_to': date_to,
+ }
+ return res
+
+ def get_report_data(self,ids,context={}):
+ company_id=get_active_company()
+ company=get_model("company").browse(company_id)
+ defaults=self.default_get(context=context)
+ date_from=defaults['date_from']
+ date_to=defaults['date_to']
+ branch_id=None
+ department_id=None
+ dom=[]
+ if ids:
+ obj=self.browse(ids)[0]
+ date_from=obj.date_from
+ date_to=obj.date_to
+ branch_id=obj.branch_id.id
+ department_id=obj.department_id.id
+ dom.append(['date','>=',date_from])
+ dom.append(['date','<=',date_to])
+ if branch_id:
+ dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
+ if department_id:
+ dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
+ print('dom ', dom)
+ lines=[]
+ citems={}
+ for line in get_model("clinic.labor.cost.line").search_browse(dom):
+ #print('xx')
+ lcost=line.labor_cost_id
+ citem=lcost.cycle_item_id
+ dpt=citem.department_id
+ qty=line.qty or 0 #XXX
+ print(citem.id)
+ import pdb; pdb.set_trace()
+ if not citem.id not in list(citems.keys()):
+ print("zzz")
+ citems[citem.id]=citem
+
+ total_hdcase=0
+ for citem_id, citem in citems.items():
+ for hdcase in citem.hd_cases:
+ if hdcase.state in ('completed','waitting_payment','paid'):
+ total_hdcase+=1
+ sub_name=''
+ if department_id:
+ dpt=get_model("clinic.department").browse(department_id)
+ sub_name="(%s)" % dpt.name or ""
+ elif branch_id:
+ branch=get_model("clinic.branch").browse(branch_id)
+ sub_name="(%s)" % branch.name or ""
+ data={
+ 'company_name': '%s %s' % (company.name or "", sub_name),
+ 'date_from': date_from,
+ 'date_to': date_to,
+ 'lines': lines,
+ 'total_hdcase': total_hdcase,
+ }
+ return data
+
+ def onchange_date(self,context={}):
+ data=context['data']
+ date=data['date']
+ year,month,day=date.split("-")
+ weekday, total_day=monthrange(int(year), int(month))
+ data['date_from']="%s-%s-01"%(year,month)
+ 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
+
+ReportLaborCost.register()
diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost.hbs
new file mode 100644
index 0000000..aef5dfa
--- /dev/null
+++ b/netforce_clinic/templates/report_labor_cost.hbs
@@ -0,0 +1,24 @@
+
+
+ {{company_name}}
+
+
+ From {{date_from}} To {{date_to}}
+
+
+
+
+
+
+ {{#each lines }}
+
+ |
+
+ {{/each}}
+
+
+
+
+
+ {{total_hdcase}}
+