Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion febraban/cnab240/itau/charge/result/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []

Expand Down Expand Up @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion febraban/cnab240/itau/sispag/payment/chargePayment.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def setPayment(self, **kwargs):
discountAmount=kwargs["discountAmount"],
addedAmount=kwargs["addedAmount"],
totalAmount=kwargs["totalAmount"],
nominalAmount=kwargs.get("nominalAmount")
)

def toString(self):
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions febraban/cnab240/itau/sispag/payment/segmentJ.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

"""
Expand Down