diff --git a/bill/invoice_scenarios_test.go b/bill/invoice_scenarios_test.go index 13bef80d..d54a8aa1 100644 --- a/bill/invoice_scenarios_test.go +++ b/bill/invoice_scenarios_test.go @@ -24,7 +24,7 @@ func TestScenarios(t *testing.T) { inv := baseInvoiceWithLines(t) inv.SetTags("random") assert.NoError(t, inv.Calculate()) - assert.ErrorContains(t, inv.Validate(), "$tags: 'random' undefined.") + assert.ErrorContains(t, inv.Validate(), "$tags: (0: 'random' undefined.).") }) t.Run("scenario for new note", func(t *testing.T) { diff --git a/bill/invoice_test.go b/bill/invoice_test.go index dd0ff694..0c0b2278 100644 --- a/bill/invoice_test.go +++ b/bill/invoice_test.go @@ -1169,7 +1169,7 @@ func TestInvoiceTagsValidation(t *testing.T) { inv.SetTags("invalid-tag") assert.NoError(t, inv.Calculate()) err = inv.ValidateWithContext(ctx) - assert.ErrorContains(t, err, "tags: 'invalid-tag' undefined") + assert.ErrorContains(t, err, "$tags: (0: 'invalid-tag' undefined.).") } func baseInvoiceWithLines(t *testing.T) *bill.Invoice { diff --git a/bill/receipt.go b/bill/receipt.go index d8fa5fac..11bbd2e7 100644 --- a/bill/receipt.go +++ b/bill/receipt.go @@ -24,7 +24,7 @@ const ( ) // ReceiptTypes defines the list of potential payment types. -var ReceiptTypes = []*cbc.KeyDefinition{ +var ReceiptTypes = []*cbc.Definition{ { Key: ReceiptTypePayment, Name: i18n.String{ @@ -62,7 +62,7 @@ const ( ) // ReceiptLineTypes defines the list of potential receipt line types. -var ReceiptLineTypes = []*cbc.KeyDefinition{ +var ReceiptLineTypes = []*cbc.Definition{ { Key: ReceiptLineTypeDebit, Name: i18n.String{ @@ -214,7 +214,7 @@ func (rct *Receipt) normalizers() tax.Normalizers { if r := rct.RegimeDef(); r != nil { normalizers = normalizers.Append(r.Normalizer) } - for _, a := range rct.GetAddonDefs() { + for _, a := range rct.AddonDefs() { normalizers = normalizers.Append(a.Normalizer) } return normalizers @@ -258,7 +258,7 @@ func (rct *Receipt) calculate() error { } // JSONSchemaExtend extends the schema with additional property details -func (rt Receipt) JSONSchemaExtend(js *jsonschema.Schema) { +func (rct Receipt) JSONSchemaExtend(js *jsonschema.Schema) { props := js.Properties // Extend type list if its, ok := props.Get("type"); ok { @@ -271,8 +271,8 @@ func (rt Receipt) JSONSchemaExtend(js *jsonschema.Schema) { } } } - rt.Regime.JSONSchemaExtend(js) - rt.Addons.JSONSchemaExtend(js) + rct.Regime.JSONSchemaExtend(js) + rct.Addons.JSONSchemaExtend(js) // Recommendations js.Extras = map[string]any{ schema.Recommended: []string{ diff --git a/bill/receipt_line.go b/bill/receipt_line.go index 19cdc2d5..9b639adc 100644 --- a/bill/receipt_line.go +++ b/bill/receipt_line.go @@ -42,7 +42,7 @@ func (rl *ReceiptLine) ValidateWithContext(ctx context.Context) error { } // JSONSchemaExtend extends the schema with additional property details -func (rtl ReceiptLine) JSONSchemaExtend(js *jsonschema.Schema) { +func (rl ReceiptLine) JSONSchemaExtend(js *jsonschema.Schema) { props := js.Properties // Extend type list if its, ok := props.Get("type"); ok { diff --git a/internal/cli/bulk_test.go b/internal/cli/bulk_test.go index 59ecb1ef..f58dee9b 100644 --- a/internal/cli/bulk_test.go +++ b/internal/cli/bulk_test.go @@ -648,7 +648,7 @@ func TestBulk(t *testing.T) { //nolint:gocyclo // Following raw message is copied and pasted! (sorry!) Payload: json.RawMessage(`{ "list": [ - "https://gobl.org/draft-0/bill/correction-options", "https://gobl.org/draft-0/bill/invoice", "https://gobl.org/draft-0/cal/date", "https://gobl.org/draft-0/cal/date-time", "https://gobl.org/draft-0/cal/period", "https://gobl.org/draft-0/cbc/code", "https://gobl.org/draft-0/cbc/code-map", "https://gobl.org/draft-0/cbc/definition", "https://gobl.org/draft-0/cbc/key", "https://gobl.org/draft-0/cbc/meta", "https://gobl.org/draft-0/cbc/note", "https://gobl.org/draft-0/currency/amount", "https://gobl.org/draft-0/currency/code", "https://gobl.org/draft-0/currency/exchange-rate", "https://gobl.org/draft-0/dsig/digest", "https://gobl.org/draft-0/dsig/signature", "https://gobl.org/draft-0/envelope", "https://gobl.org/draft-0/head/header", "https://gobl.org/draft-0/head/link", "https://gobl.org/draft-0/head/stamp", "https://gobl.org/draft-0/i18n/string", "https://gobl.org/draft-0/l10n/code", "https://gobl.org/draft-0/l10n/iso-country-code", "https://gobl.org/draft-0/l10n/tax-country-code", "https://gobl.org/draft-0/note/message", "https://gobl.org/draft-0/num/amount", "https://gobl.org/draft-0/num/percentage", "https://gobl.org/draft-0/org/address", "https://gobl.org/draft-0/org/coordinates", "https://gobl.org/draft-0/org/document-ref", "https://gobl.org/draft-0/org/email", "https://gobl.org/draft-0/org/identity", "https://gobl.org/draft-0/org/image", "https://gobl.org/draft-0/org/inbox", "https://gobl.org/draft-0/org/item", "https://gobl.org/draft-0/org/name", "https://gobl.org/draft-0/org/party", "https://gobl.org/draft-0/org/person", "https://gobl.org/draft-0/org/registration", "https://gobl.org/draft-0/org/telephone", "https://gobl.org/draft-0/org/unit", "https://gobl.org/draft-0/org/website", "https://gobl.org/draft-0/pay/advance", "https://gobl.org/draft-0/pay/instructions", "https://gobl.org/draft-0/pay/terms", "https://gobl.org/draft-0/regimes/mx/food-vouchers", "https://gobl.org/draft-0/regimes/mx/fuel-account-balance", "https://gobl.org/draft-0/schema/object", "https://gobl.org/draft-0/tax/addon-def", "https://gobl.org/draft-0/tax/catalogue-def", "https://gobl.org/draft-0/tax/extensions", "https://gobl.org/draft-0/tax/identity", "https://gobl.org/draft-0/tax/regime-def", "https://gobl.org/draft-0/tax/set", "https://gobl.org/draft-0/tax/total" + "https://gobl.org/draft-0/bill/correction-options", "https://gobl.org/draft-0/bill/invoice", "https://gobl.org/draft-0/bill/receipt", "https://gobl.org/draft-0/cal/date", "https://gobl.org/draft-0/cal/date-time", "https://gobl.org/draft-0/cal/period", "https://gobl.org/draft-0/cbc/code", "https://gobl.org/draft-0/cbc/code-map", "https://gobl.org/draft-0/cbc/definition", "https://gobl.org/draft-0/cbc/key", "https://gobl.org/draft-0/cbc/meta", "https://gobl.org/draft-0/cbc/note", "https://gobl.org/draft-0/currency/amount", "https://gobl.org/draft-0/currency/code", "https://gobl.org/draft-0/currency/exchange-rate", "https://gobl.org/draft-0/dsig/digest", "https://gobl.org/draft-0/dsig/signature", "https://gobl.org/draft-0/envelope", "https://gobl.org/draft-0/head/header", "https://gobl.org/draft-0/head/link", "https://gobl.org/draft-0/head/stamp", "https://gobl.org/draft-0/i18n/string", "https://gobl.org/draft-0/l10n/code", "https://gobl.org/draft-0/l10n/iso-country-code", "https://gobl.org/draft-0/l10n/tax-country-code", "https://gobl.org/draft-0/note/message", "https://gobl.org/draft-0/num/amount", "https://gobl.org/draft-0/num/percentage", "https://gobl.org/draft-0/org/address", "https://gobl.org/draft-0/org/coordinates", "https://gobl.org/draft-0/org/document-ref", "https://gobl.org/draft-0/org/email", "https://gobl.org/draft-0/org/identity", "https://gobl.org/draft-0/org/image", "https://gobl.org/draft-0/org/inbox", "https://gobl.org/draft-0/org/item", "https://gobl.org/draft-0/org/name", "https://gobl.org/draft-0/org/party", "https://gobl.org/draft-0/org/person", "https://gobl.org/draft-0/org/registration", "https://gobl.org/draft-0/org/telephone", "https://gobl.org/draft-0/org/unit", "https://gobl.org/draft-0/org/website", "https://gobl.org/draft-0/pay/advance", "https://gobl.org/draft-0/pay/instructions", "https://gobl.org/draft-0/pay/terms", "https://gobl.org/draft-0/regimes/mx/food-vouchers", "https://gobl.org/draft-0/regimes/mx/fuel-account-balance", "https://gobl.org/draft-0/schema/object", "https://gobl.org/draft-0/tax/addon-def", "https://gobl.org/draft-0/tax/catalogue-def", "https://gobl.org/draft-0/tax/extensions", "https://gobl.org/draft-0/tax/identity", "https://gobl.org/draft-0/tax/regime-def", "https://gobl.org/draft-0/tax/set", "https://gobl.org/draft-0/tax/total" ] }`), IsFinal: false, diff --git a/tax/tags_test.go b/tax/tags_test.go index d90ab056..169afa88 100644 --- a/tax/tags_test.go +++ b/tax/tags_test.go @@ -13,7 +13,7 @@ import ( func TestTagSetForSchema(t *testing.T) { ts1 := &tax.TagSet{ Schema: "bill/invoice", - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ { Key: "test1", Name: i18n.String{ @@ -24,7 +24,7 @@ func TestTagSetForSchema(t *testing.T) { } ts2 := &tax.TagSet{ Schema: "bill/receipt", - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ { Key: "test2", Name: i18n.String{