mx

package
v0.52.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 2

README

🇲🇽 GOBL Mexico Tax Regime

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

Public Documentation

Local Codes

UsoCFDI

The CFDI’s UsoCFDI field specifies how the invoice's recipient will use the invoice to deduce taxes for the expenditure made. The following table lists all the supported values and how GOBL will map them from the invoice's tax tags:

Code Name GOBL Tax Tag
G01 Adquisición de mercancías use+goods-acquisition
G02 Devoluciones, descuentos o bonificaciones use+returns
G03 Gastos en general use+general-expenses
I01 Construcciones use+construction
I02 Mobiliario y equipo de oficina por inversiones use+office-equipment
I03 Equipo de transporte use+transport-equipment
I04 Equipo de computo y accesorios use+computer-equipment
I05 Dados, troqueles, moldes, matrices y herramental use+manufacturing-tooling
I06 Comunicaciones telefónicas use+telephone-comms
I07 Comunicaciones satelitales use+satellite-comms
I08 Otra maquinaria y equipo use+other-machinery
D01 Honorarios médicos, dentales y gastos hospitalarios use+medical-expenses
D02 Gastos médicos por incapacidad o discapacidad use+medical-expenses+disability
D03 Gastos funerales use+funeral-expenses
D04 Donativos use+donation
D05 Intereses reales efectivamente pagados por créditos hipotecarios (casa habitación) use+mortgage-interest
D06 Aportaciones voluntarias al SAR use+sar-contribution
D07 Primas por seguros de gastos médicos use+medical-insurance
D08 Gastos de transportación escolar obligatoria use+school-transportation
D09 Depósitos en cuentas para el ahorro, primas que tengan como base planes de pensiones use+savings-deposit
D10 Pagos por servicios educativos (colegiaturas) use+school-fees
S01 Sin efectos fiscales use+no-tax-effects
CP01 Pagos use+suplementary-payment
CN01 Nómina use+payroll
Example

The following GOBL maps to the G03 (Gastos en general) value of the UsoCFDI field:

{
  "$schema": "https://gobl.org/draft-0/bill/invoice",

  // [...]

  "tax": {
    "tags": [
      "use+general-expenses"
    ]
  }
}
FormaPago

The CFDI’s FormaPago field specifies an invoice's means of payment. The following table lists all the supported values and how GOBL will map them from the invoice's payment instructions key:

Code Name GOBL Payment Instructions Key
01 Efectivo cash
02 Cheque nominativo cheque
03 Transferencia electrónica de fondos credit-transfer
04 Tarjeta de crédito card
05 Monedero electrónico online+wallet
06 Dinero electrónico online
08 Vales de despensa other+grocery-vouchers
12 Dación en pago other+in-kind
13 Pago por subrogación other+subrogation
14 Pago por consignación other+consignment
15 Condonación other+debt-relief
17 Compensación netting
23 Novación other+novation
24 Confusión other+merger
25 Remisión de deuda other+remission
26 Prescripción o caducidad other+expiration
27 A satisfacción del acreedor other+satisfy-creditor
28 Tarjeta de débito card+debit
29 Tarjeta de servicios card+services
30 Aplicación de anticipos other+advance
31 Intermediario pagos other+intermediary
99 Por definir other
Example

The following GOBL maps to the 05 (Monedero electrónico) value of the FormaPago field:

{
  "$schema": "https://gobl.org/draft-0/bill/invoice",

  // [...]

  "payment": {
    "instructions": {
      "key": "online+wallet"
    }
  }
}
ClaveUnidad

The CFDI’s ClaveUnidad field specifies the unit in which the quantity of an invoice's line is given. These are UNECE codes that GOBL will map directly from the invoice's line item unit. See the source code for the full list of supported units with its UNECE codes.

Example

The following GOBL maps to the KGM (Kilogram) value of the ClaveUnidad field:

{
  "$schema": "https://gobl.org/draft-0/bill/invoice",

  // [...]

  "lines": [
    {
      // [...]

      "item": {
        "name": "Jasmine rice",
        "unit": "kg",
        "price": "1.27"
      },
    }
  ]
}
ClaveProdServ

The CFDI’s ClaveProdServ field specifies the type of an invoice's line item. GOBL uses the line item identity type SAT to map the identity code directly (no transformation) to the ClaveProdServ field.

Example

The following GOBL maps to the 10101602 (Patos vivos) value of the ClaveProdServ field:

{
  "$schema": "https://gobl.org/draft-0/bill/invoice",

  // [...]

  "lines": [
    {
      // [...]

      "item": {
        "name": "Live ducks",
        "identities": [
          {
            "type": "SAT",
            "code": "10101602"
          }
        ]
      },
    }
  ]
}

Documentation

Overview

Package mx provides the Mexican tax regime.

Index

Constants

View Source
const (
	KeySATFormaPago         cbc.Key = "sat-forma-pago"          // for mapping to c_FormaPago’s codes
	KeySATTipoDeComprobante cbc.Key = "sat-tipo-de-comprobante" // for mapping to c_TipoDeComprobante’s codes
	KeySATTipoRelacion      cbc.Key = "sat-tipo-relacion"       // for mapping to c_TipoRelacion’s codes
	KeySATUsoCFDI           cbc.Key = "sat-uso-cfdi"            // for mapping to c_UsoCFDI’s codes

	IdentityTypeSAT cbc.Code = "SAT" // for custom codes mapped from identities (e.g. c_ClaveProdServ’s codes)
)

Custom keys used typically in meta or codes information.

View Source
const (
	MeansKeyWallet          cbc.Key = "wallet"
	MeansKeyGroceryVouchers cbc.Key = "grocery-vouchers"
	MeansKeyInKind          cbc.Key = "in-kind"
	MeansKeySubrogation     cbc.Key = "subrogation"
	MeansKeyConsignment     cbc.Key = "consignment"
	MeansKeyDebtRelief      cbc.Key = "debt-relief"
	MeansKeyNovation        cbc.Key = "novation"
	MeansKeyMerger          cbc.Key = "merger"
	MeansKeyRemission       cbc.Key = "remission"
	MeansKeyExpiration      cbc.Key = "expiration"
	MeansKeySatisfyCreditor cbc.Key = "satisfy-creditor"
	MeansKeyDebit           cbc.Key = "debit"
	MeansKeyServices        cbc.Key = "services"
	MeansKeyAdvance         cbc.Key = "advance"
	MeansKeyIntermediary    cbc.Key = "intermediary"
)

Regime Specific Payment Means Extension Keys

View Source
const (
	TagUse cbc.Key = "use" // UsoCFDI codes "namespace"

	TagGoodsAcquisition     cbc.Key = "goods-acquisition"
	TagReturns              cbc.Key = "returns"
	TagGeneralExpenses      cbc.Key = "general-expenses"
	TagConstruction         cbc.Key = "construction"
	TagOfficeEquipment      cbc.Key = "office-equipment"
	TagTransportEquipment   cbc.Key = "transport-equipment"
	TagComputerEquipment    cbc.Key = "computer-equipment"
	TagManufacturingTooling cbc.Key = "manufacturing-tooling"
	TagTelephoneComms       cbc.Key = "telephone-comms"
	TagSatelliteComms       cbc.Key = "satellite-comms"
	TagOtherMachinery       cbc.Key = "other-machinery"
	TagMedicalExpenses      cbc.Key = "medical-expenses"
	TagDisability           cbc.Key = "disability"
	TagFuneralExpenses      cbc.Key = "funeral-expenses"
	TagDonation             cbc.Key = "donation"
	TagMortgageInterest     cbc.Key = "mortgage-interest"
	TagSARContribution      cbc.Key = "sar-contribution"
	TagMedicalInsurance     cbc.Key = "medical-insurance"
	TagSchoolTransportation cbc.Key = "school-transportation"
	TagSavingsDeposit       cbc.Key = "savings-deposit"
	TagSchoolFees           cbc.Key = "school-fees"
	TagNoTaxEffects         cbc.Key = "no-tax-effects"
	TagSuplementaryPayment  cbc.Key = "suplementary-payment"
	TagPayroll              cbc.Key = "payroll"
)

Regime Specific Tags (UsoCFDI codes)

View Source
const (
	TaxIdentityTypePerson  cbc.Key = "person"
	TaxIdentityTypeCompany cbc.Key = "company"
)

Tax Identity Type

View Source
const (
	TaxIdentityPatternPerson  = `^([A-ZÑ&]{4})([0-9]{6})([A-Z0-9]{3})$`
	TaxIdentityPatternCompany = `^([A-ZÑ&]{3})([0-9]{6})([A-Z0-9]{3})$`
)

Tax Identity Patterns

View Source
const (
	StampProviderSATUUID cbc.Key = "sat-uuid" // a.k.a. Folio Fiscal
)

SAT official codes to include in stamps.

View Source
const (
	TaxIdentityCodeForeign cbc.Code = "XEXX010101000"
)

Constants used to specific tax identity codes.

View Source
const (
	TaxRateExempt cbc.Key = "exempt"
)

Tax rates specific to Mexico.

Variables

View Source
var (
	TaxIdentityRegexpPerson  = regexp.MustCompile(TaxIdentityPatternPerson)
	TaxIdentityRegexpCompany = regexp.MustCompile(TaxIdentityPatternCompany)
)

Tax Identity Regexp

Functions

func Calculate

func Calculate(doc interface{}) error

Calculate performs regime specific calculations.

func DetermineTaxCodeType

func DetermineTaxCodeType(code cbc.Code) cbc.Key

DetermineTaxCodeType determines the type of tax code or provides an empty key if it looks invalid.

func New

func New() *tax.Regime

New provides the tax region definition

func Validate

func Validate(doc interface{}) error

Validate validates a document against the tax regime.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL