Add go report badge #14

Merged
natercio merged 2 commits from go-report-badge into main 2025-11-19 11:41:54 +00:00
5 changed files with 21 additions and 19 deletions

View File

@@ -1,5 +1,7 @@
# any2anexoj # any2anexoj
[![Go Report Card](https://goreportcard.com/badge/github.com/nmoniz/any2anexoj)](https://goreportcard.com/report/github.com/nmoniz/any2anexoj)
![Screenshot](https://i.ibb.co/TDDypq8X/Screenshot-2025-11-18-at-16-17-16.png) ![Screenshot](https://i.ibb.co/TDDypq8X/Screenshot-2025-11-18-at-16-17-16.png)
This tool converts the statements from known brokers and exchanges into a format compatible with section 9 from the Portuguese IRS form: [Mod_3_anexo_j](https://info.portaldasfinancas.gov.pt/pt/apoio_contribuinte/modelos_formularios/irs/Documents/Mod_3_anexo_J.pdf) This tool converts the statements from known brokers and exchanges into a format compatible with section 9 from the Portuguese IRS form: [Mod_3_anexo_j](https://info.portaldasfinancas.gov.pt/pt/apoio_contribuinte/modelos_formularios/irs/Documents/Mod_3_anexo_J.pdf)

View File

@@ -18,7 +18,7 @@ func TestFillerQueue(t *testing.T) {
var rq FillerQueue var rq FillerQueue
if rq.Len() != 0 { if rq.Len() != 0 {
t.Fatalf("zero value should have zero lenght") t.Fatalf("zero value should have zero length")
} }
_, ok := rq.Pop() _, ok := rq.Pop()
@@ -38,12 +38,12 @@ func TestFillerQueue(t *testing.T) {
rq.Push(NewFiller(newRecord())) rq.Push(NewFiller(newRecord()))
if rq.Len() != 1 { 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())) rq.Push(NewFiller(newRecord()))
if rq.Len() != 2 { 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() peekFiller, ok := rq.Peek()
@@ -85,7 +85,7 @@ func TestFillerQueueNilReceiver(t *testing.T) {
var rq *FillerQueue var rq *FillerQueue
if rq.Len() > 0 { if rq.Len() > 0 {
t.Fatalf("nil receiver should have zero lenght") t.Fatalf("nil receiver should have zero length")
} }
_, ok := rq.Peek() _, ok := rq.Peek()

View File

@@ -27,8 +27,8 @@ func NewTableWriter(w io.Writer) *TableWriter {
t.SetAutoIndex(true) t.SetAutoIndex(true)
t.SetStyle(table.StyleLight) t.SetStyle(table.StyleLight)
t.AppendHeader(table.Row{"", "", "Realisation", "Realisation", "Realisation", "Realisation", "Aquisition", "Aquisition", "Aquisition", "Aquisition", "", "", ""}, table.RowConfig{AutoMerge: true}) 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", "Payed Taxes", "Counter Country"}) t.AppendHeader(table.Row{"Source Country", "Code", "Year", "Month", "Day", "Value", "Year", "Month", "Day", "Value", "Expenses", "Paid Taxes", "Counter Country"})
return &TableWriter{ return &TableWriter{
table: t, table: t,

View File

@@ -110,9 +110,9 @@ func (rr RecordReader) ReadRecord(_ context.Context) (internal.Record, error) {
return Record{}, fmt.Errorf("parse record timestamp: %w", err) return Record{}, fmt.Errorf("parse record timestamp: %w", err)
} }
convertionFee, err := parseOptinalDecimal(raw[16]) conversionFee, err := parseOptinalDecimal(raw[16])
if err != nil { 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]) stampDutyTax, err := parseOptinalDecimal(raw[14])
@@ -131,7 +131,7 @@ func (rr RecordReader) ReadRecord(_ context.Context) (internal.Record, error) {
quantity: qant, quantity: qant,
price: price, price: price,
timestamp: ts, timestamp: ts,
fees: convertionFee, fees: conversionFee,
taxes: stampDutyTax.Add(frenchTxTax), taxes: stampDutyTax.Add(frenchTxTax),
}, nil }, nil
} }

View File

@@ -25,7 +25,7 @@ func TestRecordReader_ReadRecord(t *testing.T) {
}, },
{ {
name: "well-formed buy", 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{ want: Record{
symbol: "SYM123456ABXY", symbol: "SYM123456ABXY",
side: internal.SideBuy, side: internal.SideBuy,
@@ -38,7 +38,7 @@ func TestRecordReader_ReadRecord(t *testing.T) {
}, },
{ {
name: "well-formed sell", 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{ want: Record{
symbol: "IE000GA3D489", symbol: "IE000GA3D489",
side: internal.SideSell, side: internal.SideSell,
@@ -51,42 +51,42 @@ func TestRecordReader_ReadRecord(t *testing.T) {
}, },
{ {
name: "malformed side", 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, wantErr: true,
}, },
{ {
name: "empty side", 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, wantErr: true,
}, },
{ {
name: "malformed qantity", 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, wantErr: true,
}, },
{ {
name: "empty qantity", 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, wantErr: true,
}, },
{ {
name: "malformed price", 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, wantErr: true,
}, },
{ {
name: "empty price", 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, wantErr: true,
}, },
{ {
name: "malformed timestamp", 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, wantErr: true,
}, },
{ {
name: "empty timestamp", 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, wantErr: true,
}, },
} }