Skip to content

Commit

Permalink
updated example and added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarolivie committed Feb 25, 2025
1 parent ab9e535 commit 02b0bbf
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 87 deletions.
2 changes: 2 additions & 0 deletions addons/it/adecf/invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func validateInvoiceSupplier(value interface{}) error {
)
}

// This done because the format requires tax to be calculated at item level
// By forcing this we can ensure that the price already has the tax included
func validateInvoiceTax(value interface{}) error {
t, ok := value.(*bill.Tax)
if !ok || t == nil {
Expand Down
10 changes: 6 additions & 4 deletions addons/it/adecf/tax.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ func validatePercentage(val any) error {
return validation.NewError("validation_percentage_percentage", "Invalid percentage")
}

// Percentages required by ade cf
// Percentages required by AdE
// The percentages are checked as when converting to the format, the percentage must be one of the following
// 2%, 4%, 5%, 6.4%, 7%, 7.3%, 7.5%, 7.65%, 7.95%, 8.3%, 8.5%, 8.8%, 9.5%, 10%, 12.3%, 22%
func validPercentages() []num.Percentage {
return []num.Percentage{
num.MakePercentage(2, 2),
num.MakePercentage(4, 2),
num.MakePercentage(5, 2),
num.MakePercentage(10, 2),
num.MakePercentage(22, 2),
num.MakePercentage(2, 2),
num.MakePercentage(64, 3),
num.MakePercentage(7, 2),
num.MakePercentage(73, 3),
Expand All @@ -65,5 +65,7 @@ func validPercentages() []num.Percentage {
num.MakePercentage(88, 3),
num.MakePercentage(95, 3),
num.MakePercentage(123, 3),
num.MakePercentage(10, 2),
num.MakePercentage(22, 2),
}
}
176 changes: 93 additions & 83 deletions examples/it/out/b2c-adecf.json
Original file line number Diff line number Diff line change
@@ -1,92 +1,102 @@
{
"$schema": "https://gobl.org/draft-0/bill/invoice",
"$regime": "IT",
"$addons": [
"it-adecf-v1"
],
"uuid": "0190a63a-1a80-7e1e-a868-08c7859b6470",
"type": "standard",
"series": "FT",
"code": "020",
"issue_date": "2024-07-12",
"currency": "EUR",
"tax": {
"prices_include": "VAT"
},
"supplier": {
"name": "Cleaning SRL",
"tax_id": {
"country": "IT",
"code": "12345678903"
"$schema": "https://gobl.org/draft-0/envelope",
"head": {
"uuid": "8a51fd30-2a27-11ee-be56-0242ac120002",
"dig": {
"alg": "sha256",
"val": "eef8e46b9a6cac86b1b4cf140f601192af04bf0f22bd3a9e5bb5b11cec0a2759"
}
},
"lines": [
{
"i": 1,
"quantity": "1",
"item": {
"name": "Cleaning services",
"price": "125.00"
"doc": {
"$schema": "https://gobl.org/draft-0/bill/invoice",
"$regime": "IT",
"$addons": [
"it-adecf-v1"
],
"uuid": "0190a63a-1a80-7e1e-a868-08c7859b6470",
"type": "standard",
"series": "FT",
"code": "020",
"issue_date": "2024-07-12",
"currency": "EUR",
"tax": {
"prices_include": "VAT"
},
"supplier": {
"name": "Cleaning SRL",
"tax_id": {
"country": "IT",
"code": "12345678903"
}
},
"lines": [
{
"i": 1,
"quantity": "1",
"item": {
"name": "Cleaning services",
"price": "125.00"
},
"sum": "125.00",
"taxes": [
{
"cat": "VAT",
"ext": {
"it-adecf-exempt": "N3"
}
}
],
"total": "125.00"
},
"sum": "125.00",
"taxes": [
{
"cat": "VAT",
"ext": {
"it-adecf-exempt": "N3"
{
"i": 2,
"quantity": "3",
"item": {
"name": "Cleaning products",
"price": "137.50"
},
"sum": "412.50",
"taxes": [
{
"cat": "VAT",
"rate": "standard",
"percent": "22.0%"
}
}
],
"total": "125.00"
},
{
"i": 2,
"quantity": "3",
"item": {
"name": "Cleaning products",
"price": "137.50"
],
"total": "412.50"
}
],
"totals": {
"sum": "537.50",
"tax_included": "74.39",
"total": "463.11",
"taxes": {
"categories": [
{
"code": "VAT",
"rates": [
{
"ext": {
"it-adecf-exempt": "N3"
},
"base": "125.00",
"amount": "0.00"
},
{
"key": "standard",
"base": "338.11",
"percent": "22.0%",
"amount": "74.39"
}
],
"amount": "74.39"
}
],
"sum": "74.39"
},
"sum": "412.50",
"taxes": [
{
"cat": "VAT",
"rate": "standard",
"percent": "22.0%"
}
],
"total": "412.50"
"tax": "74.39",
"total_with_tax": "537.50",
"payable": "537.50"
}
],
"totals": {
"sum": "537.50",
"tax_included": "74.39",
"total": "463.11",
"taxes": {
"categories": [
{
"code": "VAT",
"rates": [
{
"ext": {
"it-adecf-exempt": "N3"
},
"base": "125.00",
"amount": "0.00"
},
{
"key": "standard",
"base": "338.11",
"percent": "22.0%",
"amount": "74.39"
}
],
"amount": "74.39"
}
],
"sum": "74.39"
},
"tax": "74.39",
"total_with_tax": "537.50",
"payable": "537.50"
}
}

0 comments on commit 02b0bbf

Please sign in to comment.