Skip to content

Commit

Permalink
Merge pull request #13 from starkbank/fix/currency-format
Browse files Browse the repository at this point in the history
Modify numeric input to accept non-currency formatted values
  • Loading branch information
daltonfm-stark authored Sep 15, 2020
2 parents 66fc65e + 54df4aa commit 9fe7b6a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src.vba/ChargeGateway.bas
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Public Function getOrders(initRow As Long, midRow As Long) As Collection
MsgBox "Por favor, não deixe linhas em branco entre as ordens de cobrança", , "Erro"
End
End If
amount = Utils.IntegerFrom((obj("Valor")))
amount = getAmountLong((obj("Valor")))
customerId = Trim(obj("Id do Cliente"))
dueDate = Utils.DateToSendingFormat(Format(obj("Data de Vencimento"), "dd/mm/yyyy"))

Expand All @@ -187,21 +187,21 @@ Public Function getOrders(initRow As Long, midRow As Long) As Collection
description1.Add "text", obj("Descrição 1")
End If
If obj("Valor 1") <> "" Then
description1.Add "amount", Utils.IntegerFrom((obj("Valor 1")))
description1.Add "amount", getAmountLong((obj("Valor 1")))
End If

If obj("Descrição 2") <> "" Then
description2.Add "text", obj("Descrição 2")
End If
If obj("Valor 2") <> "" Then
description2.Add "amount", Utils.IntegerFrom((obj("Valor 2")))
description2.Add "amount", getAmountLong((obj("Valor 2")))
End If

If obj("Descrição 3") <> "" Then
description3.Add "text", obj("Descrição 3")
End If
If obj("Valor 3") <> "" Then
description3.Add "amount", Utils.IntegerFrom((obj("Valor 3")))
description3.Add "amount", getAmountLong((obj("Valor 3")))
End If

Set order = ChargeGateway.order(amount, customerId, dueDate, fine, interest, overdueLimit, description1, description2, description3)
Expand Down
9 changes: 0 additions & 9 deletions src.vba/Cnab400.bas
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,6 @@ Private Sub DebugDict()
Debug.Print "Total Amount:", totalAmount
End Sub

Private Function getAmountLong(amount As Variant)
amount = FormatCurrency(amount, 2)
amount = Replace(amount, ",", "")
amount = Replace(amount, ".", "")
amount = Replace(amount, "R$", "")
amount = CLng(amount)
getAmountLong = amount
End Function

Private Function getLogOccurrenceDate(statusCode As String, chargeId As String) As String
Dim respMessage As Variant
Dim logEvent As String
Expand Down
2 changes: 1 addition & 1 deletion src.vba/SendInternalTransferForm.frm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ End Sub
Private Sub ConfirmButton_Click()
'On Error Resume Next
Dim myFile As String: myFile = PathBox.Value
Dim amount As Long: amount = Utils.IntegerFrom(Utils.clearNonNumeric(AmountBox.Value))
Dim amount As Long: amount = getAmountLong(Utils.clearNonNumeric(AmountBox.Value))
Dim receiverId As String: receiverId = WorkspaceBox.Value
Dim externalId As String: externalId = ExternalIdBox.Value
Dim description As String: description = DescriptionBox.Value
Expand Down
2 changes: 1 addition & 1 deletion src.vba/TeamGateway.bas
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Public Function getOrders() As Collection
Unload SendOrderForm
End
End If
amount = Utils.IntegerFrom((obj("Valor")))
amount = getAmountLong((obj("Valor")))
taxId = Trim(obj("CPF/CNPJ"))
name = Trim(obj("Nome"))
bankCode = Trim(obj("Código do Banco"))
Expand Down
2 changes: 1 addition & 1 deletion src.vba/TransferGateway.bas
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Public Function getTransfersFromSheet() As Collection
Unload SendTransferForm
End
End If
amount = Utils.IntegerFrom((obj("Valor")))
amount = getAmountLong((obj("Valor")))
taxId = Trim(obj("CPF/CNPJ"))
name = Trim(obj("Nome"))
bankCode = Trim(obj("Código do Banco"))
Expand Down
9 changes: 9 additions & 0 deletions src.vba/Utils.bas
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ Function correctErrorLine(errorMessage As String, offset As Integer) As String

End Function

Public Function getAmountLong(amount As Variant)
amount = FormatCurrency(amount, 2)
amount = Replace(amount, ",", "")
amount = Replace(amount, ".", "")
amount = Replace(amount, "R$", "")
amount = CLng(amount)
getAmountLong = amount
End Function

Public Function IntegerFrom(Value As String) As Long
Dim temp As String
temp = Value
Expand Down
Binary file modified starkbank-sdk.xlsm
Binary file not shown.

0 comments on commit 9fe7b6a

Please sign in to comment.