diff --git a/netforce_clinic/layouts/import_clinic_nhso.xml b/netforce_clinic/layouts/import_clinic_nhso.xml index 5d8d366..b0a96c2 100644 --- a/netforce_clinic/layouts/import_clinic_nhso.xml +++ b/netforce_clinic/layouts/import_clinic_nhso.xml @@ -1,6 +1,12 @@
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 7e05c5e..4b672ce 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -577,9 +577,13 @@ class HDCase(Model): def done(self,ids,context={}): obj=self.browse(ids)[0] obj.update_usetime() - obj.write({ - 'state': 'waiting_payment', - }) + state='waiting_payment' + if not obj.amount: + obj.complete() + else: + obj.write({ + 'state': state, + }) def get_report_payment_data(self,context={}): settings=get_model("settings").browse(1) diff --git a/netforce_clinic/models/import_data.py b/netforce_clinic/models/import_data.py new file mode 100644 index 0000000..d2f4026 --- /dev/null +++ b/netforce_clinic/models/import_data.py @@ -0,0 +1,7 @@ +from netforce.model import Model, fields, get_model +class ImportData(Model): + _name='clinic.import.data' + _fields={ + } + +ImportData.register() diff --git a/netforce_clinic/models/import_data_nhso.py b/netforce_clinic/models/import_data_nhso.py index 04624ba..0ee45f7 100644 --- a/netforce_clinic/models/import_data_nhso.py +++ b/netforce_clinic/models/import_data_nhso.py @@ -5,7 +5,21 @@ class ImportDataNHSO(Model): _transient=True _fields={ 'name': fields.Char("Name"), + 'type': fields.Selection([['sucess','Succes'],['fail','Fail']],'Type'), + 'epostat': fields.Char("Epostat"), + 'hdrate': fields.Char("Hdrate"), + 'hdflag': fields.Char("Hdflag"), + 'amount': fields.Float("Amount"), + 'paid': fields.Float("Paid"), + 'paychk': fields.Char("Paychk"), + 'dttran': fields.Char("Dttran"), + 'hreg': fields.Char("Hreg"), + 'station': fields.Char("Station"), + 'hn': fields.Char("HN"), + 'invno': fields.Char("InvNo"), + 'rid': fields.Char("RID"), + 'cstat': fields.Char("Cstat"), + 'reimbpay': fields.Char("Reimbpay"), } - ImportDataNHSO.register() diff --git a/netforce_clinic/models/import_payment.py b/netforce_clinic/models/import_payment.py index 4cfd415..8dba2b2 100644 --- a/netforce_clinic/models/import_payment.py +++ b/netforce_clinic/models/import_payment.py @@ -1,5 +1,6 @@ import time import xlrd +import xmltodict from netforce.model import Model, fields, get_model from netforce.access import get_active_company @@ -34,13 +35,45 @@ class ImportPayment(Model): worksheet.cell_value(curr_row,2) return data - def read_xml(self,fpath=None): + def read_xml(self,fpath=None,node=""): data={} + if not node: + return data if fpath: suffix=fpath.split(".")[-1] if suffix not in ('xml'): raise Exception("ERROR : please should file xml") - return data + data=xmltodict.parse(open(fpath,"r").read()) + + stmstm=data.get('STMSTM') + if stmstm: + hdbills=stmstm.get(node) + if not hdbills: + return {} + lines=[] + for k, v in hdbills.items(): + collections=v + for collection in collections: + if isinstance(collection,dict): + line={} + for i, j in collection.items(): + key=(i or "").lower() + line[key]=j + lines.append(line) + #titles=[title for title, value in lines[0].items()] + return lines + + def import_nhso(self,ids,context={}): + obj=self.browse(ids)[0] + fname=obj.file + fpath=get_file_path(fname) + if not fpath: + raise Exception("Please select file") + lines=self.read_xml(fpath,node='HDBills') + if not lines: + raise Exception("Wrong file") + for line in lines: + print(line) def import_mg(self,ids,context={}): obj=self.browse(ids)[0] @@ -48,12 +81,6 @@ class ImportPayment(Model): fpath=get_file_path(fname) print("fpath ", fpath) - def import_nhso(self,ids,context={}): - obj=self.browse(ids)[0] - fname=obj.file - fpath=get_file_path(fname) - print("fpath ", fpath) - def import_sc(self,ids,context={}): obj=self.browse(ids)[0] fname=obj.file