diff --git a/febraban/cnab240/itau/charge/result/parser.py b/febraban/cnab240/itau/charge/result/parser.py index 0a12b54..6163d64 100644 --- a/febraban/cnab240/itau/charge/result/parser.py +++ b/febraban/cnab240/itau/charge/result/parser.py @@ -14,12 +14,15 @@ class SlipResponseStatus: class SlipResponse: - def __init__(self, identifier=None, occurrence=None, content=None, amountInCents=None, fine=None, discount=None, errors=None): + def __init__(self, identifier=None, occurrence=None, content=None, amountInCents=None, fine=None, discount=None, + creditedAmount=None, fees=None, errors=None): self.identifier = identifier self.occurrence = occurrence self.amountInCents = amountInCents self.fine = fine self.discount = discount + self.creditedAmount = creditedAmount + self.fees = fees self.content = content or [] self.errors = errors or [] @@ -77,11 +80,13 @@ def parseLines(cls, lines): currentResponse.amountInCents = int(line[81:96]) currentResponse.occurrence = line[15:17] currentResponse.identifier = line[105:130].strip() + currentResponse.fees = int(line[198:213]) currentResponse.errors = [line[213 + i:215 + i] for i in range(0, 8, 2) if line[i:i + 2] != " "] elif line[7] == "3" and line[13] == "U": currentResponse.content.append(line) currentResponse.fine = int(line[17:32]) currentResponse.discount = int(line[32:47]) + currentResponse.creditedAmount = int(line[77:92]) result.append(currentResponse) elif line[7] == "3" and line[13] == "P": currentResponse = SlipResponse() diff --git a/febraban/cnab240/itau/sispag/payment/chargePayment.py b/febraban/cnab240/itau/sispag/payment/chargePayment.py index 38b71d3..0eedb60 100644 --- a/febraban/cnab240/itau/sispag/payment/chargePayment.py +++ b/febraban/cnab240/itau/sispag/payment/chargePayment.py @@ -25,6 +25,7 @@ def setPayment(self, **kwargs): discountAmount=kwargs["discountAmount"], addedAmount=kwargs["addedAmount"], totalAmount=kwargs["totalAmount"], + nominalAmount=kwargs.get("nominalAmount") ) def toString(self): @@ -65,7 +66,7 @@ def setBarCode(self, barCode): self.segmentJ.setBarCode(barCode) self.amount = int(barCode.amount) - def setAmounts(self, discountAmount, addedAmount, totalAmount): + def setAmounts(self, discountAmount, addedAmount, totalAmount, nominalAmount=None): self.segmentJ.setAmounts( discountAmount=discountAmount, addedAmount=addedAmount, @@ -75,6 +76,10 @@ def setAmounts(self, discountAmount, addedAmount, totalAmount): self.additionAmount = addedAmount self.totalAmount = totalAmount + if not self.amount and nominalAmount: + self.segmentJ.setNominalAmount(nominalAmount=nominalAmount) + self.amount = nominalAmount + def setPositionInLot(self, index): index = 2 * index - 1 self.segmentJ.setPositionInLot(index) diff --git a/febraban/cnab240/itau/sispag/payment/segmentJ.py b/febraban/cnab240/itau/sispag/payment/segmentJ.py index ab536f1..a2e9a51 100644 --- a/febraban/cnab240/itau/sispag/payment/segmentJ.py +++ b/febraban/cnab240/itau/sispag/payment/segmentJ.py @@ -46,6 +46,12 @@ def setAmounts(self, discountAmount, addedAmount, totalAmount): ] self.content = Row.setStructs(structs=structs, content=self.content) + def setNominalAmount(self, nominalAmount): + structs = [ + (99, 114, 15, numeric, nominalAmount), # Valor Nominal do Título + ] + self.content = Row.setStructs(structs=structs, content=self.content) + def setScheduleDate(self, date): structs = [ (144, 152, 8, numeric, date) diff --git a/setup.py b/setup.py index c4f5cf0..37cddf7 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ author="Stark Bank", author_email="developers@starkbank.com", keywords=["febraban", "cnab", "cnab 240", "cnab240", "febraban240", "transfer", "billing", "bank"], - version="0.12.0" + version="0.13.0" ) """