From 2f1ebc03480ea37cad2b05a0ab101edd4ea1c950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luismi=20Cavall=C3=A9?= Date: Fri, 19 Jul 2024 12:24:54 +0000 Subject: [PATCH] Generate, compare and validate example XMLs --- converter.go | 15 +- examples_test.go | 62 + go.mod | 5 +- go.sum | 14 + retained_taxes_test.go | 2 +- signatures.go | 7 + test/data/.gitignore | 2 - test/data/invoice-hotel-private.json | 332 ++-- test/data/invoice-hotel.json | 15 +- test/data/invoice-irpef.json | 519 +++--- test/data/invoice-simple-with-pec.json | 413 ++--- test/data/invoice-simple.json | 2 +- .../invoice-simplified.json.not-supported | 128 -- test/data/out/invoice-hotel-private.xml | 173 ++ test/data/out/invoice-hotel.xml | 165 ++ test/data/out/invoice-irpef.xml | 210 +++ test/data/out/invoice-simple-with-pec.xml | 192 +++ test/data/out/invoice-simple.xml | 191 +++ .../Schema_del_file_xml_FatturaPA_v1.2.2.xsd | 1454 +++++++++++++++++ test/data/schema/xmldsig-core-schema.xsd | 318 ++++ test/examples/bare-minimum.xml | 86 - test/examples/invoice_simplified_sample.xml | 66 - test/examples/private-multiple-lines.xml | 112 -- test/examples/private-single-line.xml | 111 -- test/examples/public-multiple-lines.xml | 134 -- test/examples/public-single-line.xml | 126 -- test/examples_test.go | 13 - test/test.go | 108 +- 28 files changed, 3506 insertions(+), 1469 deletions(-) create mode 100644 examples_test.go delete mode 100644 test/data/.gitignore delete mode 100644 test/data/invoice-simplified.json.not-supported create mode 100644 test/data/out/invoice-hotel-private.xml create mode 100644 test/data/out/invoice-hotel.xml create mode 100644 test/data/out/invoice-irpef.xml create mode 100644 test/data/out/invoice-simple-with-pec.xml create mode 100644 test/data/out/invoice-simple.xml create mode 100644 test/data/schema/Schema_del_file_xml_FatturaPA_v1.2.2.xsd create mode 100644 test/data/schema/xmldsig-core-schema.xsd delete mode 100644 test/examples/bare-minimum.xml delete mode 100644 test/examples/invoice_simplified_sample.xml delete mode 100644 test/examples/private-multiple-lines.xml delete mode 100644 test/examples/private-single-line.xml delete mode 100644 test/examples/public-multiple-lines.xml delete mode 100644 test/examples/public-single-line.xml delete mode 100644 test/examples_test.go diff --git a/converter.go b/converter.go index 710419a..3aac9da 100644 --- a/converter.go +++ b/converter.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "io" + "time" "github.com/invopop/gobl" "github.com/invopop/xmldsig" @@ -24,9 +25,10 @@ type Transmitter struct { // Config contains the configuration for the Converter type Config struct { - Certificate *xmldsig.Certificate - WithTimestamp bool - Transmitter *Transmitter + Certificate *xmldsig.Certificate + WithTimestamp bool + Transmitter *Transmitter + WithCurrentTime time.Time } // Option is a function that can be passed to NewConverter to configure it @@ -53,6 +55,13 @@ func WithTimestamp() Option { } } +// WithCurrentTime will ensure the XML document is signed with the given current time +func WithCurrentTime(t time.Time) Option { + return func(c *Converter) { + c.Config.WithCurrentTime = t + } +} + // NewConverter returns a new GOBL to XML Converter with the given options func NewConverter(opts ...Option) *Converter { c := new(Converter) diff --git a/examples_test.go b/examples_test.go new file mode 100644 index 0000000..3d66019 --- /dev/null +++ b/examples_test.go @@ -0,0 +1,62 @@ +package fatturapa_test + +import ( + "encoding/xml" + "fmt" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/invopop/gobl.fatturapa/test" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestExamples(t *testing.T) { + schema, err := test.LoadSchema() + require.NoError(t, err) + + var files []string + err = filepath.Walk(test.GetDataPath(), func(path string, _ os.FileInfo, _ error) error { + if filepath.Ext(path) == ".json" { + files = append(files, filepath.Base(path)) + } + return nil + }) + require.NoError(t, err) + + for _, file := range files { + fmt.Printf("processing file: %v\n", file) + + env := test.LoadTestFile(file) + + doc, err := test.ConvertFromGOBL(env, test.NewConverter()) + require.NoError(t, err) + + data, err := xml.MarshalIndent(doc, "", "\t") + require.NoError(t, err) + + np := strings.TrimSuffix(file, filepath.Ext(file)) + ".xml" + outPath := filepath.Join(test.GetDataPath(), "out", np) + + if *test.UpdateOut { + errs := test.ValidateXML(schema, data) + for _, e := range errs { + assert.NoError(t, e) + } + if len(errs) > 0 { + assert.Fail(t, "Invalid XML:\n"+string(data)) + } + + err = os.WriteFile(outPath, data, 0644) + require.NoError(t, err, "writing file") + } + + expected, err := os.ReadFile(outPath) + + require.False(t, os.IsNotExist(err), "output file %s missing, run tests with `--update` flag to create", filepath.Base(outPath)) + require.NoError(t, err) + require.Equal(t, string(expected), string(data), "output file %s does not match, run tests with `--update` flag to update", filepath.Base(outPath)) + } +} diff --git a/go.mod b/go.mod index d148a39..4fcb73d 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,13 @@ module github.com/invopop/gobl.fatturapa -go 1.20 +go 1.21 + +toolchain go1.22.1 require ( github.com/invopop/gobl v0.81.0 github.com/invopop/xmldsig v0.8.0 + github.com/lestrrat-go/libxml2 v0.0.0-20240521004304-a75c203ac627 github.com/magefile/mage v1.14.0 github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 58baeb1..bf6dae0 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -33,16 +34,23 @@ github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso= github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/labstack/echo/v4 v4.9.1 h1:GliPYSpzGKlyOhqIbG8nmHBo3i1saKWFOgh41AN3b+Y= +github.com/labstack/echo/v4 v4.9.1/go.mod h1:Pop5HLc+xoc4qhTZ1ip6C0RtP7Z+4VzRLWZZFKqbbjo= github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= +github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= +github.com/lestrrat-go/libxml2 v0.0.0-20240521004304-a75c203ac627 h1:M7EEuhGDmn9bWSnap5mzVlg8pmVucmLytCjVjm+H4QU= +github.com/lestrrat-go/libxml2 v0.0.0-20240521004304-a75c203ac627/go.mod h1:/0MMipmS+5SMXCSkulsvJwYmddKI4IL5tVy6AZMo9n0= github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs= +github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/otiai10/copy v1.10.0 h1:znyI7l134wNg/wDktoVQPxPkgvhDfGCYUasey+h0rDQ= github.com/otiai10/copy v1.10.0/go.mod h1:rSaLseMUsZFFbsFGc7wCJnnkTAvdc5L6VWxPE4308Ww= github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= +github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -64,7 +72,9 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= +github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= gitlab.com/flimzy/testy v0.12.4 h1:J2plNCG5d9FWfik30yOZrajcPrWbiDHrk0qw1nMstNU= @@ -77,6 +87,7 @@ golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -88,10 +99,13 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/xmlpath.v1 v1.0.0-20140413065638-a146725ea6e7 h1:zibSPXbkfB1Dwl76rJgLa68xcdHu42qmFTe6vAnU4wA= +gopkg.in/xmlpath.v1 v1.0.0-20140413065638-a146725ea6e7/go.mod h1:wo0SW5T6XqIKCCAge330Cd5sm+7VI6v85OrQHIk50KM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/retained_taxes_test.go b/retained_taxes_test.go index a2a25e8..651b7fd 100644 --- a/retained_taxes_test.go +++ b/retained_taxes_test.go @@ -39,7 +39,7 @@ func TestDatiRitenuta(t *testing.T) { assert.Equal(t, "RT01", dr[1].TipoRitenuta) assert.Equal(t, "50.00", dr[1].ImportoRitenuta) assert.Equal(t, "50.00", dr[1].AliquotaRitenuta) - assert.Equal(t, "J", dr[1].CausalePagamento) + assert.Equal(t, "I", dr[1].CausalePagamento) }) }) } diff --git a/signatures.go b/signatures.go index fc0092c..3640b63 100644 --- a/signatures.go +++ b/signatures.go @@ -2,6 +2,7 @@ package fatturapa import ( "fmt" + "time" "github.com/invopop/xmldsig" ) @@ -29,6 +30,12 @@ func (d *Document) sign(config *Config) error { dsigOpts = append(dsigOpts, xmldsig.WithTimestamp(xmldsig.TimestampFreeTSA)) } + if config.WithCurrentTime != (time.Time{}) { + dsigOpts = append(dsigOpts, xmldsig.WithCurrentTime(func() time.Time { + return config.WithCurrentTime + })) + } + sig, err := xmldsig.Sign(data, dsigOpts...) if err != nil { return err diff --git a/test/data/.gitignore b/test/data/.gitignore deleted file mode 100644 index 4f20bc0..0000000 --- a/test/data/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.xml -other/ diff --git a/test/data/invoice-hotel-private.json b/test/data/invoice-hotel-private.json index 43777bb..085a1ca 100644 --- a/test/data/invoice-hotel-private.json +++ b/test/data/invoice-hotel-private.json @@ -1,168 +1,168 @@ { - "$schema": "https://gobl.org/draft-0/envelope", - "head": { - "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", - "dig": { - "alg": "sha256", - "val": "6bdbb4af110f22bad603e55d8703b9ecafcfa9d0b1750b633834add3b618f931" - } - }, - "doc": { - "$schema": "https://gobl.org/draft-0/bill/invoice", - "uuid": "018f76a8-958f-7000-ac84-68b205937de3", - "type": "standard", - "series": "SAMPLE", - "code": "003", - "issue_date": "2023-05-21", - "currency": "EUR", - "tax": { - "prices_include": "VAT" - }, - "supplier": { - "name": "Hotel California", - "tax_id": { - "country": "IT", - "type": "business", - "code": "12345678903" - }, - "addresses": [ - { - "num": "102", - "street": "Via California", - "locality": "Palermo", - "region": "PA", - "code": "33213", - "country": "IT" - } - ], - "registration": { - "currency": "EUR", - "office": "RM", - "entry": "123456" - } - }, - "customer": { - "name": "Random Person", - "tax_id": { - "country": "GB" - }, - "people": [ - { - "name": { - "given": "John", - "surname": "Doe" - } - } - ], - "addresses": [ - { - "num": "23", - "street": "Main Street", - "locality": "London", - "code": "W1 A2", - "country": "GB" - } - ] - }, - "lines": [ - { - "i": 1, - "quantity": "1", - "item": { - "name": "Tassa di Soggiorno", - "price": "1.00" - }, - "sum": "1.00", - "taxes": [ - { - "cat": "VAT", - "rate": "exempt", - "ext": { - "it-sdi-nature": "N1" - } - } - ], - "total": "1.00" - }, - { - "i": 2, - "quantity": "1", - "item": { - "name": "Camera Matrimoniale", - "price": "125.00" - }, - "sum": "125.00", - "taxes": [ - { - "cat": "VAT", - "rate": "intermediate", - "percent": "10.0%" - } - ], - "total": "125.00" - }, - { - "i": 3, - "quantity": "10", - "item": { - "name": "Camera Matrimoniale", - "price": "75.00" - }, - "sum": "750.00", - "taxes": [ - { - "cat": "VAT", - "rate": "intermediate", - "percent": "10.0%" - } - ], - "total": "750.00" - } - ], - "payment": { - "advances": [ - { - "date": "2023-05-01", - "key": "card", - "description": "deposit", - "amount": "29.00" - } - ] - }, - "totals": { - "sum": "876.00", - "tax_included": "79.55", - "total": "796.45", - "taxes": { - "categories": [ - { - "code": "VAT", - "rates": [ - { - "key": "exempt", - "ext": { - "it-sdi-nature": "N1" - }, - "base": "1.00", - "amount": "0.00" - }, - { - "key": "intermediate", - "base": "795.45", - "percent": "10.0%", - "amount": "79.55" - } - ], - "amount": "79.55" - } - ], - "sum": "79.55" - }, - "tax": "79.55", - "total_with_tax": "876.00", - "payable": "876.00", - "advance": "29.00", - "due": "847.00" - } - } + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", + "dig": { + "alg": "sha256", + "val": "d0bb18b72b2ad7b226a82829dbeceee17e139d8b8cb8e5844644e4b7071bd7c6" + } + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "uuid": "018f76a8-958f-7000-ac84-68b205937de3", + "type": "standard", + "series": "SAMPLE", + "code": "003", + "issue_date": "2023-05-21", + "currency": "EUR", + "tax": { + "prices_include": "VAT" + }, + "supplier": { + "name": "Hotel California", + "tax_id": { + "country": "IT", + "code": "12345678903", + "type": "business" + }, + "addresses": [ + { + "num": "102", + "street": "Via California", + "locality": "Palermo", + "region": "PA", + "code": "33213", + "country": "IT" + } + ], + "registration": { + "currency": "EUR", + "office": "RM", + "entry": "123456" + } + }, + "customer": { + "name": "Random Person", + "tax_id": { + "country": "GB" + }, + "people": [ + { + "name": { + "given": "John", + "surname": "Doe" + } + } + ], + "addresses": [ + { + "num": "23", + "street": "Main Street", + "locality": "London", + "code": "W1 A2", + "country": "GB" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "1", + "item": { + "name": "Tassa di Soggiorno", + "price": "1.00" + }, + "sum": "1.00", + "taxes": [ + { + "cat": "VAT", + "rate": "exempt", + "ext": { + "it-sdi-nature": "N1" + } + } + ], + "total": "1.00" + }, + { + "i": 2, + "quantity": "1", + "item": { + "name": "Camera Matrimoniale", + "price": "125.00" + }, + "sum": "125.00", + "taxes": [ + { + "cat": "VAT", + "rate": "intermediate", + "percent": "10.0%" + } + ], + "total": "125.00" + }, + { + "i": 3, + "quantity": "10", + "item": { + "name": "Camera Matrimoniale", + "price": "75.00" + }, + "sum": "750.00", + "taxes": [ + { + "cat": "VAT", + "rate": "intermediate", + "percent": "10.0%" + } + ], + "total": "750.00" + } + ], + "payment": { + "advances": [ + { + "date": "2023-05-01", + "key": "card", + "description": "deposit", + "amount": "29.00" + } + ] + }, + "totals": { + "sum": "876.00", + "tax_included": "79.55", + "total": "796.45", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "exempt", + "ext": { + "it-sdi-nature": "N1" + }, + "base": "1.00", + "amount": "0.00" + }, + { + "key": "intermediate", + "base": "795.45", + "percent": "10.0%", + "amount": "79.55" + } + ], + "amount": "79.55" + } + ], + "sum": "79.55" + }, + "tax": "79.55", + "total_with_tax": "876.00", + "payable": "876.00", + "advance": "29.00", + "due": "847.00" + } + } } \ No newline at end of file diff --git a/test/data/invoice-hotel.json b/test/data/invoice-hotel.json index b15fb1f..f20c969 100644 --- a/test/data/invoice-hotel.json +++ b/test/data/invoice-hotel.json @@ -4,11 +4,12 @@ "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", "dig": { "alg": "sha256", - "val": "796bb9019577dcda5b03baa8916eb2e46d6ba975618d42203f39941e36bd338c" + "val": "aa6690ff798fe637147f95713634f33e34f8c03b1b5bba1b12150a8665c3fb2a" } }, "doc": { "$schema": "https://gobl.org/draft-0/bill/invoice", + "uuid": "0190caea-c344-7afa-a530-252b67108175", "type": "standard", "series": "SAMPLE", "code": "002", @@ -105,7 +106,7 @@ { "date": "2023-05-01", "key": "card", - "desc": "deposit", + "description": "deposit", "amount": "29.00" } ] @@ -129,15 +130,15 @@ }, { "key": "intermediate", - "base": "113.6364", + "base": "113.64", "percent": "10.0%", - "amount": "11.3636" + "amount": "11.36" } ], - "amount": "11.3636" + "amount": "11.36" } ], - "sum": "11.3636" + "sum": "11.36" }, "tax": "11.36", "total_with_tax": "126.00", @@ -146,4 +147,4 @@ "due": "97.00" } } -} +} \ No newline at end of file diff --git a/test/data/invoice-irpef.json b/test/data/invoice-irpef.json index 8ba8c53..1aa8de8 100644 --- a/test/data/invoice-irpef.json +++ b/test/data/invoice-irpef.json @@ -1,259 +1,262 @@ { - "$schema": "https://gobl.org/draft-0/envelope", - "head": { - "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", - "dig": { - "alg": "sha256", - "val": "943bb8169e975f7b5f03e9e28bc9d476b0a715321295d65d9c29c749de171897" - } - }, - "doc": { - "$schema": "https://gobl.org/draft-0/bill/invoice", - "type": "standard", - "series": "SAMPLE", - "code": "001", - "issue_date": "2023-03-02", - "currency": "EUR", - "tax": { - "tags": ["freelance"] - }, - "supplier": { - "name": "Rossi Digital Services", - "tax_id": { - "country": "IT", - "code": "12345678903" - }, - "people": [ - { - "name": { - "given": "GIANCARLO", - "surname": "ROSSI" - } - } - ], - "addresses": [ - { - "num": "1", - "street": "VIALE DELLA LIBERTÀ", - "locality": "ROMA", - "region": "RM", - "code": "00100", - "country": "IT" - } - ], - "emails": [ - { - "addr": "billing@example.com" - } - ] - }, - "customer": { - "name": "MARIO LEONI", - "tax_id": { - "country": "IT" - }, - "identities": [ - { - "key": "it-fiscal-code", - "code": "MRALNE80E05H501C" - } - ], - "people": [ - { - "name": { - "prefix": "Dott.", - "given": "MARIO", - "surname": "LEONI" - } - } - ], - "inboxes": [ - { - "key": "codice-destinatario", - "code": "ABCDEF1" - } - ], - "addresses": [ - { - "num": "32", - "street": "VIALE DELI LAVORATORI", - "locality": "FIRENZE", - "region": "FI", - "code": "50100", - "country": "IT" - } - ], - "emails": [ - { - "addr": "leoni@mario.com" - } - ] - }, - "lines": [ - { - "i": 1, - "quantity": "20", - "item": { - "name": "Development services", - "price": "90.00", - "unit": "h" - }, - "sum": "1800.00", - "discounts": [ - { - "percent": "10%", - "amount": "180.00", - "reason": "Special discount" - } - ], - "taxes": [ - { - "cat": "VAT", - "rate": "standard", - "percent": "22.0%" - }, - { - "cat": "IRPEF", - "percent": "20.0%", - "ext": { - "it-sdi-retained-tax": "A" - } - } - ], - "total": "1620.00" - }, - { - "i": 2, - "quantity": "1", - "item": { - "name": "Truffle Gathering", - "price": "100.00", - "unit": "h" - }, - "sum": "100.00", - "taxes": [ - { - "cat": "VAT", - "rate": "exempt", - "ext": { - "it-sdi-nature": "N2.2" - } - }, - { - "cat": "IRPEF", - "percent": "50.0%", - "ext": { - "it-sdi-retained-tax": "J" - } - } - ], - "total": "100.00" - } - ], - "discounts": [ - { - "i": 1, - "base": "1720.00", - "percent": "50%", - "amount": "860.00", - "reason": "10th year anniversary discount" - } - ], - "charges": [ - { - "i": 1, - "base": "1720.00", - "percent": "10%", - "amount": "172.00", - "reason": "10th year anniversary charge" - }, - { - "key": "stamp-duty", - "i": 2, - "amount": "12.34" - } - ], - "payment": { - "terms": { - "key": "due-date", - "due_dates": [ - { - "date": "2023-03-02", - "amount": "500.00" - }, - { - "date": "2023-04-02", - "amount": "544.40" - } - ] - }, - "instructions": { - "key": "credit-transfer", - "credit_transfer": [ - { - "iban": "IT60X0542811101000000123456", - "bic": "BCITITMM", - "name": "BANCA POPOLARE DI MILANO" - } - ] - } - }, - "totals": { - "sum": "1720.00", - "discount": "860.00", - "charge": "184.34", - "total": "1044.34", - "taxes": { - "categories": [ - { - "code": "VAT", - "rates": [ - { - "key": "standard", - "base": "1620.00", - "percent": "22.0%", - "amount": "356.40" - }, - { - "key": "exempt", - "ext": { - "it-sdi-nature": "N2.2" - }, - "base": "100.00", - "amount": "0.00" - } - ], - "amount": "356.40" - }, - { - "code": "IRPEF", - "retained": true, - "rates": [ - { - "ext": { - "it-sdi-retained-tax": "A" - }, - "base": "1620.00", - "percent": "20.0%", - "amount": "324.00" - }, - { - "ext": { - "it-sdi-retained-tax": "J" - }, - "base": "100.00", - "percent": "50.0%", - "amount": "50.00" - } - ], - "amount": "374.00" - } - ], - "sum": "-17.60" - }, - "tax": "-17.60", - "total_with_tax": "1026.74", - "payable": "1026.74" - } - } -} + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", + "dig": { + "alg": "sha256", + "val": "5df55bfe1a0d605d9be685ea1c2c0d020d9cdf6626f2c0717f2fe8ae30b94035" + } + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "uuid": "0190caea-c352-7310-90fe-cbf74a3cd084", + "type": "standard", + "series": "SAMPLE", + "code": "001", + "issue_date": "2023-03-02", + "currency": "EUR", + "tax": { + "tags": [ + "freelance" + ] + }, + "supplier": { + "name": "Rossi Digital Services", + "tax_id": { + "country": "IT", + "code": "12345678903" + }, + "people": [ + { + "name": { + "given": "GIANCARLO", + "surname": "ROSSI" + } + } + ], + "addresses": [ + { + "num": "1", + "street": "VIALE DELLA LIBERTÀ", + "locality": "ROMA", + "region": "RM", + "code": "00100", + "country": "IT" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ] + }, + "customer": { + "name": "MARIO LEONI", + "tax_id": { + "country": "IT" + }, + "identities": [ + { + "key": "it-fiscal-code", + "code": "MRALNE80E05H501C" + } + ], + "people": [ + { + "name": { + "prefix": "Dott.", + "given": "MARIO", + "surname": "LEONI" + } + } + ], + "inboxes": [ + { + "key": "codice-destinatario", + "code": "ABCDEF1" + } + ], + "addresses": [ + { + "num": "32", + "street": "VIALE DELI LAVORATORI", + "locality": "FIRENZE", + "region": "FI", + "code": "50100", + "country": "IT" + } + ], + "emails": [ + { + "addr": "leoni@mario.com" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "20", + "item": { + "name": "Development services", + "price": "90.00", + "unit": "h" + }, + "sum": "1800.00", + "discounts": [ + { + "percent": "10%", + "amount": "180.00", + "reason": "Special discount" + } + ], + "taxes": [ + { + "cat": "VAT", + "rate": "standard", + "percent": "22.0%" + }, + { + "cat": "IRPEF", + "percent": "20.0%", + "ext": { + "it-sdi-retained-tax": "A" + } + } + ], + "total": "1620.00" + }, + { + "i": 2, + "quantity": "1", + "item": { + "name": "Truffle Gathering", + "price": "100.00", + "unit": "h" + }, + "sum": "100.00", + "taxes": [ + { + "cat": "VAT", + "rate": "exempt", + "ext": { + "it-sdi-nature": "N2.2" + } + }, + { + "cat": "IRPEF", + "percent": "50.0%", + "ext": { + "it-sdi-retained-tax": "I" + } + } + ], + "total": "100.00" + } + ], + "discounts": [ + { + "i": 1, + "base": "1720.00", + "percent": "50%", + "amount": "860.00", + "reason": "10th year anniversary discount" + } + ], + "charges": [ + { + "i": 1, + "base": "1720.00", + "percent": "10%", + "amount": "172.00", + "reason": "10th year anniversary charge" + }, + { + "key": "stamp-duty", + "i": 2, + "amount": "12.34" + } + ], + "payment": { + "terms": { + "key": "due-date", + "due_dates": [ + { + "date": "2023-03-02", + "amount": "500.00" + }, + { + "date": "2023-04-02", + "amount": "544.40" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "IT60X0542811101000000123456", + "bic": "BCITITMM", + "name": "BANCA POPOLARE DI MILANO" + } + ] + } + }, + "totals": { + "sum": "1720.00", + "discount": "860.00", + "charge": "184.34", + "total": "1044.34", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "1620.00", + "percent": "22.0%", + "amount": "356.40" + }, + { + "key": "exempt", + "ext": { + "it-sdi-nature": "N2.2" + }, + "base": "100.00", + "amount": "0.00" + } + ], + "amount": "356.40" + }, + { + "code": "IRPEF", + "retained": true, + "rates": [ + { + "ext": { + "it-sdi-retained-tax": "A" + }, + "base": "1620.00", + "percent": "20.0%", + "amount": "324.00" + }, + { + "ext": { + "it-sdi-retained-tax": "I" + }, + "base": "100.00", + "percent": "50.0%", + "amount": "50.00" + } + ], + "amount": "374.00" + } + ], + "sum": "-17.60" + }, + "tax": "-17.60", + "total_with_tax": "1026.74", + "payable": "1026.74" + } + } +} \ No newline at end of file diff --git a/test/data/invoice-simple-with-pec.json b/test/data/invoice-simple-with-pec.json index 7c487fb..caf1e2b 100644 --- a/test/data/invoice-simple-with-pec.json +++ b/test/data/invoice-simple-with-pec.json @@ -1,206 +1,209 @@ { - "$schema": "https://gobl.org/draft-0/envelope", - "head": { - "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", - "dig": { - "alg": "sha256", - "val": "a822e8e5808906fec7f7c01238604745da5303a975215421913e7ab1b26adfc3" - } - }, - "doc": { - "$schema": "https://gobl.org/draft-0/bill/invoice", - "type": "standard", - "series": "SAMPLE", - "code": "001", - "issue_date": "2023-03-02", - "currency": "EUR", - "tax": { - "tags": ["freelance"] - }, - "supplier": { - "name": "MªF. Services", - "tax_id": { - "country": "IT", - "code": "12345678903" - }, - "people": [ - { - "name": { - "given": "GIANCARLO", - "surname": "ROSSI" - } - } - ], - "addresses": [ - { - "num": "1", - "street": "VIALE DELLA LIBERTÀ", - "locality": "ROMA", - "region": "RM", - "code": "00100", - "country": "IT" - } - ], - "emails": [ - { - "addr": "billing@example.com" - } - ], - "telephones": [ - { - "num": "999999999" - } - ], - "registration": { - "capital": "50000.00", - "currency": "EUR", - "office": "RM", - "entry": "123456" - }, - "ext": { - "it-sdi-fiscal-regime": "RF01" - } - }, - "customer": { - "name": "MARIO LEONI", - "tax_id": { - "country": "IT", - "code": "09876543217" - }, - "people": [ - { - "name": { - "prefix": "Dott.", - "given": "MARIO", - "surname": "LEONI" - } - } - ], - "inboxes": [ - { - "key": "it-sdi-pec", - "code": "fooo@inbox.com" - } - ], - "addresses": [ - { - "num": "32", - "street": "VIALE DELI LAVORATORI", - "locality": "FIRENZE", - "region": "FI", - "code": "50100", - "country": "IT" - } - ], - "emails": [ - { - "addr": "leoni@mario.com" - } - ] - }, - "lines": [ - { - "i": 1, - "quantity": "20", - "item": { - "name": "Development services", - "price": "90.00", - "unit": "h" - }, - "sum": "1800.00", - "discounts": [ - { - "percent": "10%", - "amount": "180.00", - "reason": "Special discount" - } - ], - "taxes": [ - { - "cat": "VAT", - "rate": "standard", - "percent": "22.0%" - } - ], - "total": "1620.00" - }, - { - "i": 2, - "quantity": "1", - "item": { - "name": "Special Untaxed Work", - "price": "100.00", - "unit": "h" - }, - "sum": "100.00", - "taxes": [ - { - "cat": "VAT", - "rate": "exempt", - "ext": { - "it-sdi-nature": "N2.2" - } - } - ], - "total": "100.00" - } - ], - "discounts": [ - { - "i": 1, - "base": "1720.00", - "percent": "50%", - "amount": "860.00", - "reason": "10th year anniversary discount" - } - ], - "charges": [ - { - "i": 1, - "base": "1720.00", - "percent": "10%", - "amount": "172.00", - "reason": "10th year anniversary charge" - } - ], - "payment": { - "instructions": { - "key": "card" - } - }, - "totals": { - "sum": "1720.00", - "discount": "860.00", - "charge": "172.00", - "total": "1032.00", - "taxes": { - "categories": [ - { - "code": "VAT", - "rates": [ - { - "key": "standard", - "base": "1620.00", - "percent": "22.0%", - "amount": "356.40" - }, - { - "key": "exempt", - "ext": { - "it-sdi-nature": "N2.2" - }, - "base": "100.00", - "amount": "0.00" - } - ], - "amount": "356.40" - } - ], - "sum": "356.40" - }, - "tax": "356.40", - "total_with_tax": "1388.40", - "payable": "1388.40" - } - } -} + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", + "dig": { + "alg": "sha256", + "val": "af8a70f8e1d7a666ffd2abf461f223bfa5805af14657b00c39c1615d17fc315b" + } + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "uuid": "0190caea-c35f-72c1-92a0-728defa74ce2", + "type": "standard", + "series": "SAMPLE", + "code": "001", + "issue_date": "2023-03-02", + "currency": "EUR", + "tax": { + "tags": [ + "freelance" + ] + }, + "supplier": { + "name": "MªF. Services", + "tax_id": { + "country": "IT", + "code": "12345678903" + }, + "people": [ + { + "name": { + "given": "GIANCARLO", + "surname": "ROSSI" + } + } + ], + "addresses": [ + { + "num": "1", + "street": "VIALE DELLA LIBERTÀ", + "locality": "ROMA", + "region": "RM", + "code": "00100", + "country": "IT" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ], + "telephones": [ + { + "num": "999999999" + } + ], + "registration": { + "capital": "50000.00", + "currency": "EUR", + "office": "RM", + "entry": "123456" + }, + "ext": { + "it-sdi-fiscal-regime": "RF01" + } + }, + "customer": { + "name": "MARIO LEONI", + "tax_id": { + "country": "IT", + "code": "09876543217" + }, + "people": [ + { + "name": { + "prefix": "Dott.", + "given": "MARIO", + "surname": "LEONI" + } + } + ], + "inboxes": [ + { + "key": "it-sdi-pec", + "code": "fooo@inbox.com" + } + ], + "addresses": [ + { + "num": "32", + "street": "VIALE DELI LAVORATORI", + "locality": "FIRENZE", + "region": "FI", + "code": "50100", + "country": "IT" + } + ], + "emails": [ + { + "addr": "leoni@mario.com" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "20", + "item": { + "name": "Development services", + "price": "90.00", + "unit": "h" + }, + "sum": "1800.00", + "discounts": [ + { + "percent": "10%", + "amount": "180.00", + "reason": "Special discount" + } + ], + "taxes": [ + { + "cat": "VAT", + "rate": "standard", + "percent": "22.0%" + } + ], + "total": "1620.00" + }, + { + "i": 2, + "quantity": "1", + "item": { + "name": "Special Untaxed Work", + "price": "100.00", + "unit": "h" + }, + "sum": "100.00", + "taxes": [ + { + "cat": "VAT", + "rate": "exempt", + "ext": { + "it-sdi-nature": "N2.2" + } + } + ], + "total": "100.00" + } + ], + "discounts": [ + { + "i": 1, + "base": "1720.00", + "percent": "50%", + "amount": "860.00", + "reason": "10th year anniversary discount" + } + ], + "charges": [ + { + "i": 1, + "base": "1720.00", + "percent": "10%", + "amount": "172.00", + "reason": "10th year anniversary charge" + } + ], + "payment": { + "instructions": { + "key": "card" + } + }, + "totals": { + "sum": "1720.00", + "discount": "860.00", + "charge": "172.00", + "total": "1032.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "1620.00", + "percent": "22.0%", + "amount": "356.40" + }, + { + "key": "exempt", + "ext": { + "it-sdi-nature": "N2.2" + }, + "base": "100.00", + "amount": "0.00" + } + ], + "amount": "356.40" + } + ], + "sum": "356.40" + }, + "tax": "356.40", + "total_with_tax": "1388.40", + "payable": "1388.40" + } + } +} \ No newline at end of file diff --git a/test/data/invoice-simple.json b/test/data/invoice-simple.json index 44247bb..84ff9b8 100644 --- a/test/data/invoice-simple.json +++ b/test/data/invoice-simple.json @@ -206,4 +206,4 @@ "payable": "1388.40" } } -} +} \ No newline at end of file diff --git a/test/data/invoice-simplified.json.not-supported b/test/data/invoice-simplified.json.not-supported deleted file mode 100644 index e8e81dc..0000000 --- a/test/data/invoice-simplified.json.not-supported +++ /dev/null @@ -1,128 +0,0 @@ -{ - "$schema": "https://gobl.org/draft-0/envelope", - "head": { - "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", - "dig": { - "alg": "sha256", - "val": "427155d9bff1a6df157e956f0850ee880a44c8aa2adc8864e3cd48a758805193" - } - }, - "doc": { - "$schema": "https://gobl.org/draft-0/bill/invoice", - "type": "standard", - "series": "SAMPLE", - "code": "055", - "issue_date": "2023-12-04", - "currency": "EUR", - "tax": { - "tags": ["simplified"] - }, - "supplier": { - "name": "MªF. Services", - "tax_id": { - "country": "IT", - "code": "12345678903" - }, - "people": [ - { - "name": { - "given": "GIANCARLO", - "surname": "ROSSI" - } - } - ], - "addresses": [ - { - "num": "1", - "street": "VIALE DELLA LIBERTÀ", - "locality": "ROMA", - "region": "RM", - "code": "00100", - "country": "IT" - } - ], - "emails": [ - { - "addr": "billing@example.com" - } - ], - "telephones": [ - { - "num": "999999999" - } - ], - "registration": { - "capital": "50000.00", - "currency": "EUR", - "office": "RM", - "entry": "123456" - }, - "ext": { - "it-sdi-fiscal-regime": "RF01" - } - }, - "customer": { - "name": "MARIO LEONI", - "tax_id": { - "country": "IT", - "code": "09876543217" - } - }, - "lines": [ - { - "i": 1, - "quantity": "20", - "item": { - "name": "Random products", - "price": "90.00", - "unit": "h" - }, - "sum": "1800.00", - "discounts": [ - { - "percent": "10%", - "amount": "180.00", - "reason": "Special discount" - } - ], - "taxes": [ - { - "cat": "VAT", - "rate": "standard", - "percent": "22.0%" - } - ], - "total": "1620.00" - } - ], - "payment": { - "instructions": { - "key": "card" - } - }, - "totals": { - "sum": "1620.00", - "total": "1620.00", - "taxes": { - "categories": [ - { - "code": "VAT", - "rates": [ - { - "key": "standard", - "base": "1620.00", - "percent": "22.0%", - "amount": "356.40" - } - ], - "amount": "356.40" - } - ], - "sum": "356.40" - }, - "tax": "356.40", - "total_with_tax": "1976.40", - "payable": "1976.40" - } - } -} diff --git a/test/data/out/invoice-hotel-private.xml b/test/data/out/invoice-hotel-private.xml new file mode 100644 index 0000000..cfb2f18 --- /dev/null +++ b/test/data/out/invoice-hotel-private.xml @@ -0,0 +1,173 @@ + + + + + IT + 01234567890 + + 679a2f25 + FPR12 + XXXXXXX + + + + + IT + 12345678903 + + + Hotel California + + RF01 + + + Via California + 102 + 33213 + Palermo + PA + IT + + + RM + 123456 + LN + + + + + + + GB + 0000000 + + + John + Doe + + + + Main Street + 23 + 00000 + London + GB + + + + + + + TD01 + EUR + 2023-05-21 + SAMPLE-003 + 876.00 + + + + + 1 + Tassa di Soggiorno + 1.00 + 1.00 + 1.00 + 0.00 + N1 + + + 2 + Camera Matrimoniale + 1.00 + 113.6364 + 113.6364 + 10.00 + + + 3 + Camera Matrimoniale + 10.00 + 68.1818 + 681.8180 + 10.00 + + + 0.00 + N1 + 1.00 + 0.00 + Escluse ex. art. 15 del D.P.R. 633/1972 + + + 10.00 + 795.45 + 79.55 + + + + + + + + + + + + + GoD0VAc+efNSNyTCsAt50+3vdJtBnIbZRVg6geyiZA120uO/sSVKVX/V+Tc3kdmiIQyS19kRZr6J+t5QS3Ting== + + + + 6+b9KJiVX/kpy7+O7yI2sGdhrxIlXzoDNTq47UDlH9Pkx7IKuEmt6cmyCYAvblLsWfllzb0LQVhi5TGvh3wWLw== + + + + 7Tj/Vr2iDe5KuUvZfrT8ntgjkAtz6zIeztpC/liVkbigGbZLGFHcMpSsVtsRc+WIqqwsB7AwFVjqjSIKIDI3uw== + + + fZwpM8nA4J9oqoEH1TNA5hbsdqAJ0phrc68c6Ih7J9Hq3AsjripgpvDCqHeewwVvlJZrtkw7QQo+ch+0ZV1pqa9nsW8TWMQfYV0w/HDN6x2rov+Pe3uEhTFVYgyD5cQeAArQaPo9Yb0vi9s9nYFzkXoquIJMGfsIc8pl1X8qRiBsB9Ms9ougpOP95Hf2hN/4R96i83D1Aop4GlJikpLgrNDDjBfP1WNQlbAFZHxsSdV6If6SpJpdENZTHW3KQCzpRbWxeMMWyxqT0qMHvgl8N+/MRPO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OTVQlMjBVc3VhcmlvcyxvdT1DRVJFUyxvPUZOTVQtUkNNLGM9RVM/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdDtiaW5hcnk/YmFzZT9vYmplY3RjbGFzcz1jUkxEaXN0cmlidXRpb25Qb2ludDANBgkqhkiG9w0BAQsFAAOCAQEAH4t5/v/SLsm/dXRDw4QblCmTX+5pgXJ+4G1Lb3KTSPtDJ0UbQiAMUx+iqDDOoMHU5H7po/HZLJXgNwvKLoiLbl5/q6Mqasif87fa6awNkuz/Y6dvXw0UOJh+Ud/Wrk0EyaP9ZtrLVsraUOobNyS6g+lOrCxRrNxGRK2yAeotO6LEo1y3b7CB+Amd2jDq8lY3AtCYlrhuCaTf0AD9IBYYmigHzFD/VH5a8uG95l6J85FQG7tMsG6UQHFM2EmNhpbrYH+ihetz3UhzcC5Fd/P1X7pGBymQgbCyBjCRf/HEVzyoHL72uMp2I4JXX4v8HABZT8xtlDY4LE0am9keJhaNcg== + + + + ujAnB2L5X2Bm42S5f/axKFu1QsAcZGJAeYELZZJ04jriBu3E8V3Rus3tUxfQ+ylqBm0bNWgHfP+gekosHaYoJNQmAVBuwpd183uHksTRUtbeOAFS2xd7v29stM7ARkec+WVV+SK8G6HECIB0VIAMoB2tVs0y6XRVRcjE4I7kH1h3ZbMIzvW43B4hxruYtXcvozGwvZpxQKVrjEY8IXH5+aXHM8WLCba4I06FyhvI+2/9WUPN2YvDoml7lQM4edgepTEZifq2ZPHGpCC5NhSXj2ab5FtnGTMgUaWH6tCljT0kOdfJBOHnIWOw4dBdgkik2CuxwGyMrq/P5VqQIC2hXQ== + AQAB + + + + + + + + 2022-02-01T04:00:00+00:00 + + + + + VmNYwDiCBBXJX/IL1AUYj7uHouM2Jcp3ZkeqmB+FKGTTwXIIZnCWmZVhCSB7uNoV6Xee7nZVkMqeCMQk3tGR0g== + + + CN=AC FNMT Usuarios,OU=Ceres,O=FNMT-RCM,C=ES + 96891622000445695554354105786026700712 + + + + + + + Fattura PA + + urn:oid:1.2.840.10003.5.109.10 + + + text/xml + + + + + + + + \ No newline at end of file diff --git a/test/data/out/invoice-hotel.xml b/test/data/out/invoice-hotel.xml new file mode 100644 index 0000000..3f61e7f --- /dev/null +++ b/test/data/out/invoice-hotel.xml @@ -0,0 +1,165 @@ + + + + + IT + 01234567890 + + 679a2f25 + FPR12 + 0000000 + + + + + IT + 12345678903 + + + Hotel California + + RF01 + + + Via California + 102 + 33213 + Palermo + PA + IT + + + RM + 123456 + LN + + + + + + + IT + 13029381004 + + + Mela S.r.l. + + + + Via dei Mille + 23 + 00100 + Firenze + FI + IT + + + + + + + TD01 + EUR + 2023-05-21 + SAMPLE-002 + 126.00 + + + + + 1 + Tassa di Soggiorno + 1.00 + 1.00 + 1.00 + 0.00 + N1 + + + 2 + Camera Matrimoniale + 1.00 + 113.6364 + 113.6364 + 10.00 + + + 0.00 + N1 + 1.00 + 0.00 + Escluse ex. art. 15 del D.P.R. 633/1972 + + + 10.00 + 113.64 + 11.36 + + + + + + + + + + + + + jYM7kYt27X2bFcXWHZD/pG60gB8fJoJB7rk1U8aOL+9iPydC3Y4Cp3NhBnN/LBpsV9z6cyOkXwGxFJ9BkmVxTQ== + + + + 6+b9KJiVX/kpy7+O7yI2sGdhrxIlXzoDNTq47UDlH9Pkx7IKuEmt6cmyCYAvblLsWfllzb0LQVhi5TGvh3wWLw== + + + + 7Tj/Vr2iDe5KuUvZfrT8ntgjkAtz6zIeztpC/liVkbigGbZLGFHcMpSsVtsRc+WIqqwsB7AwFVjqjSIKIDI3uw== + + + SEsDrtqY+j1efLLDlmmOdpVRA1LqFp2a1uigdfpUmeHB+YpGEQrmrImXqoxcw4sLyKYFDg81PptRg1lkAmA0+JaRw0RdX2FofnuUe72yzZiHvUcMTg9WjiEUrkrMJ2i6DDKpFC3ewCb6UqA6NQmhBUSKwq8MQ9AhQdgfC5M/yA9diAgT8Z9ntMckryFKH5U27LNXD/06kVvulyOxsA4cRRPevk4jxu55v/Oeu5C6MMy5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=FNMT-RCM,C=ES + 96891622000445695554354105786026700712 + + + + + + + Fattura PA + + urn:oid:1.2.840.10003.5.109.10 + + + text/xml + + + + + + + + \ No newline at end of file diff --git a/test/data/out/invoice-irpef.xml b/test/data/out/invoice-irpef.xml new file mode 100644 index 0000000..6cb7359 --- /dev/null +++ b/test/data/out/invoice-irpef.xml @@ -0,0 +1,210 @@ + + + + + IT + 01234567890 + + 679a2f25 + FPR12 + 0000000 + + + + + IT + 12345678903 + + + Rossi Digital Services + + RF01 + + + VIALE DELLA LIBERTÀ + 1 + 00100 + ROMA + RM + IT + + + billing@example.com + + + + + MRALNE80E05H501C + + MARIO + LEONI + Dott. + + + + VIALE DELI LAVORATORI + 32 + 50100 + FIRENZE + FI + IT + + + + + + + TD06 + EUR + 2023-03-02 + SAMPLE-001 + + RT01 + 324.00 + 20.00 + A + + + RT01 + 50.00 + 50.00 + I + + + SI + 12.34 + + + SC + 50.00 + 860.00 + + + MG + 10.00 + 172.00 + + + MG + 0.00 + 12.34 + + 1026.74 + + + + + 1 + Development services + 20.00 + 90.00 + + SC + 10.00 + 180.00 + + 1620.00 + 22.00 + + + 2 + Truffle Gathering + 1.00 + 100.00 + 100.00 + 0.00 + N2.2 + + + 22.00 + 1620.00 + 356.40 + + + 0.00 + N2.2 + 100.00 + 0.00 + Non soggette - altri casi + + + + TP01 + + MP05 + 2023-03-02 + 500.00 + + + MP05 + 2023-04-02 + 544.40 + + + + + + + + + + + + + aRZnVDtXgaZvA8XfEKmBxoEegr3EY60wYJ2hL5ITB8U1eT1ypLwDqdojVDDl6mqZciZ1Qa5njsZOvQ+IqcPM2A== + + + + 6+b9KJiVX/kpy7+O7yI2sGdhrxIlXzoDNTq47UDlH9Pkx7IKuEmt6cmyCYAvblLsWfllzb0LQVhi5TGvh3wWLw== + + + + 7Tj/Vr2iDe5KuUvZfrT8ntgjkAtz6zIeztpC/liVkbigGbZLGFHcMpSsVtsRc+WIqqwsB7AwFVjqjSIKIDI3uw== + + + dZJIUnX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hSXj2ab5FtnGTMgUaWH6tCljT0kOdfJBOHnIWOw4dBdgkik2CuxwGyMrq/P5VqQIC2hXQ== + AQAB + + + + + + + + 2022-02-01T04:00:00+00:00 + + + + + VmNYwDiCBBXJX/IL1AUYj7uHouM2Jcp3ZkeqmB+FKGTTwXIIZnCWmZVhCSB7uNoV6Xee7nZVkMqeCMQk3tGR0g== + + + CN=AC FNMT Usuarios,OU=Ceres,O=FNMT-RCM,C=ES + 96891622000445695554354105786026700712 + + + + + + + Fattura PA + + urn:oid:1.2.840.10003.5.109.10 + + + text/xml + + + + + + + + \ No newline at end of file diff --git a/test/data/out/invoice-simple-with-pec.xml b/test/data/out/invoice-simple-with-pec.xml new file mode 100644 index 0000000..eca3ea0 --- /dev/null +++ b/test/data/out/invoice-simple-with-pec.xml @@ -0,0 +1,192 @@ + + + + + IT + 01234567890 + + 679a2f25 + FPR12 + 0000000 + fooo@inbox.com + + + + + IT + 12345678903 + + + MªF. Services + + RF01 + + + VIALE DELLA LIBERTÀ + 1 + 00100 + ROMA + RM + IT + + + RM + 123456 + 50000.00 + LN + + + 999999999 + billing@example.com + + + + + + IT + 09876543217 + + + MARIO LEONI + + + + VIALE DELI LAVORATORI + 32 + 50100 + FIRENZE + FI + IT + + + + + + + TD06 + EUR + 2023-03-02 + SAMPLE-001 + + SC + 50.00 + 860.00 + + + MG + 10.00 + 172.00 + + 1388.40 + + + + + 1 + Development services + 20.00 + 90.00 + + SC + 10.00 + 180.00 + + 1620.00 + 22.00 + + + 2 + Special Untaxed Work + 1.00 + 100.00 + 100.00 + 0.00 + N2.2 + + + 22.00 + 1620.00 + 356.40 + + + 0.00 + N2.2 + 100.00 + 0.00 + Non soggette - altri casi + + + + TP02 + + MP08 + 1388.40 + + + + + + + + + + + + + Ay6Y2DYI+Zp74duu8pt2VTaSijjo1EbPImnKjsmL6H2H7fxYu446bgq7qn9yciRr/dpWXpgDDjqzwEFNyf22xg== + + + + 6+b9KJiVX/kpy7+O7yI2sGdhrxIlX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RUtbeOAFS2xd7v29stM7ARkec+WVV+SK8G6HECIB0VIAMoB2tVs0y6XRVRcjE4I7kH1h3ZbMIzvW43B4hxruYtXcvozGwvZpxQKVrjEY8IXH5+aXHM8WLCba4I06FyhvI+2/9WUPN2YvDoml7lQM4edgepTEZifq2ZPHGpCC5NhSXj2ab5FtnGTMgUaWH6tCljT0kOdfJBOHnIWOw4dBdgkik2CuxwGyMrq/P5VqQIC2hXQ== + AQAB + + + + + + + + 2022-02-01T04:00:00+00:00 + + + + + VmNYwDiCBBXJX/IL1AUYj7uHouM2Jcp3ZkeqmB+FKGTTwXIIZnCWmZVhCSB7uNoV6Xee7nZVkMqeCMQk3tGR0g== + + + CN=AC FNMT Usuarios,OU=Ceres,O=FNMT-RCM,C=ES + 96891622000445695554354105786026700712 + + + + + + + Fattura PA + + urn:oid:1.2.840.10003.5.109.10 + + + text/xml + + + + + + + + \ No newline at end of file diff --git a/test/data/out/invoice-simple.xml b/test/data/out/invoice-simple.xml new file mode 100644 index 0000000..3bd72da --- /dev/null +++ b/test/data/out/invoice-simple.xml @@ -0,0 +1,191 @@ + + + + + IT + 01234567890 + + 679a2f25 + FPR12 + ABCDEF1 + + + + + IT + 12345678903 + + + MªF. Services + + RF02 + + + VIALE DELLA LIBERTÀ + 1 + 00100 + ROMA + RM + IT + + + RM + 123456 + 50000.00 + LN + + + 999999999 + billing@example.com + + + + + + IT + 09876543217 + + + MARIO LEONI + + + + VIALE DELI LAVORATORI + 32 + 50100 + FIRENZE + FI + IT + + + + + + + TD06 + EUR + 2023-03-02 + SAMPLE-001 + + SC + 50.00 + 860.00 + + + MG + 10.00 + 172.00 + + 1388.40 + + + + + 1 + Development services + 20.00 + 90.00 + + SC + 10.00 + 180.00 + + 1620.00 + 22.00 + + + 2 + Special Untaxed Work + 1.00 + 100.00 + 100.00 + 0.00 + N2.2 + + + 22.00 + 1620.00 + 356.40 + + + 0.00 + N2.2 + 100.00 + 0.00 + Non soggette - altri casi + + + + TP02 + + MP08 +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v8HABZT8xtlDY4LE0am9keJhaNcg== + + + + ujAnB2L5X2Bm42S5f/axKFu1QsAcZGJAeYELZZJ04jriBu3E8V3Rus3tUxfQ+ylqBm0bNWgHfP+gekosHaYoJNQmAVBuwpd183uHksTRUtbeOAFS2xd7v29stM7ARkec+WVV+SK8G6HECIB0VIAMoB2tVs0y6XRVRcjE4I7kH1h3ZbMIzvW43B4hxruYtXcvozGwvZpxQKVrjEY8IXH5+aXHM8WLCba4I06FyhvI+2/9WUPN2YvDoml7lQM4edgepTEZifq2ZPHGpCC5NhSXj2ab5FtnGTMgUaWH6tCljT0kOdfJBOHnIWOw4dBdgkik2CuxwGyMrq/P5VqQIC2hXQ== + AQAB + + + + + + + + 2022-02-01T04:00:00+00:00 + + + + + VmNYwDiCBBXJX/IL1AUYj7uHouM2Jcp3ZkeqmB+FKGTTwXIIZnCWmZVhCSB7uNoV6Xee7nZVkMqeCMQk3tGR0g== + + + CN=AC FNMT Usuarios,OU=Ceres,O=FNMT-RCM,C=ES + 96891622000445695554354105786026700712 + + + + + + + Fattura PA + + urn:oid:1.2.840.10003.5.109.10 + + + text/xml + + + + + + + + \ No newline at end of file diff --git a/test/data/schema/Schema_del_file_xml_FatturaPA_v1.2.2.xsd b/test/data/schema/Schema_del_file_xml_FatturaPA_v1.2.2.xsd new file mode 100644 index 0000000..fb48a77 --- /dev/null +++ b/test/data/schema/Schema_del_file_xml_FatturaPA_v1.2.2.xsd @@ -0,0 +1,1454 @@ + + + + + + + + XML schema fatture destinate a PA e privati in forma ordinaria 1.2.2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Blocco relativo ai dati di trasmissione della Fattura Elettronica + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fattura verso PA + + + + + Fattura verso privati + + + + + + + + + + + + + + Blocco relativo ai Dati Generali della Fattura Elettronica + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SC = Sconto + + + + + MG = Maggiorazione + + + + + + + + + + SI = Documento emesso secondo modalità e termini stabiliti con DM ai sensi dell'art. 73 DPR 633/72 + + + + + + + + + + Cassa nazionale previdenza e assistenza avvocati e procuratori legali + + + + + Cassa previdenza dottori commercialisti + + + + + Cassa previdenza e assistenza geometri + + + + + Cassa nazionale previdenza e assistenza ingegneri e architetti liberi professionisti + + + + + Cassa nazionale del notariato + + + + + Cassa nazionale previdenza e assistenza ragionieri e periti commerciali + + + + + Ente nazionale assistenza agenti e rappresentanti di commercio (ENASARCO) + + + + + Ente nazionale previdenza e assistenza consulenti del lavoro (ENPACL) + + + + + Ente nazionale previdenza e assistenza medici (ENPAM) + + + + + Ente nazionale previdenza e assistenza farmacisti (ENPAF) + + + + + Ente nazionale previdenza e assistenza veterinari (ENPAV) + + + + + Ente nazionale previdenza e assistenza impiegati dell'agricoltura (ENPAIA) + + + + + Fondo previdenza impiegati imprese di spedizione e agenzie marittime + + + + + Istituto nazionale previdenza giornalisti italiani (INPGI) + + + + + Opera nazionale assistenza orfani sanitari italiani (ONAOSI) + + + + + Cassa autonoma assistenza integrativa giornalisti italiani (CASAGIT) + + + + + Ente previdenza periti industriali e periti industriali laureati (EPPI) + + + + + Ente previdenza e assistenza pluricategoriale (EPAP) + + + + + Ente nazionale previdenza e assistenza biologi (ENPAB) + + + + + Ente nazionale previdenza e assistenza professione infermieristica (ENPAPI) + + + + + Ente nazionale previdenza e assistenza psicologi (ENPAP) + + + + + INPS + + + + + + + + + + Fattura + + + + + Acconto / anticipo su fattura + + + + + Acconto / anticipo su parcella + + + + + Nota di credito + + + + + Nota di debito + + + + + Parcella + + + + + Integrazione fattura reverse charge interno + + + + + Integrazione/autofattura per acquisto servizi dall'estero + + + + + Integrazione per acquisto di beni intracomunitari + + + + + Integrazione/autofattura per acquisto di beni ex art.17 c.2 DPR 633/72 + + + + + Autofattura per regolarizzazione e integrazione delle fatture (ex art.6 c.8 e 9-bis d.lgs.471/97 o art.46 c.5 D.L. 331/93 + + + + + Autofattura per splafonamento + + + + + Estrazione benida Deposito IVA + + + + + Estrazione beni da Deposito IVA con versamento dell'IVA + + + + + Fattura differita di cui all'art.21, comma 4, terzo periodo lett. a) DPR 633/72 + + + + + Fattura differita di cui all'art.21, comma 4, terzo periodo lett. b) DPR 633/72 + + + + + Cessione di beni ammortizzabili e per passaggi interni (ex art.36 DPR 633/72) + + + + + Fattura per autoconsumo o per cessioni gratuite senza rivalsa + + + + + Acquisti da San Marino con IVA (fattura cartacea) + + + + + + + + + + Ritenuta di acconto persone fisiche + + + + + Ritenuta di acconto persone giuridiche + + + + + Contributo INPS + + + + + Contributo ENASARCO + + + + + Contributo ENPAM + + + + + Altro contributo previdenziale + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cessionario / Committente + + + + + Terzo + + + + + + + Blocco relativo ai dati del Cedente / Prestatore + + + + + + + + + + + + + + + + + + + + + + + + + + + + Regime ordinario + + + + + Regime dei contribuenti minimi (art. 1,c.96-117, L. 244/2007) + + + + + Agricoltura e attività connesse e pesca (artt. 34 e 34-bis, D.P.R. 633/1972) + + + + + Vendita sali e tabacchi (art. 74, c.1, D.P.R. 633/1972) + + + + + Commercio dei fiammiferi (art. 74, c.1, D.P.R. 633/1972) + + + + + Editoria (art. 74, c.1, D.P.R. 633/1972) + + + + + Gestione di servizi di telefonia pubblica (art. 74, c.1, D.P.R. 633/1972) + + + + + Rivendita di documenti di trasporto pubblico e di sosta (art. 74, c.1, D.P.R. 633/1972) + + + + + Intrattenimenti, giochi e altre attività di cui alla tariffa allegata al D.P.R. 640/72 (art. 74, c.6, D.P.R. 633/1972) + + + + + Agenzie di viaggi e turismo (art. 74-ter, D.P.R. 633/1972) + + + + + Agriturismo (art. 5, c.2, L. 413/1991) + + + + + Vendite a domicilio (art. 25-bis, c.6, D.P.R. 600/1973) + + + + + Rivendita di beni usati, di oggetti d’arte, d’antiquariato o da collezione (art. 36, D.L. 41/1995) + + + + + Agenzie di vendite all’asta di oggetti d’arte, antiquariato o da collezione (art. 40-bis, D.L. 41/1995) + + + + + IVA per cassa P.A. (art. 6, c.5, D.P.R. 633/1972) + + + + + IVA per cassa (art. 32-bis, D.L. 83/2012) + + + + + Regime forfettario + + + + + Altro + + + + + + + Il campo Denominazione è in alternativa ai campi Nome e Cognome + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Blocco relativo ai dati del Rappresentante Fiscale + + + + + + + + + + + + + + + Blocco relativo ai dati del Cessionario / Committente + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Blocco relativo ai dati di Beni Servizi della Fattura Elettronica + + + + + + + + + Blocco relativo ai dati dei Veicoli della Fattura Elettronica (da indicare nei casi di cessioni tra Paesi + membri di mezzi di trasporto nuovi, in base all'art. 38, comma 4 del dl 331 del 1993) + + + + + + + + + Blocco relativo ai dati di Pagamento della Fattura Elettronica + + + + + + + + + + + + + pagamento a rate + + + + + pagamento completo + + + + + anticipo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + contanti + + + + + assegno + + + + + assegno circolare + + + + + contanti presso Tesoreria + + + + + bonifico + + + + + vaglia cambiario + + + + + bollettino bancario + + + + + carta di pagamento + + + + + RID + + + + + RID utenze + + + + + RID veloce + + + + + RIBA + + + + + MAV + + + + + quietanza erario + + + + + giroconto su conti di contabilità speciale + + + + + domiciliazione bancaria + + + + + domiciliazione postale + + + + + bollettino di c/c postale + + + + + SEPA Direct Debit + + + + + SEPA Direct Debit CORE + + + + + SEPA Direct Debit B2B + + + + + Trattenuta su somme già riscosse + + + + + PagoPA + + + + + + + + + + + + + + + + + Blocco relativo ai dati del Terzo Intermediario che emette fattura elettronica per conto del Cedente/Prestatore + + + + + + + + + + + + + + + Blocco relativo ai dati di eventuali allegati + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SI = Cessione / Prestazione soggetta a ritenuta + + + + + + + + + + + + + + + + + + + + + + + esigibilità differita + + + + + esigibilità immediata + + + + + scissione dei pagamenti + + + + + + + + + Escluse ex. art. 15 del D.P.R. 633/1972 + + + + + + Non soggette + + + + + Non soggette ad IVA ai sensi degli artt. da 7 a 7-septies del DPR 633/72 + + + + + Non soggette - altri casi + + + + + + Non imponibili + + + + + Non Imponibili - esportazioni + + + + + Non Imponibili - cessioni intracomunitarie + + + + + Non Imponibili - cessioni verso San Marino + + + + + Non Imponibili - operazioni assimilate alle cessioni all'esportazione + + + + + Non Imponibili - a seguito di dichiarazioni d'intento + + + + + Non Imponibili - altre operazioni che non concorrono alla formazione del plafond + + + + + Esenti + + + + + Regime del margine/IVA non esposta in fattura + + + + + + Inversione contabile (per le operazioni in reverse charge ovvero nei casi di autofatturazione per acquisti extra UE di servizi ovvero per importazioni di beni nei soli casi previsti) + + + + + Inversione contabile - cessione di rottami e altri materiali di recupero + + + + + Inversione contabile - cessione di oro e argento ai sensi della legge 7/2000 nonché di oreficeria usata ad OPO + + + + + Inversione contabile - subappalto nel settore edile + + + + + Inversione contabile - cessione di fabbricati + + + + + Inversione contabile - cessione di telefoni cellulari + + + + + Inversione contabile - cessione di prodotti elettronici + + + + + Inversione contabile - prestazioni comparto edile e settori connessi + + + + + Inversione contabile - operazioni settore energetico + + + + + Inversione contabile - altri casi + + + + + IVA assolta in altro stato UE (prestazione di servizi di telecomunicazioni, tele-radiodiffusione ed elettronici ex art. 7-octies lett. a, b, art. 74-sexies DPR 633/72) + + + + + + + + + + + + + + + + + + + + + + + + + socio unico + + + + + più soci + + + + + + + + + in liquidazione + + + + + non in liquidazione + + + + + + + + + + Sconto + + + + + Premio + + + + + Abbuono + + + + + Spesa accessoria + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/data/schema/xmldsig-core-schema.xsd b/test/data/schema/xmldsig-core-schema.xsd new file mode 100644 index 0000000..df126b3 --- /dev/null +++ b/test/data/schema/xmldsig-core-schema.xsd @@ -0,0 +1,318 @@ + + + + + + ]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/examples/bare-minimum.xml b/test/examples/bare-minimum.xml deleted file mode 100644 index 75c6a99..0000000 --- a/test/examples/bare-minimum.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - IT - 01234567890 - - 00001 - FPA12 - AAAAAA - - - - - IT - 01234567890 - - - ALPHA SRL - - RF19 - - - VIALE ROMA 543 - 07100 - SASSARI - SS - IT - - - - - 09876543210 - - AMMINISTRAZIONE BETA - - - - VIA TORINO 38-B - 00145 - ROMA - RM - IT - - - - - - - TD01 - EUR - 2017-01-18 - 123 - LA FATTURA FA RIFERIMENTO AD UNA OPERAZIONE AAAA BBBBBBBBBBBBBBBBBB CCC DDDDDDDDDDDDDDD E FFFFFFFFFFFFFFFFFFFF GGGGGGGGGG HHHHHHH II LLLLLLLLLLLLLLLLL MMM NNNNN OO PPPPPPPPPPP QQQQ RRRR SSSSSSSSSSSSSS - SEGUE DESCRIZIONE CAUSALE NEL CASO IN CUI NON SIANO STATI SUFFICIENTI 200 CARATTERI AAAAAAAAAAA BBBBBBBBBBBBBBBBB - - - - - 1 - DESCRIZIONE DELLA FORNITURA - 5.00 - 1.00 - 5.00 - 22.00 - - - 22.00 - 5.00 - 1.10 - I - - - - TP01 - - MP01 - 2017-02-18 - 6.10 - - - - diff --git a/test/examples/invoice_simplified_sample.xml b/test/examples/invoice_simplified_sample.xml deleted file mode 100644 index 596cfd6..0000000 --- a/test/examples/invoice_simplified_sample.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - IT - CCCNNN80D07L407I - - 36 - FSM10 - OG04W6V - - - - IT - 01754930384 - - CCCNNN80D07L407I - ANTONINO - CACCAMO - - VIA RAVENNA 402/B - 44124 - FERRARA - FE - IT - - RF01 - - - - - IT - 10442360961 - - - - A-Cube s.r.l. - - Viale San Martino 57 - 20862 - Arcore - MB - IT - - - - - - - - TD07 - EUR - 2020-06-26 - 13 - - - - test - 100.00 - - 22.00 - - - - \ No newline at end of file diff --git a/test/examples/private-multiple-lines.xml b/test/examples/private-multiple-lines.xml deleted file mode 100644 index 9219c5e..0000000 --- a/test/examples/private-multiple-lines.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - IT - 01234567890 - - 00001 - FPR12 - 0000000 - betagamma@pec.it - - - - - - IT - 01234567890 - - - SOCIETA' ALPHA SRL - - RF01 - - - VIALE ROMA 543 - 07100 - SASSARI - SS - IT - - - - - 09876543210 - - BETA GAMMA - - - - VIA TORINO 38-B - 00145 - ROMA - RM - IT - - - - - - - TD01 - EUR - 2014-12-18 - 123 - LA FATTURA FA RIFERIMENTO AD UNA OPERAZIONE AAAA BBBBBBBBBBBBBBBBBB CCC DDDDDDDDDDDDDDD E FFFFFFFFFFFFFFFFFFFF GGGGGGGGGG HHHHHHH II LLLLLLLLLLLLLLLLL MMM NNNNN OO PPPPPPPPPPP QQQQ RRRR SSSSSSSSSSSSSS - SEGUE DESCRIZIONE CAUSALE NEL CASO IN CUI NON SIANO STATI SUFFICIENTI 200 CARATTERI AAAAAAAAAAA BBBBBBBBBBBBBBBBB - - - 1 - 66685 - 1 - - - - - IT - 24681012141 - - - Trasporto spa - - - 2012-10-22T16:46:12.000+02:00 - - - - - 1 - LA DESCRIZIONE DELLA FORNITURA PUO' SUPERARE I CENTO CARATTERI CHE RAPPRESENTAVANO IL PRECEDENTE LIMITE DIMENSIONALE. TALE LIMITE NELLA NUOVA VERSIONE E' STATO PORTATO A MILLE CARATTERI - 5.00 - 1.00 - 5.00 - 22.00 - - - 2 - FORNITURE VARIE PER UFFICIO - 10.00 - 2.00 - 20.00 - 22.00 - - - 22.00 - 27.00 - 5.95 - D - - - - TP01 - - MP01 - 2015-01-30 - 32.95 - - - - diff --git a/test/examples/private-single-line.xml b/test/examples/private-single-line.xml deleted file mode 100644 index 24cb06e..0000000 --- a/test/examples/private-single-line.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - IT - 01234567890 - - 00001 - FPR12 - ABC1234 - - - - - - IT - 01234567890 - - - SOCIETA' ALPHA SRL - - RF19 - - - VIALE ROMA 543 - 07100 - SASSARI - SS - IT - - - - - 09876543210 - - DITTA BETA - - - - VIA TORINO 38-B - 00145 - ROMA - RM - IT - - - - - - - TD01 - EUR - 2014-12-18 - 123 - LA FATTURA FA RIFERIMENTO AD UNA OPERAZIONE AAAA BBBBBBBBBBBBBBBBBB CCC DDDDDDDDDDDDDDD E FFFFFFFFFFFFFFFFFFFF GGGGGGGGGG HHHHHHH II LLLLLLLLLLLLLLLLL MMM NNNNN OO PPPPPPPPPPP QQQQ RRRR SSSSSSSSSSSSSS - SEGUE DESCRIZIONE CAUSALE NEL CASO IN CUI NON SIANO STATI SUFFICIENTI 200 CARATTERI AAAAAAAAAAA BBBBBBBBBBBBBBBBB - - - 1 - 66685 - 1 - - - 1 - 123 - 2012-09-01 - 5 - 123abc - 456def - - - - - IT - 24681012141 - - - Trasporto spa - - - 2012-10-22T16:46:12.000+02:00 - - - - - 1 - DESCRIZIONE DELLA FORNITURA - 5.00 - 1.00 - 5.00 - 22.00 - - - 22.00 - 5.00 - 1.10 - I - - - - TP01 - - MP01 - 2015-01-30 - 6.10 - - - - diff --git a/test/examples/public-multiple-lines.xml b/test/examples/public-multiple-lines.xml deleted file mode 100644 index efa7a24..0000000 --- a/test/examples/public-multiple-lines.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - - IT - 01234567890 - - 00001 - FPA12 - AAAAAA - - - - - IT - 01234567890 - - - ALPHA SRL - - RF01 - - - VIALE ROMA 543 - 07100 - SASSARI - SS - IT - - - - - 09876543210 - - AMMINISTRAZIONE BETA - - - - VIA TORINO 38-B - 00145 - ROMA - RM - IT - - - - - - - TD01 - EUR - 2017-01-18 - 123 - LA FATTURA FA RIFERIMENTO AD UNA OPERAZIONE AAAA BBBBBBBBBBBBBBBBBB CCC DDDDDDDDDDDDDDD E FFFFFFFFFFFFFFFFFFFF GGGGGGGGGG HHHHHHH II LLLLLLLLLLLLLLLLL MMM NNNNN OO PPPPPPPPPPP QQQQ RRRR SSSSSSSSSSSSSS - SEGUE DESCRIZIONE CAUSALE NEL CASO IN CUI NON SIANO STATI SUFFICIENTI 200 CARATTERI AAAAAAAAAAA BBBBBBBBBBBBBBBBB - - - 1 - 66685 - 1 - 123abc - 456def - - - 1 - 123 - 2016-09-01 - 5 - 123abc - 456def - - - 1 - 456 - 5 - 123abc - 456def - - - 1 - 789 - 5 - 123abc - 456def - - - - - IT - 24681012141 - - - Trasporto spa - - - 2017-01-10T16:46:12.000+02:00 - - - - - 1 - LA DESCRIZIONE DELLA FORNITURA PUO' SUPERARE I CENTO CARATTERI CHE RAPPRESENTAVANO IL PRECEDENTE LIMITE DIMENSIONALE. TALE LIMITE NELLA NUOVA VERSIONE E' STATO PORTATO A MILLE CARATTERI - 5.00 - 1.00 - 5.00 - 22.00 - - - 2 - FORNITURE VARIE PER UFFICIO - 10.00 - 2.00 - 20.00 - 22.00 - - - 22.00 - 25.00 - 5.50 - D - - - - TP01 - - MP01 - 2017-03-30 - 30.50 - - - - diff --git a/test/examples/public-single-line.xml b/test/examples/public-single-line.xml deleted file mode 100644 index 51851f8..0000000 --- a/test/examples/public-single-line.xml +++ /dev/null @@ -1,126 +0,0 @@ - - - - - IT - 01234567890 - - 00001 - FPA12 - AAAAAA - - - - - IT - 01234567890 - - - ALPHA SRL - - RF19 - - - VIALE ROMA 543 - 07100 - SASSARI - SS - IT - - - - - 09876543210 - - AMMINISTRAZIONE BETA - - - - VIA TORINO 38-B - 00145 - ROMA - RM - IT - - - - - - - TD01 - EUR - 2017-01-18 - 123 - LA FATTURA FA RIFERIMENTO AD UNA OPERAZIONE AAAA BBBBBBBBBBBBBBBBBB CCC DDDDDDDDDDDDDDD E FFFFFFFFFFFFFFFFFFFF GGGGGGGGGG HHHHHHH II LLLLLLLLLLLLLLLLL MMM NNNNN OO PPPPPPPPPPP QQQQ RRRR SSSSSSSSSSSSSS - SEGUE DESCRIZIONE CAUSALE NEL CASO IN CUI NON SIANO STATI SUFFICIENTI 200 CARATTERI AAAAAAAAAAA BBBBBBBBBBBBBBBBB - - - 1 - 66685 - 1 - 123abc - 456def - - - 1 - 123 - 2016-09-01 - 5 - 123abc - 456def - - - 1 - 456 - 5 - 123abc - 456def - - - 1 - 789 - 5 - 123abc - 456def - - - - - IT - 24681012141 - - - Trasporto spa - - - 2017-01-10T16:46:12.000+02:00 - - - - - 1 - DESCRIZIONE DELLA FORNITURA - 5.00 - 1.00 - 5.00 - 22.00 - - - 22.00 - 5.00 - 1.10 - I - - - - TP01 - - MP01 - 2017-02-18 - 6.10 - - - - diff --git a/test/examples_test.go b/test/examples_test.go deleted file mode 100644 index 3a2b52e..0000000 --- a/test/examples_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package test_test - -import ( - "testing" - - "github.com/invopop/gobl.fatturapa/test" - "github.com/stretchr/testify/assert" -) - -func TestExamples(t *testing.T) { - err := test.TestConversion() - assert.NoError(t, err) -} diff --git a/test/test.go b/test/test.go index 437102b..0f0fb93 100644 --- a/test/test.go +++ b/test/test.go @@ -3,11 +3,13 @@ package test import ( - "fmt" + "encoding/json" + "flag" "os" "path" "path/filepath" "strings" + "time" "github.com/invopop/gobl" fatturapa "github.com/invopop/gobl.fatturapa" @@ -15,6 +17,8 @@ import ( "github.com/invopop/gobl/l10n" "github.com/invopop/gobl/schema" "github.com/invopop/xmldsig" + "github.com/lestrrat-go/libxml2" + "github.com/lestrrat-go/libxml2/xsd" ) const ( @@ -22,6 +26,9 @@ const ( certificatePassword = "invopop" ) +// UpdateOut is a flag that can be set to update example files +var UpdateOut = flag.Bool("update", false, "Update the example files in test/data and test/data/out") + // NewConverter returns a fatturapa.Converter with the test certificate and // transmitter data. func NewConverter() *fatturapa.Converter { @@ -36,9 +43,13 @@ func NewConverter() *fatturapa.Converter { TaxID: "01234567890", } + // Set a fixed time to get deterministic signatures + ts, _ := time.Parse(time.RFC3339, "2022-02-01T04:00:00Z") + converter := fatturapa.NewConverter( fatturapa.WithTransmitterData(transmitter), fatturapa.WithCertificate(cert), + fatturapa.WithCurrentTime(ts), ) return converter @@ -61,53 +72,6 @@ func ConvertFromGOBL(env *gobl.Envelope, converter ...*fatturapa.Converter) (*fa return doc, nil } -// TestConversion takes the .json invoices generated previously and converts them -// into XML fatturapa documents. -func TestConversion() error { // nolint:revive - var files []string - err := filepath.Walk(GetDataPath(), func(path string, _ os.FileInfo, _ error) error { - if filepath.Ext(path) == ".json" { - files = append(files, filepath.Base(path)) - } - return nil - }) - if err != nil { - return err - } - - for _, file := range files { - fmt.Printf("processing file: %v\n", file) - - envelopeReader, err := os.Open(GetDataPath() + file) - if err != nil { - return err - } - - env, err := fatturapa.UnmarshalGOBL(envelopeReader) - if err != nil { - return err - } - - doc, err := ConvertFromGOBL(env, NewConverter()) - if err != nil { - return err - } - - data, err := doc.Bytes() - if err != nil { - return fmt.Errorf("extracting document bytes: %w", err) - } - - np := strings.TrimSuffix(file, filepath.Ext(file)) + ".xml" - err = os.WriteFile(GetDataPath()+"/"+np, data, 0644) - if err != nil { - return fmt.Errorf("writing file: %w", err) - } - } - - return nil -} - // GetDataPath returns the path where test can find data files // to be used in tests func GetDataPath() string { @@ -133,7 +97,8 @@ func ModifyInvoice(env *gobl.Envelope, modifyFunc func(*bill.Invoice)) { // LoadTestFile loads a test file from the test/data folder as a GOBL envelope func LoadTestFile(file string) *gobl.Envelope { - f, err := os.Open(GetDataPath() + file) + path := filepath.Join(GetDataPath(), file) + f, err := os.Open(path) if err != nil { panic(err) } @@ -143,9 +108,54 @@ func LoadTestFile(file string) *gobl.Envelope { panic(err) } + if err := env.Calculate(); err != nil { + panic(err) + } + + if err := env.Validate(); err != nil { + panic(err) + } + + if *UpdateOut { + data, err := json.MarshalIndent(env, "", "\t") + if err != nil { + panic(err) + } + + if err := os.WriteFile(path, data, 0644); err != nil { + panic(err) + } + } + return env } +// LoadSchema loads a XSD schema for validating XML documents +func LoadSchema() (*xsd.Schema, error) { + schemaPath := filepath.Join(GetDataPath(), "schema", "Schema_del_file_xml_FatturaPA_v1.2.2.xsd") + schema, err := xsd.ParseFromFile(schemaPath) + if err != nil { + return nil, err + } + + return schema, nil +} + +// ValidateXML validates an XML document against a XSD schema +func ValidateXML(schema *xsd.Schema, doc []byte) []error { + xmlDoc, err := libxml2.ParseString(string(doc)) + if err != nil { + return []error{err} + } + + err = schema.Validate(xmlDoc) + if err != nil { + return err.(xsd.SchemaValidationError).Errors() + } + + return nil +} + func loadCertificate() (*xmldsig.Certificate, error) { certificatesPath := getRootFolder() + "/test/certificates/"