UNPKG

@cfdi/xml

Version:

Libreria para crear y sellar xml cfdi V4.0

3 lines (2 loc) 22.7 kB
import t from"fs";import{cer as e,key as o}from"@cfdi/csd";import{Schema as n}from"@cfdi/xsd";import r from"os";import i from"path";import{Transform as a}from"@saxon-he/cli";import c from"xml-js";function s(t,e,o,n,r,i,a){try{var c=t[i](a),s=c.value}catch(t){return void o(t)}c.done?e(s):Promise.resolve(s).then(n,r)}function u(t){return function(){var e=this,o=arguments;return new Promise((function(n,r){var i=t.apply(e,o);function a(t){s(i,n,r,a,c,"next",t)}function c(t){s(i,n,r,a,c,"throw",t)}a(void 0)}))}}function f(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,p(n.key),n)}}function l(t,e,o){return e&&f(t.prototype,e),o&&f(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t}function h(){return(h=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)({}).hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t}).apply(null,arguments)}function m(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,function(t,e){(Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}(t,e)}function d(){d=function(){return e};var t,e={},o=Object.prototype,n=o.hasOwnProperty,r=Object.defineProperty||function(t,e,o){t[e]=o.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,o){return Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,o){return t[e]=o}}function f(t,e,o,n){var i=Object.create((e&&e.prototype instanceof g?e:g).prototype),a=new w(n||[]);return r(i,"_invoke",{value:I(t,o,a)}),i}function l(t,e,o){try{return{type:"normal",arg:t.call(e,o)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",m="executing",p="completed",v={};function g(){}function b(){}function _(){}var y={};u(y,a,(function(){return this}));var C=Object.getPrototypeOf,E=C&&C(C(L([])));E&&E!==o&&n.call(E,a)&&(y=E);var S=_.prototype=g.prototype=Object.create(y);function O(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function o(r,i,a,c){var s=l(t[r],t,i);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,a,c)}),(function(t){o("throw",t,a,c)})):e.resolve(f).then((function(t){u.value=t,a(u)}),(function(t){return o("throw",t,a,c)}))}c(s.arg)}var i;r(this,"_invoke",{value:function(t,n){function r(){return new e((function(e,r){o(t,n,e,r)}))}return i=i?i.then(r,r):r()}})}function I(e,o,n){var r=h;return function(i,a){if(r===m)throw Error("Generator is already running");if(r===p){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=R(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===h)throw r=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=m;var u=l(e,o,n);if("normal"===u.type){if(r=n.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=p,n.method="throw",n.arg=u.arg)}}}function R(e,o){var n=o.method,r=e.iterator[n];if(r===t)return o.delegate=null,"throw"===n&&e.iterator.return&&(o.method="return",o.arg=t,R(e,o),"throw"===o.method)||"return"!==n&&(o.method="throw",o.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=l(r,e.iterator,o.arg);if("throw"===i.type)return o.method="throw",o.arg=i.arg,o.delegate=null,v;var a=i.arg;return a?a.done?(o[e.resultName]=a.value,o.next=e.nextLoc,"return"!==o.method&&(o.method="next",o.arg=t),o.delegate=null,v):a:(o.method="throw",o.arg=new TypeError("iterator result is not an object"),o.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function w(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var o=e[a];if(o)return o.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function o(){for(;++r<e.length;)if(n.call(e,r))return o.value=e[r],o.done=!1,o;return o.value=t,o.done=!0,o};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return b.prototype=_,r(S,"constructor",{value:_,configurable:!0}),r(_,"constructor",{value:b,configurable:!0}),b.displayName=u(_,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,u(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},O(x.prototype),u(x.prototype,c,(function(){return this})),e.AsyncIterator=x,e.async=function(t,o,n,r,i){void 0===i&&(i=Promise);var a=new x(f(t,o,n,r),i);return e.isGeneratorFunction(o)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(S),u(S,s,"Generator"),u(S,a,(function(){return this})),u(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),o=[];for(var n in e)o.push(n);return o.reverse(),function t(){for(;o.length;){var n=o.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=L,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var o in this)"t"===o.charAt(0)&&n.call(this,o)&&!isNaN(+o.slice(1))&&(this[o]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var o=this;function r(n,r){return c.type="throw",c.arg=e,o.next=n,r&&(o.method="next",o.arg=t),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var o=this.tryEntries.length-1;o>=0;--o){var r=this.tryEntries[o];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.finallyLoc===t)return this.complete(o.completion,o.afterLoc),N(o),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc===t){var n=o.completion;if("throw"===n.type){var r=n.arg;N(o)}return r}}throw Error("illegal catch attempt")},delegateYield:function(e,o,n){return this.delegate={iterator:L(e),resultName:o,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function p(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var n=o.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}var v=function(t,e){var o={};return e.forEach((function(e){e in t&&(o[e]=t[e])})),Object.keys(t).forEach((function(e){e in o||(o[e]=t[e])})),o},g=function(){function t(t){this.xml={_declaration:{_attributes:{version:"1.0",encoding:"utf-8"}}},this.tc="cfdi:Comprobante",this.version="4.0",this.XMLSchema="http://www.w3.org/2001/XMLSchema-instance",this.cfd="http://www.sat.gob.mx/cfd/4",this.locations=["http://www.sat.gob.mx/cfd/4","http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd"],this.schema=n.of();var e=t||{debug:!1},o=e.schema;this.schema.setConfig({debug:e.debug,path:null==o?void 0:o.path}),this.restartCfdi()}var e=t.prototype;return e.xmlns=function(t){for(var e in t.xsi||this.addXmlns("xsi",this.XMLSchema),t.cfdi||this.addXmlns("cfdi",this.cfd),t)this.addXmlns(e,t[e])},e.addXmlns=function(t,e){this.xml["cfdi:Comprobante"]._attributes["xmlns:"+t]=e},e.addSchemaLocation=function(t){this.xml["cfdi:Comprobante"]._attributes["xsi:schemaLocation"]||(this.xml["cfdi:Comprobante"]._attributes["xsi:schemaLocation"]="");var e=(this.xml["cfdi:Comprobante"]._attributes["xsi:schemaLocation"]||"").split(" "),o=function(t){return t.join(" ")}(Array.from(new Set([].concat(e,t).filter(Boolean))));this.xml["cfdi:Comprobante"]._attributes["xsi:schemaLocation"]=o},e.setAttributesXml=function(t){void 0===t&&(t={});var e=t.version,o=t.encoding;this.xml._declaration._attributes={version:void 0===e?"1.0":e,encoding:void 0===o?"utf-8":o}},e.setAttributes=function(t){void 0===t&&(t={});var e=t||{},o=e.schemaLocation;this.xmlns(e.xmlns||{}),this.addSchemaLocation(o||this.locations)},e.comprobante=function(t){var e=v(h({},this.xml["cfdi:Comprobante"]._attributes,{Version:this.version},t,{Sello:"",NoCertificado:"",Certificado:"",SubTotal:t.SubTotal,Descuento:t.Descuento,Total:t.Total}),["xsi:schemaLocation","Version","Serie","Folio","Fecha","Sello","FormaPago","NoCertificado","Certificado","CondicionesDePago","SubTotal","Descuento","Moneda","TipoCambio","Total","TipoDeComprobante","Exportacion","MetodoPago","LugarExpedicion","Confirmacion","xmlns:cfdi","xmlns:xsi"]);this.xml["cfdi:Comprobante"]._attributes=e,this.schema.cfdi.comprobante.validateInit(this.xml["cfdi:Comprobante"]._attributes)},e.informacionGlobal=function(t){this.schema.cfdi.informacionGlobal.validate(t),this.xml["cfdi:Comprobante"]=h({"cfdi:InformacionGlobal":{_attributes:t}},this.xml["cfdi:Comprobante"])},e.relacionados=function(t){this.xml["cfdi:Comprobante"]=h({"cfdi:CfdiRelacionados":t.getRelation()},this.xml["cfdi:Comprobante"])},e.emisor=function(t){this.xml["cfdi:Comprobante"]["cfdi:Emisor"]=t.emisor},e.receptor=function(t){this.xml["cfdi:Comprobante"]["cfdi:Receptor"]=t.receptor},e.concepto=function(t){if(t.isComplement()){var e=t.getComplementProperties();this.addXmlns(e.xmlnskey,e.xmlns),this.addSchemaLocation(e.schemaLocation)}this.xml["cfdi:Comprobante"]["cfdi:Conceptos"]||(this.xml["cfdi:Comprobante"]["cfdi:Conceptos"]={"cfdi:Concepto":[]}),this.xml["cfdi:Comprobante"]["cfdi:Conceptos"]["cfdi:Concepto"].push(t.getConcept())},e.impuesto=function(t){this.xml["cfdi:Comprobante"]["cfdi:Impuestos"]=t.impuesto},e.complemento=function(t){this.xml["cfdi:Comprobante"]["cfdi:Complemento"]||(this.xml["cfdi:Comprobante"]["cfdi:Complemento"]={});var e=t.getComplement();this.addXmlns(e.xmlnskey,e.xmlns),this.addSchemaLocation(e.schemaLocation),this.xml["cfdi:Comprobante"]["cfdi:Complemento"][e.key]=e.complement},e.setCertificado=function(t){t&&(this.xml["cfdi:Comprobante"]._attributes.Certificado=t)},e.setNoCertificado=function(t){t&&(this.xml["cfdi:Comprobante"]._attributes.NoCertificado=t)},e.setSello=function(t){t&&(this.xml["cfdi:Comprobante"]._attributes.Sello=t)},e.restartCfdi=function(){this.xml={_declaration:{_attributes:{version:"1.0",encoding:"utf-8"}}},this.xml["cfdi:Comprobante"]={_attributes:{},"cfdi:Emisor":{},"cfdi:Receptor":{}},this.setAttributes()},l(t,[{key:"xmlObject",get:function(){return this.xml}}])}(),b=function(){function e(){}return e.generateNameTemp=function(){return Date.now().toString()},e.readFileSync=function(e){return t.readFileSync(e,"utf8")},e.getTmpFullPath=function(t){return i.join(r.tmpdir(),t+".xml")},e}(),_=function(){function t(){}return t.info=function(t){for(var e,o=arguments.length,n=new Array(o>1?o-1:0),r=1;r<o;r++)n[r-1]=arguments[r];(e=console).log.apply(e,["INFO: "+t].concat(n))},t.error=function(t){for(var e,o=arguments.length,n=new Array(o>1?o-1:0),r=1;r<o;r++)n[r-1]=arguments[r];(e=console).error.apply(e,["ERROR: "+t].concat(n))},t.warn=function(t){for(var e,o=arguments.length,n=new Array(o>1?o-1:0),r=1;r<o;r++)n[r-1]=arguments[r];(e=console).warn.apply(e,["WARN: "+t].concat(n))},t}(),y=function(){function t(t){var e=t.message,o=t.code,n=t.details,r=t.name,i=t.method;this.method="",this.message=e,this.code=o,this.details=n,this.name=r||"XmlError",this.method=i||""}var e=t.prototype;return e.setName=function(t){t&&(this.name=t)},e.setMethod=function(t){t&&(this.method=t)},e.toString=function(){return this.name+": "+this.message+" "+this.method},t}();function C(t){var e=t.e,o=t.name,n=t.method,r=t.debug,i=void 0!==r&&r;if(e instanceof y)return e.setName(o),e.setMethod(n),i&&_.error(e.toString()),e;if(e instanceof Error){var a=new y({message:e.message,code:"error",method:n,name:o});return i&&_.error(a.toString()),a}var c=new y({message:String(e),code:"error",name:o,method:n});return i&&_.error(c.toString()),c}var E,S,O,x,I=function(n){function r(t){var e;return(e=n.call(this,t)||this)._cadenaOriginal="",e.saxon=void 0,e.xslt=null,e.debug=!1,e.xslt=null==t?void 0:t.xslt,e.saxon=null==t?void 0:t.saxon,e._cadenaOriginal="",e.setDebug(Boolean(null==t?void 0:t.debug)),e}m(r,n);var i=r.prototype;return i.certificar=function(t){try{return e.setFile(t),this.setNoCertificado(e.getNoCer()),this.setCertificado(e.getPem({begin:!0})),this}catch(t){throw C({e:t,method:"certificar",debug:this.debug,name:"@cfdi/csd"})}},i.sellar=function(){var t=u(d().mark((function t(e,o){var n,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.generarCadenaOriginal();case 2:return n=t.sent,t.next=5,this.generarSello(n,e,o);case 5:r=t.sent,this._cadenaOriginal=n,this.setSello(r);case 8:case"end":return t.stop()}}),t,this)})));return function(e,o){return t.apply(this,arguments)}}(),i.getJsonCdfi=function(){return this.xml},i.getXmlCdfi=function(){var t=c.js2xml(h({},this.xml),{compact:!0,ignoreComment:!0,spaces:4});return this.restartCfdi(),t},i.saveFile=function(e,o,n){try{return t.writeFileSync(""+o+n+".xml",Buffer.from(e,"base64"),"utf8"),!0}catch(t){return!1}},i.generarCadenaOriginal=function(){if(!this.xslt)throw new Error("¡Ups! Direcction Not Found Extensible Stylesheet Language Transformation");try{var e=b.getTmpFullPath(b.generateNameTemp()),o=c.js2xml(this.xml,{compact:!0,ignoreComment:!0,spaces:4});t.writeFileSync(e,o,"utf8");var n=new a(this.saxon).s(e).xsl(String(this.xslt.path)).warnings("silent").run();return this.debug&&(console.log("xslt =>",this.xslt),console.log("cadena original =>",n)),t.unlinkSync(e),n}catch(t){throw C({e:t,method:"getCadenaOriginal",debug:this.debug,name:"@cfdi/xml"})}},i.generarSello=function(t,e,n){try{return o.setFile(e,n),o.signatureHexForge(t)}catch(t){throw C({e:t,method:"getSello",debug:this.debug,name:"@cfdi/xml => @cfdi/csd"})}},i.setDebug=function(t){this.debug=t},l(r,[{key:"sello",get:function(){var t,e=this.xml["cfdi:Comprobante"];return(null==e||null==(t=e._attributes)?void 0:t.Sello)||""}},{key:"cadenaOriginal",get:function(){return this._cadenaOriginal}},{key:"isBebug",get:function(){return this.debug}}])}(g),R=function(){function t(t){this.relacionada={},n.of().cfdi.relacionados.validate(t),this.relacionada._attributes=t}var e=t.prototype;return e.addRelation=function(t){this.relacionada["cfdi:CfdiRelacionado"]||(this.relacionada["cfdi:CfdiRelacionado"]=[]);var e={UUID:t};n.of().cfdi.relacionado.validate(e),this.relacionada["cfdi:CfdiRelacionado"].push({_attributes:e})},e.getRelation=function(){return this.relacionada},e.toJson=function(){return this.relacionada},t}(),A=function(){function t(t){this.emisor={_attributes:{Rfc:"",Nombre:"",RegimenFiscal:""}},n.of().cfdi.emisor.validate(t),this.emisor._attributes=t}var e=t.prototype;return e.setRfc=function(t){this.emisor._attributes.Rfc=t},e.setNombre=function(t){this.emisor._attributes.Nombre=t},e.setRegimenFiscal=function(t){this.emisor._attributes.RegimenFiscal=t},e.setFacAtrAdquirente=function(t){this.emisor._attributes.FacAtrAdquirente=t},e.toJson=function(){return n.of().cfdi.emisor.validate(this.emisor._attributes),this.emisor},t}(),N=function(){function t(t){this.receptor={_attributes:{Rfc:"",Nombre:"",UsoCFDI:"",DomicilioFiscalReceptor:"",RegimenFiscalReceptor:""}},n.of().cfdi.receptor.validate(t),this.receptor._attributes=t}var e=t.prototype;return e.setRFC=function(t){this.receptor._attributes.Rfc=t},e.setNombre=function(t){this.receptor._attributes.Nombre=t},e.setUsoCFDI=function(t){this.receptor._attributes.UsoCFDI=t},e.setDomicilioFiscalReceptor=function(t){this.receptor._attributes.DomicilioFiscalReceptor=t},e.setResidenciaFiscal=function(t){this.receptor._attributes.ResidenciaFiscal=t},e.setNumRegIdTrib=function(t){this.receptor._attributes.NumRegIdTrib=t},e.setRegimenFiscalReceptor=function(t){this.receptor._attributes.RegimenFiscalReceptor=t},e.toJson=function(){return n.of().cfdi.receptor.validate(this.receptor._attributes),this.receptor},t}(),w=function(){function t(t){if(void 0===t&&(t={}),this.impuesto={},0!==Object.keys(t).length){var e=t;n.of().cfdi.impuestos.validate(e);var o=v(e,["TotalImpuestosRetenidos","TotalImpuestosTrasladados"]);this.impuesto._attributes=o}}var e=t.prototype;return e.setTraslado=function(t){this.impuesto["cfdi:Traslados"]||(this.impuesto["cfdi:Traslados"]={"cfdi:Traslado":[]});var e=v(t,["Base","Impuesto","TipoFactor","TasaOCuota","Importe"]);return this.impuesto["cfdi:Traslados"]["cfdi:Traslado"].push({_attributes:e}),this},e.setRetencion=function(t){this.impuesto["cfdi:Retenciones"]||(this.impuesto["cfdi:Retenciones"]={"cfdi:Retencion":[]});var e=v(t,["Base","Impuesto","TipoFactor","TasaOCuota","Importe"]);return this.impuesto["cfdi:Retenciones"]["cfdi:Retencion"].push({_attributes:e}),this},e.getTotalImpuestos=function(){return this.impuesto._attributes},e.getRetenciones=function(){return this.impuesto["cfdi:Retenciones"]["cfdi:Retencion"]},e.getTraslados=function(){return this.impuesto["cfdi:Traslados"]["cfdi:Traslado"]},t}(),L=function(t){function e(e){var o;(o=t.call(this)||this).existComplemnt=!1,o.complementProperties={},o.concepto={};var r=h({},e);return o.existComplemnt=!1,n.of().concepto.concepto.validate(r),o.concepto._attributes=r,o}m(e,t);var o=e.prototype;return o.complemento=function(t){this.concepto["cfdi:ComplementoConcepto"]||(this.concepto["cfdi:ComplementoConcepto"]={}),this.existComplemnt=!0;var e=t.getComplement(),o=e.complement,n=e.key,r=e.schemaLocation,i=e.xmlns,a=e.xmlnskey;this.complementProperties.key=n,this.complementProperties.xmlns=i,this.complementProperties.xmlnskey=a,this.complementProperties.schemaLocation=r,this.concepto["cfdi:ComplementoConcepto"][n]=o},o.terceros=function(t){return n.of().concepto.terceros.validate(t),this.concepto["cfdi:ACuentaTerceros"]={_attributes:t},this},o.predial=function(t){var e={Numero:t};return n.of().concepto.predial.validate(e),this.concepto["cfdi:CuentaPredial"]={_attributes:e},this},o.parte=function(t){var e=h({},t,{Cantidad:Number(t.Cantidad),ValorUnitario:Number(t.ValorUnitario),Importe:Number(t.ValorUnitario)});return n.of().concepto.parte.validate(e),this.concepto["cfdi:Parte"]={_attributes:e},this},o.aduana=function(t){var e={NumeroPedimento:t};return n.of().concepto.informacionAduanera.validate(e),{_attributes:e}},o.setParteInformacionAduanera=function(t){return this.concepto["cfdi:Parte"]?(this.concepto["cfdi:Parte"]["cfdi:InformacionAduanera"]||(this.concepto["cfdi:Parte"]["cfdi:InformacionAduanera"]=[]),this.concepto["cfdi:Parte"]["cfdi:InformacionAduanera"].push(this.aduana(t)),this):(console.log("utilize primero parte"),this)},o.InformacionAduanera=function(t){return this.concepto["cfdi:InformacionAduanera"]||(this.concepto["cfdi:InformacionAduanera"]=[]),this.concepto["cfdi:InformacionAduanera"].push(this.aduana(t)),this},o.traslado=function(t){var e=h({},t);return n.of().concepto.traslado.validate(e),this.setTraslado(e),this.concepto["cfdi:Impuestos"]=this.impuesto,this},o.retencion=function(t){var e=h({},t);return this.setRetencion(e),this.concepto["cfdi:Impuestos"]=this.impuesto,this},o.getConcept=function(){var t=h({},this.concepto);return this.concepto={},t},o.isComplement=function(){return this.existComplemnt},o.getComplementProperties=function(){return this.complementProperties},e}(w),D=function(t){function e(e){return void 0===e&&(e={}),t.call(this,e)||this}m(e,t);var o=e.prototype;return o.traslados=function(t){var e=h({},t);return n.of().cfdi.traslado.validate(e),this.setTraslado(e),this},o.retenciones=function(t){var e=h({},t);return n.of().cfdi.retencion.validate(e),this.setRetencion(e),this},e}(w);!function(t){t.NoobjetoDeimpuesto="01",t["SíObjetoDeImpuesto"]="02",t["SíObjetoDeImpuestoYNobligadoAlDesglose"]="03"}(E||(E={})),function(t){t.INGRESO="I",t.EGRESO="E",t.TRASLADO="T",t.NOMINA="N",t.PAGO="P"}(S||(S={})),function(t){t.NOTA_DE_CREDITO="01",t.NOTA_DE_DEBITO="02",t.DELOVUCION_DE_MERCANCIA="03",t.SUSTITUCION_DE_CFDI_PREVIOS="04",t.TRASLADOS_DE_MERCANCIA_FACTURADOS_PREVIAMENTE="05",t.FACTURA_POR_TRASLADOS_PREVIOS="06",t.APLICACION_DE_ANTICIPO="07",t.PAGOS_EN_PARCIALIDADES="08",t.PAGOS_DIFERIDOS="09"}(O||(O={})),function(t){t.GENERAL_LEY_DE_PERSONAS_MORALES="601",t.PERSONAS_MORALES_CON_FINES_NO_LUCRATIVOS="603",t.SUELDOS_Y_SALARIOS="605",t.ARRENDAMIENTO="606",t.DEMAS_INGRESOS="608",t.CONSOLIDACION="609",t.RESIDENTES_EN_EL_EXTRANJERO="610",t.INGRESOS_POR_DIVIDENDOS_SOCIOS_Y_ACCIONISTAS="611",t.PERSONAS_FISICAS_CON_ACTIVIDADES_EMPRESARIALES_Y_PROFESIONALES="612",t.INGRESOS_POR_INTERESES="614",t.SIN_OBLIGACIONES_FISCALES="616",t.SOCIEDADES_COOPERATIVAS_DE_PRODUCCION="620",t.REGIMEN_DE_INCORPORACION_FISCAL="621",t.ACTIVIDADES_AGRICOLAS_GANADERAS_SILVICOLAS_Y_PESQUERAS="622",t.OPCIONAL_PARA_GRUPOS_DE_SOCIEDADES="623",t.COORDINADOS="624",t.HIDROCARBUROS="628",t.REGIMEN_DE_ENAJENACION_O_ADQUISICION_DE_BIENES="607",t.PREFERENTES_Y_EMPRESAS_MULTINACIONALES="629",t.ENAJENACION_DE_ACCIONES_EN_BOLSA_DE_VALORES="630",t.REGIMEN_DE_LOS_INGRESOS_POR_OBTENCION_DE_PREMIOS="615"}(x||(x={}));export{I as CFDI,L as Concepto,L as Concepts,A as Emisor,D as Impuestos,O as InvoiceRelation,S as InvoiceType,E as ObjetoImpEnum,N as Receptor,R as Relacionado,x as TaxSystem}; //# sourceMappingURL=xml.esm.production.min.js.map