-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addenda Mabe in MX regime #219
Conversation
cavalle
commented
Nov 21, 2023
•
edited
Loading
edited
- Adds extensions and validations necessary to generate "Addenda Mabe" in the MX regime
- Addenda Mabe generation implemented in Addenda Mabe generation gobl.cfdi#18
@@ -95,6 +95,9 @@ type Invoice struct { | |||
// Additional complementary objects that add relevant information to the invoice. | |||
Complements []*schema.Object `json:"complements,omitempty" jsonschema:"title=Complements"` | |||
|
|||
// Extension code map for any additional regime specific codes that may be required. | |||
Ext cbc.CodeMap `json:"ext,omitempty" jsonschema:"title=Ext"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a good place to store Mabe's reference1
and reference2
fields so I added this Ext codeMap at invoice level. The content of reference1
is a bit ambiguous, and changes depending on the case:
In the case of reference2
this is what the doc says: "Referencia adicional para uso futuro o bien "NA" o "0"".
Suggestions on a better place to put this data are welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the addenda-mabe.yaml
below to see it in context
|
||
// IsMabeSupplier returns true if the invoice is from a Mabe supplier. | ||
func IsMabeSupplier(inv *bill.Invoice) bool { | ||
return inv != nil && inv.Supplier != nil && inv.Supplier.Ext.Has(ExtKeyMabeProviderCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function encapsulates the criteria to decide whether a MX GOBL invoice will produce a Mabe Addendum: if the supplier provides it's Mabe Supplier code, GOBL will validate that all the data required to generate the Mabe Addendum is present and the CFDI library will generate and attach the addendum to the CFDI.
) | ||
} | ||
|
||
func (v *invoiceValidator) validItem(value interface{}) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was a bit tricky. We are already validating the Item in the MX regime standalone (see item.go
). However, for this new validation, I need to call to the IsMabeSupplier
function with the invoice as a parameter. In the Item standalone validation, naturally, we don't have access to invoice. That's why I implemented this particular validation as part of the invoice.
Feedback on how to do this differently more than welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this approach works, I'm not totally convinced on using the ext
properties this way. With 100+ different addendas, I just can't see this scaling effectively, especially not given that we want to be able to offer UIs that help users define the extensions.
The important thing here is to have the fields mapped out. So I'll have a quick look to see if I can propose another approach quickly.
We decided to keep MX addendas out of GOBL. It won't be easy to scale to potentially hundreds or thousand of potential addendas. |