Skip to content

Commit

Permalink
Add support for parsing payer reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juraj Bubniak committed Oct 28, 2020
1 parent 48b0f79 commit 44c4104
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
fieldBIC = "26" // BIC
fieldOrderID = "17" // ID pokynu
fieldAuthor = "9" // Provedl
fieldPayerReference = "27" // Reference plátce

xmlTimeFormat = "2006-01-02-07:00"
)
Expand Down Expand Up @@ -217,6 +218,8 @@ func parseTransaction(t xmlTtransaction) (*Transaction, error) {
tx.BIC = col.Value
case fieldOrderID:
tx.OrderID = col.Value
case fieldPayerReference:
tx.PayerReference = col.Value
case fieldAuthor:
default:
return nil, fmt.Errorf(`unable to parse column: "%v"`, col.Name)
Expand Down
1 change: 1 addition & 0 deletions transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Transaction struct {
Comment string
BIC string
OrderID string
PayerReference string
}

// ByPeriodOptions represents options passed to ByPeriod.
Expand Down
4 changes: 4 additions & 0 deletions transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const transactionsResponse = `
<column_26 name="BIC" id="26">RIDBSKBXXXX</column_26>
<column_17 name="ID pokynu" id="17">15689512949</column_17>
<column_18 name="Upřesnění" id="18">45.97 EUR</column_18>
<column_27 name="Reference plátce" id="27">2000000003</column_27>
</Transaction>
</TransactionList>
</AccountStatement>
Expand Down Expand Up @@ -113,6 +114,7 @@ func TestByPeriod(t *testing.T) {
Specification: "45.97 EUR",
UserIdentification: "john doe",
Type: "Bezhotovostní příjem",
PayerReference: "2000000003",
},
},
}
Expand Down Expand Up @@ -207,6 +209,7 @@ func TestGetStatement(t *testing.T) {
Specification: "45.97 EUR",
UserIdentification: "john doe",
Type: "Bezhotovostní příjem",
PayerReference: "2000000003",
},
},
}
Expand Down Expand Up @@ -253,5 +256,6 @@ func assertEqualTransaction(t *testing.T, want Transaction, got Transaction) {
require.Equal(t, want.Comment, got.Comment)
require.Equal(t, want.UserIdentification, got.UserIdentification)
require.Equal(t, want.Type, got.Type)
require.Equal(t, want.PayerReference, got.PayerReference)
require.True(t, want.Date.Equal(got.Date))
}

0 comments on commit 44c4104

Please sign in to comment.