Beispiel #1
0
    def onBtnExport7Click(self):
        import xlwt
        start = self.dtStart_7.dateTime().toPyDateTime()
        end = self.dtEnd_7.dateTime().toPyDateTime()
        start = utils.formatDateTimeStr(start)
        end = utils.formatDateTimeStr(end)
        file = u'收银员收款汇总日报表_%s_%s.xls' % (start, end)
        file = QFileDialog.getSaveFileName(self, u'选择导出文件', file,
                                           u'统计文件(*.xls)')
        if not file:
            return
        #生成输出文件
        file = file.toUtf8().data().decode('utf-8')

        hdr = u'收银员 票数(现金) 金额(现金) 票数(支票) 金额(支票) 票数(现金+支票) 金额(现金+支票) 票数(POS收款) 金额(POS收款) 票数(小计) 金额(小计)'

        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('sheet 1')
        #写表头
        sheet.write(0, 0, u'大众国际洋山分公司收银员收银汇总日报表')

        start = self.dtStart_7.dateTime().toPyDateTime()
        end = self.dtEnd_7.dateTime().toPyDateTime()
        start = utils.formatDateTimeStr2(start)
        end = utils.formatDateTimeStr2(end)
        sheet.write(2, 0, u'结算日期:%s 至 %s' % (start, end))
        sheet.write(2, 7, u'单位:元')

        fs = hdr.split(u' ')
        c = 0
        for f in fs:
            sheet.write(3, c, f)
            c += 1
#		row = 1
        idx = 3

        #		amount=0
        #		tax = 0
        #		amount_tax = 0
        #
        rs = self.doQuery7()

        for r in rs:
            idx += 1
            row = r
            #row = map(lambda  x:unicode(x),row)

            for c in range(len(row)):
                sheet.write(idx, c, row[c])


#			row+=1
        r = idx + 1

        sheet.write(r, 7, u'审核签收')
        wbk.save(file)
        QMessageBox.about(self, u'提示', u'导出okay!')
Beispiel #2
0
    def onBtnExport6Click(self):
        import xlwt
        start = self.dtStart_6.dateTime().toPyDateTime()
        end = self.dtEnd_6.dateTime().toPyDateTime()
        start = utils.formatDateTimeStr(start)
        end = utils.formatDateTimeStr(end)
        file = u'收银员收款日报表_%s_%s.xls' % (start, end)
        file = QFileDialog.getSaveFileName(self, u'选择导出文件', file,
                                           u'统计文件(*.xls)')
        if not file:
            return
        #生成输出文件
        file = file.toUtf8().data().decode('utf-8')
        rs = self.doQuery6()
        hdr = u'结算方式 票数 金额 税额 价税合计'

        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('sheet 1')
        #写表头
        fs = hdr.split(u' ')
        c = 0
        for f in fs:
            sheet.write(4, c, f)
            c += 1
#		row = 1
        idx = 4

        for r in rs:
            idx += 1
            row = r
            #row = map(lambda  x:unicode(x),row)
            for c in range(len(row)):
                sheet.write(idx, c, row[c])
        r = idx + 1

        sheet.write(r, 0, u'收银员签字')
        sheet.write(r, 4, u'审核签收')

        sheet.write(0, 0, u'大众国际洋山分公司收银员收银日报表')
        start = self.dtStart_6.dateTime().toPyDateTime()
        end = self.dtEnd_6.dateTime().toPyDateTime()
        start = utils.formatDateTimeStr2(start)
        end = utils.formatDateTimeStr2(end)
        sheet.write(2, 0, u'结算日期:%s 至 %s' % (start, end))

        employee = self.cbxEmployee_6.currentText().toUtf8().data().strip()
        mechine = self.cbxMechine_6.currentText().toUtf8().data().strip()

        sheet.write(2, 1, u'收银员:%s' % employee.decode('utf-8'))
        sheet.write(2, 3, u'机器号:%s' % mechine.decode('utf-8'))
        sheet.write(3, 4, u'单位:元')

        wbk.save(file)

        QMessageBox.about(self, u'提示', u'导出okay!')
Beispiel #3
0
	def onBtnExport7Click(self):
		import xlwt
		start = self.dtStart_7.dateTime().toPyDateTime()
		end = self.dtEnd_7.dateTime().toPyDateTime()
		start = utils.formatDateTimeStr(start)
		end = utils.formatDateTimeStr(end)
		file = u'收银员收款汇总日报表_%s_%s.xls'%(start,end)
		file = QFileDialog.getSaveFileName(self,u'选择导出文件',file,u'统计文件(*.xls)')
		if not file:
			return
		#生成输出文件
		file = file.toUtf8().data().decode('utf-8')

		hdr=u'收银员 票数(现金) 金额(现金) 票数(支票) 金额(支票) 票数(现金+支票) 金额(现金+支票) 票数(POS收款) 金额(POS收款) 票数(小计) 金额(小计)'

		wbk = xlwt.Workbook()
		sheet = wbk.add_sheet('sheet 1')
		#写表头
		sheet.write( 0,0,u'大众国际洋山分公司收银员收银汇总日报表')

		start = self.dtStart_7.dateTime().toPyDateTime()
		end = self.dtEnd_7.dateTime().toPyDateTime()
		start = utils.formatDateTimeStr2(start)
		end = utils.formatDateTimeStr2(end)
		sheet.write( 2,0,u'结算日期:%s 至 %s'%(start,end))
		sheet.write( 2,7,u'单位:元')

		fs = hdr.split(u' ')
		c = 0
		for f in fs:
			sheet.write( 3,c,f)
			c+=1
#		row = 1
		idx = 3

#		amount=0
#		tax = 0
#		amount_tax = 0
#
		rs = self.doQuery7()

		for r in rs:
			idx+=1
			row = r
			#row = map(lambda  x:unicode(x),row)

			for c in range(len(row)):
				sheet.write(idx,c,row[c] )
#			row+=1
		r = idx+1

		sheet.write(r,7,u'审核签收')
		wbk.save(file)
		QMessageBox.about(self,u'提示',u'导出okay!')
Beispiel #4
0
	def onBtnExport6Click(self):
		import xlwt
		start = self.dtStart_6.dateTime().toPyDateTime()
		end = self.dtEnd_6.dateTime().toPyDateTime()
		start = utils.formatDateTimeStr(start)
		end = utils.formatDateTimeStr(end)
		file = u'收银员收款日报表_%s_%s.xls'%(start,end)
		file = QFileDialog.getSaveFileName(self,u'选择导出文件',file,u'统计文件(*.xls)')
		if not file:
			return
		#生成输出文件
		file = file.toUtf8().data().decode('utf-8')
		rs = self.doQuery6()
		hdr=u'结算方式 票数 金额 税额 价税合计'

		wbk = xlwt.Workbook()
		sheet = wbk.add_sheet('sheet 1')
		#写表头
		fs = hdr.split(u' ')
		c = 0
		for f in fs:
			sheet.write( 4,c,f)
			c+=1
#		row = 1
		idx = 4

		for r in rs:
			idx+=1
			row = r
			#row = map(lambda  x:unicode(x),row)
			for c in range(len(row)):
				sheet.write(idx,c,row[c] )
		r = idx+1

		sheet.write(r,0,u'收银员签字')
		sheet.write(r,4,u'审核签收')

		sheet.write(0,0,u'大众国际洋山分公司收银员收银日报表')
		start = self.dtStart_6.dateTime().toPyDateTime()
		end = self.dtEnd_6.dateTime().toPyDateTime()
		start = utils.formatDateTimeStr2(start)
		end = utils.formatDateTimeStr2(end)
		sheet.write(2,0,u'结算日期:%s 至 %s'%(start,end))

		employee = self.cbxEmployee_6.currentText().toUtf8().data().strip()
		mechine = self.cbxMechine_6.currentText().toUtf8().data().strip()

		sheet.write(2,1,u'收银员:%s'%employee.decode('utf-8'))
		sheet.write(2,3,u'机器号:%s'%mechine.decode('utf-8'))
		sheet.write(3,4,u'单位:元')

		wbk.save(file)

		QMessageBox.about(self,u'提示',u'导出okay!')
Beispiel #5
0
    def onBtnQuery5Click(self):
        amount = 0
        tax = 0
        amount_tax = 0

        self.tvList_5.clear()
        rs = self.doQuery5()
        idx = 0
        for r in rs:
            idx += 1
            invtype = u'专票'
            if r['inv_type'] == 0:  #  0 - 普通 ; 1 - 专用
                invtype = u'普票'

            amount_tax += r['inv_amount']
            tax += r['inv_tax']
            row = (str(idx), invtype,
                   '%s-%s' % (r['inv_code'], r['inv_number']),
                   utils.formatDateTimeStr2(r['settlement_time']),
                   r['cust_name'].decode('utf-8'),
                   str(r['inv_amount'] - r['inv_tax']), r['inv_tax'],
                   r['inv_amount'], str(r['client_nr']), '')
            row = map(lambda x: unicode(x), row)
            #			print row
            ti = QTreeWidgetItem(row)
            self.tvList_5.addTopLevelItem(ti)
        self.tvList_5.resizeColumnToContents(0)
        amount = amount_tax - tax

        txt = u'合计: 金额=%s 税额=%s 价税合计=%s' % (amount, tax, amount_tax)
        self.txtTotal_5.setText(txt)
Beispiel #6
0
	def onBtnQuery5Click(self):
		amount=0
		tax = 0
		amount_tax = 0

		self.tvList_5.clear()
		rs = self.doQuery5()
		idx = 0
		for r in rs:
			idx+=1
			invtype = u'专票'
			if r['inv_type'] ==0: #  0 - 普通 ; 1 - 专用
				invtype = u'普票'

			amount_tax+=r['inv_amount']
			tax+=r['inv_tax']
			row = (str(idx),
			       invtype,
			       '%s-%s'%(r['inv_code'],r['inv_number']),
					utils.formatDateTimeStr2(r['settlement_time']),
			        r['cust_name'].decode('utf-8'),
			        str(r['inv_amount'] - r['inv_tax']),
			        r['inv_tax'],
			        r['inv_amount'],
			        str(r['client_nr']),
					''
				)
			row = map(lambda  x:unicode(x),row)
#			print row
			ti = QTreeWidgetItem(row )
			self.tvList_5.addTopLevelItem(ti)
		self.tvList_5.resizeColumnToContents(0)
		amount = amount_tax - tax

		txt =u'合计: 金额=%s 税额=%s 价税合计=%s'%(amount,tax,amount_tax)
		self.txtTotal_5.setText(txt)
Beispiel #7
0
    def onBtnExport4Click(self):
        import xlwt
        start = self.dtStart_4.dateTime().toPyDateTime()
        end = self.dtEnd_4.dateTime().toPyDateTime()
        start = utils.formatDateTimeStr(start)
        end = utils.formatDateTimeStr(end)
        file = u'汇总报表-机器开票日_%s_%s.xls' % (start, end)

        file = QFileDialog.getSaveFileName(self, u'选择导出文件', file,
                                           u'统计文件(*.xls)')
        if not file:
            return
        #生成输出文件
        file = file.toUtf8().data().decode('utf-8')

        hdr = u'类别 机器号 金额 税额 价税合计'

        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('sheet 1')

        #写表头
        fs = hdr.split(u' ')
        sheet.write(0, 0, u'大众国际洋山分公司增值税发票汇总报表')

        c = 0

        start = self.dtStart_4.dateTime().toPyDateTime()
        end = self.dtEnd_4.dateTime().toPyDateTime()
        start = utils.formatDateTimeStr2(start)
        end = utils.formatDateTimeStr2(end)

        sheet.write(1, 0, u'结算日期: %s 到 %s' % (start, end))

        for f in fs:
            sheet.write(2, c, f)
            c += 1
        idx = 0
        amount = 0
        tax = 0
        amount_tax = 0
        idx = 2

        rs = self.doQuery4()

        for r in rs:
            r = list(r)
            idx += 1
            invtype = r[0]
            if not r[2]: r[2] = 0
            if not r[3]: r[3] = 0

            row = (invtype, u'机器-%s' % r[1], str(r[2] - r[3]), str(r[3]),
                   str(r[2]), '')
            row = map(lambda x: unicode(x), row)
            row[2] = float(row[2])
            row[3] = float(row[3])
            row[4] = float(row[4])

            for c in range(len(row)):
                sheet.write(idx, c, row[c])
            tax += r[3]
            amount_tax += r[2]

        r = idx + 1
        amount = amount_tax - tax

        sheet.write(r, 0, u'合计')
        sheet.write(r, 2, amount)
        sheet.write(r, 3, tax)
        sheet.write(r, 4, amount_tax)
        wbk.save(file)
        QMessageBox.about(self, u'提示', u'发票导出okay!')
Beispiel #8
0
    def onBtnExport2Click(self):
        import xlwt

        start = self.dtStart_2.dateTime().toPyDateTime()
        end = self.dtEnd_2.dateTime().toPyDateTime()
        start = utils.formatDateTimeStr(start)
        end = utils.formatDateTimeStr(end)
        mechine = self.cbxMechine_2.currentText().toUtf8().data().strip()
        file = u'发票日报表-机器_%s_%s.xls' % (start, end)

        file = QFileDialog.getSaveFileName(self, u'选择导出文件', file,
                                           u'统计文件(*.xls)')
        if not file:
            return
        #生成输出文件
        file = file.toUtf8().data().decode('utf-8')

        rs = self.doQuery2()

        hdr = u'类别 发票编号 开票日期 单位 金额 税额 价税合计 作废标志 收银员 收款方式'
        if self.cbxTimeQueryType2.currentIndex() != 0:
            hdr = u'类别 发票编号 结算日期 单位 金额 税额 价税合计 作废标志 收银员 收款方式'

        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('sheet 1')

        #		rb = open_workbook('template.xls',formatting_info=True, on_demand=True)
        #		rs = rb.sheet_by_index(0)
        #		wbk = copy(rb)
        #		sheet = wbk.get_sheet(0)

        #写表头
        fs = hdr.split(u' ')
        sheet.write(0, 0, u'大众国际洋山分公司增值税发票日报表-机器')

        c = 0

        start = self.dtStart_2.dateTime().toPyDateTime()
        end = self.dtEnd_2.dateTime().toPyDateTime()
        start = utils.formatDateTimeStr2(start)
        end = utils.formatDateTimeStr2(end)

        if self.cbxTimeQueryType2.currentIndex() == 0:
            sheet.write(1, 0, u'结算日期: %s 到 %s' % (start, end))
        else:
            sheet.write(1, 0, u'开票日期: %s 到 %s' % (start, end))
        sheet.write(1, 7, u'机器号:%s' % (mechine.decode('utf-8')))

        for f in fs:
            sheet.write(2, c, f)
            c += 1
        idx = 0
        amount = 0
        tax = 0
        amount_tax = 0

        inv_norm_tax = 0  #普票税额
        inv_norm_amount_tax = 0  #普票含税总额
        inv_norm_amount = 0  #普票总金额

        inv_spec_tax = 0  #专票税额
        inv_spec_amount_tax = 0  #专票含税总额
        inv_spec_amount = 0  #专票总金额

        idx = 2
        for r in rs:
            idx += 1
            invtype = u'专票'
            if r['inv_type'] == 0:  #  0 - 普通 ; 1 - 专用
                invtype = u'普票'

            status = u'正常'
            if r['flag_zf']:
                status = u'已作废'

            timeval = ''
            if self.cbxTimeQueryType2.currentIndex() == 0:
                timeval = utils.formatDateTimeStr(r['inv_date'])
            else:
                timeval = utils.formatDateTimeStr(r['settlement_time'])

            row = ()

            if r['flag_zf']:
                row = (invtype, '%s-%s' % (r['inv_code'], r['inv_number']),
                       timeval, r['cust_name'].decode('utf-8'), 0, 0, 0,
                       status, r['issuer'].decode('utf-8'),
                       TaxConsts.getPayTypeStr(r['pay_type']), '')
            else:
                amount_tax += r['inv_amount']
                tax += r['inv_tax']
                if r['inv_type'] == 0:
                    inv_norm_tax += r['inv_tax']
                    inv_norm_amount_tax += r['inv_amount']
                else:
                    inv_spec_tax += r['inv_tax']
                    inv_spec_amount_tax += r['inv_amount']

                row = (invtype, '%s-%s' % (r['inv_code'], r['inv_number']),
                       timeval, r['cust_name'].decode('utf-8'),
                       str(r['inv_amount'] - r['inv_tax']), r['inv_tax'],
                       r['inv_amount'], status, r['issuer'].decode('utf-8'),
                       TaxConsts.getPayTypeStr(r['pay_type']), '')
            row = map(lambda x: unicode(x), row)
            row[4] = float(row[4])
            row[5] = float(row[5])
            row[6] = float(row[6])
            for c in range(len(row)):
                sheet.write(idx, c, row[c])
        r = idx + 1

        inv_norm_amount = inv_norm_amount_tax - inv_norm_tax
        sheet.write(r, 0, u'-普票-')
        sheet.write(r, 4, inv_norm_amount)
        sheet.write(r, 5, inv_norm_tax)
        sheet.write(r, 6, inv_norm_amount_tax)
        r += 1
        inv_spec_amount = inv_spec_amount_tax - inv_spec_tax
        sheet.write(r, 0, u'-专票-')
        sheet.write(r, 4, inv_spec_amount)
        sheet.write(r, 5, inv_spec_tax)
        sheet.write(r, 6, inv_spec_amount_tax)
        r += 1

        amount = amount_tax - tax
        sheet.write(r, 0, u'合计')
        sheet.write(r, 4, amount)
        sheet.write(r, 5, tax)
        sheet.write(r, 6, amount_tax)
        wbk.save(file)

        QMessageBox.about(self, u'提示', u'发票导出okay!')
Beispiel #9
0
    def onBtnExport5Click(self):
        import xlwt
        start = self.dtStart_5.dateTime().toPyDateTime()
        end = self.dtEnd_5.dateTime().toPyDateTime()
        start = utils.formatDateTimeStr(start)
        end = utils.formatDateTimeStr(end)
        file = u'发票作废汇总表_%s_%s.xls' % (start, end)
        file = QFileDialog.getSaveFileName(self, u'选择导出文件', file,
                                           u'统计文件(*.xls)')
        if not file:
            return
        #生成输出文件
        file = file.toUtf8().data().decode('utf-8')
        rs = self.doQuery5()
        hdr = u'类别 发票编号 结算日期 单位 金额 税额 价税合计 机器号'

        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('sheet 1')
        #写表头
        fs = hdr.split(u' ')
        c = 0
        for f in fs:
            sheet.write(0, c, f)
            c += 1
#		row = 1
        idx = 0

        amount = 0
        tax = 0
        amount_tax = 0

        for r in rs:
            idx += 1
            invtype = u'专票'
            if r['inv_type'] == 0:  #  0 - 普通 ; 1 - 专用
                invtype = u'普票'
            amount_tax += r['inv_amount']
            tax += r['inv_tax']
            row = (
                #					str(idx),
                invtype,
                '%s-%s' % (r['inv_code'], r['inv_number']),
                utils.formatDateTimeStr2(r['doc_time']),
                r['cust_name'].decode('utf-8'),
                str(r['inv_amount'] - r['inv_tax']),
                r['inv_tax'],
                r['inv_amount'],
                str(r['client_nr']))
            row = map(lambda x: unicode(x), row)
            row[4] = float(row[4])
            row[5] = float(row[5])
            row[6] = float(row[6])

            for c in range(len(row)):
                sheet.write(idx, c, row[c])
#			row+=1
        r = idx + 1
        amount = amount_tax - tax
        txt = u'合计: 金额=%s 税额=%s 价税合计=%s' % (amount, tax, amount_tax)
        sheet.write(r, 0, u'合计')
        sheet.write(r, 4, amount)
        sheet.write(r, 5, tax)
        sheet.write(r, 6, amount_tax)

        wbk.save(file)

        QMessageBox.about(self, u'提示', u'发票导出okay!')
Beispiel #10
0
	def onBtnExport3Click(self):
		import xlwt
		start = self.dtStart_3.dateTime().toPyDateTime()
		end = self.dtEnd_3.dateTime().toPyDateTime()
		start = utils.formatDateTimeStr(start)
		end = utils.formatDateTimeStr(end)
		file = u'汇总报表-机器结算日_%s_%s.xls'%(start,end)

		file = QFileDialog.getSaveFileName(self,u'选择导出文件',file,u'统计文件(*.xls)')
		if not file:
			return
		#生成输出文件
		file = file.toUtf8().data().decode('utf-8')


		hdr=u'类别 机器号 金额 税额 价税合计'

		wbk = xlwt.Workbook()
		sheet = wbk.add_sheet('sheet 1')

		#写表头
		fs = hdr.split(u' ')
		sheet.write( 0,0,u'大众国际洋山分公司增值税发票汇总报表')

		c = 0

		start = self.dtStart_3.dateTime().toPyDateTime()
		end = self.dtEnd_3.dateTime().toPyDateTime()
		start = utils.formatDateTimeStr2(start)
		end = utils.formatDateTimeStr2(end)

		sheet.write( 1,0,u'结算日期: %s 到 %s'%(start,end))

		for f in fs:
			sheet.write( 2,c,f)
			c+=1
		idx = 0
		amount=0
		tax = 0
		amount_tax = 0
		idx = 2

		rs = self.doQuery3()

		for r in rs:
			r = list(r)
			idx+=1
			invtype = r[0]
			if not r[2]: r[2] = 0
			if not r[3]: r[3] = 0

			row = (
			       invtype,
			       u'机器-%s'%r[1],
			       str(r[2]-r[3]),
			       str(r[3]),
			       str(r[2]),
			       ''
			)
			row = map(lambda  x:unicode(x),row)
			row[2] = float(row[2])
			row[3] = float(row[3])
			row[4] = float(row[4])
			for c in range(len(row)):
				sheet.write(idx,c,row[c] )
			tax+=r[3]
			amount_tax+=r[2]


		r = idx+1
		amount = amount_tax - tax

		sheet.write(r,0,u'合计')
		sheet.write(r,2,amount)
		sheet.write(r,3,tax)
		sheet.write(r,4,amount_tax)
		wbk.save(file)
		QMessageBox.about(self,u'提示',u'发票导出okay!')
Beispiel #11
0
	def onBtnExport2Click(self):
		import xlwt

		start = self.dtStart_2.dateTime().toPyDateTime()
		end = self.dtEnd_2.dateTime().toPyDateTime()
		start = utils.formatDateTimeStr(start)
		end = utils.formatDateTimeStr(end)
		mechine = self.cbxMechine_2.currentText().toUtf8().data().strip()
		file = u'发票日报表-机器_%s_%s.xls'%(start,end)


		file = QFileDialog.getSaveFileName(self,u'选择导出文件',file,u'统计文件(*.xls)')
		if not file:
			return
		#生成输出文件
		file = file.toUtf8().data().decode('utf-8')

		rs = self.doQuery2()


		hdr=u'类别 发票编号 开票日期 单位 金额 税额 价税合计 作废标志 收银员 收款方式'
		if self.cbxTimeQueryType2.currentIndex()!=0:
			hdr=u'类别 发票编号 结算日期 单位 金额 税额 价税合计 作废标志 收银员 收款方式'

		wbk = xlwt.Workbook()
		sheet = wbk.add_sheet('sheet 1')

		#		rb = open_workbook('template.xls',formatting_info=True, on_demand=True)
		#		rs = rb.sheet_by_index(0)
		#		wbk = copy(rb)
		#		sheet = wbk.get_sheet(0)

		#写表头
		fs = hdr.split(u' ')
		sheet.write( 0,0,u'大众国际洋山分公司增值税发票日报表-机器')

		c = 0

		start = self.dtStart_2.dateTime().toPyDateTime()
		end = self.dtEnd_2.dateTime().toPyDateTime()
		start = utils.formatDateTimeStr2(start)
		end = utils.formatDateTimeStr2(end)

		if self.cbxTimeQueryType2.currentIndex()==0:
			sheet.write( 1,0,u'结算日期: %s 到 %s'%(start,end))
		else:
			sheet.write( 1,0,u'开票日期: %s 到 %s'%(start,end))
		sheet.write( 1,7,u'机器号:%s'%(mechine.decode('utf-8')))

		for f in fs:
			sheet.write( 2,c,f)
			c+=1
		idx = 0
		amount=0
		tax = 0
		amount_tax = 0
		
		inv_norm_tax=0 #普票税额
		inv_norm_amount_tax = 0 #普票含税总额
		inv_norm_amount = 0  #普票总金额
		
		inv_spec_tax=0 #专票税额
		inv_spec_amount_tax = 0 #专票含税总额
		inv_spec_amount = 0 #专票总金额
		
		idx = 2
		for r in rs:
			idx+=1
			invtype = u'专票'
			if r['inv_type'] ==0: #  0 - 普通 ; 1 - 专用
				invtype = u'普票'

			status = u'正常'
			if r['flag_zf']:
				status = u'已作废'
			
			timeval=''
			if self.cbxTimeQueryType2.currentIndex() == 0:
				timeval = utils.formatDateTimeStr(r['inv_date'])
			else:
				timeval = utils.formatDateTimeStr(r['settlement_time'])
			
			row = ()
			
			if r['flag_zf']:
				row = (
					invtype,
					'%s-%s'%(r['inv_code'],r['inv_number']),
					timeval,
					r['cust_name'].decode('utf-8'),
					0,
					0,
					0,
					status,
					r['issuer'].decode('utf-8'),
					TaxConsts.getPayTypeStr(r['pay_type']),
					''
				)
			else:
				amount_tax+=r['inv_amount']
				tax+=r['inv_tax']
				if r['inv_type'] ==0:
					inv_norm_tax+=r['inv_tax']
					inv_norm_amount_tax+=r['inv_amount']
				else:
					inv_spec_tax+=r['inv_tax']
					inv_spec_amount_tax+=r['inv_amount']
				
				row = (
					invtype,
					'%s-%s'%(r['inv_code'],r['inv_number']),
					timeval,
					r['cust_name'].decode('utf-8'),
					str(r['inv_amount'] - r['inv_tax']),
					r['inv_tax'],
					r['inv_amount'],
					status,
					r['issuer'].decode('utf-8'),
					TaxConsts.getPayTypeStr(r['pay_type']),
					''
				)
			row = map(lambda  x:unicode(x),row)
			row[4] = float(row[4])
			row[5] = float(row[5])
			row[6] = float(row[6])
			for c in range(len(row)):
				sheet.write(idx,c,row[c] )
		r = idx+1
		
		inv_norm_amount = inv_norm_amount_tax - inv_norm_tax
		sheet.write(r,0,u'-普票-')
		sheet.write(r,4,inv_norm_amount)
		sheet.write(r,5,inv_norm_tax)
		sheet.write(r,6,inv_norm_amount_tax)
		r+=1
		inv_spec_amount = inv_spec_amount_tax - inv_spec_tax
		sheet.write(r,0,u'-专票-')
		sheet.write(r,4,inv_spec_amount)
		sheet.write(r,5,inv_spec_tax)
		sheet.write(r,6,inv_spec_amount_tax)
		r+=1
		
		amount = amount_tax - tax
		sheet.write(r,0,u'合计')
		sheet.write(r,4,amount)
		sheet.write(r,5,tax)
		sheet.write(r,6,amount_tax)
		wbk.save(file)

		QMessageBox.about(self,u'提示',u'发票导出okay!')
Beispiel #12
0
	def onBtnExport5Click(self):
		import xlwt
		start = self.dtStart_5.dateTime().toPyDateTime()
		end = self.dtEnd_5.dateTime().toPyDateTime()
		start = utils.formatDateTimeStr(start)
		end = utils.formatDateTimeStr(end)
		file = u'发票作废汇总表_%s_%s.xls'%(start,end)
		file = QFileDialog.getSaveFileName(self,u'选择导出文件',file,u'统计文件(*.xls)')
		if not file:
			return
		#生成输出文件
		file = file.toUtf8().data().decode('utf-8')
		rs = self.doQuery5()
		hdr=u'类别 发票编号 结算日期 单位 金额 税额 价税合计 机器号'

		wbk = xlwt.Workbook()
		sheet = wbk.add_sheet('sheet 1')
		#写表头
		fs = hdr.split(u' ')
		c = 0
		for f in fs:
			sheet.write( 0,c,f)
			c+=1
#		row = 1
		idx = 0

		amount=0
		tax = 0
		amount_tax = 0

		for r in rs:
			idx+=1
			invtype = u'专票'
			if r['inv_type'] ==0: #  0 - 普通 ; 1 - 专用
				invtype = u'普票'
			amount_tax+=r['inv_amount']
			tax+=r['inv_tax']
			row = (
#					str(idx),
			       invtype,
			       '%s-%s'%(r['inv_code'],r['inv_number']),
					utils.formatDateTimeStr2(r['doc_time']),
			        r['cust_name'].decode('utf-8'),
			        str(r['inv_amount'] - r['inv_tax']),
			        r['inv_tax'],
			        r['inv_amount'],
			        str(r['client_nr'])
				)
			row = map(lambda  x:unicode(x),row)
			row[4] = float(row[4])
			row[5] = float(row[5])
			row[6] = float(row[6])
			
			for c in range(len(row)):
				sheet.write(idx,c,row[c] )
#			row+=1
		r = idx+1
		amount = amount_tax - tax
		txt =u'合计: 金额=%s 税额=%s 价税合计=%s'%(amount,tax,amount_tax)
		sheet.write(r,0,u'合计')
		sheet.write(r,4,amount)
		sheet.write(r,5,tax)
		sheet.write(r,6,amount_tax)

		wbk.save(file)

		QMessageBox.about(self,u'提示',u'发票导出okay!')