Skip to content

Commit

Permalink
comercio exterior 20; limites importe dr traslado
Browse files Browse the repository at this point in the history
  • Loading branch information
jtorz committed Mar 22, 2024
1 parent b8db8f0 commit 6c17a2b
Show file tree
Hide file tree
Showing 12 changed files with 1,086 additions and 1,082 deletions.
976 changes: 488 additions & 488 deletions cfdi40/cfdi40.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cfdi40/cfdi40_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ func encodeComplemento(enc *encoder.Encoder, c *Comprobante) {
c.Complemento.Pagos20.MarshalComplemento(enc)
}

if c.Complemento.CCE11 != nil {
c.Complemento.CCE11.MarshalComplemento(enc)
if c.Complemento.CCE20 != nil {
c.Complemento.CCE20.MarshalComplemento(enc)
}

if c.Complemento.TFD11 != nil {
Expand Down
8 changes: 4 additions & 4 deletions cfdi40/cfdi40_ns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/veyronifs/cfdi-go/complemento/cartaporte20"
"github.com/veyronifs/cfdi-go/complemento/comext11"
"github.com/veyronifs/cfdi-go/complemento/comext20"
"github.com/veyronifs/cfdi-go/complemento/pagos20"
"github.com/veyronifs/cfdi-go/complemento/tfd11"
)
Expand Down Expand Up @@ -49,7 +49,7 @@ func TestNamespaces(t *testing.T) {
Complemento: &Complemento{
CartaPorte20: &cartaporte20.CartaPorte20{},
Pagos20: &pagos20.Pagos{},
CCE11: &comext11.ComercioExterior{},
CCE20: &comext20.ComercioExterior{},
TFD11: &tfd11.TimbreFiscalDigital{},
},
},
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestNamespaces(t *testing.T) {
name: "cce11",
c: &Comprobante{
Complemento: &Complemento{
CCE11: &comext11.ComercioExterior{},
CCE20: &comext20.ComercioExterior{},
},
},
expectedNS: map[string]string{
Expand All @@ -129,7 +129,7 @@ func TestNamespaces(t *testing.T) {
c: &Comprobante{
Complemento: &Complemento{
CartaPorte20: &cartaporte20.CartaPorte20{},
CCE11: &comext11.ComercioExterior{},
CCE20: &comext20.ComercioExterior{},
},
},
expectedNS: map[string]string{
Expand Down
254 changes: 126 additions & 128 deletions cfdi40/tests/comext11_test.go
Original file line number Diff line number Diff line change
@@ -1,128 +1,126 @@
package tests_test

import (
"testing"

"github.com/shopspring/decimal"
"github.com/veyronifs/cfdi-go/cfdi40"
"github.com/veyronifs/cfdi-go/complemento/comext11"
"github.com/veyronifs/cfdi-go/types"
)

func TestComext11TipoI(t *testing.T) {
comext := &cfdi40.Comprobante{
Version: cfdi40.Version,
Exportacion: types.Exportacion02,
Serie: "B",
Folio: "2921",
Fecha: types.NewFechaHNow(),
FormaPago: "99",
CondicionesDePago: "A 45 dias",
SubTotal: decimal.NewFromFloat(3000.00),
Descuento: decimal.NewFromFloat(0.00),
Moneda: types.MonedaUSD,
TipoCambio: decimal.NewFromFloat(20.300200),
Total: decimal.NewFromFloat(3000.00),
TipoDeComprobante: types.ComprobanteI,
MetodoPago: types.MetodoPagoPPD,
LugarExpedicion: "14210",
Emisor: &cfdi40.Emisor{
Rfc: "IXS7607092R5",
Nombre: "INTERNACIONAL XIMBO Y SABORES",
RegimenFiscal: "601",
},
Receptor: &cfdi40.Receptor{
Rfc: "XEXX010101000",
Nombre: "GALDISA, USA INC. TAX ID: 36-4812096",
DomicilioFiscalReceptor: "14210",
RegimenFiscalReceptor: "616",
ResidenciaFiscal: "USA",
NumRegIdTrib: "364812096",
UsoCFDI: types.UsoCFDIS01,
},
Conceptos: cfdi40.Conceptos{
{
ClaveProdServ: "50405500",
NoIdentificacion: "1A2RNHG2A",
ObjetoImp: types.ObjetoImp02,
Cantidad: decimal.NewFromFloat(1.00),
ClaveUnidad: types.UnidadKilogramo,
ValorUnitario: decimal.NewFromFloat(3000.00),
Unidad: "kg",
Descripcion: "CACAHUATE RUNNER HIGH OLEIC 38/42",
Importe: decimal.NewFromFloat(3000.00),
Descuento: decimal.NewFromFloat(0.00),
Impuestos: &cfdi40.ConceptoImpuestos{
Traslados: cfdi40.ConceptoImpuestosTraslados{
{
Importe: decimal.NewFromFloat(0.00),
TasaOCuota: decimal.NewFromFloat(0.000000),
TipoFactor: types.TipoFactorTasa,
Impuesto: types.ImpuestoIVA,
Base: decimal.NewFromFloat(3000.00),
},
},
},
},
},
Impuestos: &cfdi40.Impuestos{
TotalImpuestosTrasladados: decimal.NewFromFloat(0.00),
Traslados: cfdi40.ImpuestosTraslados{
{
TasaOCuota: decimal.NewFromFloat(0.000000),
Importe: decimal.NewFromFloat(0.000000),
TipoFactor: types.TipoFactorTasa,
Impuesto: types.ImpuestoIVA,
Base: decimal.NewFromFloat(3000.00),
},
},
},
Complemento: &cfdi40.Complemento{
CCE11: &comext11.ComercioExterior{
Version: "1.1",
TotalUSD: decimal.NewFromFloat(3000.00),
TipoCambioUSD: decimal.NewFromFloat(20.300200),
Subdivision: 0,
Incoterm: "FOB",
CertificadoOrigen: 0,
ClaveDePedimento: "A1",
TipoOperacion: "2",
Emisor: &comext11.Emisor{
Domicilio: &comext11.Domicilio{
Calle: "Pico de Verapaz",
NumeroExterior: "449-A",
Colonia: "2085",
Municipio: "012",
Estado: "DIF",
Pais: "MEX",
CodigoPostal: "14210",
},
},
Receptor: &comext11.Receptor{
NumRegIdTrib: "364812096",
Domicilio: &comext11.Domicilio{
Calle: "3455 POLLOK DR",
NumeroExterior: "3455",
Colonia: ".",
Municipio: ".",
Estado: "TX",
Pais: "USA",
CodigoPostal: "14210",
Localidad: "LAREDO, TX",
},
},
Mercancias: comext11.Mercancias{
{
NoIdentificacion: "1A2RNHG2A",
ValorDolares: decimal.NewFromFloat(3000.00),
CantidadAduana: decimal.NewFromFloat(1.0),
ValorUnitarioAduana: decimal.NewFromFloat(3000.0),
UnidadAduana: "01",
FraccionArancelaria: "1202420100",
},
},
},
},
}
testTimbrar(t, comext)
}
package tests_test

import (
"testing"

"github.com/shopspring/decimal"
"github.com/veyronifs/cfdi-go/cfdi40"
"github.com/veyronifs/cfdi-go/complemento/comext20"
"github.com/veyronifs/cfdi-go/types"
)

func TestComext11TipoI(t *testing.T) {
comext := &cfdi40.Comprobante{
Version: cfdi40.Version,
Exportacion: types.Exportacion02,
Serie: "B",
Folio: "2921",
Fecha: types.NewFechaHNow(),
FormaPago: "99",
CondicionesDePago: "A 45 dias",
SubTotal: decimal.NewFromFloat(3000.00),
Descuento: decimal.NewFromFloat(0.00),
Moneda: types.MonedaUSD,
TipoCambio: decimal.NewFromFloat(20.300200),
Total: decimal.NewFromFloat(3000.00),
TipoDeComprobante: types.ComprobanteI,
MetodoPago: types.MetodoPagoPPD,
LugarExpedicion: "14210",
Emisor: &cfdi40.Emisor{
Rfc: "IXS7607092R5",
Nombre: "INTERNACIONAL XIMBO Y SABORES",
RegimenFiscal: "601",
},
Receptor: &cfdi40.Receptor{
Rfc: "XEXX010101000",
Nombre: "GALDISA, USA INC. TAX ID: 36-4812096",
DomicilioFiscalReceptor: "14210",
RegimenFiscalReceptor: "616",
ResidenciaFiscal: "USA",
NumRegIdTrib: "364812096",
UsoCFDI: types.UsoCFDIS01,
},
Conceptos: cfdi40.Conceptos{
{
ClaveProdServ: "50405500",
NoIdentificacion: "1A2RNHG2A",
ObjetoImp: types.ObjetoImp02,
Cantidad: decimal.NewFromFloat(1.00),
ClaveUnidad: types.UnidadKilogramo,
ValorUnitario: decimal.NewFromFloat(3000.00),
Unidad: "kg",
Descripcion: "CACAHUATE RUNNER HIGH OLEIC 38/42",
Importe: decimal.NewFromFloat(3000.00),
Descuento: decimal.NewFromFloat(0.00),
Impuestos: &cfdi40.ConceptoImpuestos{
Traslados: cfdi40.ConceptoImpuestosTraslados{
{
Importe: decimal.NewFromFloat(0.00),
TasaOCuota: decimal.NewFromFloat(0.000000),
TipoFactor: types.TipoFactorTasa,
Impuesto: types.ImpuestoIVA,
Base: decimal.NewFromFloat(3000.00),
},
},
},
},
},
Impuestos: &cfdi40.Impuestos{
TotalImpuestosTrasladados: decimal.NewFromFloat(0.00),
Traslados: cfdi40.ImpuestosTraslados{
{
TasaOCuota: decimal.NewFromFloat(0.000000),
Importe: decimal.NewFromFloat(0.000000),
TipoFactor: types.TipoFactorTasa,
Impuesto: types.ImpuestoIVA,
Base: decimal.NewFromFloat(3000.00),
},
},
},
Complemento: &cfdi40.Complemento{
CCE20: &comext20.ComercioExterior{
Version: "1.1",
TotalUSD: decimal.NewFromFloat(3000.00),
TipoCambioUSD: decimal.NewFromFloat(20.300200),
Incoterm: "FOB",
CertificadoOrigen: 0,
ClaveDePedimento: "A1",
Emisor: &comext20.Emisor{
Domicilio: &comext20.Domicilio{
Calle: "Pico de Verapaz",
NumeroExterior: "449-A",
Colonia: "2085",
Municipio: "012",
Estado: "DIF",
Pais: "MEX",
CodigoPostal: "14210",
},
},
Receptor: &comext20.Receptor{
NumRegIdTrib: "364812096",
Domicilio: &comext20.Domicilio{
Calle: "3455 POLLOK DR",
NumeroExterior: "3455",
Colonia: ".",
Municipio: ".",
Estado: "TX",
Pais: "USA",
CodigoPostal: "14210",
Localidad: "LAREDO, TX",
},
},
Mercancias: comext20.Mercancias{
{
NoIdentificacion: "1A2RNHG2A",
ValorDolares: decimal.NewFromFloat(3000.00),
CantidadAduana: decimal.NewFromFloat(1.0),
ValorUnitarioAduana: decimal.NewFromFloat(3000.0),
UnidadAduana: "01",
FraccionArancelaria: "1202420100",
},
},
},
},
}
testTimbrar(t, comext)
}
2 changes: 0 additions & 2 deletions complemento/comext20/comext20.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ type ComercioExterior struct {
Mercancias Mercancias `xml:"Mercancias,omitempty"`
Version string `xml:"Version,attr"`
MotivoTraslado string `xml:"MotivoTraslado,attr,omitempty"`
TipoOperacion string `xml:"TipoOperacion,attr"`
ClaveDePedimento string `xml:"ClaveDePedimento,attr,omitempty"`
CertificadoOrigen int `xml:"CertificadoOrigen,attr,omitempty"`
NumCertificadoOrigen string `xml:"NumCertificadoOrigen,attr,omitempty"`
NumeroExportadorConfiable string `xml:"NumeroExportadorConfiable,attr,omitempty"`
Incoterm string `xml:"Incoterm,attr,omitempty"`
Subdivision int `xml:"Subdivision,attr,omitempty"`
Observaciones string `xml:"Observaciones,attr,omitempty"`
TipoCambioUSD decimal.Decimal `xml:"TipoCambioUSD,attr,omitempty"`
TotalUSD decimal.Decimal `xml:"TotalUSD,attr,omitempty"`
Expand Down
4 changes: 1 addition & 3 deletions complemento/comext20/comext20_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func CompareEqual(v1, v2 *ComercioExterior) error {
}

func Compare(diffs *compare.Diffs, v1, v2 *ComercioExterior) {
path := "TimbreFiscalDigital11"
path := "ComercioExterior20"
if compare.Nil(diffs, v1, v2, path) {
return
} else if v1 == nil || v2 == nil {
Expand All @@ -22,13 +22,11 @@ func Compare(diffs *compare.Diffs, v1, v2 *ComercioExterior) {

compare.Comparable(diffs, v1.Version, v2.Version, path+".Version")
compare.Comparable(diffs, v1.MotivoTraslado, v2.MotivoTraslado, path+".MotivoTraslado")
compare.Comparable(diffs, v1.TipoOperacion, v2.TipoOperacion, path+".TipoOperacion")
compare.Comparable(diffs, v1.ClaveDePedimento, v2.ClaveDePedimento, path+".ClaveDePedimento")
compare.Comparable(diffs, v1.CertificadoOrigen, v2.CertificadoOrigen, path+".CertificadoOrigen")
compare.Comparable(diffs, v1.NumCertificadoOrigen, v2.NumCertificadoOrigen, path+".NumCertificadoOrigen")
compare.Comparable(diffs, v1.NumeroExportadorConfiable, v2.NumeroExportadorConfiable, path+".NumeroExportadorConfiable")
compare.Comparable(diffs, v1.Incoterm, v2.Incoterm, path+".Incoterm")
compare.Comparable(diffs, v1.Subdivision, v2.Subdivision, path+".Subdivision")
compare.Comparable(diffs, v1.Observaciones, v2.Observaciones, path+".Observaciones")
compare.Decimal(diffs, v1.TipoCambioUSD, v2.TipoCambioUSD, path+".TipoCambioUSD")
compare.Decimal(diffs, v1.TotalUSD, v2.TotalUSD, path+".TotalUSD")
Expand Down
Loading

0 comments on commit 6c17a2b

Please sign in to comment.