diff --git a/CHANGELOG.md b/CHANGELOG.md index 166af027..c9bcb805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixes +- `ch`: Deleted Supplier validation (not needed for under 2300 CHF/year) - `bill`: `Invoice` `GetExtensions` method now works correctly if missing totals [Issue #424](https://github.com/invopop/gobl/issues/424). ## [v0.205.0] - 2024-11-12 diff --git a/regimes/ch/ch.go b/regimes/ch/ch.go index 0b89dd05..666da54c 100644 --- a/regimes/ch/ch.go +++ b/regimes/ch/ch.go @@ -46,8 +46,6 @@ func New() *tax.RegimeDef { // Validate checks the document type and determines if it can be validated. func Validate(doc any) error { switch obj := doc.(type) { - case *bill.Invoice: - return validateInvoice(obj) case *tax.Identity: return validateTaxIdentity(obj) } diff --git a/regimes/ch/invoices.go b/regimes/ch/invoices.go deleted file mode 100644 index e3fd9c5d..00000000 --- a/regimes/ch/invoices.go +++ /dev/null @@ -1,31 +0,0 @@ -package ch - -import ( - "github.com/invopop/gobl/bill" - "github.com/invopop/gobl/org" - "github.com/invopop/gobl/tax" - "github.com/invopop/validation" -) - -func validateInvoice(inv *bill.Invoice) error { - return validation.ValidateStruct(inv, - validation.Field(&inv.Supplier, - validation.By(validateInvoiceSupplier), - validation.Skip, - ), - ) -} - -func validateInvoiceSupplier(value any) error { - p, ok := value.(*org.Party) - if !ok || p == nil { - return nil - } - return validation.ValidateStruct(p, - validation.Field(&p.TaxID, - validation.Required, - tax.RequireIdentityCode, - validation.Skip, - ), - ) -} diff --git a/regimes/ch/invoices_test.go b/regimes/ch/invoices_test.go index df71a841..7305a0e6 100644 --- a/regimes/ch/invoices_test.go +++ b/regimes/ch/invoices_test.go @@ -56,5 +56,5 @@ func TestInvoiceValidation(t *testing.T) { inv = validInvoice() inv.Supplier.TaxID.Code = "" require.NoError(t, inv.Calculate()) - assert.ErrorContains(t, inv.Validate(), "supplier: (tax_id: (code: cannot be blank.).)") + assert.NoError(t, inv.Validate()) }