Skip to content

Commit

Permalink
Merge pull request #12 from starkbank/feature/boleto-payment-pdf
Browse files Browse the repository at this point in the history
Add buttons for boleto payment pdf download
  • Loading branch information
daltonfm-stark authored Aug 25, 2020
2 parents 49b54cb + 9e1d502 commit 66fc65e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
32 changes: 29 additions & 3 deletions src.vba/Pdf.bas
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Public Sub downloadAllChargePdfs()
downloadAllPdfs ("charge")
End Sub

Public Sub downloadAllChargePaymentPdfs()
downloadAllPdfs ("charge-payment")
End Sub

Public Sub downloadSelectedTransferPdfs()
Dim initRow As Long
Dim lastRow As Long
Expand Down Expand Up @@ -41,6 +45,24 @@ Public Sub downloadSelectedChargePdfs()
Call downloadPdfRange(service, initRow, lastRow)
End Sub

Public Sub downloadSelectedChargePaymentPdfs()
Dim initRow As Long
Dim lastRow As Long
Dim service As String
service = "charge-payment"

initRow = Utils.Max(Selection.row, 10)
lastRow = Utils.Min(Selection.row + Selection.Rows.Count - 1, ActiveSheet.Range(ColumnId(service) + "9").CurrentRegion.Rows.Count + 8)

If initRow > lastRow Then
MsgBox "Nenhum pagamento válido selecionado"
Exit Sub
End If

Call downloadPdfRange(service, initRow, lastRow)
End Sub


Public Function downloadSinglePdf(service, id As String, folder As String)
Dim success As Boolean
Dim path As String
Expand All @@ -61,6 +83,7 @@ Public Sub downloadPdfRange(service As String, initRow, lastRow)
Dim anyFailed As Boolean
Dim tooMany As Boolean
anyFailed = False
anySuccess = False
tooMany = True

idColumn = ColumnId(service)
Expand Down Expand Up @@ -90,13 +113,16 @@ Public Sub downloadPdfRange(service As String, initRow, lastRow)
success = downloadSinglePdf(service, entityId, folder)
If Not success Then
anyFailed = True
Else
anySuccess = True
End If
Next

If anyFailed Then
MsgBox "Alguns arquivos tiveram falha no download!", vbExclamation
Else
MsgBox "Arquivos salvos com sucesso em:" + vbNewLine + folder
MsgBox "Alguns arquivos tiveram falha no download!" + vbNewLine + "Atenção: Não é possível baixar comprovantes de operações com falha ou canceladas!", vbExclamation
End If
If anySuccess Then
MsgBox "Arquivos salvos em:" + vbNewLine + folder
End If
End If
End Sub
Expand Down
7 changes: 5 additions & 2 deletions src.vba/ViewChargePaymentForm.frm
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Private Sub SearchButton_Click()
Call InputLogGateway.saveDates(afterInput, beforeInput)

'Table layout
Utils.applyStandardLayout ("G")
Range("A" & CStr(TableFormat.HeaderRow() + 1) & ":G" & Rows.Count).ClearContents
Utils.applyStandardLayout ("H")
Range("A" & CStr(TableFormat.HeaderRow() + 1) & ":H" & Rows.Count).ClearContents

'Headers definition
ActiveSheet.Cells(TableFormat.HeaderRow(), 1).Value = "Data de Criação"
Expand All @@ -57,6 +57,7 @@ Private Sub SearchButton_Click()
ActiveSheet.Cells(TableFormat.HeaderRow(), 5).Value = "Linha Digitável"
ActiveSheet.Cells(TableFormat.HeaderRow(), 6).Value = "Descrição"
ActiveSheet.Cells(TableFormat.HeaderRow(), 7).Value = "Tags"
ActiveSheet.Cells(TableFormat.HeaderRow(), 8).Value = "Id do pagamento"

Call FreezeHeader

Expand Down Expand Up @@ -106,6 +107,8 @@ Private Sub SearchButton_Click()

Dim tags As Collection: Set tags = payment("tags")
ActiveSheet.Cells(row, 7).Value = CollectionToString(tags, ",")

ActiveSheet.Cells(row, 8).Value = payment("id")

row = row + 1
Next
Expand Down
4 changes: 4 additions & 0 deletions src.vba/ViewHelpForm.frm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Private Sub HelpSandboxWebButton_Click()
ActiveWorkbook.FollowHyperlink address:="https://starkbank.com/sandbox"
End Sub

Private Sub Label2_Click()

End Sub

Private Sub SendPublicKeyButton_Click()
SendKeyForm.Show
End Sub
Binary file modified starkbank-sdk.xlsm
Binary file not shown.

0 comments on commit 66fc65e

Please sign in to comment.