complete hd case

conv_bal
watcha.h 2014-10-24 11:24:33 +07:00
parent 3b5a68260d
commit 20f304274d
5 changed files with 70 additions and 12 deletions

View File

@ -1,6 +1,12 @@
<form title="Import NHSO">
<field name="file"/>
<field name="date">
<template>
<a href="ui#name=clinic_hd_case">xx{{context.data}}</a>
</template>
</field>
<foot replace="1">
<button string="Import Data" method="import_nhso" type="primary" icon="arrow-right"/>
<!--<button string="Post" method="post" type="success"/>-->
</foot>
</form>

View File

@ -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)

View File

@ -0,0 +1,7 @@
from netforce.model import Model, fields, get_model
class ImportData(Model):
_name='clinic.import.data'
_fields={
}
ImportData.register()

View File

@ -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()

View File

@ -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,21 +35,47 @@ 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())
def import_mg(self,ids,context={}):
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)
print("fpath ", fpath)
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_nhso(self,ids,context={}):
def import_mg(self,ids,context={}):
obj=self.browse(ids)[0]
fname=obj.file
fpath=get_file_path(fname)