Skip to content

Commit

Permalink
Adding test for no tax id supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
Menendez6 committed Nov 19, 2024
1 parent 87fe0de commit fe98d99
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions regimes/ch/invoices_test.go
Original file line number Diff line number Diff line change
@@ -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())
}

0 comments on commit fe98d99

Please sign in to comment.