feat(iedu): add typed IEDU complement helpers#104
Open
alejandrobalderas wants to merge 1 commit intoFacturAPI:mainfrom
Open
feat(iedu): add typed IEDU complement helpers#104alejandrobalderas wants to merge 1 commit intoFacturAPI:mainfrom
alejandrobalderas wants to merge 1 commit intoFacturAPI:mainfrom
Conversation
Adds typed support for the IEDU (Instituciones Educativas) complement that schools include on K-12 tuition CFDIs: - IeduComplementInput, IeduEducationLevel — typed input shape - buildIeduComplement(input) — returns the SAT-required XML fragment that goes into items[].complement on a tuition invoice - IEDU_NAMESPACE — constant to push into the invoice's top-level namespaces array Pure helpers — no changes to invoices.create() or any other resource method, so non-IEDU callers are completely unaffected. Users opt in by explicitly calling the helper and registering the namespace. The IEDU complement is what enables parents of K-12 students to claim the colegiaturas deduction on their annual ISR return (Decreto 26-Dic-2013). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
3fe622d to
41b7cac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds typed support for the IEDU (Instituciones Educativas) complement that schools include on K-12 tuition CFDIs, so callers no longer need to construct the SAT XML by hand.
The PR is intentionally scoped as pure helpers:
IeduComplementInputandIeduEducationLevel— typed input shapebuildIeduComplement(input)— returns the SAT-required<iedu:instEducativas .../>XML fragment that goes intoitems[].complementon a tuition invoiceIEDU_NAMESPACE— constant to push into the invoice's top-levelnamespacesarrayNo changes to
invoices.create()or any other resource method. Non-IEDU callers are completely unaffected; users opt in explicitly when they need IEDU.Why
The IEDU complement is what enables parents of K-12 students in Mexico to claim the Decreto de Deducción de Colegiaturas on their annual ISR return (Decreto 26-Dic-2013). Without it, parents lose the deduction (capped per nivel: ~$12,900–$24,500 MXN/year). It applies to Preescolar, Primaria, Secundaria, Profesional Técnico, and Bachillerato — university tuition is excluded.
The Facturapi REST API already accepts IEDU via the per-item
complementXML string + the top-levelnamespacesarray, but the SDK requires users to build the XML themselves. This PR provides typed helpers for that.Usage
What's new
src/types/complements.tsIeduComplementInput,IeduEducationLevelsrc/utils/iedu.tsbuildIeduComplement,IEDU_NAMESPACEsrc/index.tsbuildIeduComplementandIEDU_NAMESPACEREADME.mdtest/invoice.spec.tstest/node/iedu.node.test.tstest/web/iedu.web.test.tsBackward compatibility
Fully backward compatible. No existing methods or types were modified. The PR only adds new exports.
Testing
npm run lint— cleannpm run test:types(tsd) — cleannpm run test:node— 24/24 passing (15 existing + 9 new)npm run test:web— 10/10 passing (8 existing + 2 new)npm run build— succeeds, ESM 47.69 kB / CJS 40.50 kBNotes for review
IEDU_NAMESPACE.schema_locationmatches the form documented in the FacturAPI OpenAPI spec (http://www.sat.gob.mx/sitio_interet/cfd/iedu/iedu.xsd). Happy to switch to thesitio_internet(correctly spelled) form if preferred — the constant is exported so users can also override.IeduComplementInput.CURPuses uppercase to mirror the SAT XML attribute. Open to renaming tocurpif camelCase consistency is preferred SDK-wide.🤖 Generated with Claude Code