def readFornWithAccount(self, wayFile): dataTxt = leTxt(wayFile) for data in dataTxt: dataSplit = data.split(';') codiFornecedor = funcoesUteis.treatNumberField(dataSplit[1], isInt=True) self._fornecedoresExistLanc.append(codiFornecedor)
def process(self, file): dataFile = leTxt(file, treatAsText=True, removeBlankLines=True) transferencia = Transferencia(dataFile, file) proofTransferencia = transferencia.process() if proofTransferencia is not None: funcoesUteis.updateFilesRead( self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsAmazonia-Transferencia') return proofTransferencia pagamento = Pagamento(dataFile, file) proofPagamento = pagamento.process() if proofPagamento is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsAmazonia-Pagamento') return proofPagamento pagamentoConvenio = PagamentoConvenio(dataFile, file) proofPagamentoConvenio = pagamentoConvenio.process() if proofPagamentoConvenio is not None: funcoesUteis.updateFilesRead( self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsAmazonia-PagamentoConvenio') return proofPagamentoConvenio pagamentoInss = PagamentoInss(dataFile, file) proofPagamentoInss = pagamentoInss.process() if proofPagamentoInss is not None: funcoesUteis.updateFilesRead( self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsAmazonia-PagamentoInss') return proofPagamentoInss
def process(self, file): dataFile = leTxt(file, treatAsText=True, removeBlankLines=True) fileWaySplit = file.split('\\') fileWay = '/'.join(fileWaySplit[:len(fileWaySplit) - 1]) pagamento = Pagamento(dataFile, fileWay) proofPagamento = pagamento.process() if proofPagamento is not None and len(proofPagamento) > 0: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsBradesco-Pagamento') return proofPagamento
def readFornGenerateDominio(self, wayFile): dataTxt = leTxt(wayFile) for data in dataTxt: dataSplit = data.split('|') codiFornecedor = funcoesUteis.treatNumberField(dataSplit[-1], isInt=True) if self._fornecedoresExistLanc.count(codiFornecedor) == 0: dataSplit[19] = '' self._fornecedores.append(dataSplit) self.generateNewFileForn()
def isProof(self, file): dataFile = leTxt(file, treatAsText=True, removeBlankLines=True) countProof = 0 for data in dataFile: data = funcoesUteis.treatTextField(data) if data.find('CENTRAL DE ATENDIMENTO SANTANDER EMPRESARIAL') >= 0: countProof += 1 if (data.find('4004') >= 0 or data.find('726')) and data.find('2125') >= 0: countProof += 1 if countProof == 3: return True
def process(self, file, sequential): try: dataFile = leTxt(file, removeBlankLines=True, treatAsText=True) nameFile = f"{funcoesUteis.getOnlyNameFile(os.path.basename(file))}-{sequential}.ofx" wayFileToSave = os.path.join(self._folderOFX, nameFile) with open(wayFileToSave, 'w') as txtfile: for row in dataFile: txtfile.write(f'{row}\n') except Exception as e: print(file, e) pass
def transformTxt(self, wayFile): dataTxt = leTxt(wayFile) for data in dataTxt: data = funcoesUteis.treatTextField(data) if data == '': continue dataSplit = data.split(' ') date = funcoesUteis.treatDateFieldInVector(dataSplit, 1) numeroDocumento = funcoesUteis.treatTextFieldInVector(dataSplit, 2) creditOrDebit = funcoesUteis.treatTextFieldInVector(dataSplit, 0) valorMovimento = funcoesUteis.treatDecimalFieldInVector(dataSplit, -1) historico = ' '.join(dataSplit[2:len(dataSplit)-2]) if valorMovimento > 0: dateFormated = funcoesUteis.transformaCampoDataParaFormatoBrasileiro(date) print(f'{dateFormated};;;{valorMovimento};;{historico};{numeroDocumento};{creditOrDebit}')
def process(self, file): dataFile = leTxt(file) self.processAccountPlan(dataFile) valuesOfLine = {} valuesOfFile = [] for key, data in enumerate(dataFile): try: recordType = data[0:2] dateLivro = funcoesUteis.retornaCampoComoData(data[3:11], 4) account = data[11:19] nameAccount = funcoesUteis.analyzeIfFieldIsValid(self._accountPlan, account)[0] historic = funcoesUteis.treatTextField(data[19:274]) amount = funcoesUteis.treatDecimalField(f'{data[274:285]},{data[285:287]}') note = self.searchIfANote(historic) if note != "": documentType = 1 else: documentType = 2 if account[0] == "1": movementType = 'Receitas' else: movementType = 'Despesas' if recordType == "03": valuesOfLine = { 'dateLivro': dateLivro, 'movementType':movementType, 'account': account, 'nameAccount': nameAccount, 'amount': amount, 'document': note, 'documentType': documentType, 'historic': historic } valuesOfFile.append(valuesOfLine.copy()) except Exception as e: pass return valuesOfFile
def process(self, file, sequential): dataFile = leTxt(file, removeBlankLines=True, treatAsText=True) dateExtract = None historic = None amount = 0 balance = 0 document = '' extractsTemp = [] extracts = [] for data in dataFile: dataSplit = data.split(' ') dateExtract = funcoesUteis.treatDateFieldInVector(dataSplit, 1) document = funcoesUteis.treatTextFieldInVector(dataSplit, -3) amount = funcoesUteis.treatDecimalFieldInVector(dataSplit, -2) balance = funcoesUteis.treatDecimalFieldInVector(dataSplit, -1) historic = ' '.join(dataSplit[1:len(dataSplit)-4]) historic = funcoesUteis.treatTextField(historic) if dateExtract is not None and amount > 0: extractsTemp.append({ "dateExtract": dateExtract, "document": document, "amount": amount, "balance": balance, "historic": historic }) for key, extract in enumerate(extractsTemp): if key > 0: beforeExtract = extractsTemp[key-1] balanceBefore = beforeExtract['balance'] balanceActual = extract['balance'] if balanceBefore > balanceActual: extract['operation'] = '-' else: extract['operation'] = '+' else: extract['operation'] = '+' dataFormatada = funcoesUteis.transformaCampoDataParaFormatoBrasileiro(extract['dateExtract']) print(f"{dataFormatada};{extract['document']};{extract['historic']};{extract['operation']}{extract['amount']:.2f};{extract['operation']};SANTANDER;0971130017960")
def process(self, file): # se não for desta classe nem segue pra frente if self.isProof(file) is None: return [] funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsSantander') valuesOfLine = {} valuesOfFile = [] dataFile = leTxt(file, treatAsText=True, removeBlankLines=True) nameProvider = "" historic = "" dueDate = None paymentDate = None company = "" cnpjProvider = "" amountPaid = float(0) amountOriginal = float(0) amountInterest = float(0) category = "" bank = "SANTANDER" account = "" for data in dataFile: data = str(data) dataSplit = data.split(':') fieldOne = funcoesUteis.treatTextField( funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1)) fieldTwo = funcoesUteis.treatTextField( funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2)) if data.find('CONTA CORRENTE:') >= 0: account = data[data.find('CONTA CORRENTE:') + 15:] account = funcoesUteis.treatTextField(account) accountSplit = account.split('-') account = f"{funcoesUteis.analyzeIfFieldIsValidMatrix(accountSplit, 1)}{funcoesUteis.analyzeIfFieldIsValidMatrix(accountSplit, 2)}" if data.find('BENEFICIARIO ORIGINAL') >= 0: self._beneficiaryOrPayer = 'BENEFICIARIO' elif data.count('PAGADOR ORIGINAL') > 0: self._beneficiaryOrPayer = 'PAGADOR' if self._beneficiaryOrPayer == 'PAGADOR': pass elif self._beneficiaryOrPayer == 'BENEFICIARIO': if fieldOne == "RAZAO SOCIAL": nameProvider = fieldTwo.replace('RAZAO SOCIAL', '') if fieldOne == "CNPJ": cnpjProvider = fieldTwo.replace('CNPJ', '') if fieldOne == "DATA DE VENCIMENTO": dueDate = funcoesUteis.transformaCampoDataParaFormatoBrasileiro( funcoesUteis.retornaCampoComoData(fieldTwo)) if fieldOne.count("VALOR NOMINAL") > 0: amountOriginal = funcoesUteis.treatDecimalField(fieldTwo) if fieldOne.count("ENCARGOS") > 0: amountInterest = funcoesUteis.treatDecimalField(fieldTwo) if fieldOne.count("TOTAL A COBRAR") > 0: amountPaid = funcoesUteis.treatDecimalField(fieldTwo) if amountInterest > 0: amountOriginal = amountPaid - amountInterest # é necessário fazer pois as vezes tem juros mas o valor nominal tá igual ao valor pago else: amountInterest = amountPaid - amountOriginal # é necessário fazer pois as vezes tem juros, mas não tem o campo encargos if fieldOne == "DATA DA TRANSACAO": paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo) if paymentDate is not None and amountPaid > 0: valuesOfLine = { "paymentDate": paymentDate, "nameProvider": nameProvider, "cnpjProvider": cnpjProvider, "dueDate": dueDate, "bank": bank, "account": account, "amountPaid": amountPaid, "amountDiscount": float(0), "amountInterest": amountInterest, "amountOriginal": amountOriginal, "historic": historic, "category": category, "company": company, "foundProof": True } valuesOfFile.append(valuesOfLine.copy()) paymentDate = None amountPaid = float(0) return valuesOfFile
def process(self, file: str): dataFile = leTxt(file, treatAsText=True, removeBlankLines=True) fileWaySplit = file.split('\\') fileWay = '/'.join(fileWaySplit[:len(fileWaySplit) - 1]) defaultSispag = DefaultSispag(dataFile, fileWay) proofDefaultSispag = defaultSispag.process() if proofDefaultSispag is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsItau-DefaultSispag') return proofDefaultSispag transferencia = Transferencia(dataFile, fileWay) proofTransferencia = transferencia.process() if proofTransferencia is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsItau-Transferencia') return proofTransferencia pagamentoBoleto = PagamentoBoleto(dataFile, fileWay) proofPagamentoBoleto = pagamentoBoleto.process() if proofPagamentoBoleto is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsItau-PagtoBoleto') return proofPagamentoBoleto tedC = TedC(dataFile, fileWay) proofTedC = tedC.process() if proofTedC is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsItau-TedC') return proofTedC agendamento = Agendamento(dataFile, fileWay) proofAgendamento = agendamento.process() if proofAgendamento is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsItau-Agendamento') return proofAgendamento darf = Darf(dataFile, fileWay) proofDarf = darf.process() if proofDarf is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsItau-Darf') return proofDarf gps = Gps(dataFile, fileWay) proofGps = gps.process() if proofGps is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsItau-Gps') return proofGps fgts = Fgts(dataFile, fileWay) proofFgts = fgts.process() if proofFgts is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsItau-Fgts') return proofFgts pix = Pix(dataFile, fileWay) proofPix = pix.process() if proofPix is not None: funcoesUteis.updateFilesRead(self._wayTempFilesRead, file.replace('.txt', '.pdf'), 'ProofsPaymentsItau-Pix') return proofPix