diff --git a/internal/filler_test.go b/internal/filler_test.go index 3609232..0244a96 100644 --- a/internal/filler_test.go +++ b/internal/filler_test.go @@ -18,7 +18,7 @@ func TestFillerQueue(t *testing.T) { var rq FillerQueue if rq.Len() != 0 { - t.Fatalf("zero value should have zero lenght") + t.Fatalf("zero value should have zero length") } _, ok := rq.Pop() @@ -38,12 +38,12 @@ func TestFillerQueue(t *testing.T) { rq.Push(NewFiller(newRecord())) if rq.Len() != 1 { - t.Fatalf("pushing 1st record should result in lenght of 1") + t.Fatalf("pushing 1st record should result in length of 1") } rq.Push(NewFiller(newRecord())) if rq.Len() != 2 { - t.Fatalf("pushing 2nd record should result in lenght of 2") + t.Fatalf("pushing 2nd record should result in length of 2") } peekFiller, ok := rq.Peek() @@ -85,7 +85,7 @@ func TestFillerQueueNilReceiver(t *testing.T) { var rq *FillerQueue if rq.Len() > 0 { - t.Fatalf("nil receiver should have zero lenght") + t.Fatalf("nil receiver should have zero length") } _, ok := rq.Peek() diff --git a/internal/table_writer.go b/internal/table_writer.go index a85a217..0dd822d 100644 --- a/internal/table_writer.go +++ b/internal/table_writer.go @@ -27,8 +27,8 @@ func NewTableWriter(w io.Writer) *TableWriter { t.SetAutoIndex(true) t.SetStyle(table.StyleLight) - t.AppendHeader(table.Row{"", "", "Realisation", "Realisation", "Realisation", "Realisation", "Aquisition", "Aquisition", "Aquisition", "Aquisition", "", "", ""}, table.RowConfig{AutoMerge: true}) - t.AppendHeader(table.Row{"Source Country", "Code", "Year", "Month", "Day", "Value", "Year", "Month", "Day", "Value", "Expenses", "Payed Taxes", "Counter Country"}) + t.AppendHeader(table.Row{"", "", "Realisation", "Realisation", "Realisation", "Realisation", "Acquisition", "Acquisition", "Acquisition", "Acquisition", "", "", ""}, table.RowConfig{AutoMerge: true}) + t.AppendHeader(table.Row{"Source Country", "Code", "Year", "Month", "Day", "Value", "Year", "Month", "Day", "Value", "Expenses", "Paid Taxes", "Counter Country"}) return &TableWriter{ table: t, diff --git a/internal/trading212/record.go b/internal/trading212/record.go index 1c74f44..a291c82 100644 --- a/internal/trading212/record.go +++ b/internal/trading212/record.go @@ -110,9 +110,9 @@ func (rr RecordReader) ReadRecord(_ context.Context) (internal.Record, error) { return Record{}, fmt.Errorf("parse record timestamp: %w", err) } - convertionFee, err := parseOptinalDecimal(raw[16]) + conversionFee, err := parseOptinalDecimal(raw[16]) if err != nil { - return Record{}, fmt.Errorf("parse record convertion fee: %w", err) + return Record{}, fmt.Errorf("parse record conversion fee: %w", err) } stampDutyTax, err := parseOptinalDecimal(raw[14]) @@ -131,7 +131,7 @@ func (rr RecordReader) ReadRecord(_ context.Context) (internal.Record, error) { quantity: qant, price: price, timestamp: ts, - fees: convertionFee, + fees: conversionFee, taxes: stampDutyTax.Add(frenchTxTax), }, nil } diff --git a/internal/trading212/record_test.go b/internal/trading212/record_test.go index b464f1a..6dae9ae 100644 --- a/internal/trading212/record_test.go +++ b/internal/trading212/record_test.go @@ -25,7 +25,7 @@ func TestRecordReader_ReadRecord(t *testing.T) { }, { name: "well-formed buy", - r: bytes.NewBufferString(`Market buy,2025-07-03 10:44:29,SYM123456ABXY,ABXY,"Aspargus Brocoli",EOF987654321,2.4387014200,7.3690000000,USD,1.17995999,,"EUR",15.25,"EUR",0.25,"EUR",0.02,"EUR",,`), + r: bytes.NewBufferString(`Market buy,2025-07-03 10:44:29,SYM123456ABXY,ABXY,"Aspargus Broccoli",EOF987654321,2.4387014200,7.3690000000,USD,1.17995999,,"EUR",15.25,"EUR",0.25,"EUR",0.02,"EUR",,`), want: Record{ symbol: "SYM123456ABXY", side: internal.SideBuy, @@ -38,7 +38,7 @@ func TestRecordReader_ReadRecord(t *testing.T) { }, { name: "well-formed sell", - r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:30,IE000GA3D489,ABXY,"Aspargus Brocoli",EOF987654321,2.4387014200,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",0.1,"EUR"`), + r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:30,IE000GA3D489,ABXY,"Aspargus Broccoli",EOF987654321,2.4387014200,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",0.1,"EUR"`), want: Record{ symbol: "IE000GA3D489", side: internal.SideSell, @@ -51,42 +51,42 @@ func TestRecordReader_ReadRecord(t *testing.T) { }, { name: "malformed side", - r: bytes.NewBufferString(`Aljksdaf Balsjdkf,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Brocoli",EOF987654321,2.4387014200,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), + r: bytes.NewBufferString(`Aljksdaf Balsjdkf,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Broccoli",EOF987654321,2.4387014200,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), wantErr: true, }, { name: "empty side", - r: bytes.NewBufferString(`,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Brocoli",EOF987654321,0x1234,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), + r: bytes.NewBufferString(`,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Broccoli",EOF987654321,0x1234,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), wantErr: true, }, { name: "malformed qantity", - r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Brocoli",EOF987654321,0x1234,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), + r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Broccoli",EOF987654321,0x1234,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), wantErr: true, }, { name: "empty qantity", - r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Brocoli",EOF987654321,,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), + r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Broccoli",EOF987654321,,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), wantErr: true, }, { name: "malformed price", - r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Brocoli",EOF987654321,2.4387014200,0b101010,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), + r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Broccoli",EOF987654321,2.4387014200,0b101010,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), wantErr: true, }, { name: "empty price", - r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Brocoli",EOF987654321,2.4387014200,,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), + r: bytes.NewBufferString(`Market sell,2025-08-04 11:45:39,IE000GA3D489,ABXY,"Aspargus Broccoli",EOF987654321,2.4387014200,,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), wantErr: true, }, { name: "malformed timestamp", - r: bytes.NewBufferString(`Market sell,2006-01-02T15:04:05Z07:00,IE000GA3D489,ABXY,"Aspargus Brocoli",EOF987654321,2.4387014200,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), + r: bytes.NewBufferString(`Market sell,2006-01-02T15:04:05Z07:00,IE000GA3D489,ABXY,"Aspargus Broccoli",EOF987654321,2.4387014200,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), wantErr: true, }, { name: "empty timestamp", - r: bytes.NewBufferString(`Market sell,,IE000GA3D489,ABXY,"Aspargus Brocoli",EOF987654321,2.4387014200,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), + r: bytes.NewBufferString(`Market sell,,IE000GA3D489,ABXY,"Aspargus Broccoli",EOF987654321,2.4387014200,7.9999999999,USD,1.17995999,,"EUR",15.25,"EUR",,,0.02,"EUR",,`), wantErr: true, }, }