Skip to content

Commit

Permalink
Merge pull request #23 from invopop/payment-means
Browse files Browse the repository at this point in the history
Update how `FormaPago` and `MetodoPago` are set
  • Loading branch information
cavalle authored Jan 16, 2024
2 parents 01e0242 + 856485e commit f9d1e4e
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 45 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: "1.20.4"
id: go

- name: Check out code
uses: actions/checkout@v3

Expand All @@ -23,6 +29,6 @@ jobs:
password: ${{ secrets.GO_MOD_PASS }}

- name: Lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.51
26 changes: 24 additions & 2 deletions cfdi.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/invopop/gobl/cal"
"github.com/invopop/gobl/cbc"
"github.com/invopop/gobl/num"
"github.com/invopop/gobl/pay"
"github.com/invopop/gobl/regimes/mx"
"github.com/invopop/gobl/schema"
"github.com/invopop/gobl/tax"
Expand All @@ -33,6 +34,7 @@ const (
ExportacionNoAplica = "01"
MetodoPagoUnaExhibicion = "PUE"
MetodoPagoParcialidades = "PPD"
FormaPagoPorDefinir = "99"
ObjetoImpSi = "02"
ImpuestoIVA = "002"
TipoFactorTasa = "Tasa"
Expand Down Expand Up @@ -198,20 +200,24 @@ func lookupTipoDeComprobante(inv *bill.Invoice) string {
}

func metodoPago(inv *bill.Invoice) string {
if inv.Totals.Due != nil && inv.Totals.Due.IsZero() {
if isPrepaid(inv) {
return MetodoPagoUnaExhibicion
}

return MetodoPagoParcialidades
}

func formaPago(inv *bill.Invoice) string {
if !isPrepaid(inv) {
return FormaPagoPorDefinir
}

r := inv.TaxRegime()
if r == nil {
return ""
}

keyDef := findKeyDef(r.PaymentMeansKeys, inv.Payment.Instructions.Key)
keyDef := findKeyDef(r.PaymentMeansKeys, largestAdvance(inv).Key)
if keyDef == nil {
return ""
}
Expand All @@ -220,6 +226,22 @@ func formaPago(inv *bill.Invoice) string {
return code.String()
}

func isPrepaid(inv *bill.Invoice) bool {
return inv.Totals.Due != nil && inv.Totals.Due.IsZero()
}

func largestAdvance(inv *bill.Invoice) *pay.Advance {
la := inv.Payment.Advances[0]

for _, a := range inv.Payment.Advances {
if a.Amount.Compare(la.Amount) == 1 {
la = a
}
}

return la
}

func findKeyDef(keyDefs []*tax.KeyDefinition, key cbc.Key) *tax.KeyDefinition {
for _, keyDef := range keyDefs {
if keyDef.Key == key {
Expand Down
28 changes: 15 additions & 13 deletions cfdi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/invopop/gobl.cfdi/test"
"github.com/invopop/gobl/num"
"github.com/invopop/gobl/pay"
"github.com/invopop/gobl/regimes/mx"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -37,33 +38,34 @@ func TestComprobanteIngreso(t *testing.T) {
assert.Nil(t, doc.Complemento)
})

t.Run("should return the proper MetodoPago", func(t *testing.T) {
t.Run("should return the proper MetodoPago and FormaPago", func(t *testing.T) {
inv, _ := test.LoadTestInvoice("invoice.json")

// No advances
inv.Payment.Advances = nil
doc, _ := test.GenerateCFDIFrom(inv)
assert.Equal(t, "PPD", doc.MetodoPago)
assert.Equal(t, "99", doc.FormaPago)

// Partial settlement
inv.Payment.Advances = []*pay.Advance{
{
Amount: inv.Totals.Payable.Divide(num.MakeAmount(2, 0)),
Description: "Partial settlement",
},
}
inv.Payment.Advances = append(inv.Payment.Advances, &pay.Advance{
Percent: num.NewPercentage(40, 2),
Description: "First partial settlement",
Key: pay.MeansKeyCash,
})
doc, _ = test.GenerateCFDIFrom(inv)
assert.Equal(t, "PPD", doc.MetodoPago)
assert.Equal(t, "99", doc.FormaPago)

// Full settlement
inv.Payment.Advances = []*pay.Advance{
{
Amount: inv.Totals.Payable,
Description: "Full settlement",
},
}
inv.Payment.Advances = append(inv.Payment.Advances, &pay.Advance{
Percent: num.NewPercentage(60, 2),
Description: "Second partial settlement",
Key: pay.MeansKeyOnline.With(mx.MeansKeyWallet),
})
doc, _ = test.GenerateCFDIFrom(inv)
assert.Equal(t, "PUE", doc.MetodoPago)
assert.Equal(t, "05", doc.FormaPago)
})
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/invopop/gobl.cfdi
go 1.20

require (
github.com/invopop/gobl v0.64.0
github.com/invopop/gobl v0.65.2
github.com/joho/godotenv v1.5.1
github.com/magefile/mage v1.15.0
github.com/spf13/cobra v1.7.0
Expand Down Expand Up @@ -31,11 +31,11 @@ require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/invopop/jsonschema v0.12.0 // indirect
github.com/invopop/validation v0.3.0 // indirect
github.com/invopop/validation v0.3.0
github.com/lestrrat-go/libxml2 v0.0.0-20201123224832-e6d9de61b80d
github.com/square/go-jose/v3 v3.0.0-20200630053402-0a67ce9b0693 // indirect
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
)

// replace github.com/invopop/gobl => ../gobl
20 changes: 6 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/invopop/gobl v0.62.2-0.20231121145421-5d7dce0fd42d h1:tPpq1L2YH8IyGS452WCPGlbsbjw8u0okxmuhZ21wZi0=
github.com/invopop/gobl v0.62.2-0.20231121145421-5d7dce0fd42d/go.mod h1:sEngvTr2gAxexosO0rmQInVSL8C613TUPvBcFT4xMyM=
github.com/invopop/gobl v0.62.2-0.20231121175846-f10ffeb5a094 h1:jPOc6SxQap9sq01c3LodCQi0NdC5UpfwW0g2r8cQUYg=
github.com/invopop/gobl v0.62.2-0.20231121175846-f10ffeb5a094/go.mod h1:sEngvTr2gAxexosO0rmQInVSL8C613TUPvBcFT4xMyM=
github.com/invopop/gobl v0.62.2-0.20231122224337-f193b3066d06 h1:QNX7G4qEmC+KeNjZD1feo6wxCAngu1vLugQFZpFuZd0=
github.com/invopop/gobl v0.62.2-0.20231122224337-f193b3066d06/go.mod h1:sEngvTr2gAxexosO0rmQInVSL8C613TUPvBcFT4xMyM=
github.com/invopop/gobl v0.63.0 h1:eH75trQhOtCVyp2bK+ESE1AJZ9TwBXLdBsIOAfagts4=
github.com/invopop/gobl v0.63.0/go.mod h1:sEngvTr2gAxexosO0rmQInVSL8C613TUPvBcFT4xMyM=
github.com/invopop/gobl v0.64.0 h1:eaSLjGyTKRSHGMfN6tJyc1Xh2j6oqaJjnccXv/h2tfI=
github.com/invopop/gobl v0.64.0/go.mod h1:sEngvTr2gAxexosO0rmQInVSL8C613TUPvBcFT4xMyM=
github.com/invopop/gobl v0.65.2 h1:MmbnKz2hhbeoFKtqyDh7fUPghb2btXpoAYi1bBtbtrQ=
github.com/invopop/gobl v0.65.2/go.mod h1:Jau+ajdfUCBPVH9VMor6aeYq3S9o7HuSNm07QxxxomE=
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=
github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
github.com/invopop/validation v0.3.0 h1:o260kbjXzoBO/ypXDSSrCLL7SxEFUXBsX09YTE9AxZw=
Expand Down Expand Up @@ -82,15 +74,15 @@ gitlab.com/flimzy/testy v0.12.4 h1:J2plNCG5d9FWfik30yOZrajcPrWbiDHrk0qw1nMstNU=
gitlab.com/flimzy/testy v0.12.4/go.mod h1:9wPR98kErJw1lrq/aIJ8UZ6A0Dn7CHU0T6Qx4b2FiyQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 1 addition & 1 deletion internal/lines.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ClaveUnidad(line *bill.Line) cbc.Code {
}

// ClaveProdServ determines the line's Product-Service code
func ClaveProdServ(line *bill.Line) cbc.Code {
func ClaveProdServ(line *bill.Line) cbc.KeyOrCode {
if line.Item == nil {
return ""
}
Expand Down
8 changes: 3 additions & 5 deletions test/data/invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "c4ed7c55-fef6-11ed-98ea-e6a7901137ed",
"dig": {
"alg": "sha256",
"val": "e9a3636402ea508b69819bf1b271af26bad73c564f35d813dc8d6b9e553b8849"
"val": "c965150884666e2bae569a17ebe498417798681fd711cea3564d6504b6f7a029"
},
"draft": true
},
Expand Down Expand Up @@ -84,14 +84,12 @@
},
"advances": [
{
"key": "credit-transfer",
"desc": "Top-up payment",
"percent": "100%",
"amount": "190.86"
}
],
"instructions": {
"key": "credit-transfer"
}
]
},
"totals": {
"sum": "200.20",
Expand Down
2 changes: 1 addition & 1 deletion test/data/out/addenda-mabe.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" TipoDeComprobante="I" Serie="LMC" Folio="0010" Fecha="2023-05-29T00:00:00" LugarExpedicion="26015" SubTotal="200.00" Descuento="20.00" Total="171.60" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="03" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" TipoDeComprobante="I" Serie="LMC" Folio="0010" Fecha="2023-05-29T00:00:00" LugarExpedicion="26015" SubTotal="200.00" Descuento="20.00" Total="171.60" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="99" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Emisor Rfc="EKU9003173C9" Nombre="ESCUELA KEMPER URGATE" RegimenFiscal="601"></cfdi:Emisor>
<cfdi:Receptor Rfc="URE180429TM6" Nombre="UNIVERSIDAD ROBOTICA ESPAÑOLA" DomicilioFiscalReceptor="65000" RegimenFiscalReceptor="601" UsoCFDI="G01"></cfdi:Receptor>
<cfdi:Conceptos>
Expand Down
2 changes: 1 addition & 1 deletion test/data/out/bare-minimum-addenda-mabe.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" TipoDeComprobante="I" Serie="LMC" Folio="0010" Fecha="2023-05-29T00:00:00" LugarExpedicion="26015" SubTotal="200.00" Total="232.00" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="03" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" TipoDeComprobante="I" Serie="LMC" Folio="0010" Fecha="2023-05-29T00:00:00" LugarExpedicion="26015" SubTotal="200.00" Total="232.00" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="99" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Emisor Rfc="EKU9003173C9" Nombre="ESCUELA KEMPER URGATE" RegimenFiscal="601"></cfdi:Emisor>
<cfdi:Receptor Rfc="URE180429TM6" Nombre="UNIVERSIDAD ROBOTICA ESPAÑOLA" DomicilioFiscalReceptor="65000" RegimenFiscalReceptor="601" UsoCFDI="G01"></cfdi:Receptor>
<cfdi:Conceptos>
Expand Down
2 changes: 1 addition & 1 deletion test/data/out/bare-minimum-invoice.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" TipoDeComprobante="I" Serie="LMC" Folio="0010" Fecha="2023-05-29T00:00:00" LugarExpedicion="26015" SubTotal="200.00" Total="232.00" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="03" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" TipoDeComprobante="I" Serie="LMC" Folio="0010" Fecha="2023-05-29T00:00:00" LugarExpedicion="26015" SubTotal="200.00" Total="232.00" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="99" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Emisor Rfc="EKU9003173C9" Nombre="ESCUELA KEMPER URGATE" RegimenFiscal="601"></cfdi:Emisor>
<cfdi:Receptor Rfc="URE180429TM6" Nombre="UNIVERSIDAD ROBOTICA ESPAÑOLA" DomicilioFiscalReceptor="65000" RegimenFiscalReceptor="601" UsoCFDI="G01"></cfdi:Receptor>
<cfdi:Conceptos>
Expand Down
2 changes: 1 addition & 1 deletion test/data/out/credit-note.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" TipoDeComprobante="E" Serie="CN" Folio="0003" Fecha="2023-07-26T00:00:00" LugarExpedicion="21000" SubTotal="1.77" Total="1.77" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="05" CondicionesDePago="Condiciones de pago" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" TipoDeComprobante="E" Serie="CN" Folio="0003" Fecha="2023-07-26T00:00:00" LugarExpedicion="21000" SubTotal="1.77" Total="1.77" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="99" CondicionesDePago="Condiciones de pago" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:CfdiRelacionados TipoRelacion="01">
<cfdi:CfdiRelacionado UUID="1fac4464-1111-0000-1111-cd37179db12e"></cfdi:CfdiRelacionado>
</cfdi:CfdiRelacionados>
Expand Down
2 changes: 1 addition & 1 deletion test/data/out/food-vouchers.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:valesdedespensa="http://www.sat.gob.mx/valesdedespensa" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd http://www.sat.gob.mx/valesdedespensa http://www.sat.gob.mx/sitio_internet/cfd/valesdedespensa/valesdedespensa.xsd" Version="4.0" TipoDeComprobante="I" Serie="TEST" Folio="00002" Fecha="2023-07-10T00:00:00" LugarExpedicion="21000" SubTotal="10.00" Total="11.60" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="05" CondicionesDePago="Condiciones de pago" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:valesdedespensa="http://www.sat.gob.mx/valesdedespensa" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd http://www.sat.gob.mx/valesdedespensa http://www.sat.gob.mx/sitio_internet/cfd/valesdedespensa/valesdedespensa.xsd" Version="4.0" TipoDeComprobante="I" Serie="TEST" Folio="00002" Fecha="2023-07-10T00:00:00" LugarExpedicion="21000" SubTotal="10.00" Total="11.60" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="99" CondicionesDePago="Condiciones de pago" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Emisor Rfc="EKU9003173C9" Nombre="ESCUELA KEMPER URGATE" RegimenFiscal="601"></cfdi:Emisor>
<cfdi:Receptor Rfc="URE180429TM6" Nombre="UNIVERSIDAD ROBOTICA ESPAÑOLA" DomicilioFiscalReceptor="86991" RegimenFiscalReceptor="601" UsoCFDI="G01"></cfdi:Receptor>
<cfdi:Conceptos>
Expand Down
2 changes: 1 addition & 1 deletion test/data/out/fuel-account-balance.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecc12="http://www.sat.gob.mx/EstadoDeCuentaCombustible12" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd http://www.sat.gob.mx/EstadoDeCuentaCombustible12 http://www.sat.gob.mx/sitio_internet/cfd/EstadoDeCuentaCombustible/ecc12.xsd" Version="4.0" TipoDeComprobante="I" Serie="TEST" Folio="00002" Fecha="2023-07-10T00:00:00" LugarExpedicion="21000" SubTotal="10.00" Total="11.60" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="05" CondicionesDePago="Condiciones de pago" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecc12="http://www.sat.gob.mx/EstadoDeCuentaCombustible12" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd http://www.sat.gob.mx/EstadoDeCuentaCombustible12 http://www.sat.gob.mx/sitio_internet/cfd/EstadoDeCuentaCombustible/ecc12.xsd" Version="4.0" TipoDeComprobante="I" Serie="TEST" Folio="00002" Fecha="2023-07-10T00:00:00" LugarExpedicion="21000" SubTotal="10.00" Total="11.60" Moneda="MXN" Exportacion="01" MetodoPago="PPD" FormaPago="99" CondicionesDePago="Condiciones de pago" Sello="" NoCertificado="00000000000000000000" Certificado="">
<cfdi:Emisor Rfc="EKU9003173C9" Nombre="ESCUELA KEMPER URGATE" RegimenFiscal="601"></cfdi:Emisor>
<cfdi:Receptor Rfc="URE180429TM6" Nombre="UNIVERSIDAD ROBOTICA ESPAÑOLA" DomicilioFiscalReceptor="86991" RegimenFiscalReceptor="601" UsoCFDI="G01"></cfdi:Receptor>
<cfdi:Conceptos>
Expand Down
4 changes: 4 additions & 0 deletions test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func LoadTestEnvelope(name string) (*gobl.Envelope, error) {

// GenerateCFDIFrom returns a CFDI Document from a GOBL Invoice
func GenerateCFDIFrom(inv *bill.Invoice) (*cfdi.Document, error) {
if err := inv.Calculate(); err != nil {
return nil, err
}

env, err := gobl.Envelop(inv)
if err != nil {
return nil, err
Expand Down

0 comments on commit f9d1e4e

Please sign in to comment.