diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-08-01 19:44:54 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2022-08-01 19:44:54 +0200 |
commit | 1a43f4a064950d155b08b684be651108b4b98878 (patch) | |
tree | ce39b1c4280ecea33b394c357fb316cafb20ad56 | |
parent | 3a7e57b0a475da4ceaca7c6f3bca96155c67a012 (diff) |
komplett: ignore reserved transactions
-rw-r--r-- | record/komplett/komplett.go | 18 | ||||
-rw-r--r-- | record/komplett/testdata/test.json | 26 |
2 files changed, 35 insertions, 9 deletions
diff --git a/record/komplett/komplett.go b/record/komplett/komplett.go index d93c9de..271273a 100644 --- a/record/komplett/komplett.go +++ b/record/komplett/komplett.go @@ -26,13 +26,14 @@ type jsonAmount int64 type jsonRecord struct { // The JSON from their API keeps shuffling field names. Each number corresponds to a version of the format - Time1 jsonTime `json:"FormattedPostingDate"` - Time2 jsonTime `json:"TransactionDate"` - Amount1 jsonAmount `json:"BillingAmount"` - Amount2 jsonAmount `json:"FormattedAmount"` - Text1 string `json:"DisplayDescription"` - Text2 string `json:"MerchantName"` - Text3 string `json:"Description"` + IsReserved bool `json:"IsReserved"` + Time1 jsonTime `json:"FormattedPostingDate"` + Time2 jsonTime `json:"TransactionDate"` + Amount1 jsonAmount `json:"BillingAmount"` + Amount2 jsonAmount `json:"FormattedAmount"` + Text1 string `json:"DisplayDescription"` + Text2 string `json:"MerchantName"` + Text3 string `json:"Description"` } func (t *jsonTime) UnmarshalJSON(data []byte) error { @@ -80,6 +81,9 @@ func (r *Reader) Read() ([]record.Record, error) { } var rs []record.Record for _, jr := range jrs { + if jr.IsReserved { + continue + } amount := jr.Amount1 if amount == 0 { amount = jr.Amount2 diff --git a/record/komplett/testdata/test.json b/record/komplett/testdata/test.json index 93a7b1f..9cf6686 100644 --- a/record/komplett/testdata/test.json +++ b/record/komplett/testdata/test.json @@ -62,7 +62,7 @@ { "TransactionId": "42", "TransactionType": 79, - "IsReserved": true, + "IsReserved": false, "DeferPaymentUrl": null, "IsDeferred": false, "CanDefer": false, @@ -84,7 +84,7 @@ { "TransactionId": "42", "TransactionType": 79, - "IsReserved": true, + "IsReserved": false, "DeferPaymentUrl": null, "IsDeferred": false, "CanDefer": false, @@ -102,5 +102,27 @@ "TransactionRef": "ref", "TransactionDate": "15.01.2022", "TransactionDateRaw": "1/15/2022" + }, + { + "TransactionId": "43", + "TransactionType": 79, + "IsReserved": true, + "DeferPaymentUrl": null, + "IsDeferred": false, + "CanDefer": false, + "BookingDate": null, + "RecipientAccountNr": null, + "ExchangeRate": null, + "DeferTransactionInfo": null, + "OriginalTransactionInfo": null, + "Amount": "31337,01 NOK", + "AmountCurrency": "NOK", + "BillingAmount": "-kr 31337,01", + "BillingAmountCurrency": "NOK", + "MerchantName": null, + "Description": "Varekjøp 4", + "TransactionRef": "ref", + "TransactionDate": "16.01.2022", + "TransactionDateRaw": "1/16/2022" } ] |