def getDB(self): try: if not self.db: conf = utils.SimpleConfig().load('system.conf') host = conf.get('db.host') passwd = conf.get('db.passwd') dbname = conf.get('db.name') self.db = psycopg2.connect(host=host, database=dbname, user='******', password=passwd) except: traceback.print_exc() return self.db
def getTermVersion(r): ''' 获取终端软件最新版本 读取/svr/audio/setup.cfg term_version=0.2.1.0 ''' cr = SuccCallReturn() try: cfg = utils.SimpleConfig() cfg.load('/svr/audio/setup.cfg') curver = cfg.get('term_version', '') cr.assign(curver) except: cr = FailCallReturn() return cr.httpResponse()
# -*- coding:utf-8 -*-
def initData(self): import utils self.idxdata_inv = {} self.idxdata_doc = {} self.last_impdir = u'' t = False if utils.SimpleConfig().load('system.conf').get('debug') == '1': t = True self.btnResetClear.setVisible(t) self.btnInvPrint.setVisible(True) self.btnInvRed.setVisible(False) self.btnInvCancel.setVisible(True) self.btnTodayDoc.setVisible(False) self.ckSyncToServer.setVisible(False) self.edtInvStart.setText(utils.getToDayStr2()) #------------------------------------------------- #发牌管理界面 self.cbxInvQueryTypes.addItem(u'------ 全部 ------', INV_QT_BY_ALL) self.cbxInvQueryTypes.addItem(u'发票代码', INV_QT_BY_INVCODE) self.cbxInvQueryTypes.addItem(u'发票号码', INV_QT_BY_INVNUMBER) self.cbxInvQueryTypes.addItem(u'客户名称', INV_QT_BY_CUSTNAME) self.cbxInvQueryTypes.addItem(u'客户税号', INV_QT_BY_CUSTTAXCODE) self.cbxInvQueryTypes.addItem(u'订单编号', INV_QT_BY_DOCNR) self.tvInvMain.setHeaderLabels([ u'序号', u'订单编号', u'发票状态', u'发票种类', u'发票代码', u'发票号码', u'客户名称', u'客户税号', u'客户地址', u'客户银行及账号', u'开票日期', u'开票金额', u'税率', u'税额', u'备注信息', u'', ]) #self.listRecords.setHorizontalHeaderLabels(['a','b']) self.tvInvMain.resizeColumnToContents(0) self.tvInvGoods.setHeaderLabels([ u'序号', # u'商品编号', u'商品名称', #u'商品税目', u'商品规格', u'计量单位', u'数量', # u'单价', u'金额', # u'税率', # u'税额', u'是否含税' ]) #self.listRecords.setHorizontalHeaderLabels(['a','b']) self.tvInvGoods.resizeColumnToContents(0) now = datetime.datetime.now() text = '%04d-%02d-%02d' % (now.year, now.month, now.day) self.edtInvStart.setText(text) self.edtInvEnd.setText(text) #-------------------------------------------------- #订单管理界面 self.cbxDocQueryTypes.addItem(u'------ 全部 ------', INV_QT_BY_ALL) self.cbxDocQueryTypes.addItem(u'客户名称', INV_QT_BY_CUSTNAME) self.cbxDocQueryTypes.addItem(u'客户税号', INV_QT_BY_CUSTTAXCODE) self.cbxDocQueryTypes.addItem(u'订单编号', INV_QT_BY_DOCNR) self.tvDocMain.setHeaderLabels([ u'序号', u'订单编号', u'发票种类', u'客户名称', u'客户税号', u'客户地址', u'客户银行及账号', # u'商品税目', u'备注信息', u'' ]) #self.listRecords.setHorizontalHeaderLabels(['a','b']) self.tvDocMain.resizeColumnToContents(0) self.tvDocGoods.setHeaderLabels([ u'序号', u'订单编号', u'商品名称', # u'商品税目', u'商品规格', u'计量单位', u'数量', # u'单价', u'金额', u'税率', # u'税额', u'是否含税' ]) #self.listRecords.setHorizontalHeaderLabels(['a','b']) self.tvDocGoods.resizeColumnToContents(0) #-------------------------------------------------- # print self.libfile #---------------------------------------------------- #系统设置--> 参数 try: if os.path.exists(self.confile): f = open(self.confile) self.props = pickle.load(f) f.close() self.edtCorpName.setText( QString.fromUtf8(self.props['corpname'])) self.edtTaxcode.setText(QString.fromUtf8( self.props['taxcode'])) self.edtAddress.setText(QString.fromUtf8( self.props['address'])) self.edtBank.setText(QString.fromUtf8(self.props['bank'])) self.edtBranchNo.setText(QString.fromUtf8( self.props['branch'])) self.edtServerAddress.setText( QString.fromUtf8(self.props['server_addr'])) self.edtServerPort.setText( QString.fromUtf8(self.props['server_port'])) if self.props['is_sync_server']: self.ckSyncToServer.setCheckState(2) else: self.ckSyncToServer.setCheckState(0) if self.props['is_doc_autoread']: self.ckReadDocAuto.setCheckState(2) else: self.ckReadDocAuto.setCheckState(0) self.edtReadDocDir.setText( QString.fromUtf8(self.props['doc_readdir'])) except: pass self.updateUnupload()
def importDocument(self): ''' 检查erp导出目录下的订单 ''' if not self.ckReadDocAuto.checkState(): return path = self.props['doc_readdir'].decode('utf-8') if not os.path.exists(path): QMessageBox.about(self, u'提示', u'无法访问订单目录:%s!' % path) self.ckReadDocAuto.setCheckState(0) self.props['is_doc_autoread'] = False return backdir = path + '/store' try: os.mkdir(backdir) except: pass files = os.listdir(path) for file in files: that = path + '/' + file if os.path.isdir(that): continue if that.find('.xls') == -1: continue #read doc xls-file docs = self.readDoc_xls(that) #remove file try: backfile = backdir + '/' + file if os.path.exists(backfile): os.remove(backfile) os.rename(that, backfile) except: pass if not docs: QMessageBox.about(self, u'提示', u'读取订单文件失败:%s' % that) # QMessageBox.about(self,u'提示',u'读取订单文件失败:%s\n已关闭自动读取订单模式!'%that) # self.ckReadDocAuto.setCheckState(0) # self.props['is_doc_autoread'] = False continue for doc in docs: if not self.saveDocument(doc): continue for doc in docs: #订单已存在直接忽略,需人工删除之后再次导入 doc = TaxDocument.from_db(self.db.handle(), doc.doc_nr) # if exist: # QMessageBox.about(self,u'提示',u'订单:%s 已存在,开票取消!'%doc.doc_nr) # continue if doc.status: QMessageBox.about(self, u'提示', u'此订单:%s 已开票,不能重复操作 !' % doc.doc_nr) continue #必须重db重新加载,因为db存储的字段全为str类型 # doc = TaxDocument.from_db(self.db.handle(),doc.doc_nr) # print doc.toString() if '1' != utils.SimpleConfig().load('system.conf').get( 'import_and_invoice'): return if not self.doInvoice(doc): # QMessageBox.about(self,u'提示',u'开票失败,请检查订单数据是否有效!') #continue break
def getConfig(self): return utils.SimpleConfig().load('system.conf')