diff --git a/netforce_clinic/actions/clinic_matching_payment_group.xml b/netforce_clinic/actions/clinic_matching_payment_group.xml
new file mode 100644
index 0000000..2d5371a
--- /dev/null
+++ b/netforce_clinic/actions/clinic_matching_payment_group.xml
@@ -0,0 +1,11 @@
+
+ Matching Payment Group
+ multi_view
+ clinic.matching.payment.group
+ account_menu
+ [
+ ["All",[]],
+ ["Draft",[["state","=","draft"]]],
+ ["Approved",[["state","=","approved"]]]
+ ]
+
diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml
index 5bba9fc..1775e5d 100644
--- a/netforce_clinic/layouts/clinic_account_menu.xml
+++ b/netforce_clinic/layouts/clinic_account_menu.xml
@@ -2,20 +2,15 @@
-
-
-
-
-
-
+
+
+
-
-
-
-
diff --git a/netforce_clinic/layouts/clinic_matching_payment_form.xml b/netforce_clinic/layouts/clinic_matching_payment_form.xml
index c1a26ec..92c3dc9 100644
--- a/netforce_clinic/layouts/clinic_matching_payment_form.xml
+++ b/netforce_clinic/layouts/clinic_matching_payment_form.xml
@@ -34,8 +34,8 @@
-
-
+
+
diff --git a/netforce_clinic/layouts/clinic_matching_payment_group_form.xml b/netforce_clinic/layouts/clinic_matching_payment_group_form.xml
new file mode 100644
index 0000000..c83dab9
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_matching_payment_group_form.xml
@@ -0,0 +1,26 @@
+
diff --git a/netforce_clinic/layouts/clinic_matching_payment_group_list.xml b/netforce_clinic/layouts/clinic_matching_payment_group_list.xml
new file mode 100644
index 0000000..b6ab585
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_matching_payment_group_list.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index e551bf5..4ddfc56 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -103,6 +103,8 @@ from . import make_apt
from . import make_apt_line
from . import matching_payment
from . import matching_payment_line
+from . import matching_payment_group
+from . import matching_payment_group_line
from . import matching_hdcase
from . import sale_order
from . import shop
diff --git a/netforce_clinic/models/matching_payment.py b/netforce_clinic/models/matching_payment.py
index 2e424fc..b37f2fe 100644
--- a/netforce_clinic/models/matching_payment.py
+++ b/netforce_clinic/models/matching_payment.py
@@ -16,15 +16,24 @@ class MatchingPayment(Model):
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
- match_total=0
+ total_match=0
+ total_fee=0
+ total_srv=0
+ total_epo=0
for line in obj.lines:
+ total_fee+=line.fee or 0
+ total_srv+=line.srv or 0
+ total_epo+=line.epo or 0
state=line.state or ''
if state=='match':
- match_total+=1
+ total_match+=1
res[obj.id]={
'total': len(obj.lines),
- 'match_total': match_total,
- 'unmatch_total': len(obj.lines)-match_total,
+ 'total_match': total_match,
+ 'total_unmatch': len(obj.lines)-total_match,
+ 'total_fee': total_fee,
+ 'total_srv': total_srv,
+ 'total_epo': total_epo,
}
return res
@@ -39,9 +48,12 @@ class MatchingPayment(Model):
'hcode_id': fields.Many2One("clinic.hospital","HCode"),
'lines': fields.One2Many("clinic.matching.payment.line","match_id", "Lines"),
'note': fields.Text("Note"),
- 'match_total': fields.Integer("Match",function="_get_all",function_multi=True),
- 'unmatch_total': fields.Integer("Unmatch",function="_get_all",function_multi=True),
'total': fields.Integer("Total",function="_get_all",function_multi=True),
+ 'total_match': fields.Integer("Match",function="_get_all",function_multi=True),
+ 'total_unmatch': fields.Integer("Unmatch",function="_get_all",function_multi=True),
+ 'total_fee': fields.Float("FEE",function="_get_all",function_multi=True),
+ 'total_srv': fields.Float("Service",function="_get_all",function_multi=True),
+ 'total_epo': fields.Float("EPO",function="_get_all",function_multi=True),
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
}
diff --git a/netforce_clinic/models/matching_payment_group.py b/netforce_clinic/models/matching_payment_group.py
new file mode 100644
index 0000000..dd67857
--- /dev/null
+++ b/netforce_clinic/models/matching_payment_group.py
@@ -0,0 +1,66 @@
+from netforce.model import Model, fields, get_model
+from netforce.utils import get_data_path
+
+class MatchingPaymentGroup(Model):
+ _name="clinic.matching.payment.group"
+ _string="Matching Payment Group"
+
+ def _get_all(self,ids,context={}):
+ res={}
+ for obj in self.browse(ids):
+ total=0
+ for line in obj.lines:
+ matching=line.matching_id
+ for mline in matching.lines:
+ total+=mline.fee or 0
+ total+=mline.srv or 0
+ total+=mline.epo or 0
+ res[obj.id]={
+ 'total': total,
+ }
+ return res
+
+ _fields={
+ 'name': fields.Char("Name",required=True),
+ 'lines': fields.One2Many("clinic.matching.payment.group.line","group_matching_id", "Lines"),
+ 'total': fields.Float("Total",function="_get_all",function_multi=True),
+ 'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
+ }
+
+ _defaults={
+ 'state': 'draft',
+ }
+
+ def post(self,ids,context={}):
+ for obj in self.browse(ids):
+ print("%s posted"%(obj.id))
+ return {
+ 'next': {
+ 'name': 'clinic_matching_payment_group',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash': 'Posted',
+ }
+
+ def update_amount(self,context={}):
+ data=context['data']
+ data['total']=0
+ for line in data['lines']:
+ data['total']+=line['amount'] or 0
+ return data
+
+ def onchange_matching(self,context={}):
+ data=context['data']
+ path=context['path']
+ line=get_data_path(data,path,parent=True)
+ matching_id=line['matching_id']
+ matching=get_model('clinic.matching.payment').browse(matching_id)
+ line['srv']=matching['total_srv'] or 0
+ line['epo']=matching['total_epo'] or 0
+ line['fee']=matching['total_fee'] or 0
+ line['amount']=line['fee']+line['epo']+line['srv']
+ data=self.update_amount(context=context)
+ return data
+
+MatchingPaymentGroup.register()
diff --git a/netforce_clinic/models/matching_payment_group_line.py b/netforce_clinic/models/matching_payment_group_line.py
new file mode 100644
index 0000000..c73054f
--- /dev/null
+++ b/netforce_clinic/models/matching_payment_group_line.py
@@ -0,0 +1,28 @@
+from netforce.model import Model, fields
+
+class MatchingPaymentGroupLine(Model):
+ _name="clinic.matching.payment.group.line"
+ _string="Matching Payment Group Line"
+
+ def _get_all(self,ids,context={}):
+ res={}
+ for obj in self.browse(ids):
+ fee=obj.fee or 0
+ epo=obj.epo or 0
+ srv=obj.srv or 0
+ amount=fee+epo+srv
+ res[obj.id]={
+ 'amount': amount,
+ }
+ return res
+
+ _fields={
+ 'group_matching_id': fields.Many2One("clinic.matching.payment.group","Group Matching",required=True,on_delete="cascade"),
+ 'matching_id': fields.Many2One("clinic.matching.payment","Group Matching"),
+ 'fee': fields.Float("Fee"),
+ 'srv': fields.Float("Service"),
+ 'epo': fields.Float("EPO"),
+ 'amount': fields.Float("Amount", function="_get_all", function_multi=True),
+ }
+
+MatchingPaymentGroupLine.register()
diff --git a/netforce_clinic/models/report_medical_summary.py b/netforce_clinic/models/report_medical_summary.py
index e90af73..8026e9d 100644
--- a/netforce_clinic/models/report_medical_summary.py
+++ b/netforce_clinic/models/report_medical_summary.py
@@ -167,6 +167,15 @@ class ReportMedicalSummary(Model):
company=get_model('company').browse(company_id)
month_str=utils.MONTHS['th_TH'][int(month)]
+ # remove zero
+ for line in lines:
+ #st=""
+ for sline in line['sub_lines']:
+ qty=sline['qty']
+ if not qty:
+ sline['qty']=''
+ #st+="%s"%(qty)
+ #print(st)
lines=sorted(lines, key=lambda x: x['prod_name'])
year=int(year)+543
diff --git a/netforce_clinic/templates/report_hd_case_summary.hbs b/netforce_clinic/templates/report_hd_case_summary.hbs
index dc5a5de..66b2a4b 100644
--- a/netforce_clinic/templates/report_hd_case_summary.hbs
+++ b/netforce_clinic/templates/report_hd_case_summary.hbs
@@ -132,7 +132,7 @@
-
+
{{#each titles}}
{{name}} |
@@ -141,7 +141,7 @@
{{#each medicals}}
-
+ |
{{prod_name}}
|
{{#each sub_lines}}
diff --git a/netforce_clinic/templates/report_medical_summary.hbs b/netforce_clinic/templates/report_medical_summary.hbs
index 4e11fa2..250fb68 100644
--- a/netforce_clinic/templates/report_medical_summary.hbs
+++ b/netforce_clinic/templates/report_medical_summary.hbs
@@ -7,7 +7,7 @@
ประจำเดือน {{month}} {{year}}
-
+
{{#each titles}}
{{name}} |
@@ -16,7 +16,7 @@
{{#each lines}}
-
+ |
{{prod_name}}
|
{{#each sub_lines}}