diff --git a/netforce_clinic/actions/clinic_report_staff_fee.xml b/netforce_clinic/actions/clinic_report_staff_fee.xml
new file mode 100644
index 0000000..1bcf56a
--- /dev/null
+++ b/netforce_clinic/actions/clinic_report_staff_fee.xml
@@ -0,0 +1,8 @@
+
+ Staff Fee
+ report
+ clinic.report.staff.fee
+ report_staff_fee
+ report_staff_fee
+ account_menu
+
diff --git a/netforce_clinic/actions/clinic_report_staff_fee_detail.xml b/netforce_clinic/actions/clinic_report_staff_fee_detail.xml
index 98b2999..f17d12c 100644
--- a/netforce_clinic/actions/clinic_report_staff_fee_detail.xml
+++ b/netforce_clinic/actions/clinic_report_staff_fee_detail.xml
@@ -1,5 +1,5 @@
- Report Staff Fee Detail
+ Staff Fee Detail
report
clinic.report.staff.fee.detail
report_staff_fee_detail
diff --git a/netforce_clinic/actions/clinic_report_staff_fee_sum.xml b/netforce_clinic/actions/clinic_report_staff_fee_sum.xml
index f113500..2493cbf 100644
--- a/netforce_clinic/actions/clinic_report_staff_fee_sum.xml
+++ b/netforce_clinic/actions/clinic_report_staff_fee_sum.xml
@@ -1,5 +1,5 @@
- Report Staff Fee Summary
+ Staff Fee Summary
report
clinic.report.staff.fee.sum
report_staff_fee_sum
diff --git a/netforce_clinic/layouts/clinic_cycle_item_list.xml b/netforce_clinic/layouts/clinic_cycle_item_list.xml
index 116815d..4be1752 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_list.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_list.xml
@@ -1,4 +1,7 @@
+
+
+
diff --git a/netforce_clinic/layouts/clinic_labor_cost_form.xml b/netforce_clinic/layouts/clinic_labor_cost_form.xml
index c2574a1..d5a6a04 100644
--- a/netforce_clinic/layouts/clinic_labor_cost_form.xml
+++ b/netforce_clinic/layouts/clinic_labor_cost_form.xml
@@ -79,7 +79,7 @@
-
+
diff --git a/netforce_clinic/layouts/clinic_menu_inherit.xml b/netforce_clinic/layouts/clinic_menu_inherit.xml
index 7284dd1..dea2d08 100644
--- a/netforce_clinic/layouts/clinic_menu_inherit.xml
+++ b/netforce_clinic/layouts/clinic_menu_inherit.xml
@@ -9,8 +9,9 @@
-
+
+
diff --git a/netforce_clinic/layouts/clinic_report_staff_fee.xml b/netforce_clinic/layouts/clinic_report_staff_fee.xml
new file mode 100644
index 0000000..0c67162
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_report_staff_fee.xml
@@ -0,0 +1,9 @@
+
diff --git a/netforce_clinic/layouts/clinic_report_staff_fee_detail.xml b/netforce_clinic/layouts/clinic_report_staff_fee_detail.xml
index 674cbe3..a6b5a01 100644
--- a/netforce_clinic/layouts/clinic_report_staff_fee_detail.xml
+++ b/netforce_clinic/layouts/clinic_report_staff_fee_detail.xml
@@ -1,7 +1,9 @@
diff --git a/netforce_clinic/layouts/clinic_report_staff_fee_sum.xml b/netforce_clinic/layouts/clinic_report_staff_fee_sum.xml
index 65fdd90..c0864c6 100644
--- a/netforce_clinic/layouts/clinic_report_staff_fee_sum.xml
+++ b/netforce_clinic/layouts/clinic_report_staff_fee_sum.xml
@@ -1,7 +1,9 @@
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index fd11d04..4d8e971 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -58,8 +58,9 @@ from . import report_hd_case_summary
from . import report_medical_summary
from . import report_recent_patient
from . import report_discontinue_patient
-from . import report_staff_fee_sum
+from . import report_staff_fee
from . import report_staff_fee_detail
+from . import report_staff_fee_sum
from . import report_payment_matching
from . import branch
from . import period
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index 1f022d6..7d11f53 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -74,6 +74,17 @@ class CycleItem(Model):
super().write(ids,vals,**kw)
self.function_store(ids)
+ def validate_all(self,ids,context={}):
+ for obj in self.browse(ids):
+ obj.validate()
+ return {
+ 'next': {
+ 'name': 'clinic_cycle_item',
+ 'mode': 'list',
+ },
+ 'flash': 'Cycle Item has been validated.',
+ }
+
def validate(self,ids,context={}):
obj=self.browse(ids)[0]
for obj_id in ids:
@@ -105,10 +116,10 @@ class CycleItem(Model):
}
def to_draft(self,ids,context={}):
- obj=self.browse(ids)[0]
- obj.write({
- 'state': 'draft',
- })
+ for obj in self.browse(ids):
+ obj.write({
+ 'state': 'draft',
+ })
def onchange_nurse(self,context={}):
data=context["data"]
diff --git a/netforce_clinic/models/labor_cost.py b/netforce_clinic/models/labor_cost.py
index cbb264d..cfc12c0 100644
--- a/netforce_clinic/models/labor_cost.py
+++ b/netforce_clinic/models/labor_cost.py
@@ -55,7 +55,7 @@ class LaborCost(Model):
return res
_fields={
- "cycle_item_id": fields.Many2One("clinic.cycle.item","Cycle Item",required=True),
+ "cycle_item_id": fields.Many2One("clinic.cycle.item","Cycle Item",required=True,search=True),
'var_k': fields.Float("K"),
'var_pt': fields.Integer("PT", function="_get_all",function_multi=True),
'var_ptx': fields.Char("PT x K:", function="_get_all",function_multi=True),
diff --git a/netforce_clinic/models/report_staff_fee.py b/netforce_clinic/models/report_staff_fee.py
new file mode 100644
index 0000000..138cdd3
--- /dev/null
+++ b/netforce_clinic/models/report_staff_fee.py
@@ -0,0 +1,104 @@
+import time
+from calendar import monthrange
+
+from netforce.model import Model,fields,get_model
+from netforce.access import get_active_company
+
+from . import utils
+
+class ReportStaffFee(Model):
+ _name="clinic.report.staff.fee"
+ _string="Report Staff Fee"
+ _transient=True
+
+ _fields={
+ "date": fields.Date("Month"),
+ "date_from": fields.Date("From", required=True),
+ "date_to": fields.Date("To", required=True),
+ 'staff_id': fields.Many2One("clinic.staff","Staff"),
+ 'department_id': fields.Many2One("clinic.department","Department"),
+ 'branch_id': fields.Many2One("clinic.branch","Branch"),
+ }
+
+ 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)
+
+ _defaults={
+ 'date': lambda *a: time.strftime("%Y-%m-%d"),
+ 'date_from': _get_date_from,
+ 'date_to': _get_date_to,
+ }
+
+ def get_report_data(self,ids,context={}):
+ company_id=get_active_company()
+ company=get_model('company').browse(company_id)
+ year, month=time.strftime("%Y-%m").split("-")
+ weekday, total_day=monthrange(int(year), int(month))
+ time_start='%s-%s-01'%(year,str(month).zfill(2))
+ time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
+
+ defaults=context.get('defaults')
+ if defaults:
+ year,month,day=defaults['date'].split("-")
+ time_start='%s-%s-01'%(year,str(month).zfill(2))
+ time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
+ staff_id=None
+ department_id=None
+ branch_id=None
+ if ids:
+ obj=self.browse(ids)[0]
+ month=obj.date_from.split("-")[1]
+ time_start=obj.date_from
+ time_stop=obj.date_to
+ staff_id=obj.staff_id.id
+ department_id=obj.department_id.id
+ branch_id=obj.branch_id.id
+ # new patient of this month
+ dom=[]
+ dom.append(['date','>=',time_start])
+ dom.append(['date','<=',time_stop])
+ if department_id:
+ dom.append(['department_id','=',department_id])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ staff_name=''
+ # TODO can filter doctor and nurse
+ if staff_id:
+ staff=get_model("clinic.staff").browse(staff_id)
+ staff_name=staff.name
+ dom.append(['staff_id','=',staff.id])
+ dlines=get_model('clinic.labor.cost.line').search_browse(dom)
+
+ month_str=utils.MONTHS['th_TH'][int(month)]
+ start=int(time_start[8:10])
+ stop=int(time_stop[8:10])
+ diff=stop-start
+ data={
+ 'company_name': company.name or "",
+ 'parent_company_name': company.parent_id.name or "",
+ 'staff_name': staff_name,
+ 'lines': sorted(lines,key=lambda x: x['date']),
+ 'month': month_str,
+ 'from': time_start,
+ 'to': time_stop,
+ 'is_duration': diff+1 < total_day,
+ 'year': year,
+ }
+ 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
+
+ReportStaffFee.register()
diff --git a/netforce_clinic/models/report_staff_fee_detail.py b/netforce_clinic/models/report_staff_fee_detail.py
index 017a3d1..d408659 100644
--- a/netforce_clinic/models/report_staff_fee_detail.py
+++ b/netforce_clinic/models/report_staff_fee_detail.py
@@ -8,7 +8,7 @@ from . import utils
class ReportStaffFeeDetail(Model):
_name="clinic.report.staff.fee.detail"
- _string="Report Staff Fee Summary"
+ _string="Report Staff Fee Detail"
_transient=True
_fields={
@@ -17,6 +17,8 @@ class ReportStaffFeeDetail(Model):
"date_to": fields.Date("To", required=True),
'staff_id': fields.Many2One("clinic.staff","Staff"),
"type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"),
+ 'department_id': fields.Many2One("clinic.department","Department"),
+ 'branch_id': fields.Many2One("clinic.branch","Branch"),
}
def _get_date_from(self,context={}):
@@ -49,6 +51,8 @@ class ReportStaffFeeDetail(Model):
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
staff_id=None
staff_type=None
+ department_id=None
+ branch_id=None
if ids:
obj=self.browse(ids)[0]
month=obj.date_from.split("-")[1]
@@ -56,10 +60,16 @@ class ReportStaffFeeDetail(Model):
time_stop=obj.date_to
staff_id=obj.staff_id.id
staff_type=obj.type
+ department_id=obj.department_id.id
+ branch_id=obj.branch_id.id
# new patient of this month
dom=[]
dom.append(['date','>=',time_start])
dom.append(['date','<=',time_stop])
+ if department_id:
+ dom.append(['department_id','=',department_id])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
staff_name=''
if staff_id:
staff=get_model("clinic.staff").browse(staff_id)
diff --git a/netforce_clinic/models/report_staff_fee_sum.py b/netforce_clinic/models/report_staff_fee_sum.py
index be9718e..bb91dbd 100644
--- a/netforce_clinic/models/report_staff_fee_sum.py
+++ b/netforce_clinic/models/report_staff_fee_sum.py
@@ -19,6 +19,8 @@ class ReportStaffFeeSum(Model):
"date_to": fields.Date("To", required=True),
"staff_id": fields.Many2One("clinic.staff","Staff"),
"type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"),
+ 'department_id': fields.Many2One("clinic.department","Department"),
+ 'branch_id': fields.Many2One("clinic.branch","Branch"),
}
def _get_date_from(self,context={}):
@@ -52,6 +54,8 @@ class ReportStaffFeeSum(Model):
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
staff_id=None
staff_type="nurse"
+ department_id=None
+ branch_id=None
if ids:
obj=self.browse(ids)[0]
staff_type=obj.type
@@ -59,6 +63,8 @@ class ReportStaffFeeSum(Model):
month=obj.date_from.split("-")[1]
time_start=obj.date_from
time_stop=obj.date_to
+ department_id=obj.department_id.id
+ branch_id=obj.branch_id.id
# generate list of date
fmt='%Y-%m-%d'
@@ -79,6 +85,10 @@ class ReportStaffFeeSum(Model):
total_sum=0.0
dom=[]
dom.append(['type','=',staff_type])
+ if department_id:
+ dom.append(['department_id','=',department_id])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
for staff in get_model("clinic.staff").search_browse(dom):
if staff_id:
if staff_id!=staff.id:
@@ -139,6 +149,10 @@ class ReportStaffFeeSum(Model):
'is_duration': diff+1 < total_day,
'year': year,
}
+ if obj.branch_id:
+ data['branch_name']='(%s)'%obj.branch_id.name or ''
+ if obj.department_id:
+ data['branch_name']='(%s)'%obj.department_id.name or ''
return data
def onchange_date(self,context={}):
diff --git a/netforce_clinic/reports/report_staff_fee.xlsx b/netforce_clinic/reports/report_staff_fee.xlsx
new file mode 100644
index 0000000..57c7747
Binary files /dev/null and b/netforce_clinic/reports/report_staff_fee.xlsx differ
diff --git a/netforce_clinic/templates/report_staff_fee.hbs b/netforce_clinic/templates/report_staff_fee.hbs
new file mode 100644
index 0000000..4af098d
--- /dev/null
+++ b/netforce_clinic/templates/report_staff_fee.hbs
@@ -0,0 +1,59 @@
+
+ ผลตอบแทนดูแลผู้ป่วย
+
+ {{parent_company_name}} {{company_name}}
+
+
+ {{staff_name}}
+
+
+ {{#if is_duration}}
+ ระหว่างวันที่ {{from}} ถึง {{to}}
+ {{else}}
+ ประจำเดือน {{month}} {{year}}
+ {{/if}}
+
+
+{{#if lines}}
+
+
+ วันที่ |
+ {{#unless ../staff_name}}
+ บุคลากร |
+ ประเภท |
+ {{/unless}}
+ ชั้น |
+ สาขา |
+ จำนวนคนไข้ |
+ จำนวนเงิน |
+
+
+ {{#each lines}}
+
+ {{date}} |
+ {{#unless ../staff_name}}
+ {{staff_name}} |
+ {{staff_type}} |
+ {{/unless}}
+ {{dpt_name}} |
+ {{branch_name}} |
+ {{qty}} |
+ {{currency amount}} |
+
+ {{/each}}
+
+
+ {{#unless ../staff_name}}
+ |
+ |
+ {{/unless}}
+ |
+ |
+ |
+ รวม |
+ {{currency total_amount}} |
+
+
+{{else}}
+ No items to display.
+{{/if}}
diff --git a/netforce_clinic/templates/report_staff_fee_sum.hbs b/netforce_clinic/templates/report_staff_fee_sum.hbs
index 436a7e5..c8e686a 100644
--- a/netforce_clinic/templates/report_staff_fee_sum.hbs
+++ b/netforce_clinic/templates/report_staff_fee_sum.hbs
@@ -1,7 +1,7 @@
สรุปค่าธรรมเนียมพยาบาล
- {{parent_company_name}} {{company_name}}
+ {{parent_company_name}} {{company_name}} {{branch_name}}
{{#if is_duration}}
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index a105c72..59649bc 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1,31 +1,8 @@
todo:
- - XXXX
- - make a script to generate cycle item
- - make a sharing setting
-
- - filter data
- 1. company
- 2. branch
- 3. department
- - cycle item
- - sickedbed
- - patient
- - staff
- - script
- - after split department
- - cycle item should be see only that department
- - accounting
- - doctor detail
- - import match hn
- - visit summary -> ok
-
- - calendar
- - search calendar
- - remove
- - multi company
- - running number for each branch
- - make an appoitment
- -
+ - report
+ - doctor labort cost detail
+ - matching payment
+ - popup messagging
=======
generate visit ใหม่ -> ok
popup select dyalyzer -> ok