diff --git a/addon/bill_invoices.go b/addon/bill_invoices.go index 347ccc0..64d09a3 100644 --- a/addon/bill_invoices.go +++ b/addon/bill_invoices.go @@ -1,8 +1,6 @@ package finvoice import ( - "strings" - "github.com/invopop/gobl/bill" "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/pay" @@ -76,14 +74,14 @@ func firstCreditTransferHasIBAN(val any) bool { return cts[0] != nil && cts[0].IBAN != "" } -// normalizePayInstructions strips the grouping spaces conventionally used -// when displaying Finnish reference numbers and RF references. +// normalizePayInstructions drops the grouping spaces conventionally used when +// displaying Finnish reference numbers and RF references. func normalizePayInstructions(instr *pay.Instructions) { - instr.Ref = cbc.Code(strings.ReplaceAll(instr.Ref.String(), " ", "")) + instr.Ref = cbc.NormalizeAlphanumericalCode(instr.Ref) } // normalizePayCreditTransfer converts the IBAN to its machine form: no // grouping spaces, upper case. func normalizePayCreditTransfer(ct *pay.CreditTransfer) { - ct.IBAN = strings.ToUpper(strings.ReplaceAll(ct.IBAN, " ", "")) + ct.IBAN = cbc.NormalizeAlphanumericalCode(ct.IBAN) } diff --git a/addon/bill_invoices_test.go b/addon/bill_invoices_test.go index 4f8e69a..d7b7659 100644 --- a/addon/bill_invoices_test.go +++ b/addon/bill_invoices_test.go @@ -287,7 +287,7 @@ func TestNormalization(t *testing.T) { inv := testInvoiceStandard(t) inv.Payment.Instructions.CreditTransfer[0].IBAN = "fi21 1234 5600 0007 85" require.NoError(t, inv.Calculate()) - assert.Equal(t, "FI2112345600000785", inv.Payment.Instructions.CreditTransfer[0].IBAN) + assert.Equal(t, "FI2112345600000785", inv.Payment.Instructions.CreditTransfer[0].IBAN.String()) assert.NoError(t, rules.Validate(inv)) }) diff --git a/go.mod b/go.mod index 50c6155..f965e6a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/invopop/gobl.fi.finvoice go 1.25.0 require ( - github.com/invopop/gobl v0.503.1-0.20260803162610-15cd103fc60a + github.com/invopop/gobl v0.504.0 github.com/stretchr/testify v1.11.1 ) diff --git a/go.sum b/go.sum index b896af8..6b66a22 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/invopop/gobl v0.503.1-0.20260803162610-15cd103fc60a h1:cs0QnFnU+JTB5FFLhGJlsELFbyPRsbRnwOkA/PcuxL4= -github.com/invopop/gobl v0.503.1-0.20260803162610-15cd103fc60a/go.mod h1:HmiEdQreTSQYyNbhs81VKTmI7BAJKYC/6enh9RDwnE0= +github.com/invopop/gobl v0.504.0 h1:RLmZmeAk9RL4rkMUc7xQfC70/RGiBeekRwVgMsMthQA= +github.com/invopop/gobl v0.504.0/go.mod h1:HmiEdQreTSQYyNbhs81VKTmI7BAJKYC/6enh9RDwnE0= github.com/invopop/jsonschema v0.14.0 h1:MHQqLhvpNUZfw+hM3AZDYK7jxO8FZoQeQM77g8iyZjg= github.com/invopop/jsonschema v0.14.0/go.mod h1:ygm6C2EaVNMBDPpaPlnOA2pFAxBnxGjFlMZABxm9n2I= github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso=