Пример #1
0
    def foundProductInNote(self, productsXML, nameProductAccountSystem,
                           qtdAccountSystem, vunitAccountSystem):
        productsEquals = []

        for productXML in productsXML:
            nameProductXML = funcoesUteis.treatTextField(
                productXML['prod']['xProd'])
            qtdProductXML = round(
                funcoesUteis.treatDecimalField(productXML['prod']['qCom']), 2)
            vunitProductXML = round(
                funcoesUteis.treatDecimalField(productXML['prod']['vUnCom']),
                2)
            # vtotProductXML = round(funcoesUteis.treatDecimalField(productXML['prod']['vProd']),2)

            if qtdProductXML == qtdAccountSystem and vunitProductXML == vunitAccountSystem:
                productXML[
                    'valueComparationBetweenAccountSystemAndXML'] = SequenceMatcher(
                        None, nameProductAccountSystem,
                        nameProductXML).ratio()
                if productXML[
                        'valueComparationBetweenAccountSystemAndXML'] > 0.85:
                    return productXML
                else:
                    productsEquals.append(productXML)

        if len(productsEquals) > 0:
            return sorted(productsEquals,
                          key=itemgetter(
                              'valueComparationBetweenAccountSystemAndXML'))[0]
Пример #2
0
 def getBalance(self, clas_cta):
     get = self._getBalances.get(self._codi_emp, self._codi_emp_plano_contas, clas_cta, self._start_date, self._end_date)
     credito = treatDecimalField(get[0]['credit'])
     debito = treatDecimalField(get[1]['debit'])
     balance = debito - credito
     balance = round(balance, 2)
     return balance * (-1) if balance < 0 else balance
Пример #3
0
    def returnProductComparation(self, productAccountSystem, productsXML):
        if len(productsXML) == 0:
            return None

        nameProductAccountSystem = funcoesUteis.treatTextField(
            productAccountSystem['desc_pdi'])
        qtdAccountSystem = round(
            funcoesUteis.treatDecimalField(productAccountSystem['qtd']), 2)
        vunitAccountSystem = round(
            funcoesUteis.treatDecimalField(productAccountSystem['vunit']), 2)
        vtotAccountSystem = round(
            funcoesUteis.treatDecimalField(productAccountSystem['vtot']), 2)

        productXML = None

        if len(productsXML) == 1:
            productXML = productsXML[0]
            nameProductXML = funcoesUteis.treatTextField(
                productXML['prod']['xProd'])
            productXML[
                'valueComparationBetweenAccountSystemAndXML'] = SequenceMatcher(
                    None, nameProductAccountSystem, nameProductXML).ratio()
        else:
            productXML = self.foundProductInNote(productsXML,
                                                 nameProductAccountSystem,
                                                 qtdAccountSystem,
                                                 vunitAccountSystem)

        return productXML
Пример #4
0
    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 getProductsFixedAssets(self, codi_emp, month, year, products):
        try:
            collectionFixedAssets = self._dbMongo['EntryNoteProductsFixedAssets']
            collectionFixedAssets.delete_many( {"$and": [{'codi_emp': codi_emp}, {'monthFilter': month}, {'yearFilter': year}] } )

            for product in products:
                if str(product['cfop']) in ('1551', '2551', '3551', '1406', '2406'):
                    product['classificado_corretamente_cfop'] = True
                    collectionFixedAssets.insert_one(product)
                elif str(product['cfop']) in ('1556', '2556', '3556', '1407', '2407'):
                    vunit = funcoesUteis.treatDecimalField(product['vunit'])
                    if vunit >= 1200:
                        desc_pdi = funcoesUteis.treatTextField(product['desc_pdi'])
                        hasNameProductFixedAsset = list(filter(lambda name: desc_pdi.find(funcoesUteis.treatTextField(name)) >= 0, self._namesProductsBase))
                        if len(hasNameProductFixedAsset) > 0:
                            product['classificado_corretamente_cfop'] = False
                            collectionFixedAssets.insert_one(product)
                        else:
                            continue
                else:
                    continue
        except Exception:
            pass
Пример #6
0
    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
Пример #7
0
    def process(self):
        valuesOfLine = {}

        isProofTransferencia = False

        nameProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""

        for data in self._dataFile:
            if isProofTransferencia == False and data.find(
                    'COMPROVANTE DE TRANSFERENCIA') >= 0:
                isProofTransferencia = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))

            if fieldOne.count('IDENTIFICACAO NO EXTRATO') > 0:
                historic = funcoesUteis.treatTextField(fieldTwo)

            if fieldOne.count('CONTA DEBITADA') > 0:
                self._accountDebitOrCredit = 'DEBIT'
            elif fieldOne.count('CONTA CREDITADA') > 0:
                self._accountDebitOrCredit = 'CREDIT'

            if self._accountDebitOrCredit == 'DEBIT':
                if fieldOne.count('AGENCIA') > 0:
                    account = funcoesUteis.treatTextField(
                        funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 3))
                    account = str(funcoesUteis.treatNumberField(account))
                    # account = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(account.split('-'), 1))
                    # if account.find(' ') > 0:
                    #     account = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(account.split(' '), 1))
            elif self._accountDebitOrCredit == 'CREDIT':
                if fieldOne == "NOME":
                    nameProvider = fieldTwo

                if fieldOne.count("VALOR") > 0:
                    amountPaid = funcoesUteis.treatDecimalField(fieldTwo)

            for valueOfLineDatePayment in self._valuesOfLineDatePayment:
                if data[0:len(valueOfLineDatePayment
                              )] == valueOfLineDatePayment:
                    paymentDate = funcoesUteis.treatTextField(
                        data[len(valueOfLineDatePayment) +
                             1:len(valueOfLineDatePayment) + 11])
                    if paymentDate.find('.') >= 0:
                        paymentDate = funcoesUteis.retornaCampoComoData(
                            paymentDate.replace('.', '/'))
                    else:
                        paymentDate = funcoesUteis.retornaCampoComoData(
                            paymentDate)

                    if paymentDate is not None and amountPaid > 0 and isProofTransferencia is True:
                        valuesOfLine = {
                            "paymentDate": paymentDate,
                            "nameProvider": nameProvider,
                            "cgceProvider": '',
                            "dueDate": '',
                            "bank": 'ITAU',
                            "account": account,
                            "amountPaid": round(amountPaid, 2),
                            "historic": historic,
                            "category": 'TRANSFERENCIA',
                            "cgcePaying": '',
                            "foundProof": True,
                            "amountPaidPerLote": round(amountPaid, 2),
                            "wayFile": self._file
                        }

                        return valuesOfLine.copy()
Пример #8
0
    def process(self):
        valuesOfLine = {}

        isFgts = False

        nameProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        amountFine = float(0)
        paymentDate = None

        for data in self._dataFile:
            if isFgts == False and data.find(
                    'RECOLHIMENTO') >= 0 and data.find('FGTS') >= 0:
                isFgts = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))

            if fieldOne.count('AGENCIA') > 0 and fieldOne.count('CONTA') > 0:
                account = fieldTwo.split('/')
                account = funcoesUteis.analyzeIfFieldIsValidMatrix(account, 2)
                account = str(funcoesUteis.treatNumberField(account))
            if fieldOne == "PAGAMENTO EFETUADO EM":
                paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo)
            if fieldOne == "VALOR RECOLHIDO":
                amountPaid = funcoesUteis.treatDecimalField(fieldTwo)
            if fieldOne.count('DESCRICAO DO PAGAMENTO') > 0:
                nameProvider = f"RECOLHIMENTO FGTS - {fieldTwo}"

            if paymentDate is not None and amountPaid > 0 and isFgts is True:
                valuesOfLine = {
                    "paymentDate": paymentDate,
                    "nameProvider": nameProvider,
                    "cgceProvider": "",
                    "dueDate": None,
                    "bank": 'ITAU',
                    "account": account,
                    "amountPaid": round(amountPaid, 2),
                    "amountInterest": round(amountInterest, 2),
                    "amountDiscount": round(amountDiscount, 2),
                    "amountFine": round(amountFine, 2),
                    "amountOriginal": round(amountOriginal, 2),
                    "historic": historic,
                    "category": 'FGTS - RECOLHEIMENTO',
                    "cgcePaying": "",
                    "foundProof": True,
                    "amountPaidPerLote": round(amountPaid, 2),
                    "wayFile": self._file
                }

                return valuesOfLine.copy()
Пример #9
0
    def process(self):
        valuesOfLine = {}

        isProofFileThisClass = False

        nameProvider = ""
        cgceProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        dueDate = None
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        paymentDate = None

        for data in self._dataFile:
            # if isProofFileThisClass == False and data.find('TIPO DE PAGAMENTO PIX') >= 0:
            #     isProofFileThisClass = True

            data = str(data)
            dataSplitTwoPoints = data.split(':')

            fieldOne = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(
                    dataSplitTwoPoints, 1))
            fieldTwo = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(
                    dataSplitTwoPoints, 2))

            if data.find('DADOS DO PAGADOR') >= 0:
                self._typeLineRead = 'PAGADOR'
            elif data.find('DADOS DO RECEBEDOR') >= 0:
                self._typeLineRead = 'RECEBEDOR'
            elif data.find('DADOS DA TRANSACAO') >= 0:
                self._typeLineRead = 'TRANSACAO'

            if self._typeLineRead == 'PAGADOR':
                if fieldOne.count('AGENCIA/CONTA') > 0:
                    account = funcoesUteis.analyzeIfFieldIsValidMatrix(
                        fieldTwo.split('/'), 2)
                    account = str(funcoesUteis.treatNumberField(account))

                if fieldOne.count('CPF / CNPJ') > 0:
                    cgcePaying = fieldTwo
            elif self._typeLineRead == 'RECEBEDOR':
                if fieldOne == "NOME DO RECEBEDOR":
                    nameProvider = fieldTwo

                if fieldOne.count('CPF / CNPJ') > 0:
                    cgceProvider = funcoesUteis.treatNumberField(fieldTwo)

            elif self._typeLineRead == 'TRANSACAO':
                if fieldOne == "VALOR":
                    amountPaid = funcoesUteis.treatDecimalField(fieldTwo)

                if fieldOne.count('DATA DA TRANSF') > 0:
                    paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo)

            if fieldOne.count('TIPO DE PAGAMENTO') > 0:
                # print(fieldOne, fieldTwo, paymentDate, amountPaid, isProofFileThisClass)
                if paymentDate is not None and amountPaid > 0:
                    valuesOfLine = {
                        "paymentDate": paymentDate,
                        "nameProvider": nameProvider,
                        "cgceProvider": cgceProvider,
                        "dueDate": dueDate,
                        "bank": 'ITAU',
                        "account": account,
                        "amountPaid": round(amountPaid, 2),
                        "amountInterest": round(amountInterest, 2),
                        "amountDiscount": round(amountDiscount, 2),
                        "amountOriginal": round(amountOriginal, 2),
                        "historic": historic,
                        "category": 'PIX',
                        "cgcePaying": cgcePaying,
                        "foundProof": True,
                        "amountPaidPerLote": round(amountPaid, 2),
                        "wayFile": self._file
                    }

                    return valuesOfLine.copy()
Пример #10
0
    def process(self):
        valuesOfLine = {}

        isTransferencia = False

        nameProvider = ""
        cgceProvider = ''
        historic = ""
        amountPaid = float(0)
        account = ""
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        amountFine = float(0)
        paymentDate = None
        
        for data in self._dataFile:
            if isTransferencia == False and data.find('COMPROVANTE DE TRANSF') >= 0:
                isTransferencia = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))
            fieldThree = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 3))

            if fieldOne.count('DO DOCUMENTO') > 0:
                self._accountDebitOrCredit = 'DEBIT'
            elif fieldOne.count('FAVORECIDO') > 0:
                self._accountDebitOrCredit = 'CREDIT'
            
            if fieldTwo.count("DATA DA TRANSF") > 0:
                paymentDate = funcoesUteis.retornaCampoComoData(fieldThree)

            if self._accountDebitOrCredit == 'DEBIT':
                if fieldOne == 'CONTA':
                    account = str(funcoesUteis.treatNumberField(fieldTwo, isInt=True))

            if fieldOne == 'NOME':
                nameProvider = fieldTwo  
            if fieldOne == 'CPF':
                cgceProvider = fieldTwo            
            if fieldOne == 'CNPJ':
                cgceProvider = fieldTwo
            if fieldOne == "VALOR":
                amountPaid = funcoesUteis.treatDecimalField(fieldTwo)
            if fieldOne.count("DATA DA TRANSF") > 0:
                paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo)

            if fieldOne == "DESCRICAO":
                if paymentDate is not None and amountPaid > 0 and isTransferencia is True:
                    valuesOfLine = {
                        "paymentDate": paymentDate,
                        "nameProvider": nameProvider,
                        "cgceProvider": cgceProvider,
                        "dueDate": None,
                        "bank": 'AMAZONIA',
                        "account": account,
                        "amountPaid": round(amountPaid, 2),
                        "amountInterest": round(amountInterest, 2),
                        "amountDiscount": round(amountDiscount, 2),
                        "amountFine": round(amountFine, 2),
                        "amountOriginal": round(amountOriginal, 2),
                        "historic": historic,
                        "category": 'TRANSFERENCIA',
                        "cgcePaying": "",
                        "foundProof": True,
                        "amountPaidPerLote": round(amountPaid, 2),
                        "wayFile": self._file
                    }

                    return valuesOfLine.copy()
Пример #11
0
    def process(self):
        valuesOfFile = []
        valuesOfLine = {}

        isPagamento = False

        nameProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        amountFine = float(0)
        paymentDate = None
        dueDate = None
        countQtdDataNecessaryToProofIsValid = 0

        for data in self._dataFile:
            # print(data)
            if data.find('SICOOB - SISTEMA DE COOPERATIVAS') >= 0:
                countQtdDataNecessaryToProofIsValid = 0
                countQtdDataNecessaryToProofIsValid += 1

            if data.find('PAGAMENTO DE TITULO') >= 0:
                countQtdDataNecessaryToProofIsValid += 1

            if countQtdDataNecessaryToProofIsValid >= 2:
                isPagamento = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))
            # fieldThree = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 3))

            if fieldOne == 'CONTA':
                account = funcoesUteis.treatNumberField(fieldTwo.split('/')[0])

            if fieldOne.count('NOME') > 0 and fieldOne.count(
                    "BENEFICIARIO") > 0:
                nameProvider = fieldTwo

            if fieldOne.count('CNPJ') > 0 and fieldOne.count(
                    "BENEFICIARIO") > 0:
                cgceProvider = fieldTwo

            if fieldOne.count('CNPJ') > 0 and fieldOne.count("PAGADOR") > 0:
                cgcePaying = fieldTwo

            if fieldOne == "DATA PAGAMENTO":
                paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo)

            if fieldOne == "DATA VENCIMENTO":
                dueDate = funcoesUteis.retornaCampoComoData(fieldTwo)

            if fieldOne == "VALOR DOCUMENTO":
                amountOriginal = funcoesUteis.treatDecimalField(fieldTwo)

            if fieldOne.count('DESCONTO') > 0 and fieldOne.count(
                    "ABATIMENTO") > 0:
                amountDiscount = funcoesUteis.treatDecimalField(fieldTwo)

            if fieldOne.count('OUTROS ACRESCIMOS') > 0:
                amountInterest = funcoesUteis.treatDecimalField(fieldTwo)

            if fieldOne == "VALOR PAGO":
                amountPaid = funcoesUteis.treatDecimalField(fieldTwo)

            if fieldOne == "VALOR PAGO":
                if paymentDate is not None and amountPaid > 0 and isPagamento is True:
                    valuesOfLine = {
                        "paymentDate": paymentDate,
                        "nameProvider": nameProvider,
                        "cgceProvider": cgceProvider,
                        "dueDate": dueDate,
                        "bank": 'SICOOB',
                        "account": account,
                        "amountPaid": round(amountPaid, 2),
                        "amountInterest": round(amountInterest, 2),
                        "amountDiscount": round(amountDiscount, 2),
                        "amountFine": round(amountFine, 2),
                        "amountOriginal": round(amountOriginal, 2),
                        "historic": historic,
                        "category": '',
                        "cgcePaying": cgcePaying,
                        "foundProof": True,
                        "amountPaidPerLote": round(amountPaid, 2),
                        "wayFile": self._file
                    }

                    valuesOfFile.append(valuesOfLine.copy())

        return valuesOfFile
Пример #12
0
    def process(self):
        valuesOfLine = {}

        isPagamento = False

        nameProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        amountFine = float(0)
        paymentDate = None
        dueDate = None

        for data in self._dataFile:
            if isPagamento == False and data.find(
                    'COMPROVANTE DE PAGAMENTO') >= 0:
                isPagamento = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))
            fieldThree = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 3))

            if fieldOne.count('DO DOCUMENTO') > 0 and fieldTwo.count(
                    "DATA") > 0:
                paymentDate = funcoesUteis.retornaCampoComoData(fieldThree)

            if fieldOne == 'CONTA':
                account = str(
                    funcoesUteis.treatNumberField(fieldTwo, isInt=True))

            if fieldOne.count('BENEFICIARIO') > 0:
                self._accountDebitOrCredit = 'DEBIT'
            elif fieldOne.count('PAGADOR') > 0:
                self._accountDebitOrCredit = 'CREDIT'
            elif fieldOne.count('SACADOR') > 0:
                self._accountDebitOrCredit = ''

            if self._accountDebitOrCredit == 'DEBIT':
                if fieldOne == 'RAZAO SOCIAL':
                    nameProvider = fieldTwo
                if fieldOne == 'CNPJ/CPF':
                    cgceProvider = fieldTwo

            elif self._accountDebitOrCredit == 'CREDIT':
                if fieldOne == "DATA DO PAGAMENTO":
                    paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo)
                if fieldOne == "DATA DE VENCIMENTO":
                    dueDate = funcoesUteis.retornaCampoComoData(fieldTwo)
                if fieldOne == "VALOR NOMINAL":
                    amountOriginal = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == 'ENCARGOS':
                    amountInterest = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "VALOR PAGO":
                    amountPaid = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "DESCONTO":
                    amountDiscount = funcoesUteis.treatDecimalField(fieldTwo)

            if fieldOne == "VALOR PAGO":
                if paymentDate is not None and amountPaid > 0 and isPagamento is True:
                    valuesOfLine = {
                        "paymentDate": paymentDate,
                        "nameProvider": nameProvider,
                        "cgceProvider": cgceProvider,
                        "dueDate": dueDate,
                        "bank": 'AMAZONIA',
                        "account": account,
                        "amountPaid": round(amountPaid, 2),
                        "amountInterest": round(amountInterest, 2),
                        "amountDiscount": round(amountDiscount, 2),
                        "amountFine": round(amountFine, 2),
                        "amountOriginal": round(amountOriginal, 2),
                        "historic": historic,
                        "category": 'PAGAMENTO',
                        "cgcePaying": "",
                        "foundProof": True,
                        "amountPaidPerLote": round(amountPaid, 2),
                        "wayFile": self._file
                    }

                    return valuesOfLine.copy()
Пример #13
0
    def process(self):
        valuesOfLine = {}

        isProofAgendamento = False

        nameProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        amountFine = float(0)
        paymentDate = None

        for data in self._dataFile:
            if isProofAgendamento == False and data.find(
                    'COMPROVANTE DE AGENDAMENTO') >= 0:
                isProofAgendamento = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))

            # faço esta separação pra poder identificar o que deve ser lido, pois os dados estão na linha abaixo e não onde 'BENEFICIARIO' por exemplo
            if fieldOne.count('CONTA A SER DEBITADA') > 0:
                self._typeLineRead = 'conta_debitada'
            elif fieldOne.count('DADOS DO PAGAMENTO') > 0:
                self._typeLineRead = 'dados_pagamento'
            elif fieldOne.count('DADOS DO BENEFICIARIO') > 0:
                self._typeLineRead = 'beneficiario'
            elif fieldOne.count('DADOS DO PAGADOR') > 0:
                self._typeLineRead = 'pagador'
            elif fieldOne.count('DADOS DO BOLETO') > 0:
                self._typeLineRead = 'dados_boleto'

            if self._typeLineRead == "conta_debitada":
                if fieldOne.count('AGENCIA') > 0:
                    account = funcoesUteis.treatTextField(
                        funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 3))
                    account = str(funcoesUteis.treatNumberField(account))
                    # account = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(account.split('-'), 1))
                    # if account.find(' ') > 0:
                    #     account = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(account.split(' '), 1))
            if self._typeLineRead == 'beneficiario':
                if fieldOne == "NOME":
                    nameProvider = fieldTwo
                if fieldOne == "RAZAO SOCIAL":
                    nameProvider = fieldTwo
                if fieldOne.count('CNPJ') > 0 or fieldOne.count('CPF') > 0:
                    cgceProvider = funcoesUteis.treatNumberField(fieldTwo)
            if self._typeLineRead == 'pagador':
                if fieldOne.count('CNPJ') > 0 or fieldOne.count('CPF') > 0:
                    cgcePaying = funcoesUteis.treatNumberField(fieldTwo)
            elif self._typeLineRead == 'dados_boleto':
                if fieldOne == "DATA DE VENCIMENTO":
                    dueDate = funcoesUteis.retornaCampoComoData(fieldTwo)
                if fieldOne == "DATA DO PAGAMENTO":
                    paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo)
                if fieldOne == "VALOR DO DOCUMENTO":
                    amountOriginal = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "DESCONTO":
                    amountDiscount = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "JUROS/MORA":
                    amountInterest = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "MULTA":
                    amountFine = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "VALOR DO PAGAMENTO":
                    amountPaid = funcoesUteis.treatDecimalField(fieldTwo)

            for valueOfLineDatePayment in self._valuesOfLineDatePayment:
                if data[0:len(valueOfLineDatePayment
                              )] == valueOfLineDatePayment:
                    if paymentDate is None:  # apenas se for None, pq o de agendamento tem um campo especifico pra data
                        paymentDate = funcoesUteis.treatTextField(
                            data[len(valueOfLineDatePayment) +
                                 1:len(valueOfLineDatePayment) + 11])
                        if paymentDate.find('.') >= 0:
                            paymentDate = funcoesUteis.retornaCampoComoData(
                                paymentDate.replace('.', '/'))
                        else:
                            paymentDate = funcoesUteis.retornaCampoComoData(
                                paymentDate)

                    if paymentDate is not None and amountPaid > 0 and isProofAgendamento is True:
                        valuesOfLine = {
                            "paymentDate": paymentDate,
                            "nameProvider": nameProvider,
                            "cgceProvider": cgceProvider,
                            "dueDate": dueDate,
                            "bank": 'ITAU',
                            "account": account,
                            "amountPaid": round(amountPaid, 2),
                            "amountInterest": round(amountInterest, 2),
                            "amountDiscount": round(amountDiscount, 2),
                            "amountFine": round(amountFine, 2),
                            "amountOriginal": round(amountOriginal, 2),
                            "historic": historic,
                            "category": 'AGENDAMENTO',
                            "cgcePaying": cgcePaying,
                            "foundProof": True,
                            "amountPaidPerLote": round(amountPaid, 2),
                            "wayFile": self._file
                        }

                        return valuesOfLine.copy()
Пример #14
0
    def process(self):
        valuesOfLine = {}

        isPagamentoInss = False

        nameProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        amountFine = float(0)
        paymentDate = None
        dueDate = None

        for data in self._dataFile:
            if isPagamentoInss == False and data.find(
                    'COMPROVANTE DE PAGAMENTO') >= 0 and (data.find('INSS') or
                                                          data.find('DARF')):
                isPagamentoInss = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))
            fieldThree = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 3))

            if fieldOne.count('DO DOCUMENTO') > 0 and fieldTwo.count(
                    "DATA") > 0:
                paymentDate = funcoesUteis.retornaCampoComoData(fieldThree)

            if fieldOne == 'CONTA':
                account = str(
                    funcoesUteis.treatNumberField(fieldTwo, isInt=True))

            if fieldOne.count('MULTA') > 0 or fieldOne.count('JUROS') > 0:
                amountInterest = funcoesUteis.treatDecimalField(fieldTwo)
            if fieldOne == "VALOR TOTAL":
                amountPaid = funcoesUteis.treatDecimalField(fieldTwo)

            if fieldOne == 'DESCRICAO':
                nameProvider = fieldTwo

            if fieldOne == "DESCRICAO":
                if paymentDate is not None and amountPaid > 0 and isPagamentoInss is True:
                    valuesOfLine = {
                        "paymentDate": paymentDate,
                        "nameProvider": nameProvider,
                        "cgceProvider": "",
                        "dueDate": dueDate,
                        "bank": 'AMAZONIA',
                        "account": account,
                        "amountPaid": round(amountPaid, 2),
                        "amountInterest": round(amountInterest, 2),
                        "amountDiscount": round(amountDiscount, 2),
                        "amountFine": round(amountFine, 2),
                        "amountOriginal": round(amountOriginal, 2),
                        "historic": historic,
                        "category": 'PAGAMENTO',
                        "cgcePaying": "",
                        "foundProof": True,
                        "amountPaidPerLote": round(amountPaid, 2),
                        "wayFile": self._file
                    }

                    return valuesOfLine.copy()
Пример #15
0
 def getBalancePeriod(self, clas_cta, accountResultado):
     get = self._getBalancesPeriod.get(self._codi_emp, self._codi_emp_plano_contas, clas_cta, self._start_date, self._end_date)
     credito = treatDecimalField(get[0]['credit'])
     debito = treatDecimalField(get[1]['debit'])
     if accountResultado is True:
         self._amountResultado += debito + credito
Пример #16
0
    def process(self):
        valuesOfLine = {}

        isDarf = False

        nameProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        amountFine = float(0)
        paymentDate = None

        for data in self._dataFile:
            if isDarf == False and data.find('PAGAMENTO') >= 0 and (
                    data.find('DARF') >= 0
                    or data.find('SIMPLES NACIONAL') >= 0):
                isDarf = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))

            if fieldOne.count('CONTA DEBITADA') > 0:
                self._accountDebitOrCredit = 'DEBIT'
            elif fieldOne.count('AGENTE ARRECADADOR') > 0:
                self._accountDebitOrCredit = 'CREDIT'

            if self._accountDebitOrCredit == 'DEBIT':
                # if fieldOne.count('AGENCIA/CONTA') > 0:
                #     account = fieldTwo.split()
                #     account = funcoesUteis.analyzeIfFieldIsValidMatrix(account, 2)
                #     account = str(funcoesUteis.treatNumberField(account))
                if fieldOne.count('AGENCIA') > 0 and fieldOne.count(
                        'CONTA') > 0:
                    account = fieldTwo.split('/')
                    account = funcoesUteis.analyzeIfFieldIsValidMatrix(
                        account, 2)
                    account = str(
                        funcoesUteis.treatNumberField(account, isInt=True))
            elif self._accountDebitOrCredit == 'CREDIT':
                if fieldOne == "DATA DO PAGAMENTO":
                    paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo)
                if fieldOne == "VALOR PRINCIPAL":
                    amountOriginal = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "DESCONTO":
                    amountDiscount = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "VALOR DOS JUROS/ENCARGOS":
                    amountInterest = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "VALOR DA MULTA":
                    amountFine = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "VALOR TOTAL":
                    amountPaid = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne.count('CPF OU CNPJ') > 0:
                    nameProvider = f"DARF - {fieldTwo}"
                if nameProvider == "":
                    nameProvider = "SIMPLES NACIONAL"

            if fieldOne.count('AGENCIA') > 0 and fieldOne.count('CONTA') > 0:
                if paymentDate is not None and amountPaid > 0 and isDarf is True:
                    valuesOfLine = {
                        "paymentDate":
                        paymentDate,
                        "nameProvider":
                        nameProvider,
                        "cgceProvider":
                        "",
                        "dueDate":
                        None,
                        "bank":
                        'ITAU',
                        "account":
                        account,
                        "amountPaid":
                        round(amountPaid, 2),
                        "amountInterest":
                        round(amountInterest, 2),
                        "amountDiscount":
                        round(amountDiscount, 2),
                        "amountFine":
                        round(amountFine, 2),
                        "amountOriginal":
                        round(amountOriginal, 2),
                        "historic":
                        historic,
                        "category":
                        'DARF' if nameProvider != "SIMPLES NACIONAL" else
                        nameProvider,
                        "cgcePaying":
                        "",
                        "foundProof":
                        True,
                        "amountPaidPerLote":
                        round(amountPaid, 2),
                        "wayFile":
                        self._file
                    }

                    return valuesOfLine.copy()
Пример #17
0
    def process(self):
        valuesOfFile = []
        valuesOfLine = {}

        isPagamento = False

        cgceProvider = ''
        cgcePaying = ''
        nameProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        amountFine = float(0)
        paymentDate = None
        dueDate = None
        countQtdDataNecessaryToProofIsValid = 0
        
        for data in self._dataFile:
            if data.find('COMPROVANTE DE TRANSACAO BANCARIA') >= 0:
                countQtdDataNecessaryToProofIsValid = 0
                countQtdDataNecessaryToProofIsValid += 1

            if data.find('TRANSACAO ACIMA FOI REALIZADA') >= 0:
                countQtdDataNecessaryToProofIsValid += 1
                
            if countQtdDataNecessaryToProofIsValid >= 2:
                isPagamento = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))
            # fieldThree = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 3))
            
            if fieldOne == 'CONTA DE DEBITO':
                account = funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 4)
                account = account.split('|')
                account = funcoesUteis.analyzeIfFieldIsValidMatrix(account, 1)
                account = account.split('-')
                account = funcoesUteis.treatNumberFieldInVector(account, 1, isInt=True)
                account = str(account)

            if data.count('RAZAO SOCIAL') > 0 and data.count('SACADOR') == 0:
                positionRazaoSocial = data.find('RAZAO SOCIAL') + len('RAZAO SOCIAL')
                nameProvider = funcoesUteis.treatTextField(data[positionRazaoSocial:])

            if fieldOne.count('CNPJ') > 0 and fieldOne.count("BENEFICIARIO") > 0:
                cgceProvider = fieldTwo

            if fieldOne.count('CNPJ') > 0 and fieldOne.count("PAGADOR") > 0:
                cgcePaying = fieldTwo

            if fieldOne == "DATA DE DEBITO":
                paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo)

            if fieldOne == "DATA DE VENCIMENTO":
                dueDate = funcoesUteis.retornaCampoComoData(fieldTwo)

            if fieldOne == "VALOR":
                amountOriginal = funcoesUteis.treatDecimalField(fieldTwo, decimalSeparator='.')

            if fieldOne.count('DESCONTO') > 0:
                amountDiscount = funcoesUteis.treatDecimalField(fieldTwo, decimalSeparator='.')

            if fieldOne.count('MULTA') > 0:
                amountFine = funcoesUteis.treatDecimalField(fieldTwo, decimalSeparator='.')

            if fieldOne.count('JUROS') > 0:
                amountInterest = funcoesUteis.treatDecimalField(fieldTwo, decimalSeparator='.')

            if fieldOne == "VALOR TOTAL":
                amountPaid = funcoesUteis.treatDecimalField(fieldTwo, decimalSeparator='.')

            if fieldOne == "DESCRICAO":
                historic = funcoesUteis.treatDecimalField(fieldTwo)            

            if data.find('TRANSACAO ACIMA FOI REALIZADA') >= 0:
                if paymentDate is not None and amountPaid > 0 and isPagamento is True:
                    valuesOfLine = {
                        "paymentDate": paymentDate,
                        "nameProvider": nameProvider,
                        "cgceProvider": cgceProvider,
                        "dueDate": dueDate,
                        "bank": 'BRADESCO',
                        "account": account,
                        "amountPaid": round(amountPaid, 2),
                        "amountInterest": round(amountInterest, 2),
                        "amountDiscount": round(amountDiscount, 2),
                        "amountFine": round(amountFine, 2),
                        "amountOriginal": round(amountOriginal, 2),
                        "historic": historic,
                        "category": '',
                        "cgcePaying": cgcePaying,
                        "foundProof": True,
                        "amountPaidPerLote": round(amountPaid, 2),
                        "wayFile": self._file
                    }

                    valuesOfFile.append(valuesOfLine.copy())

        return valuesOfFile
Пример #18
0
    def process(self):
        valuesOfLine = {}

        isProofPagamentoBoleto = False

        nameProvider = ""
        cgceProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        dueDate = None
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)

        for data in self._dataFile:
            if isProofPagamentoBoleto == False and data.find(
                    'PAGAMENTO DE BOLETO') >= 0:
                isProofPagamentoBoleto = True

            data = str(data)
            dataSplitTwoPoints = data.split(':')
            dataSplitSpace = data.split(' ')

            fieldOne = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(
                    dataSplitTwoPoints, 1))
            fieldTwo = funcoesUteis.treatTextField(
                funcoesUteis.analyzeIfFieldIsValidMatrix(
                    dataSplitTwoPoints, 2))

            if fieldOne.count('AGENCIA/CONTA') > 0:
                account = funcoesUteis.analyzeIfFieldIsValidMatrix(
                    fieldTwo.split('/'), 2)
                account = str(funcoesUteis.treatNumberField(account))
                # account = str(funcoesUteis.treatNumberField(funcoesUteis.analyzeIfFieldIsValidMatrix(account.split('-'), 1), isInt=True))

                cgcePaying = funcoesUteis.treatNumberField(
                    funcoesUteis.analyzeIfFieldIsValidMatrix(
                        dataSplitTwoPoints, 3))

            # faço esta separação pra poder identificar o que deve ser lido, pois os dados estão na linha abaixo e não onde 'BENEFICIARIO' por exemplo
            if fieldOne == 'BENEFICIARIO':
                self._typeLineRead = 'beneficiario'
            elif fieldOne.count('VALOR DO BOLETO') > 0 or fieldOne.count(
                    'VALOR DO DOCUMENTO') > 0:
                self._typeLineRead = 'valor_boleto'
            elif fieldOne.count('DESCONTO') > 0 and fieldOne.count('(-)') > 0:
                self._typeLineRead = 'desconto'
            elif fieldOne.count('MORA/MULTA') > 0 and fieldOne.count(
                    '(+)') > 0:
                self._typeLineRead = 'juros'
            if data.count('VALOR DO PAGAMENTO') > 0 and data.count('R$') > 0:
                self._typeLineRead = 'valor_pago'
            elif data.count('DATA DE PAGAMENTO') > 0:
                self._typeLineRead = 'data_pagamento'

            # dados da linha do BENEFICIARIO
            if self._typeLineRead == 'beneficiario' and fieldOne.count(
                    'BENEFICIARIO') == 0:
                # alguns comprovantes de boleto tem a RAZAO SOCIAL e CNPJ também
                if (fieldOne == "RAZAO SOCIAL"):
                    nameProvider = ' '.join(
                        dataSplitSpace[2:len(dataSplitSpace) - 2])
                    cgceProvider = funcoesUteis.treatNumberField(
                        dataSplitSpace[len(dataSplitSpace) - 2])
                else:
                    nameProvider = ' '.join(
                        dataSplitSpace[:len(dataSplitSpace) - 1])

                nameProvider = nameProvider.strip()
                dueDate = funcoesUteis.retornaCampoComoData(
                    dataSplitSpace[len(dataSplitSpace) - 1])
            # dados da linha do VALOR ORIGINAL DO BOLETO
            elif self._typeLineRead == 'valor_boleto' and fieldOne.count(
                    'VALOR DO BOLETO') == 0 and fieldOne.count(
                        'VALOR DO DOCUMENTO') == 0:
                amountOriginal = funcoesUteis.treatDecimalField(
                    dataSplitSpace[len(dataSplitSpace) - 1])
            # dados da linha do VALOR DESCONTO
            elif self._typeLineRead == 'desconto' and fieldOne.count(
                    'DESCONTO') == 0:
                amountDiscount = funcoesUteis.treatDecimalField(
                    dataSplitSpace[len(dataSplitSpace) - 1])
            # dados da linha do VALOR MORA/MULTA
            elif self._typeLineRead == 'juros' and fieldOne.count(
                    'MORA/MULTA') == 0:
                amountInterest = funcoesUteis.treatDecimalField(
                    dataSplitSpace[len(dataSplitSpace) - 1])
            # dados da linha do VALOR MORA/MULTA
            elif self._typeLineRead == 'valor_pago' and data.count(
                    'VALOR DO PAGAMENTO') == 0 and data.count('R$') == 0:
                amountPaid = funcoesUteis.treatDecimalField(
                    dataSplitSpace[len(dataSplitSpace) - 1])

            for valueOfLineDatePayment in self._valuesOfLineDatePayment:
                if data[0:len(valueOfLineDatePayment
                              )] == valueOfLineDatePayment:
                    paymentDate = funcoesUteis.treatTextField(
                        data[len(valueOfLineDatePayment) +
                             1:len(valueOfLineDatePayment) + 11])
                    if paymentDate.find('.') >= 0:
                        paymentDate = funcoesUteis.retornaCampoComoData(
                            paymentDate.replace('.', '/'))
                    else:
                        paymentDate = funcoesUteis.retornaCampoComoData(
                            paymentDate)

                    if paymentDate is not None and amountPaid > 0 and isProofPagamentoBoleto is True:
                        valuesOfLine = {
                            "paymentDate": paymentDate,
                            "nameProvider": nameProvider,
                            "cgceProvider": cgceProvider,
                            "dueDate": dueDate,
                            "bank": 'ITAU',
                            "account": account,
                            "amountPaid": round(amountPaid, 2),
                            "amountInterest": round(amountInterest, 2),
                            "amountDiscount": round(amountDiscount, 2),
                            "amountOriginal": round(amountOriginal, 2),
                            "historic": historic,
                            "category": 'PAGTO DE BOLETO',
                            "cgcePaying": cgcePaying,
                            "foundProof": True,
                            "amountPaidPerLote": round(amountPaid, 2),
                            "wayFile": self._file
                        }

                        return valuesOfLine.copy()
Пример #19
0
    def process(self, file, numberFile):

        valuesOfLine = {}
        valuesOfFile = []

        try:
            with codecs.open(file) as fileobj:
                ofx = OfxParser.parse(fileobj, fail_fast=False)

            accountData = ofx.account

            try:
                institution = accountData.institution
                fid = int(institution.fid)
            except Exception:
                fid = 0

            bankId = int(accountData.routing_number)
            bankId = fid if fid == 82 else bankId
            bankName = funcoesUteis.returnBankForNumber(bankId) #self.returnNameBank(bankId)

            account = accountData.account_id
            account = str(account).replace('-', '')
            account = self.returnAccount(bankId, account)

            # shutil.copy(file, f'{self._wayOriginal}/ofx_organizados/{bankName}_{account}_{numberFile}.ofx')

            transactions = accountData.statement.transactions
            for transaction in transactions:
                typeTransaction = funcoesUteis.treatTextField(transaction.type)
                
                dateTransaction = transaction.date
                dateTransaction = datetime.datetime.date(dateTransaction)
                
                amount = funcoesUteis.treatDecimalField(transaction.amount)
                if amount < 0:
                    operation = '-'
                    amount *= -1
                else:
                    operation = '+'

                if operation == "+":
                    historicCode = 24
                else:
                    historicCode = 78
                
                document = funcoesUteis.treatTextField(transaction.checknum)

                historic = funcoesUteis.treatTextField(transaction.memo)
                # ignora lancamentos no extrato como saldo parcial, pq nao é um lançamento em si
                if historic == 'SALDO' or historic.find('SALDO PARCIAL') >= 0 or historic.find('SALDO INICIAL') >= 0 \
                    or historic.find('SALDO FINAL') >= 0 or historic.find('SALDO APLIC') >= 0 or historic.find('SALDO A LIBERAR') >= 0 \
                    or historic.find('SDO CTA') >= 0 or historic.find('SALDO') >= 0:
                    continue

                valuesOfLine = {
                    "bank": bankName,
                    "account": account,
                    "typeTransaction": typeTransaction,
                    "dateTransaction": dateTransaction,
                    "amount": round(amount, 2),
                    "operation": operation,
                    "document": document,
                    "historicCode": historicCode,
                    "historic": historic,
                    "wayFile": file
                }

                valuesOfFile.append(valuesOfLine.copy())
        except Exception as e:
            print(file, e)
            pass
        
        return valuesOfFile
Пример #20
0
    def process(self):
        valuesOfLine = {}

        isProofDefaultSispag = False

        nameProvider = ""
        namePayee = ""
        historic = ""
        dueDate = None
        cgcePaying = ""
        cnpjProvider = ""
        amountPaid = float(0)
        category = ""
        bank = "ITAU"
        account = ""

        for data in self._dataFile:

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))

            fieldTwo = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))

            if fieldOne.count('COMPROVANTE DE OPERACAO') > 0:
                category = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(data.split('-'), 2))
            if fieldOne.count('PAGAMENTO COM CODIGO DE BARRAS') > 0:
                category = 'PAGTO COD BARRA'
            if fieldOne.count("PAGAMENTO DE CONCESSIONARIAS") > 0:
                category = 'PAGTO CONCESSIONARIA'
            if fieldOne.count("FGTS") > 0 or fieldOne.count("GRRF") > 0:
                category = 'PAGTO FGTS-GRRF'
            if fieldOne.count("GUIA DE RECOLHIMENTO") > 0:
                category = 'PAGTO GRF'
                historic = funcoesUteis.treatTextField(data)
            
            if fieldOne.count("IDENTIFICACAO NO EXTRATO") > 0:
                historic = fieldTwo

            if fieldOne.count('CONTA') > 0 and fieldOne.count('DEBITADA') > 0:
                self._accountDebitOrCredit = 'DEBIT'
            elif fieldOne.count('CONTA A SER CREDITADA') > 0 or fieldOne.count('DADOS DO PAGAMENTO') > 0:
                self._accountDebitOrCredit = 'CREDIT'

            if self._accountDebitOrCredit == 'DEBIT':
                if fieldOne.count('AGENCIA') > 0:
                    account = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 3))
                    account = str(funcoesUteis.treatNumberField(account))
                    # account = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(account.split('-'), 1))
                    # if account.find(' ') > 0:
                    #     account = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(account.split(' '), 1))
            elif self._accountDebitOrCredit == 'CREDIT':
                if fieldOne == "NOME":
                    nameProvider = fieldTwo

                if fieldOne == "NOME DO FAVORECIDO":
                    nameProvider = fieldTwo
                    namePayee = nameProvider
                    
                if fieldOne == "INFORMACOES FORNECIDAS PELO PAGADOR":
                    historic = fieldTwo
                
                if fieldOne == "DATA DE VENCIMENTO":
                    dueDate = funcoesUteis.transformaCampoDataParaFormatoBrasileiro(funcoesUteis.retornaCampoComoData(fieldTwo))

                if ( fieldOne.count("CPF") > 0 or fieldOne.count("CNPJ") > 0 ) and fieldOne.count("PAGADOR") > 0:
                    cgcePaying = funcoesUteis.treatNumberField(fieldTwo)

                if ( fieldOne.count("CPF") > 0 or fieldOne.count("CNPJ") > 0 ) and fieldOne.count("PAGADOR") == 0:
                    cnpjProvider = funcoesUteis.treatNumberField(fieldTwo)

                if fieldOne.count("VALOR") > 0:
                    amountPaid = funcoesUteis.treatDecimalField(fieldTwo)

			# quando é pagamento de imposto não tem o nome do fornecedor, o dados vem na informação complementar
            if historic != "" and dueDate == "" and namePayee == "":
                nameProvider = historic

            # se o nome do fornecedor ainda for vazio, então considero a categoria como fornecedor
            if nameProvider == "" and category != "":
                nameProvider = category

            for valueOfLineDatePayment in self._valuesOfLineDatePayment:
                if data[0 : len(valueOfLineDatePayment) ] == valueOfLineDatePayment:
                    paymentDate = funcoesUteis.treatTextField(data[len(valueOfLineDatePayment)+1:len(valueOfLineDatePayment)+11])
                    paymentDate = funcoesUteis.retornaCampoComoData(paymentDate.replace('.', '/'))

                    if paymentDate is not None and amountPaid > 0:
                        valuesOfLine = {
                            "paymentDate": paymentDate,
                            "nameProvider": nameProvider,
                            "cgceProvider": cnpjProvider,
                            "dueDate": dueDate,
                            "bank": bank,
                            "account": account,
                            "amountPaid": round(amountPaid, 2),
                            "historic": historic,
                            "category": category,
                            "cgcePaying": cgcePaying,
                            "foundProof": True,
                            "amountPaidPerLote": round(amountPaid, 2),
                            "wayFile": self._file
                        }

                        return valuesOfLine.copy()
    def sheetProducts(self):
        sheet = self._workbook.add_worksheet('Products')
        sheet.freeze_panes(1, 0)

        sheet.set_column(10, 12, options={
            'hidden': True
        })  # qtd, valor unitário e valor total domínio
        sheet.set_column(15, 17,
                         options={'hidden': True
                                  })  # qtd, valor unitário e valor total xml

        sheet.write(0, 0, "Código Empresa", self._cell_format_header)
        sheet.write(0, 1, "Código Nota", self._cell_format_header)
        sheet.write(0, 2, "Número", self._cell_format_header)
        sheet.write(0, 3, "Tipo Nota", self._cell_format_header)
        sheet.write(0, 4, "Cliente/Fornecedor", self._cell_format_header)
        sheet.write(0, 5, "Emissão", self._cell_format_header)
        sheet.write(0, 6, "Entrada/Saída", self._cell_format_header)
        sheet.write(0, 7, "Código Produto Domínio", self._cell_format_header)
        sheet.write(0, 8, "Descrição", self._cell_format_header)
        sheet.write(0, 9, "CFOP", self._cell_format_header)
        sheet.write(0, 10, "Quantidade", self._cell_format_header)
        sheet.write(0, 11, "Valor Unitário", self._cell_format_header)
        sheet.write(0, 12, "Valor Total", self._cell_format_header)
        sheet.write(0, 13, "Código Produto XML", self._cell_format_header)
        sheet.write(0, 14, "Descrição", self._cell_format_header)
        sheet.write(0, 15, "Quantidade", self._cell_format_header)
        sheet.write(0, 16, "Valor Unitário", self._cell_format_header)
        sheet.write(0, 17, "Valor Total", self._cell_format_header)
        sheet.write(0, 18, "Comparação", self._cell_format_header)
        sheet.write(0, 19, "Chave Nota", self._cell_format_header)

        productsAccountSystemXXML = self._collection.find()

        for key, productAccountSystemXXML in enumerate(
                productsAccountSystemXXML):
            row = key + 1

            print(f' - Processando {row}')

            codiEmp = funcoesUteis.analyzeIfFieldIsValid(
                productAccountSystemXXML, "codiEmp")
            codiNote = funcoesUteis.returnDataFieldInDict(
                productAccountSystemXXML, ["productDominio", "codigo_nota"])
            numberNote = funcoesUteis.returnDataFieldInDict(
                productAccountSystemXXML, ["productDominio", "numero"])
            typeNF = funcoesUteis.analyzeIfFieldIsValid(
                productAccountSystemXXML, "typeNF")
            cliFor = funcoesUteis.returnDataFieldInDict(
                productAccountSystemXXML, ["productDominio", "cli_for"])
            issueDate = funcoesUteis.retornaCampoComoData(
                funcoesUteis.returnDataFieldInDict(
                    productAccountSystemXXML, ["productDominio", "emissao"]),
                2)
            saidaEntradaDate = funcoesUteis.retornaCampoComoData(
                funcoesUteis.returnDataFieldInDict(
                    productAccountSystemXXML,
                    ["productDominio", "saida_entrada"]), 2)
            codeProductAccountSystem = funcoesUteis.returnDataFieldInDict(
                productAccountSystemXXML,
                ["productDominio", "codi_pdi"]).strip()
            nameProductAccountSystem = funcoesUteis.treatTextField(
                funcoesUteis.returnDataFieldInDict(
                    productAccountSystemXXML, ["productDominio", "desc_pdi"]))
            cfopProductAccountSystem = funcoesUteis.returnDataFieldInDict(
                productAccountSystemXXML, ["productDominio", "cfop"])
            qtdProductAccountSystem = funcoesUteis.treatDecimalField(
                funcoesUteis.returnDataFieldInDict(productAccountSystemXXML,
                                                   ["productDominio", "qtd"]))
            vunitProductAccountSystem = funcoesUteis.treatDecimalField(
                funcoesUteis.returnDataFieldInDict(
                    productAccountSystemXXML, ["productDominio", "vunit"]))
            vtotProductAccountSystem = funcoesUteis.treatDecimalField(
                funcoesUteis.returnDataFieldInDict(productAccountSystemXXML,
                                                   ["productDominio", "vtot"]))
            codeProductXML = funcoesUteis.returnDataFieldInDict(
                productAccountSystemXXML,
                ["productXML", "prod", "cProd"]).strip()
            nameProductXML = funcoesUteis.treatTextField(
                funcoesUteis.returnDataFieldInDict(
                    productAccountSystemXXML, ["productXML", "prod", "xProd"]))
            qtdProductXML = funcoesUteis.treatDecimalField(
                funcoesUteis.returnDataFieldInDict(
                    productAccountSystemXXML, ["productXML", "prod", "qCom"]))
            vunitProductXML = funcoesUteis.treatDecimalField(
                funcoesUteis.returnDataFieldInDict(
                    productAccountSystemXXML,
                    ["productXML", "prod", "vUnCom"]))
            vtotProductXML = funcoesUteis.treatDecimalField(
                funcoesUteis.returnDataFieldInDict(
                    productAccountSystemXXML, ["productXML", "prod", "vProd"]))
            valueComparationBetweenAccountSystemAndXML = funcoesUteis.treatDecimalField(
                funcoesUteis.returnDataFieldInDict(
                    productAccountSystemXXML,
                    ["valueComparationBetweenAccountSystemAndXML"]))
            keyNF = funcoesUteis.returnDataFieldInDict(
                productAccountSystemXXML, ["productDominio", "chave_nfe"])

            sheet.write(row, 0, codiEmp)
            sheet.write(row, 1, codiNote)
            sheet.write(row, 2, numberNote)
            sheet.write(row, 3, typeNF)
            sheet.write(row, 4, cliFor)
            sheet.write(row, 5, issueDate, self._cell_format_date)
            sheet.write(row, 6, saidaEntradaDate, self._cell_format_date)
            sheet.write(row, 7, codeProductAccountSystem)
            sheet.write(row, 8, nameProductAccountSystem)
            sheet.write(row, 9, cfopProductAccountSystem)
            sheet.write(row, 10, qtdProductAccountSystem,
                        self._cell_format_money)
            sheet.write(row, 11, vunitProductAccountSystem,
                        self._cell_format_money)
            sheet.write(row, 12, vtotProductAccountSystem,
                        self._cell_format_money)
            sheet.write(row, 13, codeProductXML)
            sheet.write(row, 14, nameProductXML)
            sheet.write(row, 15, qtdProductXML, self._cell_format_money)
            sheet.write(row, 16, vunitProductXML, self._cell_format_money)
            sheet.write(row, 17, vtotProductXML, self._cell_format_money)
            sheet.write(row, 18, valueComparationBetweenAccountSystemAndXML,
                        self._cell_format_money)
            sheet.write(row, 19, keyNF)
Пример #22
0
    def process(self):
        valuesOfLine = {}

        isDarf = False

        nameProvider = ""
        historic = ""
        amountPaid = float(0)
        account = ""
        amountOriginal = float(0)
        amountDiscount = float(0)
        amountInterest = float(0)
        amountFine = float(0)
        paymentDate = None
        
        for data in self._dataFile:
            if isDarf == False and data.find('PAGAMENTO DE GPS') >= 0:
                isDarf = True

            data = str(data)
            dataSplit = data.split(':')

            fieldOne = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 1))
            fieldTwo = funcoesUteis.treatTextField(funcoesUteis.analyzeIfFieldIsValidMatrix(dataSplit, 2))

            if fieldOne.count('CONTA DEBITADA') > 0:
                self._accountDebitOrCredit = 'DEBIT'
            elif fieldOne.count('AGENTE ARRECADADOR') > 0:
                self._accountDebitOrCredit = 'CREDIT'

            if self._accountDebitOrCredit == 'DEBIT':
                if fieldOne.count('AGENCIA') > 0 and fieldOne.count('CONTA') > 0:
                    account = fieldTwo.split('/')
                    account = funcoesUteis.analyzeIfFieldIsValidMatrix(account, 2)
                    account = str(funcoesUteis.treatNumberField(account, isInt=True))
            elif self._accountDebitOrCredit == 'CREDIT':
                if fieldOne == "DATA DO PAGAMENTO":
                    paymentDate = funcoesUteis.retornaCampoComoData(fieldTwo)
                if fieldOne.count("MON/JUR/MUL") > 0:
                    amountInterest = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "VALOR TOTAL":
                    amountPaid = funcoesUteis.treatDecimalField(fieldTwo)
                if fieldOne == "CODIGO DE PAGAMENTO":
                    nameProvider = f"GPS - {fieldTwo}"
                if fieldOne.count('IDENTIFICADOR') > 0:
                    cgceProvider = fieldTwo

            if fieldOne == "AGENCIA" or ( fieldOne.count('AGENCIA') > 0 and fieldOne.count('CONTA') > 0 ):
                if paymentDate is not None and amountPaid > 0 and isDarf is True:
                    valuesOfLine = {
                        "paymentDate": paymentDate,
                        "nameProvider": nameProvider,
                        "cgceProvider": cgceProvider,
                        "dueDate": None,
                        "bank": 'ITAU',
                        "account": account,
                        "amountPaid": round(amountPaid, 2),
                        "amountInterest": round(amountInterest, 2),
                        "amountDiscount": round(amountDiscount, 2),
                        "amountFine": round(amountFine, 2),
                        "amountOriginal": round(amountOriginal, 2),
                        "historic": historic,
                        "category": 'DARF',
                        "cgcePaying": "",
                        "foundProof": True,
                        "amountPaidPerLote": round(amountPaid, 2),
                        "wayFile": self._file
                    }

                    return valuesOfLine.copy()