diff --git a/internal/report.go b/internal/report.go index fb931d0..0cb392b 100644 --- a/internal/report.go +++ b/internal/report.go @@ -12,7 +12,7 @@ import ( type Record interface { Symbol() string - Nature() string + Nature() Nature BrokerCountry() int64 AssetCountry() int64 Side() Side diff --git a/internal/trading212/record.go b/internal/trading212/record.go index 34ae163..337ba4f 100644 --- a/internal/trading212/record.go +++ b/internal/trading212/record.go @@ -15,20 +15,23 @@ import ( type Record struct { symbol string + timestamp time.Time side internal.Side quantity decimal.Decimal price decimal.Decimal - timestamp time.Time fees decimal.Decimal taxes decimal.Decimal + + // natureGetter allows us to defer the operation of figuring out the nature to only when/if needed. + natureGetter func() internal.Nature } func (r Record) Symbol() string { return r.symbol } -func (r Record) Nature() string { - return "" // TODO: implement this +func (r Record) Timestamp() time.Time { + return r.timestamp } func (r Record) BrokerCountry() int64 { @@ -51,10 +54,6 @@ func (r Record) Price() decimal.Decimal { return r.price } -func (r Record) Timestamp() time.Time { - return r.timestamp -} - func (r Record) Fees() decimal.Decimal { return r.fees } @@ -63,6 +62,10 @@ func (r Record) Taxes() decimal.Decimal { return r.taxes } +func (r Record) Nature() internal.Nature { + return r.natureGetter() +} + type RecordReader struct { reader *csv.Reader } @@ -134,9 +137,9 @@ func (rr RecordReader) ReadRecord(_ context.Context) (internal.Record, error) { side: side, quantity: qant, price: price, - timestamp: ts, fees: conversionFee, taxes: stampDutyTax.Add(frenchTxTax), + timestamp: ts, }, nil } }