diff --git a/netforce_clinic/layouts/clinic_shop_list.xml b/netforce_clinic/layouts/clinic_shop_list.xml
index a57ad49..9e3ed09 100644
--- a/netforce_clinic/layouts/clinic_shop_list.xml
+++ b/netforce_clinic/layouts/clinic_shop_list.xml
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/netforce_clinic/models/payment_matching.py b/netforce_clinic/models/payment_matching.py
index 0484a58..9da2c2f 100644
--- a/netforce_clinic/models/payment_matching.py
+++ b/netforce_clinic/models/payment_matching.py
@@ -2,6 +2,9 @@ import time
from calendar import monthrange
from netforce.model import Model, fields, get_model
+from netforce.utils import get_file_path
+
+from . import utils
class PaymentMatching(Model):
_name="clinic.payment.matching"
@@ -20,6 +23,9 @@ class PaymentMatching(Model):
'branch_id': fields.Many2One("clinic.branch","Branch"),
"inv_state": fields.Selection([("draft","Draft"),("waiting_approval","Waiting Approval"),("waiting_payment","Waiting Payment"),("paid","Paid"),("voided","Voided")],"Status"),
"view_type": fields.Selection([("invoice","Invoice"),("file","File")],"View Type"),
+ 'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",required=True),
+ 'pcode': fields.Char("Code",required=True),
+ 'hcode_id': fields.Many2One("clinic.hospital","HCode"),
}
def _get_date_from(self,context={}):
@@ -43,6 +49,10 @@ class PaymentMatching(Model):
date_from=line.date_start
date_to=line.date_stop
break
+ tids=get_model('clinic.patient.type').search([['default','=',True]])
+ patient_type_id=None
+ if tids:
+ patient_type_id=tids[0]
res={
'period_id': period_id,
'date': time.strftime("%Y-%m-%d"),
@@ -50,6 +60,7 @@ class PaymentMatching(Model):
'date_to': date_to,
'inv_state': 'waiting_payment',
'view_type': 'invoice',
+ 'patient_type_id': patient_type_id,
}
return res
@@ -61,6 +72,45 @@ class PaymentMatching(Model):
data['date_to']=period.date_stop
return data
+ def onchange_ptype(self,context={}):
+ data=context['data']
+ type_id=data['patient_type_id']
+ if type_id:
+ t=get_model('clinic.patient.type').browse(type_id)
+ data['pcode']=t.code or ""
+ return data
+
+ def get_line(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ if not obj.file_id.file:
+ raise Exception("File not found!")
+ fname=obj.file_id.file
+ if obj.pcode=='SSO':
+ hcode=obj.hcode_id.code or ""
+ if not hcode:
+ raise Exception("Wrong HCode")
+ try:
+ n,sf=fname.split(".")
+ except Exception as e:
+ print("ERROR: wrong file ", e)
+
+ if sf not in ('xls','xlsx'):
+ raise Exception("File should be xls or xlsx")
+ fpath=get_file_path(fname)
+ lines=utils.read_excel(fpath,show_datetime=True)
+
+ elif obj.pcode=='UC':
+ fpath=get_file_path(fname)
+ node='HDBills'
+ lines=utils.read_xml(fpath,node=node)
+ hcode=fname.split("_")[0]
+ else:
+ raise Exception("Type %s is not support"%obj.pcode or "")
+
+ if not lines:
+ raise Exception("No data to match")
+ return lines
+
def get_report_data(self,ids,context={}):
defaults=self.default_get(context=context)
print('defaults ', defaults)
@@ -104,5 +154,4 @@ class PaymentMatching(Model):
}
return data
-
PaymentMatching.register()
diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py
index d50bb65..7fd46c7 100644
--- a/netforce_clinic/models/shop.py
+++ b/netforce_clinic/models/shop.py
@@ -13,8 +13,6 @@ class Shop(Model):
def _get_all(self,ids,context={}):
res={}
- st=get_model("clinic.setting").browse(1)
- shop_categs=[x.id for x in st.shop_categs]
for obj in self.browse(ids):
sub_total=0
tax_amount=0
@@ -30,7 +28,6 @@ class Shop(Model):
'tax_amount': tax_amount,
'total': total,
'due_amount': total,
- 'shop_categs': shop_categs,
}
return res
@@ -54,7 +51,6 @@ class Shop(Model):
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
"payments": fields.One2Many("account.payment","related_id","Payments"),
'dom_str': fields.Char("Dom Str"),
- 'shop_categs': fields.Many2Many("product.categ","Categs",function="_get_all",function_multi=True,store=True),
"related_id": fields.Reference([["sale.order","Sales Order"],["purchase.order","Purchase Order"],["project","Project"],["job","Service Order"],["service.contract","Service Contract"]],"Related To"),
'company_id': fields.Many2One("company","Company"),
"pay_type": fields.Selection([("cash","Cash"),("credit","Credit")],"Pay Type"),
@@ -70,11 +66,6 @@ class Shop(Model):
_order="date desc"
- def _get_shop_categs(self,context={}):
- st=get_model("clinic.setting").browse(1)
- shop_categs=[x.id for x in st.shop_categs]
- return shop_categs
-
def _get_related(self,context={}):
related_id=None
if context.get('refer_id'):
@@ -169,7 +160,6 @@ class Shop(Model):
'branch_id': _get_branch,
'department_id': _get_department,
'state': 'draft',
- 'shop_categs': _get_shop_categs,
'related_id': _get_related,
'patient_id': _get_patient,
'contact_id': _get_contact,
diff --git a/netforce_clinic/templates/payment_matching.hbs b/netforce_clinic/templates/payment_matching.hbs
index e750aa0..83a2bfb 100644
--- a/netforce_clinic/templates/payment_matching.hbs
+++ b/netforce_clinic/templates/payment_matching.hbs
@@ -9,7 +9,7 @@
- TOTAL: {{total_inv}}
+ TOTAL: {{currency total_inv}}