Skip to content

Commit c9e08e7

Browse files
Create ChargePayment setPayment method
1 parent 8b06311 commit c9e08e7

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
*.RET
66
*.egg-info/*
77
dist
8+
temp
89
env/*

febraban/cnab240/itau/sispag/file/lot.py

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def add(self, register):
2424
register.setPositionInLot(index=self.index)
2525
self.registers.append(register)
2626
self.amount += register.amountInCents()
27+
if self._isBoletoPayment():
28+
self.totalAmount += register.totalAmountInCents()
2729
if self._isNonBarCodeTax():
2830
self.otherAmount += register.otherAmountInCents()
2931
self.additionAmount += register.additionAmountInCents()
@@ -81,6 +83,9 @@ def toString(self):
8183
additionSum=self.additionAmount,
8284
totalSum=self.totalAmount,
8385
)
86+
elif self._isBoletoPayment():
87+
self.trailerLot.setSumOfValues(sum=self.totalAmount)
88+
8489
else:
8590
self.trailerLot.setSumOfValues(sum=self.amount)
8691

@@ -94,6 +99,9 @@ def toString(self):
9499
def _count(self, cls):
95100
return len([register for register in self.registers if isinstance(register, cls)])
96101

102+
def _isBoletoPayment(self):
103+
return self.kind == PaymentKind.diverse and self.method in [PaymentMethod.itau, PaymentMethod.other]
104+
97105
def _isNonBarCodeTax(self):
98106
return self.kind == PaymentKind.tribute and self.method in PaymentMethod.nonBarcodeTaxes()
99107

febraban/cnab240/itau/sispag/payment/chargePayment.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,21 @@ def __init__(self):
99
self.segmentJ52 = SegmentJ52()
1010
self.amount = 0
1111
self.discountAmount = 0
12-
self.addedAmount = 0
12+
self.additionAmount = 0
1313
self.totalAmount = 0
1414

15+
def setPayment(self, **kwargs):
16+
self.setSender(kwargs["sender"])
17+
self.setReceiverTaxId(kwargs["receiverTaxId"])
18+
self.setBarCode(kwargs["barCode"])
19+
self.setIdentifier(kwargs["identifier"])
20+
self.setScheduleDate(kwargs["scheduleDate"].strftime("%d%m%Y"))
21+
self.setAmounts(
22+
kwargs.get("discountAmount"),
23+
kwargs.get("addedAmount"),
24+
kwargs.get("totalAmount"),
25+
)
26+
1527
def toString(self):
1628
return "\r\n".join((
1729
self.segmentJ.content,
@@ -21,6 +33,9 @@ def toString(self):
2133
def amountInCents(self):
2234
return self.amount
2335

36+
def totalAmountInCents(self):
37+
return self.totalAmount
38+
2439
def setSender(self, user):
2540
"""Sets the sender for the payment. The sender represents a user, its bank and its address."""
2641
self.segmentJ.setSenderBank(user.bank)
@@ -46,7 +61,7 @@ def setBarCode(self, barCode):
4661
def setAmounts(self, discountAmount, addedAmount, totalAmount):
4762
self.segmentJ.setAmounts(discountAmount, addedAmount, totalAmount)
4863
self.discountAmount = discountAmount
49-
self.addedAmount = addedAmount
64+
self.additionAmount = addedAmount
5065
self.totalAmount = totalAmount
5166

5267
def setPositionInLot(self, index):

febraban/cnab240/itau/sispag/result/parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from libs.febraban.cnab240.libs.paymentType import NonBarcodeTaxPayment
1+
from .....cnab240.libs.paymentType import NonBarcodeTaxPayment
22
from .occurrences import occurrences
33

44

0 commit comments

Comments
 (0)