Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Addenda Mabe in MX regime #219

wants to merge 1 commit into from

Conversation

cavalle
Copy link
Contributor

@cavalle cavalle commented Nov 21, 2023

@@ -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"`
Copy link
Contributor Author

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:

image

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!

Copy link
Contributor Author

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)
Copy link
Contributor Author

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 {
Copy link
Contributor Author

@cavalle cavalle Nov 21, 2023

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.

@cavalle cavalle marked this pull request as ready for review November 21, 2023 11:53
@cavalle cavalle requested a review from samlown November 21, 2023 11:53
Copy link
Collaborator

@samlown samlown left a 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.

Base automatically changed from mx-retentions to main November 21, 2023 14:54
@cavalle
Copy link
Contributor Author

cavalle commented Nov 22, 2023

We decided to keep MX addendas out of GOBL. It won't be easy to scale to potentially hundreds or thousand of potential addendas.

@cavalle cavalle closed this Nov 22, 2023
@samlown samlown deleted the addenda-mabe branch July 24, 2024 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants