File tree Expand file tree Collapse file tree 4 files changed +34
-114
lines changed Expand file tree Collapse file tree 4 files changed +34
-114
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -93,6 +93,8 @@ func TestInvoiceValidation(t *testing.T) {
9393 require .NoError (t , inv .Validate ())
9494 })
9595
96+ // FIX: currently failing since we don't have a way to separate Supplier and Customer
97+ // with current implementation.
9698 t .Run ("missing supplier tax ID" , func (t * testing.T ) {
9799 t .Parallel ()
98100 inv := testInvoiceStandard (t )
Original file line number Diff line number Diff line change 1+ package se
2+
3+ import (
4+ "github.com/invopop/gobl/org"
5+ "github.com/invopop/validation"
6+ )
7+
8+ // validateOrgParty checks the organization party fulfills Swedish requirements.
9+ func validateOrgParty (value any ) error {
10+ party , ok := value .(* org.Party )
11+ if ! ok || party == nil {
12+ return nil
13+ }
14+
15+ // TO-DO: Find a way to validate that Suppliers must always include the Tax ID
16+
17+ return validation .ValidateStruct (party ,
18+ // Names are always required.
19+ validation .Field (& party .Name ,
20+ validation .Required ,
21+ validation .Skip ,
22+ ),
23+ // Addresses are required, but needn't be Swedish. It could be 2 foreign companies
24+ // where the supplier is registered for VAT in Sweden and the operation happens in Sweden.
25+ validation .Field (& party .Addresses ,
26+ validation .Required ,
27+ validation .Skip ,
28+ ),
29+ )
30+ }
Original file line number Diff line number Diff line change 22package se
33
44import (
5- "github.com/invopop/gobl/bill"
65 "github.com/invopop/gobl/currency"
76 "github.com/invopop/gobl/i18n"
87 "github.com/invopop/gobl/l10n"
@@ -43,12 +42,12 @@ func New() *tax.RegimeDef {
4342// Validate checks the document type and determines if it can be validated.
4443func Validate (doc any ) error {
4544 switch obj := doc .(type ) {
46- case * bill.Invoice :
47- return validateInvoice (obj )
4845 case * tax.Identity :
4946 return validateTaxIdentity (obj )
5047 case * org.Identity :
5148 return validateOrgIdentity (obj )
49+ case * org.Party :
50+ return validateOrgParty (obj )
5251 }
5352 return nil
5453}
You can’t perform that action at this time.
0 commit comments