Skip to content

Commit

Permalink
Merge pull request #39 from invopop/drop-ext-key-post-code
Browse files Browse the repository at this point in the history
Drop support for `mx-cfdi-post-code`
  • Loading branch information
cavalle authored Dec 10, 2024
2 parents ab36c1d + 176211b commit 405bf76
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 66 deletions.
2 changes: 1 addition & 1 deletion addendas/mabe.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func newMabeEntrega(inv *bill.Invoice) *MabeEntrega {
e.Calle = addr.Street
e.NoExterior = addr.Number
e.NoInterior = MabeNotApplicable
e.CodigoPostal = addr.Code
e.CodigoPostal = addr.Code.String()
}

return e
Expand Down
4 changes: 0 additions & 4 deletions cfdi.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ func validateSupport(inv *bill.Invoice) error {
}
}

if len(inv.Outlays) > 0 {
errs["outlays"] = ErrNotSupported
}

// Deprecation pending...
if inv.HasTags(tax.TagSelfBilled) {
errs["self-billed"] = ErrNotSupported
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
toolchain go1.22.5

require (
github.com/invopop/gobl v0.203.0
github.com/invopop/gobl v0.206.1
github.com/joho/godotenv v1.5.1
github.com/magefile/mage v1.15.0
github.com/spf13/cobra v1.8.1
Expand All @@ -29,16 +29,16 @@ require (
)

require (
cloud.google.com/go v0.110.2
github.com/Masterminds/semver/v3 v3.2.1 // indirect
cloud.google.com/go v0.116.0
github.com/Masterminds/semver/v3 v3.3.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/invopop/jsonschema v0.12.0 // indirect
github.com/invopop/validation v0.7.0
github.com/invopop/validation v0.8.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.26.0 // indirect
golang.org/x/crypto v0.30.0 // indirect
)

// replace github.com/invopop/gobl => ../gobl
32 changes: 16 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cloud.google.com/go v0.110.2 h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA=
cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE=
cloud.google.com/go v0.116.0/go.mod h1:cEPSRWPzZEswwdr9BxE6ChEn01dWlTaF05LiC2Xs70U=
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
Expand All @@ -20,12 +20,12 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.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.203.0 h1:41aIW+gZfyVcP0G0kz+IX4w8AMSx9EgbnALpn0s9CzA=
github.com/invopop/gobl v0.203.0/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU=
github.com/invopop/gobl v0.206.1 h1:uWqMI56Rc1KQRWiUaiMylggfgRatcHz0T3QeBzdCTMY=
github.com/invopop/gobl v0.206.1/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU=
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.7.0 h1:NBPLqvYGmLZLQuk5jh0PbaBBetJW7f2VEk/BTWJkGBU=
github.com/invopop/validation v0.7.0/go.mod h1:nLLeXYPGwUNfdCdJo7/q3yaHO62LSx/3ri7JvgKR9vg=
github.com/invopop/validation v0.8.0 h1:e5hXHGnONHImgJdonIpNbctg1hlWy1ncaHoVIQ0JWuw=
github.com/invopop/validation v0.8.0/go.mod h1:nLLeXYPGwUNfdCdJo7/q3yaHO62LSx/3ri7JvgKR9vg=
github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso=
github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
Expand Down Expand Up @@ -76,18 +76,18 @@ gitlab.com/flimzy/testy v0.14.0 h1:2nZV4Wa1OSJb3rOKHh0GJqvvhtE03zT+sKnPCI0owfQ=
gitlab.com/flimzy/testy v0.14.0/go.mod h1:m3aGuwdXc+N3QgnH+2Ar2zf1yg0UxNdIaXKvC5SlfMk=
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.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
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.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
Expand Down
6 changes: 3 additions & 3 deletions parties.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func newReceptor(customer *org.Party, issuePlace string) *Receptor {
}
}

postcode := customer.Ext[cfdi.ExtKeyPostCode].String() // TODO: Drop support for ExtKeyPostCode
if postcode == "" && len(customer.Addresses) > 0 {
postcode = customer.Addresses[0].Code
var postcode string
if len(customer.Addresses) > 0 {
postcode = customer.Addresses[0].Code.String()
}

return &Receptor{
Expand Down
21 changes: 0 additions & 21 deletions parties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"testing"

"github.com/invopop/gobl.cfdi/test"
"github.com/invopop/gobl/addons/mx/cfdi"
"github.com/invopop/gobl/org"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -64,23 +62,4 @@ func TestReceptor(t *testing.T) {
assert.Equal(t, "9014514805", r.NumRegIdTrib)
assert.Equal(t, "COL", r.ResidenciaFiscal)
})

t.Run("should map DomicilioFiscal from customer post code", func(t *testing.T) {
inv, err := test.LoadTestInvoice("invoice-b2b-bare.json")
require.NoError(t, err)

delete(inv.Customer.Ext, cfdi.ExtKeyPostCode)
inv.Customer.Addresses = []*org.Address{{Code: "21000"}}

doc, err := test.GenerateCFDIFrom(inv)
require.NoError(t, err)

r := doc.Receptor

assert.Equal(t, "URE180429TM6", r.Rfc)
assert.Equal(t, "UNIVERSIDAD ROBOTICA ESPAÑOLA", r.Nombre)
assert.Equal(t, "21000", r.DomicilioFiscalReceptor)
assert.Equal(t, "601", r.RegimenFiscalReceptor)
assert.Equal(t, "G01", r.UsoCFDI)
})
}
8 changes: 6 additions & 2 deletions test/data/addenda-mabe-bare.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "01922d7f-7439-7933-91f0-913da04c5bd0",
"dig": {
"alg": "sha256",
"val": "07bef5b9ef29218054874e1fe09e6b94f3c18bbfd97d835c96d7684c4a57c30b"
"val": "be151648fa57afb1ab6df01aae16ddf3c64b1ee811bf308bd12bf1b641b96521"
}
},
"doc": {
Expand Down Expand Up @@ -47,9 +47,13 @@
"country": "MX",
"code": "URE180429TM6"
},
"addresses": [
{
"code": "65000"
}
],
"ext": {
"mx-cfdi-fiscal-regime": "601",
"mx-cfdi-post-code": "65000",
"mx-cfdi-use": "G01"
}
},
Expand Down
8 changes: 6 additions & 2 deletions test/data/addenda-mabe-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "01922d7f-7453-7c28-9a74-ac9d94b1e5c9",
"dig": {
"alg": "sha256",
"val": "955ec82928366a2b73748e6efc44bddf1c34f2d2f81e718b2a501546d4598c73"
"val": "034496c5f1cda9d25e1e4f38f7ea1ba4011a5d53fc2eef2d5f772d1cd9a928c2"
}
},
"doc": {
Expand Down Expand Up @@ -47,9 +47,13 @@
"country": "MX",
"code": "URE180429TM6"
},
"addresses": [
{
"code": "65000"
}
],
"ext": {
"mx-cfdi-fiscal-regime": "601",
"mx-cfdi-post-code": "65000",
"mx-cfdi-use": "G01"
}
},
Expand Down
8 changes: 6 additions & 2 deletions test/data/credit-note.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "01922d7f-7467-7840-88e7-d70a607a85bf",
"dig": {
"alg": "sha256",
"val": "dc0483e3d07d8b7a317a22cb5b2f31dbd20f320d11560683d0ae3e51d75d5674"
"val": "76792da4c23add3ac91f85438f70ba42dea5df7b351e06de88f29da02dd7b5c0"
}
},
"doc": {
Expand Down Expand Up @@ -55,9 +55,13 @@
"country": "MX",
"code": "URE180429TM6"
},
"addresses": [
{
"code": "86991"
}
],
"ext": {
"mx-cfdi-fiscal-regime": "601",
"mx-cfdi-post-code": "86991",
"mx-cfdi-use": "G03"
}
},
Expand Down
10 changes: 8 additions & 2 deletions test/data/food-vouchers.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "01922d7f-747d-702b-b7a9-261a7c0fc97d",
"dig": {
"alg": "sha256",
"val": "bb21712b8c1b97cd234826370a4c5b5bddc87b7e1bc003bd818cd95994020d7c"
"val": "aa93619acbfe907cc9206e261ed0a7db04be9a84b86805b38a3fd5ea52501a08"
}
},
"doc": {
Expand Down Expand Up @@ -41,9 +41,13 @@
"country": "MX",
"code": "URE180429TM6"
},
"addresses": [
{
"code": "86991"
}
],
"ext": {
"mx-cfdi-fiscal-regime": "601",
"mx-cfdi-post-code": "86991",
"mx-cfdi-use": "G01"
}
},
Expand Down Expand Up @@ -112,6 +116,7 @@
"total": "30.52",
"lines": [
{
"i": 1,
"e_wallet_id": "ABC1234",
"issue_date_time": "2022-07-19T10:20:30",
"employee": {
Expand All @@ -123,6 +128,7 @@
"amount": "10.12"
},
{
"i": 2,
"e_wallet_id": "BCD4321",
"issue_date_time": "2022-08-20T11:20:30",
"employee": {
Expand Down
10 changes: 8 additions & 2 deletions test/data/fuel-account-balance.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "01922d7f-748e-7ac6-a885-133ddca0eb29",
"dig": {
"alg": "sha256",
"val": "cd54fda67404318f15299978b2d450e05c0b4dd69b7618e4e307972373003f0d"
"val": "5b1eaa9bbf2acf0e7a5a66160184d90ef381a7d7d725b79320f6910b8ce3ba88"
}
},
"doc": {
Expand Down Expand Up @@ -41,9 +41,13 @@
"country": "MX",
"code": "URE180429TM6"
},
"addresses": [
{
"code": "86991"
}
],
"ext": {
"mx-cfdi-fiscal-regime": "601",
"mx-cfdi-post-code": "86991",
"mx-cfdi-use": "G01"
}
},
Expand Down Expand Up @@ -112,6 +116,7 @@
"total": "400.00",
"lines": [
{
"i": 1,
"e_wallet_id": "1234",
"purchase_date_time": "2022-07-19T10:20:30",
"vendor_tax_code": "RWT860605OF5",
Expand Down Expand Up @@ -139,6 +144,7 @@
]
},
{
"i": 2,
"e_wallet_id": "1234",
"purchase_date_time": "2022-08-19T10:20:30",
"vendor_tax_code": "DJV320816JT1",
Expand Down
8 changes: 6 additions & 2 deletions test/data/invoice-b2b-bare.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "01922d7f-749f-7dda-881c-9ad8dc87167a",
"dig": {
"alg": "sha256",
"val": "12437bc00851d113c0bdafebd26d58339091b194e608bd91284d72eda0c09df0"
"val": "f9231dd4b55d44cdb46b0159eaa9d08ec481f76e92d5fe3a7e0b417185390076"
}
},
"doc": {
Expand Down Expand Up @@ -41,9 +41,13 @@
"country": "MX",
"code": "URE180429TM6"
},
"addresses": [
{
"code": "65000"
}
],
"ext": {
"mx-cfdi-fiscal-regime": "601",
"mx-cfdi-post-code": "65000",
"mx-cfdi-use": "G01"
}
},
Expand Down
8 changes: 6 additions & 2 deletions test/data/invoice-b2b-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "01922d7f-74af-73f4-9cfa-675fedc70c03",
"dig": {
"alg": "sha256",
"val": "f4425b1183b192d5093dced4787201afe6d6d93711f058d80dd6ee5bfad58b8b"
"val": "14c160ddb0cf03d744445fedca48d548c41e88f2aa85afbf5e75e2986224f8c4"
}
},
"doc": {
Expand Down Expand Up @@ -41,9 +41,13 @@
"country": "MX",
"code": "URE180429TM6"
},
"addresses": [
{
"code": "65000"
}
],
"ext": {
"mx-cfdi-fiscal-regime": "601",
"mx-cfdi-post-code": "65000",
"mx-cfdi-use": "G01"
}
},
Expand Down
8 changes: 6 additions & 2 deletions test/data/invoice-multi-currency.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "01922d7f-74e9-727e-b21d-2f40440d9a64",
"dig": {
"alg": "sha256",
"val": "32da573d7772a5cdc6ca727de820073227f6f25b76999fabb668bec9db241b8f"
"val": "b3b87462fcad74e2b58bb9367ce1f0d821e5f22db92813252f0afa058efdf804"
}
},
"doc": {
Expand Down Expand Up @@ -48,9 +48,13 @@
"country": "MX",
"code": "URE180429TM6"
},
"addresses": [
{
"code": "65000"
}
],
"ext": {
"mx-cfdi-fiscal-regime": "601",
"mx-cfdi-post-code": "65000",
"mx-cfdi-use": "G01"
}
},
Expand Down

0 comments on commit 405bf76

Please sign in to comment.