[SYNC] chore: Update carta-porte XML service
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8f592af5cf
commit
49839476c4
@ -93,8 +93,8 @@ export class CartaPorteXmlService {
|
||||
attrs.push('MetodoPago="PUE"');
|
||||
}
|
||||
|
||||
// Lugar de expedicion (CP del emisor)
|
||||
attrs.push(`LugarExpedicion="${cp.emisorDomicilioFiscalCp || '00000'}"`);
|
||||
// Lugar de expedicion (CP del receptor o default)
|
||||
attrs.push(`LugarExpedicion="${cp.receptorDomicilioFiscalCp || '00000'}"`);
|
||||
|
||||
// Construir XML
|
||||
let xml = `<cfdi:Comprobante ${attrs.join(' ')}>\n`;
|
||||
@ -228,7 +228,7 @@ export class CartaPorteXmlService {
|
||||
let xml = ' <cartaporte31:Ubicaciones>\n';
|
||||
|
||||
// Ordenar por secuencia
|
||||
const sorted = [...ubicaciones].sort((a, b) => a.numeroSecuencia - b.numeroSecuencia);
|
||||
const sorted = [...ubicaciones].sort((a, b) => a.secuencia - b.secuencia);
|
||||
|
||||
for (const ub of sorted) {
|
||||
const tipoUbicacion = ub.tipoUbicacion === TipoUbicacionCartaPorte.ORIGEN ? 'Origen' : 'Destino';
|
||||
@ -244,7 +244,7 @@ export class CartaPorteXmlService {
|
||||
attrs.push(`FechaHoraSalidaLlegada="${fechaStr}"`);
|
||||
}
|
||||
|
||||
if (ub.distanciaRecorrida !== undefined && ub.distanciaRecorrida > 0) {
|
||||
if (ub.distanciaRecorrida !== undefined && ub.distanciaRecorrida !== null && ub.distanciaRecorrida > 0) {
|
||||
attrs.push(`DistanciaRecorrida="${ub.distanciaRecorrida.toFixed(2)}"`);
|
||||
}
|
||||
|
||||
@ -268,14 +268,14 @@ export class CartaPorteXmlService {
|
||||
const attrs: string[] = [];
|
||||
|
||||
if (ub.calle) attrs.push(`Calle="${this.escapeXml(ub.calle)}"`);
|
||||
if (ub.numExterior) attrs.push(`NumeroExterior="${this.escapeXml(ub.numExterior)}"`);
|
||||
if (ub.numInterior) attrs.push(`NumeroInterior="${this.escapeXml(ub.numInterior)}"`);
|
||||
if (ub.numeroExterior) attrs.push(`NumeroExterior="${this.escapeXml(ub.numeroExterior)}"`);
|
||||
if (ub.numeroInterior) attrs.push(`NumeroInterior="${this.escapeXml(ub.numeroInterior)}"`);
|
||||
if (ub.colonia) attrs.push(`Colonia="${ub.colonia}"`);
|
||||
if (ub.localidad) attrs.push(`Localidad="${ub.localidad}"`);
|
||||
if (ub.referencia) attrs.push(`Referencia="${this.escapeXml(ub.referencia)}"`);
|
||||
if (ub.municipio) attrs.push(`Municipio="${ub.municipio}"`);
|
||||
if (ub.estado) attrs.push(`Estado="${ub.estado}"`);
|
||||
attrs.push('Pais="MEX"');
|
||||
attrs.push(`Pais="${ub.pais}"`);
|
||||
attrs.push(`CodigoPostal="${ub.codigoPostal}"`);
|
||||
|
||||
return ` <cartaporte31:Domicilio ${attrs.join(' ')}/>\n`;
|
||||
@ -324,16 +324,16 @@ export class CartaPorteXmlService {
|
||||
attrs.push(`ClaveUnidad="${merc.claveUnidad}"`);
|
||||
if (merc.unidad) attrs.push(`Unidad="${this.escapeXml(merc.unidad)}"`);
|
||||
|
||||
if (merc.dimensionesLargo && merc.dimensionesAncho && merc.dimensionesAlto) {
|
||||
const dims = `${merc.dimensionesLargo}/${merc.dimensionesAncho}/${merc.dimensionesAlto}cm`;
|
||||
if (merc.largoCm && merc.anchoCm && merc.altoCm) {
|
||||
const dims = `${merc.largoCm}/${merc.anchoCm}/${merc.altoCm}cm`;
|
||||
attrs.push(`Dimensiones="${dims}"`);
|
||||
}
|
||||
|
||||
if (merc.materialPeligroso) {
|
||||
attrs.push('MaterialPeligroso="Sí"');
|
||||
if (merc.cveMaterialPeligroso) attrs.push(`CveMaterialPeligroso="${merc.cveMaterialPeligroso}"`);
|
||||
if (merc.embalaje) attrs.push(`Embalaje="${merc.embalaje}"`);
|
||||
if (merc.descripEmbalaje) attrs.push(`DescripEmbalaje="${this.escapeXml(merc.descripEmbalaje)}"`);
|
||||
if (merc.tipoEmbalaje) attrs.push(`Embalaje="${merc.tipoEmbalaje}"`);
|
||||
if (merc.descripcionEmbalaje) attrs.push(`DescripEmbalaje="${this.escapeXml(merc.descripcionEmbalaje)}"`);
|
||||
} else {
|
||||
attrs.push('MaterialPeligroso="No"');
|
||||
}
|
||||
@ -361,16 +361,16 @@ export class CartaPorteXmlService {
|
||||
const auto = autos[0]; // Usualmente solo hay uno
|
||||
|
||||
const attrs: string[] = [];
|
||||
attrs.push(`PermSCT="${auto.permSCT}"`);
|
||||
attrs.push(`NumPermisoSCT="${auto.numPermisoSCT}"`);
|
||||
attrs.push(`PermSCT="${auto.permSct}"`);
|
||||
attrs.push(`NumPermisoSCT="${auto.numPermisoSct}"`);
|
||||
|
||||
let xml = ` <cartaporte31:Autotransporte ${attrs.join(' ')}>\n`;
|
||||
|
||||
// Identificacion vehicular
|
||||
const idVehAttrs: string[] = [];
|
||||
idVehAttrs.push(`ConfigVehicular="${auto.configVehicular}"`);
|
||||
idVehAttrs.push(`PlacaVM="${auto.placaVM}"`);
|
||||
if (auto.anioModeloVM) idVehAttrs.push(`AnioModeloVM="${auto.anioModeloVM}"`);
|
||||
idVehAttrs.push(`PlacaVM="${auto.placaVm}"`);
|
||||
if (auto.anioModeloVm) idVehAttrs.push(`AnioModeloVM="${auto.anioModeloVm}"`);
|
||||
|
||||
xml += ` <cartaporte31:IdentificacionVehicular ${idVehAttrs.join(' ')}/>\n`;
|
||||
|
||||
@ -417,10 +417,8 @@ export class CartaPorteXmlService {
|
||||
const attrs: string[] = [];
|
||||
attrs.push(`TipoFigura="${fig.tipoFigura}"`);
|
||||
if (fig.rfcFigura) attrs.push(`RFCFigura="${fig.rfcFigura}"`);
|
||||
attrs.push(`NombreFigura="${this.escapeXml(fig.nombreFigura)}"`);
|
||||
if (fig.nombreFigura) attrs.push(`NombreFigura="${this.escapeXml(fig.nombreFigura)}"`);
|
||||
if (fig.numLicencia) attrs.push(`NumLicencia="${fig.numLicencia}"`);
|
||||
if (fig.numRegIdTribFigura) attrs.push(`NumRegIdTribFigura="${fig.numRegIdTribFigura}"`);
|
||||
if (fig.residenciaFiscalFigura) attrs.push(`ResidenciaFiscalFigura="${fig.residenciaFiscalFigura}"`);
|
||||
|
||||
xml += ` <cartaporte31:TiposFigura ${attrs.join(' ')}`;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user