From ed7cc61078cd71d789f59cdee5722de97f227c50 Mon Sep 17 00:00:00 2001
From: Menendez6 <pabloj.menendez@gmail.com>
Date: Mon, 18 Nov 2024 17:57:58 +0000
Subject: [PATCH 1/4] Deleting supplier validation

---
 regimes/ch/ch.go            |  2 --
 regimes/ch/invoices.go      | 31 -------------------
 regimes/ch/invoices_test.go | 60 -------------------------------------
 3 files changed, 93 deletions(-)
 delete mode 100644 regimes/ch/invoices.go
 delete mode 100644 regimes/ch/invoices_test.go

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
deleted file mode 100644
index df71a841..00000000
--- a/regimes/ch/invoices_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package ch_test
-
-import (
-	"testing"
-
-	"github.com/invopop/gobl/bill"
-	"github.com/invopop/gobl/num"
-	"github.com/invopop/gobl/org"
-	"github.com/invopop/gobl/tax"
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-)
-
-func validInvoice() *bill.Invoice {
-	return &bill.Invoice{
-		Series: "TEST",
-		Code:   "0002",
-		Supplier: &org.Party{
-			Name: "Test Supplier",
-			TaxID: &tax.Identity{
-				Country: "CH",
-				Code:    "E100416306",
-			},
-		},
-		Customer: &org.Party{
-			Name: "Test Customer",
-			TaxID: &tax.Identity{
-				Country: "CH",
-				Code:    "E432825998",
-			},
-		},
-		Lines: []*bill.Line{
-			{
-				Quantity: num.MakeAmount(1, 0),
-				Item: &org.Item{
-					Name:  "bogus",
-					Price: num.MakeAmount(10000, 2),
-					Unit:  org.UnitPackage,
-				},
-				Taxes: tax.Set{
-					{
-						Category: "VAT",
-						Rate:     "standard",
-					},
-				},
-			},
-		},
-	}
-}
-
-func TestInvoiceValidation(t *testing.T) {
-	inv := validInvoice()
-	require.NoError(t, inv.Calculate())
-	assert.NoError(t, inv.Validate())
-
-	inv = validInvoice()
-	inv.Supplier.TaxID.Code = ""
-	require.NoError(t, inv.Calculate())
-	assert.ErrorContains(t, inv.Validate(), "supplier: (tax_id: (code: cannot be blank.).)")
-}

From 87fe0de6f4417ce7745d0f1cabdb35b9d8bdeb46 Mon Sep 17 00:00:00 2001
From: Menendez6 <pabloj.menendez@gmail.com>
Date: Mon, 18 Nov 2024 18:07:59 +0000
Subject: [PATCH 2/4] Changes in Changelog.md

---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

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

From fe98d991396c100d53624410aaa98c451f1bb35d Mon Sep 17 00:00:00 2001
From: Menendez6 <pabloj.menendez@gmail.com>
Date: Tue, 19 Nov 2024 08:32:07 +0000
Subject: [PATCH 3/4] Adding test for no tax id supplier

---
 regimes/ch/invoices_test.go | 60 +++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 regimes/ch/invoices_test.go

diff --git a/regimes/ch/invoices_test.go b/regimes/ch/invoices_test.go
new file mode 100644
index 00000000..7a13aebb
--- /dev/null
+++ b/regimes/ch/invoices_test.go
@@ -0,0 +1,60 @@
+package ch_test
+
+import (
+	"testing"
+
+	"github.com/invopop/gobl/bill"
+	"github.com/invopop/gobl/num"
+	"github.com/invopop/gobl/org"
+	"github.com/invopop/gobl/tax"
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
+)
+
+func validInvoice() *bill.Invoice {
+	return &bill.Invoice{
+		Series: "TEST",
+		Code:   "0002",
+		Supplier: &org.Party{
+			Name: "Test Supplier",
+			TaxID: &tax.Identity{
+				Country: "CH",
+				Code:    "E100416306",
+			},
+		},
+		Customer: &org.Party{
+			Name: "Test Customer",
+			TaxID: &tax.Identity{
+				Country: "CH",
+				Code:    "E432825998",
+			},
+		},
+		Lines: []*bill.Line{
+			{
+				Quantity: num.MakeAmount(1, 0),
+				Item: &org.Item{
+					Name:  "bogus",
+					Price: num.MakeAmount(10000, 2),
+					Unit:  org.UnitPackage,
+				},
+				Taxes: tax.Set{
+					{
+						Category: "VAT",
+						Rate:     "standard",
+					},
+				},
+			},
+		},
+	}
+}
+
+func TestInvoiceValidation(t *testing.T) {
+	inv := validInvoice()
+	require.NoError(t, inv.Calculate())
+	assert.NoError(t, inv.Validate())
+
+	inv = validInvoice()
+	inv.Supplier.TaxID.Code = ""
+	require.NoError(t, inv.Calculate())
+	assert.Error(t, inv.Validate())
+}

From 1ac0530b82a1209179a7901e26bbdd9d5e39041b Mon Sep 17 00:00:00 2001
From: Menendez6 <pabloj.menendez@gmail.com>
Date: Tue, 19 Nov 2024 08:39:31 +0000
Subject: [PATCH 4/4] Correcting test

---
 regimes/ch/invoices_test.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/regimes/ch/invoices_test.go b/regimes/ch/invoices_test.go
index 7a13aebb..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.Error(t, inv.Validate())
+	assert.NoError(t, inv.Validate())
 }