Skip to content

Commit

Permalink
Merge branch 'main' into br-regime
Browse files Browse the repository at this point in the history
  • Loading branch information
cavalle committed Oct 18, 2024
2 parents ce4698c + dc9192c commit ab05aa7
Show file tree
Hide file tree
Showing 11 changed files with 345 additions and 47 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Added

- `br`: added basic Brazil regime
- `uuid` - SQL library compatibility for type conversion.

### Fixed

Expand Down
20 changes: 14 additions & 6 deletions regimes/it/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ Example IT GOBL files can be found in the [`examples`](./examples) (YAML uncalcu

### FatturaPA

- [Historical Documentation](https://www.fatturapa.gov.it/en/norme-e-regole/documentazione-fattura-elettronica/formato-fatturapa/)
- [Schema V1.2.1 Spec Table View (EN)](https://www.fatturapa.gov.it/export/documenti/fatturapa/v1.2.1/Table-view-B2B-Ordinary-invoice.pdf) - by far the most comprehensible spec doc. Since the difference between 1.2.2 and 1.2.1 is minimal, this is perfectly usable.
- [Schema V1.2.2 PDF (IT)](https://www.fatturapa.gov.it/export/documenti/Specifiche_tecniche_del_formato_FatturaPA_v1.3.1.pdf) - most up-to-date but difficult
- [FatturaPA documentation: Agenzia delle Entrate's webside](https://www.agenziaentrate.gov.it/portale/web/guest/fatturazione-elettronica-e-dati-fatture-transfrontaliere-new)
- [FatturaPA documentation: FatturPA's website](https://www.fatturapa.gov.it/it/norme-e-regole/documentazione-fattura-elettronica/formato-fatturapa/)

#### Ordinary invoices (Fattura Ordinaria)
- [Schema V1.2.3 PDF (IT)](https://www.fatturapa.gov.it/export/documenti/fatturapa/v1.2.2/RappresentazioneTabellareFattOrdinariav123.pdf) - most up-to-date but in Italian.
- [Schema V1.2.1 Spec Table View (EN)](https://www.fatturapa.gov.it/export/documenti/fatturapa/v1.2.1/Table-view-B2B-Ordinary-invoice.pdf) - last version of the table translated to English. Since the difference between 1.2.3 and 1.2.1 is minimal, this is perfectly usable.
- [XSD V1.2.2](https://www.fatturapa.gov.it/export/documenti/fatturapa/v1.2.2/Schema_del_file_xml_FatturaPA_v1.2.2.xsd)
- [FatturaPA filling guide](https://www.agenziaentrate.gov.it/portale/documents/20143/451259/Guida_compilazione-FE-Esterometro-V_1.9_2024-03-05.pdf/67fe4c2d-1174-e8de-f1ee-cea77b7f5203) - useful to understand what values to choose within the extensions (e.g. Natura)

#### Changes from 1.2.1 to 1.2.2

##### Changes from 1.2.1 to 1.2.3
- Documentation changes: TD25, N1, N6.2, N7
- Addition of TD28: Acquisti da San Marino con IVA (fattura cartacea)
- New codes have been introduced for the AltriDatiGestionali block for agricultural producers under the special regime.
- New check has been introduced to reject invoices with invalidated declaration of intent 00477.
-The guidelines for the use of TD28 for transactions to and from entities not established in Italy have been updated.

#### Simplified invoices (Fattura Semplificata)
- [Simplified invoice schema – table view (IT)](https://www.agenziaentrate.gov.it/portale/documents/20143/4631413/RappresentazioneTabellareFattSemplificata.xlsx/a7ec4a67-f4cf-b558-1bda-0aaab4f0e552)


### Tax Rates

Expand Down
31 changes: 2 additions & 29 deletions regimes/it/examples/flat-rate.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"cat": "VAT",
"rate": "exempt",
"ext": {
"it-sdi-nature": "N2.1"
"it-sdi-nature": "N2.2"
}
}
],
Expand All @@ -78,32 +78,5 @@
"amount": "2.00",
"reason": "Imposta di bollo"
}
],
"totals": {
"sum": "125.00",
"charge": "2.00",
"total": "127.00",
"taxes": {
"categories": [
{
"code": "VAT",
"rates": [
{
"key": "exempt",
"ext": {
"it-sdi-nature": "N2.1"
},
"base": "125.00",
"amount": "0.00"
}
],
"amount": "0.00"
}
],
"sum": "0.00"
},
"tax": "0.00",
"total_with_tax": "127.00",
"payable": "127.00"
}
]
}
6 changes: 3 additions & 3 deletions regimes/it/examples/out/flat-rate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "8a51fd30-2a27-11ee-be56-0242ac120002",
"dig": {
"alg": "sha256",
"val": "fa85e1e27b0963b7fc7f122590d8fb999d5d9a74b37a395cf32b7765cd57a00e"
"val": "66cb2d1829e9b66e0062a4911c4520d931ca0f1a0225a68a0bc7de32625cfaea"
}
},
"doc": {
Expand Down Expand Up @@ -82,7 +82,7 @@
"cat": "VAT",
"rate": "exempt",
"ext": {
"it-sdi-exempt": "N2.1"
"it-sdi-exempt": "N2.2"
}
}
],
Expand All @@ -109,7 +109,7 @@
{
"key": "exempt",
"ext": {
"it-sdi-exempt": "N2.1"
"it-sdi-exempt": "N2.2"
},
"base": "125.00",
"amount": "0.00"
Expand Down
21 changes: 12 additions & 9 deletions regimes/mx/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# 🇲🇽 GOBL Mexico Tax Regime

Mexico uses the CFDI (Comprobante Fiscal Digital por Internet) format for their e-invoicing system.
Mexico uses the CFDI (Comprobante Fiscal Digital por Internet) format for e-invoicing.

Example MX GOBL files can be found in the [`examples`](./examples) (YAML uncalculated documents) and [`examples/out`](./examples/out) (JSON calculated envelopes) subdirectories.
Find example MX GOBL files in the [`examples`](./examples) (YAML uncalculated documents) and [`examples/out`](./examples/out) (JSON calculated envelopes) subdirectories.

## Public Documentation

- [Formato de factura (Anexo 20)](http://omawww.sat.gob.mx/tramitesyservicios/Paginas/anexo_20.htm)
- [Invoice Format (Anexo 20)](http://omawww.sat.gob.mx/tramitesyservicios/Paginas/anexo_20.htm)
- [CFDI 4.0 Filling Guide](http://omawww.sat.gob.mx/tramitesyservicios/Paginas/documentos/Anexo_20_Guia_de_llenado_CFDI.pdf)
- [Global CFDI 4.0 Filling Guide](http://omawww.sat.gob.mx/tramitesyservicios/Paginas/documentos/GuiallenadoCFDIglobal311221.pdf)

## Mexico specifics
## Mexico-specific Requirements

Mexican invoices as defined in the CFDI specification must include a set of specific codes that will either need to be known in advance by the supplier or requested from the customer during their purchase process.
Mexican invoices require specific codes as defined in the CFDI specification. Suppliers need to know these in advance or request them from customers during purchase.

The following sections highlight these codes and how they can be defined inside your GOBL documents.
Here's how to include these codes in your GOBL documents:

### `LugarExpedicion` - Issue Place
### Issue Place (`LugarExpedicion`)

Every MX invoice needs to specify the postal code of place where it was issued. In a GOBL Invoice, you can provide this value using the `mx-cfdi-issue-place` extension under the `tax` of the invoice.
Specify the postal code where the invoice was issued using the `mx-cfdi-issue-place` extension under the `tax` field of the invoice.

#### Example

Expand Down Expand Up @@ -316,7 +318,7 @@ The following GOBL maps to the `10101602` ("live ducks") value to the `ClaveProd
}
```

### Generic RFCs
### Generic RFCs (B2C sales)

In MX, CFDI invoices to end consumers need to use a generic RFC code (`XAXX010101000`) in the document's `Receptor` and some specific values for the supplier extensions. In GOBL, you don't need to enter those values explicitly. Just set the `simplified` tax tag in your invoice and exclude the customer, the GOBL to CFDI conversor will take care of the rest:

Expand All @@ -336,6 +338,7 @@ In MX, CFDI invoices to end consumers need to use a generic RFC code (`XAXX01010

}
```
Sellers can issue one simplified invoice for every B2C sale or aggregate all daily transactions into a single invoice to _the general public_ ("al público en general"). The rules on how to issue global B2C invoices are available in the [public documentation](http://omawww.sat.gob.mx/tramitesyservicios/Paginas/documentos/GuiallenadoCFDIglobal311221.pdf).

Similarly, CFDI invoices to foreign customers are required to use the foreign generic RFC (`XEXX010101000`) along with some specific values for the extensions. The country and the local tax code of the supplier are included in separated CFDI fields. And again, in GOBL, you just need to provide the actual country and tax code of the supplier (without extensions), and the GOBL to CFDI conversor will take care of producing the correct document:

Expand Down
120 changes: 120 additions & 0 deletions regimes/mx/examples/out/simplified-invoice.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"$schema": "https://gobl.org/draft-0/envelope",
"head": {
"uuid": "8a51fd30-2a27-11ee-be56-0242ac120002",
"dig": {
"alg": "sha256",
"val": "4df4dd22fc22b163c693d45a7b2605340fd241c5bd8bfa0ba9132deb8e26b809"
}
},
"doc": {
"$schema": "https://gobl.org/draft-0/bill/invoice",
"$regime": "MX",
"$addons": [
"mx-cfdi-v4"
],
"$tags": [
"simplified"
],
"uuid": "3aea7b56-59d8-4beb-90bd-f8f280d852a0",
"type": "standard",
"series": "TEST",
"code": "00001",
"issue_date": "2023-07-10",
"currency": "MXN",
"tax": {
"ext": {
"mx-cfdi-doc-type": "I",
"mx-cfdi-issue-place": "21000"
}
},
"supplier": {
"name": "ESCUELA KEMPER URGATE",
"tax_id": {
"country": "MX",
"code": "EKU9003173C9"
},
"ext": {
"mx-cfdi-fiscal-regime": "601"
}
},
"lines": [
{
"i": 1,
"quantity": "1",
"item": {
"name": "Cobro por tarjetas",
"price": "10.00",
"ext": {
"mx-cfdi-prod-serv": "84141602"
}
},
"sum": "10.00",
"discounts": [
{
"percent": "10.0%",
"amount": "1.00"
}
],
"taxes": [
{
"cat": "VAT",
"rate": "standard",
"percent": "16.0%"
}
],
"total": "9.00"
},
{
"i": 2,
"quantity": "1",
"item": {
"name": "Porcentaje sobre GMV",
"price": "10.00",
"unit": "service",
"ext": {
"mx-cfdi-prod-serv": "80141628"
}
},
"sum": "10.00",
"taxes": [
{
"cat": "VAT",
"rate": "standard",
"percent": "16.0%"
}
],
"total": "10.00"
}
],
"payment": {
"terms": {
"notes": "Condiciones de pago"
}
},
"totals": {
"sum": "19.00",
"total": "19.00",
"taxes": {
"categories": [
{
"code": "VAT",
"rates": [
{
"key": "standard",
"base": "19.00",
"percent": "16.0%",
"amount": "3.04"
}
],
"amount": "3.04"
}
],
"sum": "3.04"
},
"tax": "3.04",
"total_with_tax": "22.04",
"payable": "22.04"
}
}
}
44 changes: 44 additions & 0 deletions regimes/mx/examples/simplified-invoice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
$schema: "https://gobl.org/draft-0/bill/invoice"
$addons:
- "mx-cfdi-v4"
$tags:
- "simplified"
uuid: "3aea7b56-59d8-4beb-90bd-f8f280d852a0"
issue_date: "2023-07-10"
series: "TEST"
code: "00001"
tax:
ext:
mx-cfdi-issue-place: "21000"
supplier:
name: "ESCUELA KEMPER URGATE"
ext:
mx-cfdi-fiscal-regime: "601"
tax_id:
country: "MX"
code: "EKU9003173C9"
lines:
- quantity: "1"
item:
name: "Cobro por tarjetas"
price: "10.00"
ext:
mx-cfdi-prod-serv: "84141602"
discounts:
- percent: "10.0%"
taxes:
- cat: "VAT"
rate: "standard"
- quantity: "1"
item:
name: "Porcentaje sobre GMV"
price: "10.00"
unit: "service"
ext:
mx-cfdi-prod-serv: "80141628"
taxes:
- cat: "VAT"
rate: "standard"
payment:
terms:
notes: "Condiciones de pago"
37 changes: 37 additions & 0 deletions uuid/sql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package uuid

import (
"database/sql"
"database/sql/driver"
"fmt"
)

var _ driver.Valuer = UUID("")
var _ sql.Scanner = (*UUID)(nil)

// Value implements the driver.Valuer interface.
func (u UUID) Value() (driver.Value, error) {
return u.String(), nil
}

// Scan implements the sql.Scanner interface.
// A 16-byte slice will be handled by UnmarshalBinary, while
// a longer byte slice or a string will be handled by UnmarshalText.
func (u *UUID) Scan(src interface{}) error {
switch src := src.(type) {
case UUID:
*u = src
return nil
case []byte:
if len(src) == Size {
return u.UnmarshalBinary(src)
}
return u.UnmarshalText(src)
case string:
uu, err := Parse(src)
*u = uu
return err
}

return fmt.Errorf("cannot convert %T to UUID", src)
}
Loading

0 comments on commit ab05aa7

Please sign in to comment.