Exemple #1
0
 def selectPayBtn_clicked(self, sender):
     self.sltCheqListStore.clear()
     query = self.session.query(Cheque).filter(
         or_(Cheque.chqStatus == 3,
             Cheque.chqStatus == 6)).filter(Cheque.chqDelete == False)
     cheqlist = query.all()
     numcheqs = 0
     for cheq in cheqlist:
         numcheqs += 1
         order = utility.LN(numcheqs, False)
         ID = utility.LN(cheq.chqId)
         amount = utility.LN(cheq.chqAmount)
         wrtDate = dateentry.dateToString(cheq.chqWrtDate)
         dueDate = dateentry.dateToString(cheq.chqDueDate)
         status = self.chequeStatus[cheq.chqStatus]
         bank = self.bankaccounts_class.get_bank_name(cheq.chqAccount)
         customer = self.session.query(Customers).filter(
             Customers.custId == cheq.chqCust).first()
         if customer != None:
             customer = customer.custName
         else:
             continue
         self.sltCheqListStore.append(
             (ID, order, customer, amount, wrtDate, dueDate, bank,
              cheq.chqSerial, status, cheq.chqDesc))
     self.chqSltWindow.show_all()
	def fillChequeTable(self):
		total = 0
		
# 		# comment for test
# 		query = self.session.query(Cheque, Customers.custName)
# 		query = query.select_from(outerjoin(Cheque, Customers, Cheque.chqCust == Customers.custId))
		print self.transId 

		query = self.session.query(Cheque).select_from(Cheque)


		#TODO find why chqBillId  and chqOrder has been removed and what must be do!
		#query = query.filter(and_(Cheque.chqTransId == self.transId, Cheque.chqBillId == self.billId))
		query = query.filter(Cheque.chqTransId == self.transCode)
		cheqlist = query.order_by(Cheque.chqOrder.asc()).all()
		#cheqlist = query.all()
		for cheq in cheqlist:
			self.numcheqs += 1
			total += cheq.chqAmount
			order = utility.LN(self.numcheqs, False)
			amount = utility.LN(cheq.chqAmount)
			wrtDate = dateentry.dateToString(cheq.chqWrtDate)
			dueDate = dateentry.dateToString(cheq.chqDueDate)
			status = self.chequeStatus[cheq.chqStatus]
			
			self.cheqListStore.append((order, "in testing", amount, wrtDate, dueDate, "", 
			                         cheq.chqSerial, status, cheq.chqDesc))
		self.addToTotalAmount(total)
Exemple #3
0
    def fillChequeTable(self):
        total = 0

        # 		# comment for test
        # 		query = self.session.query(Cheque, Customers.custName)
        # 		query = query.select_from(outerjoin(Cheque, Customers, Cheque.chqCust == Customers.custId))
        print self.transId

        query = self.session.query(Cheque).select_from(Cheque)

        #TODO find why chqBillId  and chqOrder has been removed and what must be do!
        #query = query.filter(and_(Cheque.chqTransId == self.transId, Cheque.chqBillId == self.billId))
        query = query.filter(Cheque.chqTransId == self.transCode)
        cheqlist = query.order_by(Cheque.chqOrder.asc()).all()
        #cheqlist = query.all()
        for cheq in cheqlist:
            self.numcheqs += 1
            total += cheq.chqAmount
            order = utility.LN(self.numcheqs, False)
            amount = utility.LN(cheq.chqAmount)
            wrtDate = dateentry.dateToString(cheq.chqWrtDate)
            dueDate = dateentry.dateToString(cheq.chqDueDate)
            status = self.chequeStatus[cheq.chqStatus]

            self.cheqListStore.append(
                (order, "in testing", amount, wrtDate, dueDate, "",
                 cheq.chqSerial, status, cheq.chqDesc))
        self.addToTotalAmount(total)
	def fillRecptTable(self):
		total = 0
		query = self.session.query(Payment).select_from(Payment)
		query = query.filter(and_(Payment.paymntTransId== self.transCode))
		paylist = query.order_by(Payment.paymntOrder.asc()).all()
		print paylist
		for pay in paylist:
			self.numrecpts += 1
			total += pay.paymntAmount
			order = utility.LN(self.numrecpts, False)
			amount = utility.LN(pay.paymntAmount)
			wrtDate = dateentry.dateToString(pay.paymntWrtDate)
			dueDate = dateentry.dateToString(pay.paymntDueDate)
			
			self.paysListStore.append((order, "in testing", amount, wrtDate, dueDate, pay.paymntBank,
			                         pay.paymntSerial, pay.paymntTrckCode, pay.paymntDesc))
		self.addToTotalAmount(total)
Exemple #5
0
    def fillRecptTable(self):
        total = 0
        query = self.session.query(Payment).select_from(Payment)
        query = query.filter(and_(Payment.paymntTransId == self.transCode))
        paylist = query.order_by(Payment.paymntOrder.asc()).all()
        # print paylist
        for pay in paylist:
            self.numrecpts += 1
            total += pay.paymntAmount
            order = utility.LN(self.numrecpts, False)
            amount = utility.LN(pay.paymntAmount)
            wrtDate = dateentry.dateToString(pay.paymntWrtDate)
            dueDate = dateentry.dateToString(pay.paymntDueDate)

            self.paysListStore.append(
                (order, "in testing", amount, wrtDate, dueDate, pay.paymntBank,
                 pay.paymntSerial, pay.paymntTrckCode, pay.paymntDesc))
        self.addToTotalAmount(total)
Exemple #6
0
    def fillChequeTable(self):
        total = 0
        if self.transId != 0:  #  from factors
            if self.sellFlag:
                #spendedCheuqesList =self.session.execute("select cheque.* from cheque join chequehistory on cheque.chqId = chequehistory.ChequeId where TransId = 4 and Status <>5 ")

                query = self.session.query(Cheque).select_from(ChequeHistory).filter(Cheque.chqId == ChequeHistory.ChequeId)\
                 .filter(Cheque.chqStatus==5).filter(ChequeHistory.TransId == self.transId).order_by(ChequeHistory.Id.desc()).distinct(Cheque.chqId)
                spendedCheuqesList = query.all()
                self.chequesList += spendedCheuqesList
            query = self.session.query(Cheque)
            query = query.filter(Cheque.chqTransId == self.transId).filter(
                Cheque.chqDelete == False)
            cheqlist = query.all()
            self.chequesList += cheqlist
            for cheq in self.chequesList:
                self.numcheqs += 1
                total += cheq.chqAmount
                ID = utility.LN(cheq.chqId)
                order = utility.LN(self.numcheqs, False)
                ID = utility.LN(cheq.chqId)
                amount = utility.LN(cheq.chqAmount)
                wrtDate = dateentry.dateToString(cheq.chqWrtDate)
                dueDate = dateentry.dateToString(cheq.chqDueDate)
                status = self.chequeStatus[cheq.chqStatus]
                bank = self.bankaccounts_class.get_bank_name(cheq.chqAccount)
                customer = self.session.query(Customers).filter(
                    Customers.custId == cheq.chqCust).first().custName
                self.cheqListStore.append(
                    (ID, order, customer, amount, wrtDate, dueDate, bank,
                     cheq.chqSerial, status, cheq.chqDesc))
            self.addToTotalAmount(total)
        cheque = self.session.query(Cheque).order_by(desc(
            Cheque.chqId)).first()
        if cheque != None:
            self.lastChqID = cheque.chqId
Exemple #7
0
    def submitPayment(self, sender=0):
        if self.validatePayment() == False:
            return
        pre_amnt = 0
        pymntAmnt = self.pymntAmntEntry.get_float()
        wrtDate = self.writeDateEntry.getDateObject()
        dueDte = self.dueDateEntry.getDateObject()
        bank = int(self.bankCombo.get_active()) + 1
        if self.sellFlag:
            bank_name = self.bankaccounts_class.get_bank_name(bank)
        else:
            bank_name = self.bankaccounts_class.get_account(bank).accName
        serial = unicode(self.serialNoEntry.get_text())
        pymntDesc = unicode(self.pymntDescEntry.get_text())
        payer = self.payerEntry.get_text()
        iter = None
        pymnt_str = utility.LN(pymntAmnt)
        wrtDate_str = dateentry.dateToString(wrtDate)
        dueDte_str = dateentry.dateToString(dueDte)

        status = 3 if self.sellFlag else 1  # buy -> pardakhti , sell -> daryafti
        if self.edtPymntFlg:
            iter = self.edititer
            number = utility.convertToLatin(self.cheqListStore.get(iter, 1)[0])
            number = utility.getInt(number)
            cheque = self.chequesList[number - 1]
            if cheque.chqStatus == 5:
                return
            query = self.session.query(Cheque)
            cheque = query.filter(
                and_(Cheque.chqTransId == cheque.chqTransId)).first()
            pre_amnt = cheque.chqAmount
            cheque.chqAmount = pymntAmnt
            cheque.chqWrtDate = wrtDate
            cheque.chqDueDate = dueDte
            cheque.chqSerial = serial
            #cheque.chqStatus = status 			 must edit from automatic accounting
            cheque.chqCust = None  #self.payerEntry.get_text()
            cheque.chqAccount = bank
            #	cheque.chqOwnerName	= self.payerEntry.get_text()
            cheque.chqDesc = pymntDesc

            self.cheqListStore.set(iter, 2, self.customerNameLbl.get_text(), 3,
                                   pymnt_str, 4, wrtDate_str, 5, dueDte_str, 6,
                                   unicode(bank_name), 7, serial, 8,
                                   self.chequeStatus[status], 9, pymntDesc)
            self.lastChqID += 1

            self.chequesList[number - 1] = Cheque(
                pymntAmnt,
                wrtDate,
                dueDte,
                serial,
                status,
                None,
                bank,
                self.transId,
                0,  #notebook ID 
                pymntDesc,
                0,  #history			            		           
                chqId=cheque.chqId)
        else:  # adding cheque
            self.numcheqs += 1
            order = utility.LN(self.numcheqs)
            self.lastChqID += 1
            cheque = Cheque(
                pymntAmnt,
                wrtDate,
                dueDte,
                serial,
                status,
                None,  # customer Id . later after submiting factor or auto accounting will be updated 
                bank,
                self.transId,
                0,
                pymntDesc,
                0,
                chqId=self.lastChqID)

            self.session.add(cheque)
            iter = self.cheqListStore.append(
                (unicode(self.lastChqID), order,
                 self.customerNameLbl.get_text(), pymnt_str, wrtDate_str,
                 dueDte_str, unicode(bank_name), serial,
                 self.chequeStatus[status], pymntDesc))
            self.chequesList.append(cheque)

            path = self.cheqListStore.get_path(iter)
            self.cheqTreeView.scroll_to_cell(path, None, False, 0, 0)
            self.cheqTreeView.set_cursor(path, None, False)

        #self.session.commit()
        self.addToTotalAmount(pymntAmnt -
                              pre_amnt)  # current pay value - prev pay value
        self.addPymntDlg.hide()
	def submitPayment(self, sender=0):
		if self.validatePayment() == False:
			return
		print 'validate paymanet is true'
		pre_amnt 	= 0
		pymntAmnt 	= self.pymntAmntEntry.get_float()
		wrtDate 	= self.writeDateEntry.getDateObject()
		dueDte 		= self.dueDateEntry.getDateObject()
		bank 		= unicode(self.bankCombo.get_active_text())
		serial 		= unicode(self.serialNoEntry.get_text())
		pymntDesc 	= unicode(self.pymntDescEntry.get_text())
		payer		= unicode(self.payerEntry.get_text())
		iter = None
		
		pymnt_str = utility.LN(pymntAmnt)
		wrtDate_str = dateentry.dateToString(wrtDate)
		dueDte_str = dateentry.dateToString(dueDte)
		
		if self.isCheque.get_active():
			status = self.cheqStatusList.get_active()
			if self.edtPymntFlg:
				query = self.session.query(Cheque).select_from(Cheque)
				cheque = query.filter(Cheque.chqId == self.editid).first()
				pre_amnt = cheque.chqAmount
				cheque.chqAmount = pymntAmnt
				cheque.chqWrtDate = wrtDate
				cheque.chqDueDate = dueDte
				cheque.chqSerial = serial
				cheque.chqStatus = status
				#cheque.chqCust = self.payerEntry.get_text()
				cheque.chqOwnerName	= self.payerEntry.get_text()
				cheque.chqDesc = pymntDesc
				iter = self.edititer
				self.cheqListStore.set(self.edititer, 1, cheque.chqCust, 2, pymnt_str,
				                      3, wrtDate_str, 4, dueDte_str, 6, serial, 7, 
				                      self.chequeStatus[status], 8, pymntDesc)
			else:
				self.numcheqs += 1
				order = utility.LN(self.numcheqs)
				
				
				
				##add cheque history
				self.chequeHistoryChequeId 	= 	0
				self.chequeHistoryAmount   	=	pymntAmnt
				self.chequeHistoryWrtDate  	=	wrtDate
				self.chequeHistoryDueDate	=	dueDte
				self.chequeHistorySerial	=	serial
				self.chequeHistoryStatus	=	status
				self.chequeHistoryCust		=	payer
				self.chequeHistoryAccount	=	None
				self.chequeHistoryDesc		=	pymntDesc
				self.chequeHistoryDate		=	wrtDate
				self.chequeHistoryTransId	=	self.transId
				
				
				
# 				chequeHistory= ChequeHistory(			
# 						self.chequeHistoryChequeId 	,
# 						self.chequeHistoryAmount   	,
# 						self.chequeHistoryWrtDate  	,
# 						self.chequeHistoryDueDate	,
# 						self.chequeHistorySerial	,
# 						self.chequeHistoryStatus	,
# 						self.chequeHistoryCust		,
# 						self.chequeHistoryAccount	,
# 						self.chequeHistoryTransId	,
# 						self.chequeHistoryDesc		,
# 						self.chequeHistoryDate			)

				
				cheque = Cheque(
							pymntAmnt						,
							wrtDate							, 
							dueDte							, 
							serial							, 
							0								,
							#self.payerEntry.get_text()		,
							#self.payerEntry.get_text() 		,
							None							,
				            None							,
				            self.transCode					, 
				            self.billId						, 
				            pymntDesc						, 
				            self.numcheqs					,
				            self.billId						,
				           	self.numcheqs					)				            				

				iter = self.cheqListStore.append((order, self.payerEntry.get_text(), pymnt_str, wrtDate_str, 
		                      dueDte_str, bank, serial, self.chequeStatus[status], pymntDesc))
				
			#self.session.add(chequeHistory)
			self.session.add(cheque)
			self.session.commit()
			
			
		## updat chequehistory id	
# 			query=self.session.query(ChequeHistory).select_from(ChequeHistory)
# 			from sqlalchemy.sql.expression import desc
# 			
# 			chequeHistory=query.filter(ChequeHistory.TransId == self.transId).order_by(desc(ChequeHistory.Id)).first()
# 			print chequeHistory.Id
# 								
# 			query = self.session.query(Cheque).select_from(Cheque)
# 			tempCheque = query.filter(Cheque.chqTransId == self.transId).order_by(desc(Cheque.chqId)).first()
# 			
# 			tempCheque.chqHistoryId=chequeHistory.Id
# 			chequeHistory.ChequeId=tempCheque.chqId
# 			
# 			self.session.commit()					
#   		
#  		
 			
#  			
# 			self.session.commit()
# 			
# 			
# 			
# 			
# 			
			
			path = self.cheqListStore.get_path(iter)
			self.cheqTreeView.scroll_to_cell(path, None, False, 0, 0)
			self.cheqTreeView.set_cursor(path, None, False)
			
		else:
			trackCode = unicode(self.trackingCodeEntry.get_text())
			if self.edtPymntFlg:
				query = self.session.query(Payment).select_from(Payment)
				payment = query.filter(Payment.paymntId == self.editid).first()
				pre_amnt = payment.paymntAmount
				payment.paymntDueDate = dueDte
				payment.paymntBank = bank
				payment.paymntSerial = serial
				payment.paymntAmount = pymntAmnt
				payment.paymntNamePayer=self.payerEntry.get_text()
				payment.paymntPayer = self.payerEntry.get_text()
				payment.paymntWrtDate = wrtDate
				payment.paymntDesc = pymntDesc
				payment.paymntTrckCode = trackCode
				iter = self.edititer
				self.paysListStore.set(self.edititer, 1, self.payerEntry.get_text(), 2, pymnt_str,
				                      3, wrtDate_str, 4, dueDte_str, 5, bank, 6, serial,
				                      7, trackCode, 8, pymntDesc)
			else:
				self.numrecpts += 1
				order = utility.LN(self.numrecpts)
				payment = Payment(dueDte, bank, serial, pymntAmnt, self.payerEntry.get_text(), wrtDate,
				                 pymntDesc, self.transCode, self.billId, trackCode, self.numrecpts)
				iter = self.paysListStore.append((order, self.payerEntry.get_text() , pymnt_str, wrtDate_str, 
		                      dueDte_str, bank, serial, trackCode, pymntDesc))
		                      
			self.session.add(payment)
			self.session.commit()
			path = self.paysListStore.get_path(iter)
			self.paysTreeView.scroll_to_cell(path, None, False, 0, 0)
			self.paysTreeView.set_cursor(path, None, False)
		
		self.addToTotalAmount(pymntAmnt - pre_amnt)
		self.addPymntDlg.hide()
Exemple #9
0
    def submitPayment(self, sender=0):
        if self.validatePayment() == False:
            return
        print 'validate paymanet is true'
        pre_amnt = 0
        pymntAmnt = self.pymntAmntEntry.get_float()
        wrtDate = self.writeDateEntry.getDateObject()
        dueDte = self.dueDateEntry.getDateObject()
        bank = unicode(self.bankCombo.get_active_text())
        serial = unicode(self.serialNoEntry.get_text())
        pymntDesc = unicode(self.pymntDescEntry.get_text())
        payer = unicode(self.payerEntry.get_text())
        iter = None

        pymnt_str = utility.LN(pymntAmnt)
        wrtDate_str = dateentry.dateToString(wrtDate)
        dueDte_str = dateentry.dateToString(dueDte)

        if self.isCheque.get_active():
            status = self.cheqStatusList.get_active()
            if self.edtPymntFlg:
                query = self.session.query(Cheque).select_from(Cheque)
                cheque = query.filter(Cheque.chqId == self.editid).first()
                pre_amnt = cheque.chqAmount
                cheque.chqAmount = pymntAmnt
                cheque.chqWrtDate = wrtDate
                cheque.chqDueDate = dueDte
                cheque.chqSerial = serial
                cheque.chqStatus = status
                #cheque.chqCust = self.payerEntry.get_text()
                cheque.chqOwnerName = self.payerEntry.get_text()
                cheque.chqDesc = pymntDesc
                iter = self.edititer
                self.cheqListStore.set(self.edititer, 1, cheque.chqCust, 2,
                                       pymnt_str, 3, wrtDate_str, 4,
                                       dueDte_str, 6, serial, 7,
                                       self.chequeStatus[status], 8, pymntDesc)
            else:
                self.numcheqs += 1
                order = utility.LN(self.numcheqs)

                ##add cheque history
                self.chequeHistoryChequeId = 0
                self.chequeHistoryAmount = pymntAmnt
                self.chequeHistoryWrtDate = wrtDate
                self.chequeHistoryDueDate = dueDte
                self.chequeHistorySerial = serial
                self.chequeHistoryStatus = status
                self.chequeHistoryCust = payer
                self.chequeHistoryAccount = None
                self.chequeHistoryDesc = pymntDesc
                self.chequeHistoryDate = wrtDate
                self.chequeHistoryTransId = self.transId

                # 				chequeHistory= ChequeHistory(
                # 						self.chequeHistoryChequeId 	,
                # 						self.chequeHistoryAmount   	,
                # 						self.chequeHistoryWrtDate  	,
                # 						self.chequeHistoryDueDate	,
                # 						self.chequeHistorySerial	,
                # 						self.chequeHistoryStatus	,
                # 						self.chequeHistoryCust		,
                # 						self.chequeHistoryAccount	,
                # 						self.chequeHistoryTransId	,
                # 						self.chequeHistoryDesc		,
                # 						self.chequeHistoryDate			)

                cheque = Cheque(
                    pymntAmnt,
                    wrtDate,
                    dueDte,
                    serial,
                    0,
                    #self.payerEntry.get_text()		,
                    #self.payerEntry.get_text() 		,
                    None,
                    None,
                    self.transCode,
                    self.billId,
                    pymntDesc,
                    self.numcheqs,
                    self.billId,
                    self.numcheqs)

                iter = self.cheqListStore.append(
                    (order, self.payerEntry.get_text(), pymnt_str, wrtDate_str,
                     dueDte_str, bank, serial, self.chequeStatus[status],
                     pymntDesc))

            #self.session.add(chequeHistory)
            self.session.add(cheque)
            self.session.commit()

            ## updat chequehistory id
            # 			query=self.session.query(ChequeHistory).select_from(ChequeHistory)
            # 			from sqlalchemy.sql.expression import desc
            #
            # 			chequeHistory=query.filter(ChequeHistory.TransId == self.transId).order_by(desc(ChequeHistory.Id)).first()
            # 			print chequeHistory.Id
            #
            # 			query = self.session.query(Cheque).select_from(Cheque)
            # 			tempCheque = query.filter(Cheque.chqTransId == self.transId).order_by(desc(Cheque.chqId)).first()
            #
            # 			tempCheque.chqHistoryId=chequeHistory.Id
            # 			chequeHistory.ChequeId=tempCheque.chqId
            #
            # 			self.session.commit()
            #
            #

            #
            # 			self.session.commit()
            #
            #
            #
            #
            #

            path = self.cheqListStore.get_path(iter)
            self.cheqTreeView.scroll_to_cell(path, None, False, 0, 0)
            self.cheqTreeView.set_cursor(path, None, False)

        else:
            trackCode = unicode(self.trackingCodeEntry.get_text())
            if self.edtPymntFlg:
                query = self.session.query(Payment).select_from(Payment)
                payment = query.filter(Payment.paymntId == self.editid).first()
                pre_amnt = payment.paymntAmount
                payment.paymntDueDate = dueDte
                payment.paymntBank = bank
                payment.paymntSerial = serial
                payment.paymntAmount = pymntAmnt
                payment.paymntNamePayer = self.payerEntry.get_text()
                payment.paymntPayer = self.payerEntry.get_text()
                payment.paymntWrtDate = wrtDate
                payment.paymntDesc = pymntDesc
                payment.paymntTrckCode = trackCode
                iter = self.edititer
                self.paysListStore.set(self.edititer, 1,
                                       self.payerEntry.get_text(), 2,
                                       pymnt_str, 3, wrtDate_str, 4,
                                       dueDte_str, 5, bank, 6, serial, 7,
                                       trackCode, 8, pymntDesc)
            else:
                self.numrecpts += 1
                order = utility.LN(self.numrecpts)
                payment = Payment(dueDte, bank, serial, pymntAmnt,
                                  self.payerEntry.get_text(), wrtDate,
                                  pymntDesc, self.transCode, self.billId,
                                  trackCode, self.numrecpts)
                iter = self.paysListStore.append(
                    (order, self.payerEntry.get_text(), pymnt_str, wrtDate_str,
                     dueDte_str, bank, serial, trackCode, pymntDesc))

            self.session.add(payment)
            self.session.commit()
            path = self.paysListStore.get_path(iter)
            self.paysTreeView.scroll_to_cell(path, None, False, 0, 0)
            self.paysTreeView.set_cursor(path, None, False)

        self.addToTotalAmount(pymntAmnt - pre_amnt)
        self.addPymntDlg.hide()
Exemple #10
0
    def showResult(self,
                   chequeId=None,
                   chqSerial=None,
                   amountFrom=None,
                   amountTo=None,
                   dateFrom=None,
                   dateTo=None,
                   wDateTo=None,
                   wDateFrom=None):
        self.treestoreIncoming.clear()
        self.treestoreOutgoing.clear()
        self.treestoreNotPassed.clear()
        self.treestoreNotCashed.clear()
        self.treestoreDeleted.clear()
        self.treestorePassed.clear()
        self.treestoreCashed.clear()
        self.treestoreSpent.clear()
        self.treestoreBounced.clear()
        self.treestoreBouncedP.clear()
        self.treestoreReturnedT.clear()
        self.treestoreReturnedF.clear()

        result = config.db.session.query(
            Cheque, Customers.custName).select_from(
                outerjoin(Cheque, Customers,
                          Customers.custId == Cheque.chqCust))
        # Apply filters
        delimiter = config.datedelims[config.datedelim]
        if chequeId:
            result = result.filter(Cheque.chqId == chequeId)
        if chqSerial:
            result = result.filter(Cheque.chqSerial.like(chqSerial + "%"))
        if amountFrom:
            result = result.filter(Cheque.chqAmount >= amountFrom)
        if amountTo:
            result = result.filter(Cheque.chqAmount <= amountTo)

        if dateTo:
            dateTo = dateentry.stringToDate(dateTo)
        if dateFrom:
            dateFrom = dateentry.stringToDate(dateFrom)
        if wDateTo:
            wDateTo = dateentry.stringToDate(wDateTo)
        if wDateFrom:
            wDateFrom = dateentry.stringToDate(wDateFrom)

        if dateTo:
            result = result.filter(Cheque.chqDueDate <= dateTo)
        if wDateTo:
            result = result.filter(Cheque.chqWrtDate <= wDateTo)
        if dateFrom:
            #dateFrom -= timedelta(days=1)
            result = result.filter(Cheque.chqDueDate >= dateFrom)
        if wDateFrom:
            #wDateFrom -= timedelta(days=1)
            result = result.filter(Cheque.chqWrtDate >= wDateFrom)

        totalIn = totalGo = totalnotcash = totalnotpass = totalPass = totalCash = totalSpent = totalBouncedp = totalBounced = totalRetT = totalRetF = totalFloat = 0
        # Show
        for cheque, cust in result.all():
            chqWrtDate = dateentry.dateToString(cheque.chqWrtDate)
            chqDueDate = dateentry.dateToString(cheque.chqDueDate)

            # if (cheque.chqStatus == 2) or (cheque.chqStatus == 4):
            #     clear = _('Cleared')
            # else:
            #     clear = _('Not Cleared' )
            chqBill = config.db.session.query(Notebook.bill_id).filter(
                Notebook.chqId == cheque.chqId).first()
            if chqBill:
                chqBill = chqBill.bill_id
            else:
                chqBill = 0
            self.bankaccounts_class = class_bankaccounts.BankAccountsClass()
            isSpended = False
            stat = cheque.chqStatus
            if stat == 6:
                history = config.db.session.query(ChequeHistory).filter(
                    ChequeHistory.ChequeId == cheque.chqId).order_by(
                        ChequeHistory.Id.desc()).limit(2).all()
                if len(history):
                    history = history[1]
                    isSpended = True if history.Status == 5 else False
            if stat in [1, 2, 6, 8] and not isSpended:
                chqAccount = self.bankaccounts_class.get_account(
                    cheque.chqAccount).accName
            else:
                chqAccount = self.bankaccounts_class.get_bank_name(
                    cheque.chqAccount)
            addingRow = (str(cheque.chqId), str(cheque.chqAmount),
                         str(chqWrtDate), str(chqDueDate),
                         str(cheque.chqSerial), str(cust), str(chqAccount),
                         str(cheque.chqDesc), str(chqBill),
                         str(unicode(self.chequeStatus[cheque.chqStatus])))
            if cheque.chqDelete == False:
                if stat in [3, 4, 7, 9]:
                    self.treestoreIncoming.append(None, addingRow)
                    totalIn += cheque.chqAmount
                else:
                    self.treestoreOutgoing.append(None, addingRow)
                    totalGo += cheque.chqAmount

                if stat == 1:
                    self.treestoreNotPassed.append(None, addingRow)
                    totalPass += cheque.chqAmount
                elif (stat == 2):
                    self.treestorePassed.append(None, addingRow)
                    totalnotpass += cheque.chqAmount
                elif stat == 3:
                    self.treestoreNotCashed.append(None, addingRow)
                    totalnotcash += cheque.chqAmount
                elif stat == 4:
                    self.treestoreCashed.append(None, addingRow)
                    totalCash += cheque.chqAmount
                elif stat == 5:
                    self.treestoreSpent.append(None, addingRow)
                    totalSpent += cheque.chqAmount
                elif stat == 6:
                    self.treestoreReturnedF.append(None, addingRow)
                    totalRetF += cheque.chqAmount
                elif stat == 7:
                    self.treestoreReturnedT.append(None, addingRow)
                    totalRetT += cheque.chqAmount
                elif stat == 8:
                    self.treestoreBouncedP.append(None, addingRow)
                    totalBouncedp += cheque.chqAmount
                elif stat == 9:
                    self.treestoreBounced.append(None, addingRow)
                    totalBounced += cheque.chqAmount
                elif stat == 10:
                    self.treestoreFloat.append(None, addingRow)
                    totalFloat += cheque.chqAmount
            else:
                self.treestoreDeleted.append(None, addingRow)
        self.totals = (totalIn, totalGo, totalnotpass, totalnotcash, totalPass,
                       totalCash, totalSpent, totalBounced, totalBouncedp,
                       totalRetT, totalRetF, totalFloat, "")
        self.builder.get_object("totalLbl").set_text(str(totalIn))
        self.currentTreeview = 0