From 661788201e4cca33d98cf0e9def9559cc074bbd2 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Mon, 24 Jul 2023 13:45:52 +0000 Subject: [PATCH] Save example output and compare --- examples_test.go | 45 ++++- note/examples/out/message.json | 16 ++ regimes/co/examples/out/simple.json | 108 +++++++++++ .../examples/out/invoice-es-es-freelance.json | 137 ++++++++++++++ .../out/invoice-es-es-vateqs-provider.json | 168 ++++++++++++++++++ .../out/invoice-es-es-vateqs-retailer.json | 87 +++++++++ .../es/examples/out/invoice-es-es.env.json | 90 ++++++++++ regimes/es/examples/out/invoice-es-es.json | 121 +++++++++++++ .../es/examples/out/invoice-es-nl-b2b.json | 125 +++++++++++++ .../out/invoice-es-nl-digital-b2c.json | 94 ++++++++++ regimes/fr/examples/out/invoice-fr-fr.json | 112 ++++++++++++ regimes/it/examples/out/freelance.json | 165 +++++++++++++++++ regimes/it/examples/out/hotel.json | 135 ++++++++++++++ regimes/us/examples/out/invoice-us-us.json | 101 +++++++++++ 14 files changed, 1497 insertions(+), 7 deletions(-) create mode 100644 note/examples/out/message.json create mode 100644 regimes/co/examples/out/simple.json create mode 100644 regimes/es/examples/out/invoice-es-es-freelance.json create mode 100644 regimes/es/examples/out/invoice-es-es-vateqs-provider.json create mode 100644 regimes/es/examples/out/invoice-es-es-vateqs-retailer.json create mode 100644 regimes/es/examples/out/invoice-es-es.env.json create mode 100644 regimes/es/examples/out/invoice-es-es.json create mode 100644 regimes/es/examples/out/invoice-es-nl-b2b.json create mode 100644 regimes/es/examples/out/invoice-es-nl-digital-b2c.json create mode 100644 regimes/fr/examples/out/invoice-fr-fr.json create mode 100644 regimes/it/examples/out/freelance.json create mode 100644 regimes/it/examples/out/hotel.json create mode 100644 regimes/us/examples/out/invoice-us-us.json diff --git a/examples_test.go b/examples_test.go index e5ac786d..7bff0ba4 100644 --- a/examples_test.go +++ b/examples_test.go @@ -2,6 +2,7 @@ package gobl_test import ( "encoding/json" + "flag" "fmt" "io/ioutil" "os" @@ -10,6 +11,7 @@ import ( "testing" "github.com/invopop/gobl" + "github.com/invopop/gobl/uuid" "github.com/invopop/yaml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -18,9 +20,12 @@ import ( var skipExamplePaths = []string{ "build/", ".out.", + "/out/", ".github", } +var updateExamples = flag.Bool("update", false, "Update the examples in the repository") + // TestConvertExamplesToJSON finds all of the `.json` and `.yaml` files in the // package and attempts to convert the to JSON Envelopes. func TestConvertExamplesToJSON(t *testing.T) { @@ -77,20 +82,46 @@ func processFile(t *testing.T, path string) error { } } - if err := env.Sign(testKey); err != nil { - return fmt.Errorf("failed to sign the doc: %w", err) + // override the UUID + env.Head.UUID = uuid.MustParse("8a51fd30-2a27-11ee-be56-0242ac120002") + + if err := env.Validate(); err != nil { + return fmt.Errorf("validation failed: %w", err) } - // Output to the filesystem (.out.json is defined in .gitignore) - np := strings.TrimSuffix(path, filepath.Ext(path)) + ".out.json" + // Output to the filesystem in the /out/ directory out, err := json.MarshalIndent(env, "", " ") if err != nil { return fmt.Errorf("marshalling output: %w", err) } - if err := ioutil.WriteFile(np, out, 0644); err != nil { - return fmt.Errorf("saving file data: %w", err) + + dir := filepath.Join(filepath.Dir(path), "out") + of := strings.TrimSuffix(filepath.Base(path), filepath.Ext(path)) + ".json" + np := filepath.Join(dir, of) + if _, err := os.Stat(np); err != nil { + if !os.IsNotExist(err) { + return fmt.Errorf("checking file: %s: %w", np, err) + } + if !*updateExamples { + return fmt.Errorf("output file missing, run tests with `--update` flag to create") + } + } + + if *updateExamples { + if err := ioutil.WriteFile(np, out, 0644); err != nil { + return fmt.Errorf("saving file data: %w", err) + } + t.Logf("wrote file: %v", np) + } else { + // Compare to existing file + existing, err := ioutil.ReadFile(np) + if err != nil { + return fmt.Errorf("reading existing file: %w", err) + } + t.Run(np, func(t *testing.T) { + assert.JSONEq(t, string(existing), string(out), "output file does not match, run tests with `--update` flag to update") + }) } - t.Logf("wrote file: %v", np) return nil } diff --git a/note/examples/out/message.json b/note/examples/out/message.json new file mode 100644 index 00000000..2dc8dce7 --- /dev/null +++ b/note/examples/out/message.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "45ac3115c8569a1789e58af8d0dc91ef3baa1fb71daaf38f5aef94f82b4d0033" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/note/message", + "title": "Test Message", + "content": "We hope you like this test message!" + } +} \ No newline at end of file diff --git a/regimes/co/examples/out/simple.json b/regimes/co/examples/out/simple.json new file mode 100644 index 00000000..032e3b52 --- /dev/null +++ b/regimes/co/examples/out/simple.json @@ -0,0 +1,108 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "5fff065413fac95076f9ee278ee219b351da74f6251244aa7accc6f6a57ae471" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "series": "SETT", + "code": "1234", + "type": "standard", + "currency": "COP", + "issue_date": "2021-01-01", + "supplier": { + "name": "EXAMPLE SUPPLIER S.A.S.", + "tax_id": { + "country": "CO", + "zone": "11001", + "type": "tin", + "code": "9014514812" + } + }, + "customer": { + "name": "EXAMPLE CUSTOMER S.A.S.", + "tax_id": { + "country": "CO", + "zone": "11001", + "type": "tin", + "code": "9014514805" + }, + "addresses": [ + { + "street": "CRA 8 113 31 OF 703", + "locality": "Bogotá, D.C.", + "region": "Bogotá", + "country": "CO" + } + ], + "emails": [ + { + "addr": "benito.ortiz@example.com" + } + ], + "telephones": [ + { + "num": "3114131811" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "1", + "item": { + "name": "Servicios Mes de Julio 2022", + "price": "200000.00" + }, + "sum": "200000.00", + "taxes": [ + { + "cat": "VAT", + "percent": "19%" + } + ], + "total": "200000.00" + } + ], + "payment": { + "terms": { + "key": "", + "due_dates": [ + { + "date": "2021-01-01", + "amount": "238000.00", + "percent": "100%" + } + ] + } + }, + "totals": { + "sum": "200000.00", + "total": "200000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "base": "200000.00", + "percent": "19%", + "amount": "38000.00" + } + ], + "amount": "38000.00" + } + ], + "sum": "38000.00" + }, + "tax": "38000.00", + "total_with_tax": "238000.00", + "payable": "238000.00" + } + } +} \ No newline at end of file diff --git a/regimes/es/examples/out/invoice-es-es-freelance.json b/regimes/es/examples/out/invoice-es-es-freelance.json new file mode 100644 index 00000000..215b42a7 --- /dev/null +++ b/regimes/es/examples/out/invoice-es-es-freelance.json @@ -0,0 +1,137 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "f1d54d434ba07ddd90f33d711f6a6725a80228f80cd831f11fcaa21357796571" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "code": "SAMPLE-001", + "type": "standard", + "currency": "EUR", + "issue_date": "2022-02-01", + "supplier": { + "name": "MªF. Services", + "tax_id": { + "country": "ES", + "code": "58384285G" + }, + "people": [ + { + "name": { + "given": "MARIA FRANCISCA", + "surname": "MONTERO", + "surname2": "ESTEBAN" + } + } + ], + "addresses": [ + { + "num": "9", + "street": "CAMÍ MADRID", + "locality": "CANENA", + "region": "JAÉN", + "code": "23480", + "country": "ES" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ] + }, + "customer": { + "name": "Sample Consumer", + "tax_id": { + "country": "ES", + "code": "54387763P" + } + }, + "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": "21.0%" + }, + { + "cat": "IRPF", + "percent": "15.0%" + } + ], + "total": "1620.00" + } + ], + "payment": { + "terms": { + "key": "instant" + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "ES06 0128 0011 3901 0008 1391", + "name": "Bankinter" + } + ] + } + }, + "totals": { + "sum": "1620.00", + "total": "1620.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "1620.00", + "percent": "21.0%", + "amount": "340.20" + } + ], + "amount": "340.20" + }, + { + "code": "IRPF", + "retained": true, + "rates": [ + { + "base": "1620.00", + "percent": "15.0%", + "amount": "243.00" + } + ], + "amount": "243.00" + } + ], + "sum": "97.20" + }, + "tax": "97.20", + "total_with_tax": "1717.20", + "payable": "1717.20" + } + } +} \ No newline at end of file diff --git a/regimes/es/examples/out/invoice-es-es-vateqs-provider.json b/regimes/es/examples/out/invoice-es-es-vateqs-provider.json new file mode 100644 index 00000000..5f26a28e --- /dev/null +++ b/regimes/es/examples/out/invoice-es-es-vateqs-provider.json @@ -0,0 +1,168 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "be3f4ef1fe594f569535d860a7b85ba7e2fb0ee70d4deed9cf9c5761faa1e446" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "code": "SAMPLE-001", + "type": "standard", + "currency": "EUR", + "tax": { + "prices_include": "VAT" + }, + "issue_date": "2022-02-01", + "supplier": { + "name": "Provide One S.L.", + "tax_id": { + "country": "ES", + "code": "B98602642" + }, + "addresses": [ + { + "num": "42", + "street": "Calle Pradillo", + "locality": "Madrid", + "region": "Madrid", + "code": "28002", + "country": "ES" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ] + }, + "customer": { + "name": "Simple Goods Store", + "tax_id": { + "country": "ES", + "code": "54387763P" + }, + "addresses": [ + { + "num": "43", + "street": "Calle Mayor", + "locality": "Madrid", + "region": "Madrid", + "code": "28003" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Mugs from provider", + "price": "10.00" + }, + "sum": "100.00", + "taxes": [ + { + "cat": "VAT", + "rate": "standard+eqs", + "percent": "21.0%", + "surcharge": "5.2%" + } + ], + "total": "100.00" + }, + { + "i": 2, + "quantity": "1", + "item": { + "name": "Delivery Costs", + "price": "10.00" + }, + "sum": "10.00", + "taxes": [ + { + "cat": "VAT", + "rate": "standard", + "percent": "21.0%" + } + ], + "total": "10.00" + } + ], + "payment": { + "terms": { + "key": "due-date", + "due_dates": [ + { + "date": "2021-10-30", + "amount": "45.72", + "percent": "40%" + }, + { + "date": "2021-11-30", + "amount": "68.58", + "percent": "60%" + } + ] + }, + "advances": [ + { + "date": "2021-09-01", + "desc": "Deposit paid upfront", + "amount": "25.00" + } + ], + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "ES06 0128 0011 3901 0008 1391", + "bic": "BKBKESMMXXX", + "name": "Bankinter" + } + ] + } + }, + "totals": { + "sum": "110.00", + "tax_included": "19.09", + "total": "90.91", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard+eqs", + "base": "82.6446", + "percent": "21.0%", + "surcharge": { + "percent": "5.2%", + "amount": "4.2975" + }, + "amount": "17.3554" + }, + { + "key": "standard", + "base": "8.2645", + "percent": "21.0%", + "amount": "1.7355" + } + ], + "amount": "19.0909", + "surcharge": "4.2975" + } + ], + "sum": "23.3884" + }, + "tax": "23.39", + "total_with_tax": "114.30", + "payable": "114.30", + "advance": "25.00", + "due": "89.30" + } + } +} \ No newline at end of file diff --git a/regimes/es/examples/out/invoice-es-es-vateqs-retailer.json b/regimes/es/examples/out/invoice-es-es-vateqs-retailer.json new file mode 100644 index 00000000..290c68bd --- /dev/null +++ b/regimes/es/examples/out/invoice-es-es-vateqs-retailer.json @@ -0,0 +1,87 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "e12bfa758ae6fa0678f4e6e58a882fba4427f9f099bdfbb542fdb00a04e240cb" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "code": "SAMPLE-001", + "type": "standard", + "currency": "EUR", + "tax": { + "prices_include": "VAT", + "tags": [ + "simplified" + ] + }, + "issue_date": "2022-02-01", + "supplier": { + "name": "Simple Goods Store", + "tax_id": { + "country": "ES", + "code": "54387763P" + }, + "addresses": [ + { + "num": "43", + "street": "Calle Mayor", + "locality": "Madrid", + "region": "Madrid", + "code": "28003" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Mugs from provider", + "price": "16.00", + "meta": { + "source": "provider" + } + }, + "sum": "160.00", + "taxes": [ + { + "cat": "VAT", + "rate": "standard", + "percent": "21.0%" + } + ], + "total": "160.00" + } + ], + "totals": { + "sum": "160.00", + "tax_included": "27.77", + "total": "132.23", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "132.2314", + "percent": "21.0%", + "amount": "27.7686" + } + ], + "amount": "27.7686" + } + ], + "sum": "27.7686" + }, + "tax": "27.77", + "total_with_tax": "160.00", + "payable": "160.00" + } + } +} \ No newline at end of file diff --git a/regimes/es/examples/out/invoice-es-es.env.json b/regimes/es/examples/out/invoice-es-es.env.json new file mode 100644 index 00000000..193ce108 --- /dev/null +++ b/regimes/es/examples/out/invoice-es-es.env.json @@ -0,0 +1,90 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "690b45d7d13ea3cc32b9b71bd1d08d55bcc13782974ca7a2a65b553d380515bd" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "code": "SAMPLE-001", + "type": "standard", + "currency": "EUR", + "issue_date": "2022-02-01", + "supplier": { + "name": "Provide One S.L.", + "tax_id": { + "country": "ES", + "code": "B98602642" + }, + "addresses": [ + { + "num": "42", + "street": "Calle Pradillo", + "locality": "Madrid", + "region": "Madrid", + "code": "28002", + "country": "ES" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ] + }, + "customer": { + "name": "Sample Consumer", + "tax_id": { + "country": "ES", + "code": "54387763P" + } + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Item being purchased", + "price": "100.00" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "rate": "standard", + "percent": "21.0%" + } + ], + "total": "1000.00" + } + ], + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "1000.00", + "percent": "21.0%", + "amount": "210.00" + } + ], + "amount": "210.00" + } + ], + "sum": "210.00" + }, + "tax": "210.00", + "total_with_tax": "1210.00", + "payable": "1210.00" + } + } +} \ No newline at end of file diff --git a/regimes/es/examples/out/invoice-es-es.json b/regimes/es/examples/out/invoice-es-es.json new file mode 100644 index 00000000..e5c96e5a --- /dev/null +++ b/regimes/es/examples/out/invoice-es-es.json @@ -0,0 +1,121 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "506978043814863e52aab1d9f8097b5bb65f5e5f9572356027b9bc715381e922" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "code": "SAMPLE-001", + "type": "standard", + "currency": "EUR", + "issue_date": "2022-02-01", + "supplier": { + "name": "Provide One S.L.", + "tax_id": { + "country": "ES", + "code": "B98602642" + }, + "addresses": [ + { + "num": "42", + "street": "Calle Pradillo", + "locality": "Madrid", + "region": "Madrid", + "code": "28002", + "country": "ES" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ] + }, + "customer": { + "name": "Sample Consumer", + "tax_id": { + "country": "ES", + "code": "54387763P" + } + }, + "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": "21.0%" + } + ], + "total": "1620.00" + }, + { + "i": 2, + "quantity": "1", + "item": { + "name": "Financial service", + "price": "10.00" + }, + "sum": "10.00", + "taxes": [ + { + "cat": "VAT", + "rate": "zero", + "percent": "0.0%" + } + ], + "total": "10.00" + } + ], + "totals": { + "sum": "1630.00", + "total": "1630.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "1620.00", + "percent": "21.0%", + "amount": "340.20" + }, + { + "key": "zero", + "base": "10.00", + "percent": "0.0%", + "amount": "0.00" + } + ], + "amount": "340.20" + } + ], + "sum": "340.20" + }, + "tax": "340.20", + "total_with_tax": "1970.20", + "payable": "1970.20" + } + } +} \ No newline at end of file diff --git a/regimes/es/examples/out/invoice-es-nl-b2b.json b/regimes/es/examples/out/invoice-es-nl-b2b.json new file mode 100644 index 00000000..4f27ab9c --- /dev/null +++ b/regimes/es/examples/out/invoice-es-nl-b2b.json @@ -0,0 +1,125 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "e7ecd9dd17dfb68facd7ad474b2fcfc7f5497f05b8a71e8fa4e26d5c0f6ecbc2" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "code": "SAMPLE-X-002", + "type": "standard", + "currency": "EUR", + "tax": { + "prices_include": "VAT", + "tags": [ + "reverse-charge" + ] + }, + "issue_date": "2022-02-01", + "supplier": { + "name": "Provide One S.L.", + "tax_id": { + "country": "ES", + "code": "B98602642" + }, + "addresses": [ + { + "num": "42", + "street": "Calle Pradillo", + "locality": "Madrid", + "region": "Madrid", + "code": "28002", + "country": "ES" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ] + }, + "customer": { + "name": "Sample Consumer", + "tax_id": { + "country": "NL", + "code": "000099995B57" + } + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Services exported", + "price": "20.00", + "unit": "day" + }, + "sum": "200.00", + "taxes": [ + { + "cat": "VAT", + "rate": "standard", + "percent": "21.0%" + } + ], + "total": "200.00" + }, + { + "i": 2, + "quantity": "50", + "item": { + "name": "Branded Mugs", + "price": "7.50", + "meta": { + "product": "goods" + } + }, + "sum": "375.00", + "taxes": [ + { + "cat": "VAT", + "rate": "standard", + "percent": "21.0%" + } + ], + "total": "375.00" + } + ], + "totals": { + "sum": "575.00", + "tax_included": "99.79", + "total": "475.21", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "475.2067", + "percent": "21.0%", + "amount": "99.7934" + } + ], + "amount": "99.7934" + } + ], + "sum": "99.7934" + }, + "tax": "0.00", + "total_with_tax": "475.21", + "payable": "475.21" + }, + "notes": [ + { + "key": "legal", + "src": "reverse-charge", + "text": "Reverse Charge / Inversión del sujeto pasivo." + } + ] + } +} \ No newline at end of file diff --git a/regimes/es/examples/out/invoice-es-nl-digital-b2c.json b/regimes/es/examples/out/invoice-es-nl-digital-b2c.json new file mode 100644 index 00000000..b877d476 --- /dev/null +++ b/regimes/es/examples/out/invoice-es-nl-digital-b2c.json @@ -0,0 +1,94 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "06b5812258b4ea63f20b385f7de2035f03dbef9d45621d92721dd4f6043e5945" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "code": "SAMPLE-X-002", + "type": "standard", + "currency": "EUR", + "tax": { + "tags": [ + "customer-rates" + ] + }, + "issue_date": "2022-02-01", + "supplier": { + "name": "Provide One S.L.", + "tax_id": { + "country": "ES", + "code": "B98602642" + }, + "addresses": [ + { + "num": "42", + "street": "Calle Pradillo", + "locality": "Madrid", + "region": "Madrid", + "code": "28002", + "country": "ES" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ] + }, + "customer": { + "name": "Sample Consumer", + "tax_id": { + "country": "NL" + } + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Services exported", + "price": "100.00" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "rate": "standard", + "percent": "21.0%" + } + ], + "total": "1000.00" + } + ], + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "1000.00", + "percent": "21.0%", + "amount": "210.00" + } + ], + "amount": "210.00" + } + ], + "sum": "210.00" + }, + "tax": "210.00", + "total_with_tax": "1210.00", + "payable": "1210.00" + } + } +} \ No newline at end of file diff --git a/regimes/fr/examples/out/invoice-fr-fr.json b/regimes/fr/examples/out/invoice-fr-fr.json new file mode 100644 index 00000000..9aba0e2b --- /dev/null +++ b/regimes/fr/examples/out/invoice-fr-fr.json @@ -0,0 +1,112 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "5b61832e7890d87f657af524f1a0e068aa06217a8967d724f821d9ea258c7371" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "series": "SAMPLE", + "code": "001", + "type": "standard", + "currency": "EUR", + "issue_date": "2022-02-01", + "supplier": { + "name": "Provide One Inc.", + "tax_id": { + "country": "FR", + "code": "44732829320" + }, + "addresses": [ + { + "num": "42", + "street": "Calle Pradillo", + "locality": "Madrid", + "region": "Madrid", + "code": "28002", + "country": "ES" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ] + }, + "customer": { + "name": "Sample Consumer", + "tax_id": { + "country": "FR", + "code": "39356000000" + }, + "addresses": [ + { + "num": "1", + "street": "Rue Sundacsakn", + "locality": "Saint-Germain-En-Laye", + "code": "75050" + } + ], + "emails": [ + { + "addr": "email@sample.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": "20.0%" + } + ], + "total": "1620.00" + } + ], + "totals": { + "sum": "1620.00", + "total": "1620.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "1620.00", + "percent": "20.0%", + "amount": "324.00" + } + ], + "amount": "324.00" + } + ], + "sum": "324.00" + }, + "tax": "324.00", + "total_with_tax": "1944.00", + "payable": "1944.00" + } + } +} \ No newline at end of file diff --git a/regimes/it/examples/out/freelance.json b/regimes/it/examples/out/freelance.json new file mode 100644 index 00000000..264feac1 --- /dev/null +++ b/regimes/it/examples/out/freelance.json @@ -0,0 +1,165 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "be0d3110e56c1813eca6b7fd17c0d2a6300c3bcba77351a04a658725f0544dae" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "series": "SAMPLE", + "code": "001", + "type": "standard", + "currency": "EUR", + "tax": { + "tags": [ + "freelance" + ] + }, + "issue_date": "2023-03-02", + "supplier": { + "name": "MªF. Services", + "tax_id": { + "country": "IT", + "code": "12345678903" + }, + "people": [ + { + "name": { + "given": "MARIA FRANCISCA", + "surname": "MONTERO", + "surname2": "ESTEBAN" + } + } + ], + "addresses": [ + { + "num": "9", + "street": "VIA DI TORREVECCHIA", + "locality": "ROMA", + "region": "RM", + "code": "23480", + "country": "IT" + } + ], + "emails": [ + { + "addr": "billing@example.com" + } + ] + }, + "customer": { + "name": "David Bowie", + "tax_id": { + "country": "IT", + "code": "13029381004" + }, + "addresses": [ + { + "num": "1", + "street": "Via del Corso", + "locality": "Roma", + "region": "RM", + "code": "00100", + "country": "IT" + } + ] + }, + "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", + "rate": "self-employed-habitual", + "percent": "20.0%" + } + ], + "total": "1620.00" + }, + { + "i": 2, + "quantity": "1", + "item": { + "name": "Zero test", + "price": "100.00", + "unit": "h" + }, + "sum": "100.00", + "taxes": [ + { + "cat": "VAT", + "rate": "zero", + "percent": "0.0%" + } + ], + "total": "100.00" + } + ], + "totals": { + "sum": "1720.00", + "total": "1720.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "base": "1620.00", + "percent": "22.0%", + "amount": "356.40" + }, + { + "key": "zero", + "base": "100.00", + "percent": "0.0%", + "amount": "0.00" + } + ], + "amount": "356.40" + }, + { + "code": "IRPEF", + "retained": true, + "rates": [ + { + "key": "self-employed-habitual", + "base": "1620.00", + "percent": "20.0%", + "amount": "324.00" + } + ], + "amount": "324.00" + } + ], + "sum": "32.40" + }, + "tax": "32.40", + "total_with_tax": "1752.40", + "payable": "1752.40" + } + } +} \ No newline at end of file diff --git a/regimes/it/examples/out/hotel.json b/regimes/it/examples/out/hotel.json new file mode 100644 index 00000000..9fea653a --- /dev/null +++ b/regimes/it/examples/out/hotel.json @@ -0,0 +1,135 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "315f83a516a4ca1efc18c8d31878c61a2ddcccd6dd9218e825950ccf3d4ab8c8" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "series": "SAMPLE", + "code": "002", + "type": "standard", + "currency": "EUR", + "tax": { + "prices_include": "VAT" + }, + "issue_date": "2023-05-21", + "supplier": { + "name": "Hotel California", + "tax_id": { + "country": "IT", + "code": "12345678903" + }, + "addresses": [ + { + "num": "102", + "street": "Via California", + "locality": "Palermo", + "region": "PA", + "code": "33213", + "country": "IT" + } + ], + "registration": { + "capital": "50000.00", + "currency": "EUR", + "office": "RM", + "entry": "123456" + } + }, + "customer": { + "name": "Mela S.r.l.", + "tax_id": { + "country": "IT", + "code": "13029381004" + }, + "inboxes": [ + { + "key": "codice-destinatario", + "code": "M5UXCR5" + } + ], + "addresses": [ + { + "num": "23", + "street": "Via dei Mille", + "locality": "Firenze", + "region": "FI", + "code": "00100", + "country": "IT" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "1", + "item": { + "name": "Tassa di Soggiorno", + "price": "1.00" + }, + "sum": "1.00", + "taxes": [ + { + "cat": "VAT", + "rate": "zero", + "percent": "0.0%" + } + ], + "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" + } + ], + "totals": { + "sum": "126.00", + "tax_included": "11.36", + "total": "114.64", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "zero", + "base": "1.0000", + "percent": "0.0%", + "amount": "0.0000" + }, + { + "key": "intermediate", + "base": "113.6364", + "percent": "10.0%", + "amount": "11.3636" + } + ], + "amount": "11.3636" + } + ], + "sum": "11.3636" + }, + "tax": "11.36", + "total_with_tax": "126.00", + "payable": "126.00" + } + } +} \ No newline at end of file diff --git a/regimes/us/examples/out/invoice-us-us.json b/regimes/us/examples/out/invoice-us-us.json new file mode 100644 index 00000000..ff7583a4 --- /dev/null +++ b/regimes/us/examples/out/invoice-us-us.json @@ -0,0 +1,101 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "2f42c17792ca424df809c674ff0fa4101e69581473bbe8e9b27b93d42314c6c2" + }, + "draft": true + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "series": "SAMPLE", + "code": "001", + "type": "standard", + "currency": "USD", + "tax": { + "prices_include": "ST" + }, + "issue_date": "2023-04-21", + "supplier": { + "name": "Provide One Inc.", + "tax_id": { + "country": "US" + }, + "addresses": [ + { + "num": "16", + "street": "Jessie Street", + "locality": "San Francisco", + "region": "CA", + "code": "94105", + "country": "US" + } + ], + "emails": [ + { + "addr": "billing@provideone.com" + } + ] + }, + "customer": { + "name": "Sample Consumer", + "emails": [ + { + "addr": "email@sample.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": "ST", + "percent": "8.5%" + } + ], + "total": "1620.00" + } + ], + "totals": { + "sum": "1620.00", + "tax_included": "126.91", + "total": "1493.09", + "taxes": { + "categories": [ + { + "code": "ST", + "rates": [ + { + "base": "1493.0876", + "percent": "8.5%", + "amount": "126.9124" + } + ], + "amount": "126.9124" + } + ], + "sum": "126.9124" + }, + "tax": "126.91", + "total_with_tax": "1620.00", + "payable": "1620.00" + } + } +} \ No newline at end of file