UNPKG

@cfdi/xml

Version:

Libreria para crear y sellar xml cfdi V4.0

3 lines (2 loc) 23 kB
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("fs")),o=require("@cfdi/csd"),r=require("@cfdi/xsd"),n=t(require("os")),i=t(require("path")),a=require("@saxon-he/cli"),c=t(require("xml-js"));function s(t,e,o,r,n,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(r,n)}function u(t){return function(){var e=this,o=arguments;return new Promise((function(r,n){var i=t.apply(e,o);function a(t){s(i,r,n,a,c,"next",t)}function c(t){s(i,r,n,a,c,"throw",t)}a(void 0)}))}}function f(t,e){for(var o=0;o<e.length;o++){var r=e[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,p(r.key),r)}}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 r in o)({}).hasOwnProperty.call(o,r)&&(t[r]=o[r])}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,r=o.hasOwnProperty,n=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,r){var i=Object.create((e&&e.prototype instanceof b?e:b).prototype),a=new w(r||[]);return n(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 b(){}function g(){}function _(){}var y={};u(y,a,(function(){return this}));var S=Object.getPrototypeOf,C=S&&S(S(L([])));C&&C!==o&&r.call(C,a)&&(y=C);var E=_.prototype=b.prototype=Object.create(y);function x(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function o(n,i,a,c){var s=l(t[n],t,i);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==typeof f&&r.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;n(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return i=i?i.then(n,n):n()}})}function I(e,o,r){var n=h;return function(i,a){if(n===m)throw Error("Generator is already running");if(n===p){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=R(c,r);if(s){if(s===v)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=m;var u=l(e,o,r);if("normal"===u.type){if(n=r.done?p:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=p,r.method="throw",r.arg=u.arg)}}}function R(e,o){var r=o.method,n=e.iterator[r];if(n===t)return o.delegate=null,"throw"===r&&e.iterator.return&&(o.method="return",o.arg=t,R(e,o),"throw"===o.method)||"return"!==r&&(o.method="throw",o.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=l(n,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 n=-1,i=function o(){for(;++n<e.length;)if(r.call(e,n))return o.value=e[n],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 g.prototype=_,n(E,"constructor",{value:_,configurable:!0}),n(_,"constructor",{value:g,configurable:!0}),g.displayName=u(_,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"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(E),t},e.awrap=function(t){return{__await:t}},x(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,o,r,n,i){void 0===i&&(i=Promise);var a=new O(f(t,o,r,n),i);return e.isGeneratorFunction(o)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),o=[];for(var r in e)o.push(r);return o.reverse(),function t(){for(;o.length;){var r=o.pop();if(r in e)return t.value=r,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)&&r.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 n(r,n){return c.type="throw",c.arg=e,o.next=r,n&&(o.method="next",o.arg=t),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var o=this.tryEntries.length-1;o>=0;--o){var n=this.tryEntries[o];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;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 r=o.completion;if("throw"===r.type){var n=r.arg;N(o)}return n}}throw Error("illegal catch attempt")},delegateYield:function(e,o,r){return this.delegate={iterator:L(e),resultName:o,nextLoc:r},"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 r=o.call(t,"string");if("object"!=typeof r)return r;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},b=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=r.Schema.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}}])}(),g=function(){function t(){}return t.generateNameTemp=function(){return Date.now().toString()},t.readFileSync=function(t){return e.readFileSync(t,"utf8")},t.getTmpFullPath=function(t){return i.join(n.tmpdir(),t+".xml")},t}(),_=function(){function t(){}return t.info=function(t){for(var e,o=arguments.length,r=new Array(o>1?o-1:0),n=1;n<o;n++)r[n-1]=arguments[n];(e=console).log.apply(e,["INFO: "+t].concat(r))},t.error=function(t){for(var e,o=arguments.length,r=new Array(o>1?o-1:0),n=1;n<o;n++)r[n-1]=arguments[n];(e=console).error.apply(e,["ERROR: "+t].concat(r))},t.warn=function(t){for(var e,o=arguments.length,r=new Array(o>1?o-1:0),n=1;n<o;n++)r[n-1]=arguments[n];(e=console).warn.apply(e,["WARN: "+t].concat(r))},t}(),y=function(){function t(t){var e=t.message,o=t.code,r=t.details,n=t.name,i=t.method;this.method="",this.message=e,this.code=o,this.details=r,this.name=n||"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 S(t){var e=t.e,o=t.name,r=t.method,n=t.debug,i=void 0!==n&&n;if(e instanceof y)return e.setName(o),e.setMethod(r),i&&_.error(e.toString()),e;if(e instanceof Error){var a=new y({message:e.message,code:"error",method:r,name:o});return i&&_.error(a.toString()),a}var c=new y({message:String(e),code:"error",name:o,method:r});return i&&_.error(c.toString()),c}var C,E,x,O,I=function(t){function r(e){var o;return(o=t.call(this,e)||this)._cadenaOriginal="",o.saxon=void 0,o.xslt=null,o.debug=!1,o.xslt=null==e?void 0:e.xslt,o.saxon=null==e?void 0:e.saxon,o._cadenaOriginal="",o.setDebug(Boolean(null==e?void 0:e.debug)),o}m(r,t);var n=r.prototype;return n.certificar=function(t){try{return o.cer.setFile(t),this.setNoCertificado(o.cer.getNoCer()),this.setCertificado(o.cer.getPem({begin:!0})),this}catch(t){throw S({e:t,method:"certificar",debug:this.debug,name:"@cfdi/csd"})}},n.sellar=function(){var t=u(d().mark((function t(e,o){var r,n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.generarCadenaOriginal();case 2:return r=t.sent,t.next=5,this.generarSello(r,e,o);case 5:n=t.sent,this._cadenaOriginal=r,this.setSello(n);case 8:case"end":return t.stop()}}),t,this)})));return function(e,o){return t.apply(this,arguments)}}(),n.getJsonCdfi=function(){return this.xml},n.getXmlCdfi=function(){var t=c.js2xml(h({},this.xml),{compact:!0,ignoreComment:!0,spaces:4});return this.restartCfdi(),t},n.saveFile=function(t,o,r){try{return e.writeFileSync(""+o+r+".xml",Buffer.from(t,"base64"),"utf8"),!0}catch(t){return!1}},n.generarCadenaOriginal=function(){if(!this.xslt)throw new Error("¡Ups! Direcction Not Found Extensible Stylesheet Language Transformation");try{var t=g.getTmpFullPath(g.generateNameTemp()),o=c.js2xml(this.xml,{compact:!0,ignoreComment:!0,spaces:4});e.writeFileSync(t,o,"utf8");var r=new a.Transform(this.saxon).s(t).xsl(String(this.xslt.path)).warnings("silent").run();return this.debug&&(console.log("xslt =>",this.xslt),console.log("cadena original =>",r)),e.unlinkSync(t),r}catch(t){throw S({e:t,method:"getCadenaOriginal",debug:this.debug,name:"@cfdi/xml"})}},n.generarSello=function(t,e,r){try{return o.key.setFile(e,r),o.key.signatureHexForge(t)}catch(t){throw S({e:t,method:"getSello",debug:this.debug,name:"@cfdi/xml => @cfdi/csd"})}},n.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}}])}(b),R=function(){function t(t){this.relacionada={},r.Schema.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};r.Schema.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:""}},r.Schema.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 r.Schema.of().cfdi.emisor.validate(this.emisor._attributes),this.emisor},t}(),N=function(){function t(t){this.receptor={_attributes:{Rfc:"",Nombre:"",UsoCFDI:"",DomicilioFiscalReceptor:"",RegimenFiscalReceptor:""}},r.Schema.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 r.Schema.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;r.Schema.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 n=h({},e);return o.existComplemnt=!1,r.Schema.of().concepto.concepto.validate(n),o.concepto._attributes=n,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,r=e.key,n=e.schemaLocation,i=e.xmlns,a=e.xmlnskey;this.complementProperties.key=r,this.complementProperties.xmlns=i,this.complementProperties.xmlnskey=a,this.complementProperties.schemaLocation=n,this.concepto["cfdi:ComplementoConcepto"][r]=o},o.terceros=function(t){return r.Schema.of().concepto.terceros.validate(t),this.concepto["cfdi:ACuentaTerceros"]={_attributes:t},this},o.predial=function(t){var e={Numero:t};return r.Schema.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 r.Schema.of().concepto.parte.validate(e),this.concepto["cfdi:Parte"]={_attributes:e},this},o.aduana=function(t){var e={NumeroPedimento:t};return r.Schema.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 r.Schema.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),T=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 r.Schema.of().cfdi.traslado.validate(e),this.setTraslado(e),this},o.retenciones=function(t){var e=h({},t);return r.Schema.of().cfdi.retencion.validate(e),this.setRetencion(e),this},e}(w);(C=exports.ObjetoImpEnum||(exports.ObjetoImpEnum={})).NoobjetoDeimpuesto="01",C["SíObjetoDeImpuesto"]="02",C["SíObjetoDeImpuestoYNobligadoAlDesglose"]="03",(E=exports.InvoiceType||(exports.InvoiceType={})).INGRESO="I",E.EGRESO="E",E.TRASLADO="T",E.NOMINA="N",E.PAGO="P",(x=exports.InvoiceRelation||(exports.InvoiceRelation={})).NOTA_DE_CREDITO="01",x.NOTA_DE_DEBITO="02",x.DELOVUCION_DE_MERCANCIA="03",x.SUSTITUCION_DE_CFDI_PREVIOS="04",x.TRASLADOS_DE_MERCANCIA_FACTURADOS_PREVIAMENTE="05",x.FACTURA_POR_TRASLADOS_PREVIOS="06",x.APLICACION_DE_ANTICIPO="07",x.PAGOS_EN_PARCIALIDADES="08",x.PAGOS_DIFERIDOS="09",(O=exports.TaxSystem||(exports.TaxSystem={})).GENERAL_LEY_DE_PERSONAS_MORALES="601",O.PERSONAS_MORALES_CON_FINES_NO_LUCRATIVOS="603",O.SUELDOS_Y_SALARIOS="605",O.ARRENDAMIENTO="606",O.DEMAS_INGRESOS="608",O.CONSOLIDACION="609",O.RESIDENTES_EN_EL_EXTRANJERO="610",O.INGRESOS_POR_DIVIDENDOS_SOCIOS_Y_ACCIONISTAS="611",O.PERSONAS_FISICAS_CON_ACTIVIDADES_EMPRESARIALES_Y_PROFESIONALES="612",O.INGRESOS_POR_INTERESES="614",O.SIN_OBLIGACIONES_FISCALES="616",O.SOCIEDADES_COOPERATIVAS_DE_PRODUCCION="620",O.REGIMEN_DE_INCORPORACION_FISCAL="621",O.ACTIVIDADES_AGRICOLAS_GANADERAS_SILVICOLAS_Y_PESQUERAS="622",O.OPCIONAL_PARA_GRUPOS_DE_SOCIEDADES="623",O.COORDINADOS="624",O.HIDROCARBUROS="628",O.REGIMEN_DE_ENAJENACION_O_ADQUISICION_DE_BIENES="607",O.PREFERENTES_Y_EMPRESAS_MULTINACIONALES="629",O.ENAJENACION_DE_ACCIONES_EN_BOLSA_DE_VALORES="630",O.REGIMEN_DE_LOS_INGRESOS_POR_OBTENCION_DE_PREMIOS="615",exports.CFDI=I,exports.Concepto=L,exports.Concepts=L,exports.Emisor=A,exports.Impuestos=T,exports.Receptor=N,exports.Relacionado=R; //# sourceMappingURL=xml.cjs.production.min.js.map