Пример #1
0
    def getSettingsFromToOfAccounts(self):
        dataFile = leXls_Xlsx(self._wayFileSettings, 'DeParaPlanoContas')

        for data in dataFile:
            try:
                fieldHeader = funcoesUteis.treatTextFieldInVector(data, 1)
                if fieldHeader.count('CODIGO CONTA SISTEMA CLIENTE') > 0:
                    self._posionsOfHeaderFromToAccounts.clear()
                    for keyField, nameField in enumerate(data):
                        nameField = funcoesUteis.treatTextField(nameField)
                        self._posionsOfHeaderFromToAccounts[
                            nameField] = keyField
                    continue

                valueComparation = funcoesUteis.treatTextFieldInVector(
                    data, 1, self._posionsOfHeaderFromToAccounts,
                    "Código Conta Sistema Cliente")

                accountDominio = int(
                    funcoesUteis.treatNumberFieldInVector(
                        data, 4, self._posionsOfHeaderFromToAccounts,
                        "Conta Contábil Domínio"))

                if valueComparation != "" and accountDominio != "":
                    self._valuesFromToAccounts[
                        valueComparation] = accountDominio
            except Exception as e:
                pass

        return self._valuesFromToAccounts
Пример #2
0
    def getSettingsProviderOrExpense(self):
        dataFile = leXls_Xlsx(self._wayFileSettings, 'FornecedorOuDespesa')

        for data in dataFile:
            try:
                if str(data[0]).upper().count('QUANDO NO CAMPO') > 0:
                    self._posionsOfHeaderProviderOrExpense.clear()
                    for keyField, nameField in enumerate(data):
                        nameField = funcoesUteis.treatTextField(nameField)
                        self._posionsOfHeaderProviderOrExpense[
                            nameField] = keyField
                    continue

                fieldComparation = funcoesUteis.treatTextFieldInVector(
                    data, 1, self._posionsOfHeaderProviderOrExpense,
                    "Quando no Campo")
                fieldComparation = self._settingsFieldComparation[
                    fieldComparation]

                typeComparation = funcoesUteis.treatTextFieldInVector(
                    data, 2, self._posionsOfHeaderProviderOrExpense,
                    "Tipo comparação")
                typeComparation = self._settingsTypeComparation[
                    typeComparation]

                valueComparation = funcoesUteis.treatTextFieldInVector(
                    data, 3, self._posionsOfHeaderProviderOrExpense, "Valor")

                accountDominio = int(
                    funcoesUteis.treatNumberFieldInVector(
                        data, 4, self._posionsOfHeaderProviderOrExpense,
                        "Conta Contábil Domínio"))

                overwriteAccount = funcoesUteis.treatTextFieldInVector(
                    data, 5, self._posionsOfHeaderProviderOrExpense,
                    "Sobrescrever a Conta na Planilha Processada?")

                if fieldComparation != "" and valueComparation != "" and accountDominio > 0:
                    self._valuesOfLineProviderOrExpense = {
                        "fieldComparation": fieldComparation,
                        "typeComparation": typeComparation,
                        "valueComparation": valueComparation,
                        "accountDominio": accountDominio,
                        "overwriteAccount": overwriteAccount
                    }

                    self._valuesOfFileProviderOrExpense.append(
                        self._valuesOfLineProviderOrExpense.copy())
            except Exception as e:
                pass

        return self._valuesOfFileProviderOrExpense
Пример #3
0
    def getSettingsAccountAndHistoricOthers(self):
        dataFile = leXls_Xlsx(self._wayFileSettings, 'ContasEHistoricoOutros')

        for data in dataFile:
            try:
                fieldHeader = funcoesUteis.treatTextFieldInVector(data, 1)
                if fieldHeader.count('QUANDO HOUVER') > 0:
                    self._posionsOfHeaderAccountAndHistoricOthers.clear()
                    for keyField, nameField in enumerate(data):
                        nameField = funcoesUteis.treatTextField(nameField)
                        self._posionsOfHeaderAccountAndHistoricOthers[
                            nameField] = keyField
                    continue

                # juros, multa, desconto
                fieldComparation = funcoesUteis.treatTextFieldInVector(
                    data, 1, self._posionsOfHeaderAccountAndHistoricOthers,
                    "Quando houver")
                if fieldComparation == "":
                    continue

                # historico ou conta contabil
                fieldOthers = funcoesUteis.treatTextFieldInVector(
                    data, 2, self._posionsOfHeaderAccountAndHistoricOthers,
                    "na Domínio o código do(a)")

                valueDominio = funcoesUteis.treatNumberFieldInVector(
                    data, 3, self._posionsOfHeaderAccountAndHistoricOthers,
                    "Será o")

                if fieldComparation != "" and fieldOthers != "" and valueDominio != "":
                    self._valuesAccountAndHistoricOthers[
                        fieldComparation, fieldOthers] = valueDominio

                whenColumnDocumento = funcoesUteis.treatTextFieldInVector(
                    data, 7, self._posionsOfHeaderAccountAndHistoricOthers,
                    "Quando na Coluna Documento")

                compositionHistoric = funcoesUteis.treatTextFieldInVector(
                    data,
                    8,
                    self._posionsOfHeaderAccountAndHistoricOthers,
                    "Composição Histórico",
                    keepTextOriginal=False)

                if whenColumnDocumento != "" and compositionHistoric != "":
                    self._valuesAccountAndHistoricOthers[
                        whenColumnDocumento] = compositionHistoric

            except Exception as e:
                pass
Пример #4
0
    def getSettingsExtract(self):
        dataFile = leXls_Xlsx(self._wayFileSettings, 'ExtratoBancario')

        for data in dataFile:
            try:
                if str(data[0]).upper().count('QUANDO NO CAMPO') > 0:
                    self._posionsOfHeaderExtracts.clear()
                    for keyField, nameField in enumerate(data):
                        nameField = funcoesUteis.treatTextField(nameField)
                        self._posionsOfHeaderExtracts[nameField] = keyField
                    continue

                fieldComparation = funcoesUteis.treatTextFieldInVector(
                    data, 1, self._posionsOfHeaderExtracts, "Quando no Campo")
                fieldComparation = self._settingsFieldComparationExtract[
                    fieldComparation]

                operationComparation = funcoesUteis.treatTextFieldInVector(
                    data, 2, self._posionsOfHeaderExtracts, "Operação for")
                operationComparation = self._settingsOperationComparation[
                    operationComparation]

                typeComparation = funcoesUteis.treatTextFieldInVector(
                    data, 3, self._posionsOfHeaderExtracts, "Tipo comparação")
                typeComparation = self._settingsTypeComparation[
                    typeComparation]

                valueComparation = funcoesUteis.treatTextFieldInVector(
                    data, 4, self._posionsOfHeaderExtracts, "Valor")

                accountDominio = int(
                    funcoesUteis.treatNumberFieldInVector(
                        data, 5, self._posionsOfHeaderExtracts,
                        "Conta Contábil Domínio"))

                if fieldComparation != "" and valueComparation != "" and accountDominio > 0:
                    self._valuesOfLineExtracts = {
                        "fieldComparation": fieldComparation,
                        "operationComparation": operationComparation,
                        "typeComparation": typeComparation,
                        "valueComparation": valueComparation,
                        "accountDominio": accountDominio
                    }

                    self._valuesOfFileExtracts.append(
                        self._valuesOfLineExtracts.copy())
            except Exception as e:
                pass

        return self._valuesOfFileExtracts
Пример #5
0
    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}')
Пример #6
0
    def isPaymentsLysPorMoeda(self, file):
        dataFile = leXls_Xlsx(file)

        for data in dataFile:
            identificationField = funcoesUteis.treatTextFieldInVector(data, 5)
            if identificationField.count('NMPESSOACREDORA') > 0:
                return True
Пример #7
0
    def getSettingsBanks(self):
        dataFile = leXls_Xlsx(self._wayFileSettings, 'Bancos')

        for data in dataFile:
            try:
                if str(data[0]).upper().count('COMPARAR COM') > 0 or str(
                        data[0]).upper().count('BANCO') > 0:
                    self._posionsOfHeaderBanks.clear()
                    for keyField, nameField in enumerate(data):
                        nameField = funcoesUteis.treatTextField(nameField)
                        self._posionsOfHeaderBanks[nameField] = keyField
                    continue

                compareWith = funcoesUteis.treatTextFieldInVector(
                    data, 1, self._posionsOfHeaderBanks, "Comparar Com")
                compareWith = "" if compareWith != "EXTRATO BANCARIO" and compareWith != "FINANCEIRO DO CLIENTE" else compareWith

                nameBank = funcoesUteis.treatTextFieldInVector(
                    data, 2, self._posionsOfHeaderBanks, "Banco")

                account = funcoesUteis.treatTextFieldInVector(
                    data, 3, self._posionsOfHeaderBanks,
                    "Conta Corrente (Sem o Dígito Verificador)")
                # account = account[:-1] # o -1 é pra tirar o digíto verificador caso o pessoal preencha na configuração, então pega sempre um char a menos evitando este problema

                accountDominio = int(
                    funcoesUteis.treatNumberFieldInVector(
                        data, 4, self._posionsOfHeaderBanks,
                        "Conta Contábil Banco na Domínio"))

                if nameBank != "" and accountDominio > 0:
                    self._valuesOfLineBanks = {
                        "compareWith": compareWith,
                        "nameBankComparation": nameBank,
                        "accountComparation": account,
                        "accountDominio": accountDominio
                    }

                    self._valuesOfFileBanks.append(
                        self._valuesOfLineBanks.copy())
            except Exception as e:
                pass

        return self._valuesOfFileBanks
    def getLivroCaixa(self):
        dataFile = leXls_Xlsx(self._file, 'Lancamentos')

        for data in dataFile:
            if str(data[0]).upper().count('DOCUMENTO') > 0:
                self._posionsOfHeader.clear()
                for keyField, nameField in enumerate(data):
                    nameField = funcoesUteis.treatTextField(nameField)
                    self._posionsOfHeader[nameField] = keyField
                continue

            dateLivro = funcoesUteis.treatDateFieldInVector(
                data, 1, self._posionsOfHeader, "Data")
            movementType = funcoesUteis.treatTextFieldInVector(
                data, 2, self._posionsOfHeader, "Tipo Movimento")
            account = funcoesUteis.treatTextFieldInVector(
                data, 3, self._posionsOfHeader, "Conta Contábil")
            nameAccount = funcoesUteis.treatTextFieldInVector(
                data, 4, self._posionsOfHeader, "Nome Conta")
            amount = funcoesUteis.treatDecimalFieldInVector(
                data, 5, self._posionsOfHeader, "Valor")
            document = funcoesUteis.treatTextFieldInVector(
                data, 6, self._posionsOfHeader, "Documento")
            documentType = funcoesUteis.treatTextFieldInVector(
                data, 7, self._posionsOfHeader, "Tipo Documento")
            participante = funcoesUteis.treatTextFieldInVector(
                data, 8, self._posionsOfHeader, "Participante")
            imovelRural = funcoesUteis.treatTextFieldInVector(
                data, 9, self._posionsOfHeader, "Imóvel Rural")
            historic = funcoesUteis.treatTextFieldInVector(
                data, 10, self._posionsOfHeader, "Histórico")

            if amount != 0:
                self._dataOfLine = {
                    'dateLivro': dateLivro,
                    'movementType': movementType,
                    'account': account,
                    'nameAccount': nameAccount,
                    'amount': amount,
                    'document': document,
                    'documentType': documentType,
                    'participante': participante,
                    'imovelRural': imovelRural,
                    'historic': historic
                }

                self._dataOfFile.append(self._dataOfLine.copy())

        return self._dataOfFile
Пример #9
0
    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 getAccountPlan(self):
        dataFile = leXls_Xlsx(self._file, 'PlanoContas')

        for data in dataFile:
            if str(data[0]).upper().count('CONTA') > 0:
                self._posionsOfHeaderAccountPlan.clear()
                for keyField, nameField in enumerate(data):
                    nameField = funcoesUteis.treatTextField(nameField)
                    self._posionsOfHeaderAccountPlan[nameField] = keyField
                continue

            account = funcoesUteis.treatTextFieldInVector(
                data, 1, self._posionsOfHeaderAccountPlan, "Conta")
            # nameAccount = funcoesUteis.treatTextFieldInVector(data, 2, self._posionsOfHeaderAccountPlan, "Nome")
            # nameAccountMain = funcoesUteis.treatTextFieldInVector(data, 3, self._posionsOfHeaderAccountPlan, "Grupo Principal")
            # nameAccountSubMain = funcoesUteis.treatTextFieldInVector(data, 4, self._posionsOfHeaderAccountPlan, "Subgrupo")
            accountDominio = funcoesUteis.treatNumberFieldInVector(
                data, 5, self._posionsOfHeaderAccountPlan,
                "Código Conta Domínio")

            self._dataOfLineAccountPlan[account] = accountDominio

        return self._dataOfLineAccountPlan
Пример #11
0
    def getPayments(self):
        dataFile = leXls_Xlsx(self._file, 'Pagamentos')

        for data in dataFile:
            if str(data[0]).upper().count('LOTE') > 0:
                self._posionsOfHeaderPayments.clear()
                for keyField, nameField in enumerate(data):
                    nameField = funcoesUteis.treatTextField(nameField)
                    self._posionsOfHeaderPayments[nameField] = keyField
                continue

            numberLote = int(
                funcoesUteis.treatDecimalFieldInVector(
                    data, 1, self._posionsOfHeaderPayments, "Lote"))
            document = funcoesUteis.treatTextFieldInVector(
                data, 2, self._posionsOfHeaderPayments, "Documento")

            findNote = funcoesUteis.treatTextFieldInVector(
                data, 3, self._posionsOfHeaderPayments, "NF na Domínio?")
            if findNote == "1":
                findNote = True
            elif findNote == "0":
                findNote = False
            else:
                findNote = ""

            parcelNumber = funcoesUteis.treatTextFieldInVector(
                data, 4, self._posionsOfHeaderPayments, "Parcela")
            nameProvider = funcoesUteis.treatTextFieldInVector(
                data, 5, self._posionsOfHeaderPayments, "Fornecedor")
            cgceProvider = funcoesUteis.treatTextFieldInVector(
                data, 6, self._posionsOfHeaderPayments, "CNPJ Fornecedor")

            bankAndAccount = funcoesUteis.treatTextFieldInVector(
                data, 7, self._posionsOfHeaderPayments,
                "Banco Financeiro").split('-')
            if len(bankAndAccount) == 2:
                bank = bankAndAccount[0]
                account = bankAndAccount[1]
            elif len(bankAndAccount) == 1:
                bank = bankAndAccount[0]
                account = ""
            else:
                bank = ""
                account = ""

            bankAndAccountExtract = funcoesUteis.treatTextFieldInVector(
                data, 8, self._posionsOfHeaderPayments,
                "Banco Extrato").split('-')
            if len(bankAndAccountExtract) == 2:
                bankExtract = bankAndAccountExtract[0]
                accountExtract = bankAndAccountExtract[1]
            elif len(bankAndAccountExtract) == 1:
                bankExtract = bankAndAccountExtract[0]
                accountExtract = ""
            else:
                bankExtract = ""
                accountExtract = ""

            foundProof = funcoesUteis.treatTextFieldInVector(
                data, 9, self._posionsOfHeaderPayments, "Comprovante Pagto?")
            if foundProof == "1":
                foundProof = True
            elif foundProof == "0":
                foundProof = False
            else:
                foundProof = ""

            paymentDate = funcoesUteis.treatDateFieldInVector(
                data, 10, self._posionsOfHeaderPayments, "Data Financeiro")
            extractDate = funcoesUteis.treatDateFieldInVector(
                data, 11, self._posionsOfHeaderPayments, "Data Extrato")
            dateOfImport = funcoesUteis.treatDateFieldInVector(
                data, 12, self._posionsOfHeaderPayments, "Importação Domínio")
            dueDate = funcoesUteis.treatTextFieldInVector(
                data, 13, self._posionsOfHeaderPayments, "Vencimento")
            issueDate = funcoesUteis.treatTextFieldInVector(
                data, 14, self._posionsOfHeaderPayments, "Emissão")
            amountPaid = funcoesUteis.treatDecimalFieldInVector(
                data, 15, self._posionsOfHeaderPayments, "Valor Pago")
            amountDiscount = funcoesUteis.treatDecimalFieldInVector(
                data, 16, self._posionsOfHeaderPayments, "Desconto")
            amountInterest = funcoesUteis.treatDecimalFieldInVector(
                data, 17, self._posionsOfHeaderPayments, "Juros")
            amountFine = funcoesUteis.treatDecimalFieldInVector(
                data, 18, self._posionsOfHeaderPayments, "Multa")
            amountOriginal = funcoesUteis.treatDecimalFieldInVector(
                data, 19, self._posionsOfHeaderPayments, "Valor Original")
            accountCode = funcoesUteis.treatNumberFieldInVector(
                data, 20, self._posionsOfHeaderPayments,
                "Conta Contabil Domínio")
            codiEmp = funcoesUteis.treatTextFieldInVector(
                data, 21, self._posionsOfHeaderPayments, "Codigo Empresa")
            historic = funcoesUteis.treatTextFieldInVector(
                data, 22, self._posionsOfHeaderPayments,
                "Historico Financeiro")
            category = funcoesUteis.treatTextFieldInVector(
                data, 23, self._posionsOfHeaderPayments, "Categoria")
            accountPlan = funcoesUteis.treatTextFieldInVector(
                data, 24, self._posionsOfHeaderPayments, "Plano de Contas")
            cgcePaying = funcoesUteis.treatTextFieldInVector(
                data, 25, self._posionsOfHeaderPayments, "CNPJ Pagador")
            historicExtract = funcoesUteis.treatTextFieldInVector(
                data, 26, self._posionsOfHeaderPayments,
                "Historico Extrato Bancário")
            accountCodeOld = funcoesUteis.treatTextFieldInVector(
                data, 27, self._posionsOfHeaderPayments,
                "Conta Contabil Sistema Cliente")

            if amountPaid != 0:
                self._paymentsOfLine = {
                    "numberLote": numberLote,
                    "document": document,
                    "findNote": findNote,
                    "parcelNumber": parcelNumber,
                    "nameProvider": nameProvider,
                    "cgceProvider": cgceProvider,
                    "bank": bank,
                    "account": account,
                    "bankExtract": bankExtract,
                    "accountExtract": accountExtract,
                    "foundProof": foundProof,
                    "paymentDate": paymentDate,
                    "dateExtract": extractDate,
                    "dateOfImport": dateOfImport,
                    "dueDate": dueDate,
                    "issueDate": issueDate,
                    "amountPaid": amountPaid,
                    "amountDiscount": amountDiscount,
                    "amountInterest": amountInterest,
                    "amountFine": amountFine,
                    "amountOriginal": amountOriginal,
                    "accountCode": accountCode,
                    "companyBranch": codiEmp,
                    "historic": historic,
                    "category": category,
                    "accountPlan": accountPlan,
                    "cgcePaying": cgcePaying,
                    "historicExtract": historicExtract,
                    "accountCodeOld": accountCodeOld
                }

                self._paymentsOfFile.append(self._paymentsOfLine.copy())

        return self._paymentsOfFile
Пример #12
0
    def getExtracts(self):
        dataFile = leXls_Xlsx(self._file, 'ExtratosBancarios')

        for key, data in enumerate(dataFile):
            if str(data[0]).upper().count('DATA') > 0:
                self._posionsOfHeaderExtracts.clear()
                for keyField, nameField in enumerate(data):
                    nameField = funcoesUteis.treatTextField(nameField)
                    self._posionsOfHeaderExtracts[nameField] = keyField
                continue

            dateExtract = funcoesUteis.treatDateFieldInVector(data, 1)
            accountCodeDebit = funcoesUteis.treatNumberFieldInVector(
                data, 2, self._posionsOfHeaderExtracts, "Debito")
            accountCodeCredit = funcoesUteis.treatNumberFieldInVector(
                data, 3, self._posionsOfHeaderExtracts, "Credito")
            amount = funcoesUteis.treatDecimalFieldInVector(
                data, 4, self._posionsOfHeaderExtracts, "Valor")
            historicCode = funcoesUteis.treatNumberFieldInVector(
                data, 5, self._posionsOfHeaderExtracts, "Cod. Hist")
            historic = funcoesUteis.treatTextFieldInVector(
                data, 6, self._posionsOfHeaderExtracts, "Historico")

            foundProofInPayments = funcoesUteis.treatTextFieldInVector(
                data, 7, self._posionsOfHeaderExtracts,
                "Encontrou no Financeiro?")
            if foundProofInPayments == "1":
                foundProofInPayments = True
            elif foundProofInPayments == "0":
                foundProofInPayments = False
            else:
                foundProofInPayments = ""

            bank = funcoesUteis.treatTextFieldInVector(
                data, 10, self._posionsOfHeaderExtracts, "Banco")
            account = funcoesUteis.treatTextFieldInVector(
                data, 11, self._posionsOfHeaderExtracts, "Conta Corrente")
            typeTransaction = funcoesUteis.treatTextFieldInVector(
                data, 13, self._posionsOfHeaderExtracts, "Tipo Transacao")
            operation = funcoesUteis.treatTextFieldInVector(
                data, 14, self._posionsOfHeaderExtracts, "Operacao")
            document = funcoesUteis.treatTextFieldInVector(
                data, 16, self._posionsOfHeaderExtracts, "Documento")

            if dateExtract is not None and amount > 0:
                self._extractsOfLine = {
                    "dateTransaction": dateExtract,
                    "accountCodeDebit": accountCodeDebit,
                    "accountCodeCredit": accountCodeCredit,
                    "amount": amount,
                    "historicCode": historicCode,
                    "historic": historic,
                    "foundProofInPayments": foundProofInPayments,
                    "bank": bank,
                    "account": account,
                    "typeTransaction": typeTransaction,
                    "operation": operation,
                    "document": document
                }
                self._extractsOfFile.append(self._extractsOfLine.copy())
                self._extractsOfLine.clear()

        return self._extractsOfFile
Пример #13
0
    def process(self, file):

        if self.isPaymentsLysPorMoeda(file) is not True:
            return []

        valuesOfLine = {}
        valuesOfFile = []
        posionsOfHeader = {}

        dataFile = leXls_Xlsx(file)

        for data in dataFile:
            try:
                headerField = funcoesUteis.treatTextFieldInVector(data, 5)
                if headerField.count('NMPESSOACREDORA') > 0:
                    posionsOfHeader.clear()
                    for keyField, nameField in enumerate(data):
                        nameField = funcoesUteis.treatTextField(nameField)
                        posionsOfHeader[nameField] = keyField
                    continue

                idAccountPaid = funcoesUteis.treatTextFieldInVector(
                    data, 1, posionsOfHeader, "idsContaPagar")
                paymentDate = funcoesUteis.treatDateFieldInVector(
                    data, 14, posionsOfHeader, "dtPagamento")
                accountCode = funcoesUteis.treatNumberFieldInVector(
                    data, 23, posionsOfHeader, "nrContaContabil")

                bankAndAccount = funcoesUteis.treatTextFieldInVector(
                    data, 20, posionsOfHeader, "idFonte")

                idCentroCusto = funcoesUteis.treatTextFieldInVector(
                    data, 17, posionsOfHeader, "idCentroDeCustoPagamento")

                positionWordBank = bankAndAccount.find('BANCO')
                if positionWordBank >= 0:
                    positionPlusSign = bankAndAccount[positionWordBank:].find(
                        '>') + positionWordBank
                    bank = funcoesUteis.returnBankForName(
                        funcoesUteis.treatTextField(
                            bankAndAccount[positionWordBank +
                                           6:positionPlusSign]))

                    positionWordAccount = bankAndAccount.find('CONTA')
                    positionSplitSign = bankAndAccount[
                        positionWordAccount:].find(
                            '/') + positionWordAccount + 1
                    accountBank = funcoesUteis.treatTextField(
                        bankAndAccount[positionSplitSign:])
                else:
                    bank = "DINHEIRO"
                    accountBank = ""
                    bank = f'{bank} {idCentroCusto}'

                if paymentDate is not None:
                    valuesOfLine = {
                        "idAccountPaid": idAccountPaid,
                        "paymentDate": paymentDate,
                        "bank": bank,
                        "accountBank": accountBank,
                        "accountCode": accountCode
                    }

                    valuesOfFile.append(valuesOfLine.copy())
            except Exception:
                pass
        return valuesOfFile
Пример #14
0
    def process(self, file):

        if self.isPaymentsLysPorData(file) is not True:
            return []

        dataFile = leXls_Xlsx(file)

        valuesOfLine = {}
        valuesOfFile = []
        posionsOfHeader = {}

        for data in dataFile:
            try:
                headerField = funcoesUteis.treatTextFieldInVector(data, 5)
                if headerField.count('IDPESSOACREDORA') > 0:
                    posionsOfHeader.clear()
                    for keyField, nameField in enumerate(data):
                        nameField = funcoesUteis.treatTextField(nameField)
                        posionsOfHeader[nameField] = keyField
                    continue

                idAccountPaid = funcoesUteis.treatTextFieldInVector(
                    data, 1, posionsOfHeader, "idsContaPagar")
                parcelNumber = funcoesUteis.treatTextFieldInVector(
                    data, 2, posionsOfHeader, "cdParcela")
                dueDate = funcoesUteis.transformaCampoDataParaFormatoBrasileiro(
                    funcoesUteis.treatDateFieldInVector(
                        data, 4, posionsOfHeader, "dtVencimento"))
                nameProvider = funcoesUteis.treatTextFieldInVector(
                    data, 6, posionsOfHeader, "nmPessoaCredora")
                document = funcoesUteis.treatTextFieldInVector(
                    data, 11, posionsOfHeader, "nrDocFiscalOriginal")
                issueDate = funcoesUteis.transformaCampoDataParaFormatoBrasileiro(
                    funcoesUteis.treatDateFieldInVector(
                        data, 12, posionsOfHeader, "dtEmissao"))
                amountPaid = funcoesUteis.treatDecimalFieldInVector(
                    data, 36, posionsOfHeader, "valorLiquido")
                amountDiscount = funcoesUteis.treatDecimalFieldInVector(
                    data, 19, posionsOfHeader, "valordesconto")
                amountInterest = funcoesUteis.treatDecimalFieldInVector(
                    data, 20, posionsOfHeader, "valormulta")
                amountFine = funcoesUteis.treatDecimalFieldInVector(
                    data, 30, posionsOfHeader, "valorjuro")
                amountOriginal = funcoesUteis.treatDecimalFieldInVector(
                    data, 10)
                historic = funcoesUteis.treatTextFieldInVector(
                    data, 34, posionsOfHeader, "justificaticaDaConta")

                paymentsMoeda = self.returnDataPaymentsPorMoeda(idAccountPaid)

                paymentDate = funcoesUteis.analyzeIfFieldIsValid(
                    paymentsMoeda, "paymentDate", None)
                bank = funcoesUteis.analyzeIfFieldIsValid(
                    paymentsMoeda, "bank")
                accountBank = funcoesUteis.analyzeIfFieldIsValid(
                    paymentsMoeda, "accountBank")
                accountCode = funcoesUteis.analyzeIfFieldIsValid(
                    paymentsMoeda, "accountCode")

                if paymentDate is not None and amountPaid > 0:
                    valuesOfLine = {
                        "document": document,
                        "parcelNumber": parcelNumber,
                        "nameProvider": nameProvider,
                        "paymentDate": paymentDate,
                        "dueDate": dueDate,
                        "issueDate": issueDate,
                        "bank": bank,
                        "account": accountBank,
                        "amountPaid": amountPaid,
                        "amountDiscount": amountDiscount,
                        "amountInterest": amountInterest,
                        "amountFine": amountFine,
                        "amountOriginal": amountOriginal,
                        "accountCodeOld": accountCode,
                        "historic": historic
                    }

                    valuesOfFile.append(valuesOfLine.copy())
            except Exception:
                pass
        return valuesOfFile