Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Configurar los siguientes Disparadores en el archivo SX7 - Disparadores:

Cnt. DominioC6_FRACCATipo1 - PrimarioReglaIIf(FINDFUNCTION("LxFraccAra"),LxFraccAra(M->C6_PRODUTO, M->C5_TIPOPE),"")Posiciona2 - NoAliasOrden0ClaveCondiciónCampo

C6_PRODUTO

Secuencia
Campo

C6_PRODUTO

Secuencia
007
008
Cnt. DominioC6_UNIADU
Tipo1 - Primario
ReglaIIf(FINDFUNCTION("LxUMFracc"),LxUMFracc(M->C6_FRACCA, M->C5_TIPOPE),"")
Posiciona2 - No
Alias
Orden0
Clave
Condición
Campo

C6_FRACCA

Secuencia001
Cnt. DominioC6_UNIADU
Tipo1 - Primario
ReglaIIf(FINDFUNCTION("LxUMFracc"),LxUMFracc(M->C6_FRACCA, M->C5_TIPOPE),"")
Posiciona2 - No
Alias
Orden0
Clave
Condición
Campo

D2_COD

Secuencia008
Cnt. DominioD2_FRACCA
Tipo1 - Primario
ReglaIIf(FINDFUNCTION("LxFraccAra"),LxFraccAra(M->D2_COD, M->F2_TIPOPE),"")
Posiciona2 - No
Alias
Orden0
Clave
Condición
Campo

D2_COD

Secuencia009
Cnt. DominioD2_UNIADU
Tipo1 - Primario
ReglaIIf(FINDFUNCTION("LxUMFracc"),LxUMFracc(M->D2_FRACCA, M->F2_TIPOPE),"")
Posiciona2 - No
Alias
Orden0
Clave
Condición
Campo

D2_FRACCA

Secuencia002
Cnt. DominioD2_UNIADU
Tipo1 - Primario
ReglaIIf(FINDFUNCTION("LxUMFracc"),LxUMFracc(M->D2_FRACCA, M->F2_TIPOPE),"")
Posiciona2 - No
Alias
Orden0
Clave
Condición


Configurar el la siguiente campo consulta estándar en el archivo SX3 SXB - CamposConsulta Estándar:

Campo

Alias

B1_CODICE

Tipo

C - Caracter
Secuencia
Tamaño
Columna
10
Descripción
Decimal
Contenido
0

MEX014

Formato

1

@!
01
Contexto
RE
Real
Fraccion Arancelaria
Propiedad
F3I
Modificar

MEX014

Tit. EspañolFracc Arance

2

0101Fraccion ArancelariaF812SXB("S014","FracAran")

MEX014

5

01

VAR_IXB


Configurar el siguiente campo en el archivo SX3 - Campos:

CampoB1_CODICE
TipoC - Caracter
Tamaño10
Decimal0
Formato@!
ContextoReal
PropiedadModificar
Tit. EspañolFracc Arance
Desc
Desc
. EspañolFracción arancelaria 
Consulta EstándarMEX014
ValidaciónVazio() .or. ValidF3I("S014", M->B1_CODICE,1,8)
ObligatorioNo
UsadoSi
Exhibe en BrowseNo
Help

Fracción Arancelaria aplicable a la mercancía según corresponda, conforme a la TIGIE.

Si se tiene la funcionalidad de uso del archivo de Generación de XML para Documentos de Salida (FATSMEX.INI), se deben realizar los siguientes ajustes para hacer uso de la funcion FxDelExp().


Informações

//FATSMEX.INI V4.0 --- Modelo 2022

[XXX POSICIONAMENTOS]
(PRE) If(AllTrim(SF2->F2_ESPECIE)=="NDI",SA2->(MSSeek(xFilial("SA2")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)
(PRE) If(AllTrim(SF2->F2_ESPECIE)<>"NDI",SA1->(MSSeek(xFilial("SA1")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF2->F2_COND)) , .T.)
(PRE) (AI0->(MSSeek(xFilial("AI0")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)

[XXX INICIALIZACION]
(PRE) SD2->(DbSetOrder(1))
(PRE) SB1->(DbSetOrder(1))
(PRE) SYA->(DbSetOrder(1))
(PRE) SC6->(DbSetOrder(1))
(PRE) SE4->(DbSetOrder(1)) 
(PRE) CTO->(DbSetOrder(1)) 
(PRE) SAH->(DbSetOrder(1)) 
(PRE) _aTotal[009] := SuperGetMV("MV_CFDICPG", .F., "")
(PRE) _aTotal[010] := FindFunction("zh_FechaHoraUTC") .And. !Empty(_aTotal[009])
(PRE) _aTotal[011] := FindFunction("LxFunaCaPo")
(PRE) _aTotal[094] := ""
(PRE) _aTotal[095] := ""
(PRE) _aTotal[033] := ""
(PRE) _aTotal[034] := ""
(PRE) _aTotal[035] := ""
(PRE) _aTotal[036] := 0
(PRE) _aTotal[037] := 0
(PRE) _aTotal[038] := 0
(PRE) _aTotal[039] := SuperGetMV("MV_CFDIEXP",.F.,.F.)
(PRE) _aTotal[075] := Alltrim(SM0->M0_NOMECOM)
(PRE) _aTotal[076] := ((_aTotal[039] .And. !Empty(SF2->F2_TIPOPE)) .Or. SF2->(ColumnPos("F2_TPCOMPL")) > 0 .And. AllTrim(SF2->F2_TPCOMPL)=="S") .And. Alltrim(SF2->F2_TIPODOC) == "21"
(PRE) IIf(_aTotal[010],_aTotal[096] := zh_FechaHoraUTC(Alltrim(_aTotal[009]),Alltrim(SM0->M0_CEPENT),SF2->F2_EMISSAO,SF2->F2_HORA),"")
(PRE) IIf(!_aTotal[010],_aTotal[096] := DtoS(SF2->F2_EMISSAO),"")
(PRE) IIf(!_aTotal[010],_aTotal[096] := Left(_aTotal[096],4) + "-" + Substr(_aTotal[096],5,2)+ "-" + Right(_aTotal[096],2),"")
(PRE) IIf(!_aTotal[010],_aTotal[096] += "T" + SF2->F2_HORA,"")
(PRE) _aTotal[097] := {"SD2",""}
(PRE) _aTotal[098] := "|"
(PRE) _aTotal[099] := "||"
(PRE) _aTotal[100] := ""
(PRE) _aTotal[101] := "OPERACION DE CONFORMIDAD CON EL ART. 29 FRACCION I DE LIVA Y LO ESTIPULADO EN LAS RGCE 5.2.6. FRACCION I, 5.2.7 Y 4.3.21"
(PRE) _aTotal[102] := "OPERACION DE CONFORMIDAD CON EL ART. 29 FRACCION I DE LIVA Y LO ESTIPULADO EN LAS RGCE 5.2.6. FRACCION II, 5.2.7 Y 4.3.21"
(PRE) _aTotal[103] := fSumBC(SF2->F2_DOC,SF2->F2_SERIE,SF2->F2_CLIENTE,SF2->F2_LOJA)
(PRE) _aTotal[104] := IIf(SF2->(ColumnPos("F2_TPCOMPL")) > 0 .And. AllTrim(SF2->F2_TPCOMPL)=="S",.T.,.F.)
(PRE) _aTotal[105] := ""
(PRE) _aTotal[106] := IIf(Alltrim(SF2->F2_TIPODOC) == "21",0,2)
(PRE) _aTotal[107] := IIf(SF2->(ColumnPos("F2_TPDOC")) > 0,ALLTRIM(SF2->F2_TPDOC),ALLTRIM(AI0->AI0_MPAGO))
(PRE) _aTotal[108] := IIf(_aTotal[076],AllTrim(SM0->M0_CGC),AllTrim(SA1->A1_CGC))
(PRE) _aTotal[109] := IIf(FindFunction("FxDelExp"),FxDelExp(IIf(_aTotal[076],_aTotal[075],Alltrim(SA1->A1_NOME))),IIf(_aTotal[076],_aTotal[075],Alltrim(SA1->A1_NOME)))
(PRE) _aTotal[110] := IIf(_aTotal[076],AllTrim(SM0->M0_CEPENT),Alltrim(SA1->A1_CEP))
(PRE) _aTotal[111] := IIf(_aTotal[076],Alltrim(SM0->M0_DSCCNA),Alltrim(AI0->AI0_REGFIS))
(PRE) _aTotal[112] := FormPagGlo(SF2->F2_DOC,SF2->F2_SERIE)
(PRE) _aTotal[113] := IIf(!_aTotal[039] .Or. (_aTotal[039] .And. Empty(SF2->F2_TIPOPE)),"01",IIf(SF2->F2_CVEPED !="A1" .Or. Alltrim(SF2->F2_TIPOPE)== "3","04","02"))
(PRE) _aTotal[114] := IIf(_aTotal[113] == "04" .And.( Empty(SF2->F2_CERORI) .Or. Empty(SF2->F2_INCOTER) .Or. Empty(SF2->F2_SUBDIV) .Or. Empty(SF2->F2_TCUSD) .Or. Empty(SF2->F2_TOTUSD)) ,.F.,.T.)
(PRE) _aTotal[115] := {}
(PRE) lCCCE        := .F.
(PRE) cNodoCCE     := ""
(PREREG) FsQuery(_aTotal[097],1,"D2_DOC='" + SF2->F2_DOC + "' AND D2_SERIE='" + SF2->F2_SERIE + "' AND D2_CLIENTE='" + SF2->F2_CLIENTE + "' AND D2_LOJA='" + SF2->F2_LOJA + "'","SD2->D2_DOC=SF2->F2_DOC .AND. SD2->D2_SERIE=SF2->F2_SERIE .AND. SD2->D2_CLIENTE=SF2->F2_CLIENTE .AND. SD2->D2_LOJA=SF2->F2_LOJA","D2_ITEM") .And. .T.

(PRE) fImptosD(SF2->F2_DOC,SF2->F2_SERIE,SF2->F2_CLIENTE,SF2->F2_LOJA,IIf(ALLTRIM(SF2->F2_TIPODOC) == "21",.T.,.F.),"SD2", SF2->F2_GLOBAL == "1",@(_aTotal[036]),_aTotal[104],@_aTotal[037], @_aTotal[038], ,@_aTotal[115]) 

[SD2 CADENAORIGINAL_SELLO]
(PRE) If(AllTrim(SF2->F2_ESPECIE)=="NDI",SA2->(MSSeek(xFilial("SA2")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)
(PRE) If(AllTrim(SF2->F2_ESPECIE)=="NDI",SYA->(MsSeek(xFilial("SYA")+SA2->A2_PAIS)) , .T.)
(PRE) If(AllTrim(SF2->F2_ESPECIE)=="NDI",CTO->(MsSeek(xFilial("CTO")+Strzero(SF2->F2_MOEDA,2))) , .T.)
(PRE) If(AllTrim(SF2->F2_ESPECIE)<>"NDI",SA1->(MSSeek(xFilial("SA1")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)
(PRE) If(AllTrim(SF2->F2_ESPECIE)<>"NDI",SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS)) , .T.)
(PRE) If(AllTrim(SF2->F2_ESPECIE)<>"NDI",CTO->(MsSeek(xFilial("CTO")+Strzero(SF2->F2_MOEDA,2))) , .T.)
//////////////////////////////////////////////CADENA ORIGINAL//////////////////////////////////////////////
(PRE) cCadOrig   := _aTotal[099]
(PRE) lCCCE      := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.)  .And. !Empty(SF2->F2_TIPOPE)  .And. _aTotal[114], .T., .F.)
(PRE) cCadOriCCE := ""

//Cadena Original | Complemento de Comercio Exterior (Mercancias)
(PREREG) IIf(lCCCE .And. !Empty(SD2->D2_ITEM + SD2->D2_COD), (cCadOriCCE += Alltrim(SD2->D2_ITEM + SD2->D2_COD) + _aTotal[098],.T.),("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(SD2->D2_FRACCA), (cCadOriCCE += Alltrim(SD2->D2_FRACCA) + Alltrim(SD2->D2_NICO) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(Str(SD2->D2_CANADU)), (cCadOriCCE += Alltrim(Str(SD2->D2_CANADU)) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(SD2->D2_FRACCA), (cCadOriCCE += AllTrim(ObtColSAT("S014",AllTrim(SD2->D2_FRACCA),1,8,9,2)) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(Str(SD2->D2_VALADU)), (cCadOriCCE += Alltrim(Str(SD2->D2_VALADU,14,2)) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(Str(SD2->D2_USDADU)), (cCadOriCCE += Alltrim(Str(SD2->D2_USDADU,14,2)) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. SA1->A1_CONTRBE=="1" .And. Alltrim(SF2->F2_ESPECIE) == "NF", (cCadOriCCE += '1.0' +_aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. SA1->A1_CONTRBE=="1" .And. SF2->F2_CONUNI=="1", (cCadOriCCE += 'IMMEX:' + ALLTRIM(SA1->A1_PFISICA) + ' ' + _aTotal[101] + _aTotal[098],.T.), IIf (lCCCE .And. SA1->A1_CONTRBE=="1" .And. SF2->F2_CONUNI=="2", (cCadOriCCE += 'IMMEX:' + ALLTRIM(SA1->A1_PFISICA) + ' ' + _aTotal[102] + _aTotal[098],.T.), ("",,.T.)))

///////////DATOS DE LA FACTURA/////////////////
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF2->F2_COND)) , .T.)
(PRE) (AI0->(MSSeek(xFilial("AI0")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)
//Version
(PRE) cCadOrig += "4.0" + _aTotal[098]
//Serie
(PRE) cCadOrig += Alltrim(SF2->F2_SERIE) + _aTotal[098]
//Folio
(PRE) cCadOrig += Alltrim(SF2->F2_DOC) + _aTotal[098]
//Fecha
(PRE) cCadOrig += Alltrim(_aTotal[096]) + _aTotal[098]
//FormaPago
(PRE) cCadOrig += IIf(Alltrim(SF2->F2_TIPODOC) == "21", "", IIf(SF2->F2_GLOBAL == '1',IIf(!Empty(_aTotal[112]),_aTotal[112],_aTotal[107]),IIf(Empty(_aTotal[107]).Or. Alltrim(SE4->E4_MPAGSAT) == "PPD","99",_aTotal[107])) + _aTotal[098] )
//NoCertificado
(PRE) cCadOrig += Alltrim(SF2->F2_CERTFOL) + _aTotal[098]
//CondicionesDePago
(PRE) cCadOrig += IIf(Alltrim(SF2->F2_TIPODOC) == "21", "", CFDCarEsp(Alltrim(SE4->E4_DESCRI)) + _aTotal[098] ) 
//Subtotal
(PRE) cCadOrig += Alltrim(STR(IIF(ALLTRIM(SF2->F2_TIPODOC) == "21", 0, (SF2->(F2_VALMERC+F2_FRETE+F2_SEGURO+F2_DESPESA) + _aTotal[103] + SF2->F2_DESCONT) - _aTotal[036] - _aTotal[037]),14,_aTotal[106])) + _aTotal[098]
//Descuento
(PRE) cCadOrig += IIF(ALLTRIM(SF2->F2_TIPODOC) == "21", "", IIf( SF2->F2_DESCONT == 0, "", Alltrim(STR(SF2->F2_DESCONT,14,2)) + _aTotal[098]) )
//Moneda
(PRE) cCadOrig += IIf(Alltrim(SF2->F2_TIPODOC) == "21","XXX",Alltrim(CTO->CTO_MOESAT)) + _aTotal[098]
//TipoCambio
(PRE) cCadOrig += IIf(Alltrim(SF2->F2_TIPODOC) == "21","",IIf(Alltrim(CTO->CTO_MOESAT) <> "MXN", Alltrim(STR(SF2->F2_TXMOEDA,14,2)), "1") + _aTotal[098])
//Total
(PRE) cCadOrig += Alltrim(Str(IIf(ALLTRIM(SF2->F2_TIPODOC) == "21", 0, iif(GetSx3Cache("F2_VALBRUT","X3_DECIMAL")<= 2,SF2->F2_VALBRUT + _aTotal[103]- _aTotal[037] - IIf(Len(_aTotal[115]) > 0,_aTotal[115][1],0),Round(SF2->F2_VALBRUT,2) + _aTotal[103] - _aTotal[037] - IIf(Len(_aTotal[115]) > 0,_aTotal[115][1],0))),14,_aTotal[106])) + _aTotal[098]
//TipoDeComprobante
(PRE) cCadOrig += IIf(Alltrim(SF2->F2_ESPECIE) == "NF",IIf(ALLTRIM(SF2->F2_TIPODOC) == "21", "T", "I" ), "E") + _aTotal[098]
//Exportacion
(PRE) cCadOrig += IIf(!Empty(_aTotal[113]),_aTotal[113],"01") + _aTotal[098]
//MetodoPago
(PRE) cCadOrig += IIf(Alltrim(SF2->F2_TIPODOC) == "21", "", Alltrim(SE4->E4_MPAGSAT) + _aTotal[098] )
//LugarExpedicion
(PRE) cCadOrig += CFDCarEsp(AllTrim(SM0->M0_CEPENT)) + _aTotal[098]
//Periodicidad
(PRE) cCadOrig += IIf(SF2->(ColumnPos("F2_IDCBAJA")) > 0 .And. SF2->F2_GLOBAL == "1", SF2->F2_IDCBAJA + _aTotal[098],"")
//Meses
(PRE) cCadOrig += IIf(SF2->(ColumnPos("F2_MODCONS")) > 0 .And. SF2->F2_GLOBAL == "1", SF2->F2_MODCONS + _aTotal[098],"")
//Año
(PRE) cCadOrig += IIf(SF2->(ColumnPos("F2_PTOEMIS")) > 0 .And. SF2->F2_GLOBAL == "1", SF2->F2_PTOEMIS + _aTotal[098],"")

//////////////////////CFDI Relacionados//////////////////////////
(PREREG)!Empty(SF2->F2_RELSAT).Or. !Empty(SF2->F2_SERMAN).Or. !Empty(SF2->F2_DOCMAN)
(PRE) IIf(_aTotal[104] .And. Alltrim(SF2->F2_TIPODOC) == "21","",fGetFolRel("S",.T.))

///////////DATOS DEL EMISOR///////////////////////
//Rfc
(PRE) cCadOrig += CFDCarEsp(AllTrim(SM0->M0_CGC),.F.) + _aTotal[098]
//Nombre
(PRE) cCadOrig += CFDCarEsp(_aTotal[075],.F.) + _aTotal[098]
//RegimenFiscal
(PRE) cCadOrig += CFDCarEsp(Alltrim(SM0->M0_DSCCNA)) + _aTotal[098]

//////////////////////DATOS DEL RECEPTOR//////////////////////////
(PRE) AllTrim(SF2->F2_ESPECIE) <> "NDI"
(PRE) SA1->(MSSeek(xFilial("SA1")+SF2->F2_CLIENTE+SF2->F2_LOJA))
(PRE) SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS))
//Rfc
(PRE) (cCadOrig += IIf(!_aTotal[104] .And. ((ALLTRIM(SF2->F2_TIPODOC) == "21" .And. !lCCCE) .Or. SF2->F2_GLOBAL == "1"), "XAXX010101000", CFDCarEsp(_aTotal[108], .F.)) + _aTotal[098])
//Nombre
(PRE) (cCadOrig += IIF(SF2->F2_GLOBAL == "1", "PUBLICO EN GENERAL",CFDCarEsp(_aTotal[109],.F.)) + _aTotal[098], .T.)
//DomicilioFiscalReceptor
(PRE) (cCadOrig += CFDCarEsp(_aTotal[110],.F.) + _aTotal[098], .T.)
//ResidenciaFiscal
(PRE) IIf(lCCCE .And. !Empty(CFDCarEsp(Alltrim(SF2->F2_RESIDE))) .And. !_aTotal[076], cCadOrig += AllTrim(Posicione("SYA",1,xFilial("SYA")+SF2->F2_RESIDE,"YA_CCESAT")) + _aTotal[098], "")
//NumRegIdTrib
(PRE) IIf(lCCCE .And. !Empty(CFDCarEsp(Alltrim(SF2->F2_IDTRIB))) .And. !_aTotal[076], cCadOrig += CFDCarEsp(AllTrim(AllTrim(SF2->F2_IDTRIB))) + _aTotal[098], "")
//RegimenFiscalReceptor
(PRE) (cCadOrig += IIf(AI0->(ColumnPos("AI0_REGFIS")) > 0,CFDCarEsp(_aTotal[111],.F.) + _aTotal[098],""), .T.)
//UsoCFDI
(PRE) (cCadOrig += Alltrim(SF2->F2_USOCFDI) + _aTotal[098], .T.)

(PRE) (cCadOrig += fXMLFUN("CO",.T., IIf(ALLTRIM(SF2->F2_TIPODOC) == "21",.T.,.F.),_aTotal[104]),.T.)
(PRE) (cCadOrig += fXMLFUN("TI",.T., IIf(ALLTRIM(SF2->F2_TIPODOC) == "21",.T.,.F.)),.T.)

(POS) IIf(lCCCE, cCadOrig += "1.1" + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF2->F2_TRASLA), cCadOrig += Alltrim(SF2->F2_TRASLA) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF2->F2_TIPOPE), cCadOrig += IIf(Alltrim(SF2->F2_TIPOPE)=="3","2",Alltrim(SF2->F2_TIPOPE)) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF2->F2_CVEPED), cCadOrig += Alltrim(SF2->F2_CVEPED) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF2->F2_CERORI), cCadOrig += Alltrim(SF2->F2_CERORI) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF2->F2_NUMCER), cCadOrig += Alltrim(SF2->F2_NUMCER) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF2->F2_EXPCONF), cCadOrig += Alltrim(SF2->F2_EXPCONF) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF2->F2_INCOTER), cCadOrig += Alltrim(SF2->F2_INCOTER) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF2->F2_SUBDIV), cCadOrig += Alltrim(SF2->F2_SUBDIV) + _aTotal[098], "")
(POS) IIf(lCCCE .And. SF2->(ColumnPos("F2_OBSCE")) > 0 .And. !Empty(SF2->F2_OBSCE), cCadOrig += CFDCarEsp(AllTrim(SF2->F2_OBSCE), .F.) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(Str(SF2->F2_TCUSD)), cCadOrig += Alltrim(Str(SF2->F2_TCUSD)) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(Str(SF2->F2_TOTUSD)), cCadOrig += Alltrim(Str(SF2->F2_TOTUSD,14,2)) + _aTotal[098], "")

//Emisor
(POS) IIf(lCCCE , cCadOrig += CFDCarEsp(AllTrim(SM0->M0_ENDCOB)) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SM0->M0_CEPENT), cCadOrig += CFDCarEsp(AllTrim(ObtColSAT("S015",AllTrim(SM0->M0_CODZOSE)+ALLTRIM(SM0->M0_CEPENT),1,9,1,4))) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SM0->M0_CODMUN), cCadOrig += AllTrim(SM0->M0_CODMUN) + _aTotal[098], "")
(POS) IIf(lCCCE , cCadOrig += CFDCarEsp(Alltrim(ObtColSAT("S004",AllTrim(SM0->M0_CEPENT),1,5,6,3))) + _aTotal[098], "")
(POS) IIf(lCCCE , cCadOrig += "MEX" + _aTotal[098], "")
(POS) IIf(lCCCE , cCadOrig += AllTrim(SM0->M0_CEPENT) + _aTotal[098], "")

//Receptor Domicilio
(POS) IIf(lCCCE .And. _aTotal[108] == "XEXX010101000", cCadOrig += CFDCarEsp(AllTrim(AllTrim(SF2->F2_IDTRIB))) + _aTotal[098], "")
(POS) IIf(lCCCE, cCadOrig += CFDCarEsp(AllTrim(SA1->A1_END)) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_NR_END)), cCadOrig += AllTrim(SA1->A1_NR_END) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_NROINT)), cCadOrig += AllTrim(SA1->A1_NROINT) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(SA1->A1_BAIRRO))), cCadOrig +=  CFDCarEsp(CFDCarEsp(AllTrim(SA1->A1_BAIRRO))) + _aTotal[098],"")
(POS) IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(SA1->A1_MUN))), cCadOrig +=  CFDCarEsp(AllTrim(SA1->A1_MUN),.F.) + _aTotal[098],"")
(POS) IIf(lCCCE, cCadOrig += CFDCarEsp(Alltrim(Posicione("SX5",1,xFilial("SX5")+"12"+SA1->A1_EST,"X5_DESCRI"))) + _aTotal[098],"")
(POS) IIf(lCCCE, cCadOrig += AllTrim(Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCESAT")) + _aTotal[098], "")
(POS) IIf(lCCCE, cCadOrig += AllTrim(SA1->A1_CEP) + _aTotal[098], "")

//Destinatarios
(POS) IIf(lCCCE .And. FindFunction("LxCEDest") .And. SF2->(ColumnPos("F2_ACOPLA")) > 0, cCadOrig += LxCEDest(SF2->F2_CLIENTE,SF2->F2_LOJA,SF2->F2_ACOPLA, .T.), "")

(POS) cCadOrig += IIf(!Empty(cCadOriCCE), cCadOriCCE, "")

//Carta Porte
(POS) IIf(_aTotal[011],(cCadOrig += LxFunaCaPo(SF2->F2_FILIAL,SF2->F2_DOC,SF2->F2_SERIE,.T.,IIf(ALLTRIM(SF2->F2_TIPODOC) == "21",.T.,.F.),_aTotal[104]),.T.),"")

(POS) (cCadOrig += fXMLFUN("IL",.T., IIf(ALLTRIM(SF2->F2_TIPODOC) == "21",.T.,.F.)),.T.)

(POS) cCadOrig += _aTotal[098]
(POS) _aTotal[033] := cCadOrig

//SELLO
(POS) _aTotal[100] := EVPDigest(cCadOrig,5)
(POS) _aTotal[100] := PrivSignRSA(&(SuperGetMv("MV_CFDDIRS",,""))+SuperGetMv("MV_CFDARQS",,""),_aTotal[100],6,"assinatura")
(POS) _aTotal[100] := ENCODE64(_aTotal[100])
[XXX CABECERA]
Linha1     C 041 0 Chr(239) + Chr(187) + Chr(191) + '<?xml version="1.0" encoding="UTF-8"?>'
[XXX FACTURA]
//Certificado del SAT incluido para pruebas 
(PRE) cCert := "MIIF5TCCA82gAwIBAgIUMDAwMDEwMDAwMDA1MDI2MzYxOTcwDQYJKoZIhvcNAQEL"
(PRE) cCert += "BQAwggGEMSAwHgYDVQQDDBdBVVRPUklEQUQgQ0VSVElGSUNBRE9SQTEuMCwGA1UE"
(PRE) cCert += "CgwlU0VSVklDSU8gREUgQURNSU5JU1RSQUNJT04gVFJJQlVUQVJJQTEaMBgGA1UE"
(PRE) cCert += "CwwRU0FULUlFUyBBdXRob3JpdHkxKjAoBgkqhkiG9w0BCQEWG2NvbnRhY3RvLnRl"
(PRE) cCert += "Y25pY29Ac2F0LmdvYi5teDEmMCQGA1UECQwdQVYuIEhJREFMR08gNzcsIENPTC4g"
(PRE) cCert += "R1VFUlJFUk8xDjAMBgNVBBEMBTA2MzAwMQswCQYDVQQGEwJNWDEZMBcGA1UECAwQ"
(PRE) cCert += "Q0lVREFEIERFIE1FWElDTzETMBEGA1UEBwwKQ1VBVUhURU1PQzEVMBMGA1UELRMM"
(PRE) cCert += "U0FUOTcwNzAxTk4zMVwwWgYJKoZIhvcNAQkCE01yZXNwb25zYWJsZTogQURNSU5J"
(PRE) cCert += "U1RSQUNJT04gQ0VOVFJBTCBERSBTRVJWSUNJT1MgVFJJQlVUQVJJT1MgQUwgQ09O"
(PRE) cCert += "VFJJQlVZRU5URTAeFw0yMDAxMDYyMjIwMzhaFw0yNDAxMDYyMjIwMzhaMIGzMR4w"
(PRE) cCert += "HAYDVQQDExVUT1RWUyBNRVhJQ08gU0EgREUgQ1YxHjAcBgNVBCkTFVRPVFZTIE1F"
(PRE) cCert += "WElDTyBTQSBERSBDVjEeMBwGA1UEChMVVE9UVlMgTUVYSUNPIFNBIERFIENWMSUw"
(PRE) cCert += "IwYDVQQtExxUTUUwMzExMTJCQzAgLyBIRVJNNjcwODI4MkU0MR4wHAYDVQQFExUg"
(PRE) cCert += "LyBIRVJNNjcwODI4SERGUkJOMDMxCjAIBgNVBAsTATEwggEiMA0GCSqGSIb3DQEB"
(PRE) cCert += "AQUAA4IBDwAwggEKAoIBAQDSxcVwA52Ec5xakhUEyuaeozyzccDhukYJuXYDuLxH"
(PRE) cCert += "lDtiTdCE5Bof3c1wVN+EAvTvOBCvXcCOeLgo6EJlc6hArdFIKaiH+Ylf2xmq3u89"
(PRE) cCert += "X1JgwwbrqyTJoC6bw1fbyeDAGVsV7yGRs8YsZ65AU2RKK6L5GiyQKampRpaTiBoU"
(PRE) cCert += "pp5NR+B41+lc46rFI2wQrXGzry+vIkCnyJSH7w0XUgrDChyk8ORLdmQicUY0xkcy"
(PRE) cCert += "b3ql5Uvkd3AF+7RMck8gow8dby10rctjoCN4KY/wyWu5j7PHguH9rgbuOpo14hON"
(PRE) cCert += "Hx7720Eo1KA6GK3jPqVdpG7wfm6EVE0Kf9K7F471wZoRAgMBAAGjHTAbMAwGA1Ud"
(PRE) cCert += "EwEB/wQCMAAwCwYDVR0PBAQDAgbAMA0GCSqGSIb3DQEBCwUAA4ICAQBa+6i9/Qto"
(PRE) cCert += "ouwZNQIOZALwkAzEJfEasxQkm+Ggu2xhNJc75A1/qMxaKi84YCFDMr1eWwjQEs9H"
(PRE) cCert += "nfdwZKjkF/55vgQoTMEZBlemG5IJPwMDy01ho4FAShYG780sdPpa9RMYzjE1o82O"
(PRE) cCert += "226yv5ksy1yBySoGY7NWyRj1f5zCXQfyE8fAwAkaNiMmZYljztWg0cPvEG+gOgFl"
(PRE) cCert += "aLhy9YFMkFp3wEZjn/vZP5tbMvXCm3wRbf5ncJUCbr0xkpkDMIvgV/obTAfllvB0"
(PRE) cCert += "mQuVjLsTTA43NkvmpaV9+yYhvvzD24TOnZE8goB6C1bu8MooyMnVg6+RthZxLmzb"
(PRE) cCert += "syw+FkMzpjfMJU/J5nZL9VAZgdDX4H3wtmupAfKmL1hm95D9s0VA7sSFeAJkPvWG"
(PRE) cCert += "8ZcjlridsAFbSIFcfc8S8+NqBMKNFJsRF4X2Yj2Wxq3ZrNe9lPeq5skot9iJ9bz/"
(PRE) cCert += "1sfVTTqmqw1S3w13aCIqkwzU2aFpC7aMHT13Fx2SK5djvlnR0aHNycGxjA46iq+b"
(PRE) cCert += "vdHtC2Tqf/ZHJB/jeogiUeISbJ+uUHNEbXaE3YLsuhEsbNi7E++MRS/CtUeOxXZx"
(PRE) cCert += "FgnV6luIS1kzu+7aj4WR+m3Gweo6pOuz2s1MhtASDIucGWMyJm30DiWSZkrKmyTr"
(PRE) cCert += "OG6983CcMAhLkT16E0a32/Fn9OgZfiSMsg=="

(PRE) lCCCE := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.) .And. !Empty(SF2->F2_TIPOPE) .And. _aTotal[114], .T., .F.)
(PRE) cNodoCCE := ""

(PRE) If(AllTrim(SF2->F2_ESPECIE)=="NDI",SYA->(MsSeek(xFilial("SYA")+SA2->A2_PAIS)) , .T.)
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF2->F2_COND)) , .T.)
(PRE) (AI0->(MSSeek(xFilial("AI0")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)
(PRE) _aTotal[001] := '<cfdi:Comprobante'
(PRE) _aTotal[001] += ' xmlns:cfdi="http://www.sat.gob.mx/cfd/4"'
(PRE) _aTotal[001] += ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
(PRE) _aTotal[001] += Iif(_aTotal[104],' xmlns:cartaporte20="http://www.sat.gob.mx/CartaPorte20"','')
(PRE) _aTotal[001] += ' xmlns:implocal="http://www.sat.gob.mx/implocal"'
(PRE) _aTotal[001] += IIf(lCCCE .And. SA1->A1_CONTRBE == "1" .And. Alltrim(SF2->F2_ESPECIE) == "NF", ' xmlns:leyendasFisc="http://www.sat.gob.mx/leyendasFiscales"' , "")
(PRE) _aTotal[001] += ' xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd '
(PRE) _aTotal[001] += IIF(lCCCE,'http://www.sat.gob.mx/ComercioExterior11 http://www.sat.gob.mx/sitio_internet/cfd/ComercioExterior11/ComercioExterior11.xsd ','http://www.sat.gob.mx/implocal http://www.sat.gob.mx/sitio_internet/cfd/implocal/implocal.xsd')
(PRE) _aTotal[001] += IIf(_aTotal[104],'http://www.sat.gob.mx/CartaPorte20 http://www.sat.gob.mx/sitio_internet/cfd/CartaPorte/CartaPorte20.xsd','')
(PRE) _aTotal[001] += IIf(lCCCE .And. SA1->A1_CONTRBE == "1" .And. Alltrim(SF2->F2_ESPECIE) == "NF", ' http://www.sat.gob.mx/leyendasFiscales http://www.sat.gob.mx/sitio_internet/cfd/leyendasFiscales/leyendasFisc.xsd"' , '"')
(PRE) _aTotal[001] += IIf(lCCCE, ' xmlns:cce11="http://www.sat.gob.mx/ComercioExterior11"' , "")
(PRE) _aTotal[001] += ' Version="4.0"'
(PRE) _aTotal[001] += ' Serie="' + Alltrim(SF2->F2_SERIE) + '"'
(PRE) _aTotal[001] += ' Folio="' + Alltrim(SF2->F2_DOC) + '"'
(PRE) _aTotal[001] += ' Fecha="' + Alltrim(_aTotal[096]) + '"'
(PRE) _aTotal[001] += ' Sello="' + Alltrim(_aTotal[100]) + '"'
(PRE) _aTotal[001] += IIf(Alltrim(SF2->F2_TIPODOC) == "21", "", ' FormaPago="' +  IIf(SF2->F2_GLOBAL == '1',IIf(!Empty(_aTotal[112]),_aTotal[112],_aTotal[107]),IIf(Empty(_aTotal[107]) .Or. Alltrim(SE4->E4_MPAGSAT) == "PPD","99",_aTotal[107])) + '"' )
(PRE) _aTotal[001] += ' NoCertificado="' + Alltrim(SF2->F2_CERTFOL) + '"'
(PRE) _aTotal[001] += ' Certificado="' + cCert + '"'
(PRE) _aTotal[001] += IIf(Alltrim(SF2->F2_TIPODOC) == "21", "", ' CondicionesDePago="' +  CFDCarEsp(Alltrim(SE4->E4_DESCRI)) + '"' ) 
(PRE) _aTotal[001] += ' SubTotal="' + Alltrim(STR(IIF(ALLTRIM(SF2->F2_TIPODOC) == "21", 0, (SF2->(F2_VALMERC+F2_FRETE+F2_SEGURO+F2_DESPESA)  + _aTotal[103] + SF2->F2_DESCONT) - _aTotal[036] - _aTotal[037] ),14,_aTotal[106])) + '"'
(PRE) _aTotal[001] += IIF(ALLTRIM(SF2->F2_TIPODOC) == "21", "", IIf( SF2->F2_DESCONT == 0, "", ' Descuento="' + Alltrim(STR(SF2->F2_DESCONT,14,2)) + '"' ))
(PRE) _aTotal[001] += ' Moneda="' + IIf(Alltrim(SF2->F2_TIPODOC) == "21","XXX",Alltrim(CTO->CTO_MOESAT)) + '"'
(PRE) _aTotal[001] += IIf(Alltrim(SF2->F2_TIPODOC) == "21", "", ' TipoCambio="' + IIf(Alltrim(CTO->CTO_MOESAT) <> "MXN", Alltrim(STR(SF2->F2_TXMOEDA,14,2)), "1") + '"') 
(PRE) _aTotal[001] += ' Total="' + Alltrim(Str(IIf(Alltrim(SF2->F2_TIPODOC) == "21", 0, IIf(GetSx3Cache("F2_VALBRUT","X3_DECIMAL") <= 2,SF2->F2_VALBRUT + _aTotal[103] - _aTotal[037] - _aTotal[038] - IIf(Len(_aTotal[115]) > 0,_aTotal[115][1],0),Round(SF2->F2_VALBRUT,2) + _aTotal[103] - _aTotal[037] - _aTotal[038] - IIf(Len(_aTotal[115]) > 0,_aTotal[115][1],0))),14,_aTotal[106])) +  '"'
(PRE) _aTotal[001] += ' TipoDeComprobante="' + IIf(Alltrim(SF2->F2_ESPECIE) == "NF",IIf(Alltrim(SF2->F2_TIPODOC) == "21", "T", "I"), "E") + '"'
(PRE) _aTotal[001] += ' Exportacion="'+IIf(!Empty(_aTotal[113]),_aTotal[113],"01")+'"'
(PRE) _aTotal[001] += IIf(Alltrim(SF2->F2_TIPODOC) == "21", "", ' MetodoPago="' +  Alltrim(SE4->E4_MPAGSAT) + '"' )
(PRE) _aTotal[001] += ' LugarExpedicion="' + CFDCarEsp(AllTrim(SM0->M0_CEPENT)) + '"'
(PRE) _aTotal[001] += '>'
(PREREG) _aTotal[001]

(POS) cNodoCCE := IIf(lCCCE, '        <cce11:ComercioExterior' , "")
(POS) cNodoCCE += IIf(lCCCE, ' Version="1.1"' , "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF2->F2_TRASLA), ' MotivoTraslado="' + Alltrim(SF2->F2_TRASLA) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF2->F2_TIPOPE), ' TipoOperacion="' + IIF(Alltrim(SF2->F2_TIPOPE)== "3","2",Alltrim(SF2->F2_TIPOPE)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF2->F2_CVEPED), ' ClaveDePedimento="' + Alltrim(SF2->F2_CVEPED) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF2->F2_CERORI), ' CertificadoOrigen="' + Alltrim(SF2->F2_CERORI) +'"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF2->F2_NUMCER), ' NumCertificadoOrigen="' + Alltrim(SF2->F2_NUMCER) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF2->F2_EXPCONF), ' NumeroExportadorConfiable="' + Alltrim(SF2->F2_EXPCONF) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF2->F2_INCOTER), ' Incoterm="' + Alltrim(SF2->F2_INCOTER) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF2->F2_SUBDIV), ' Subdivision="' + Alltrim(SF2->F2_SUBDIV) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. SF2->(ColumnPos("F2_OBSCE")) > 0 .And. !Empty(SF2->F2_OBSCE), ' Observaciones="' + CFDCarEsp(AllTrim(SF2->F2_OBSCE), .T.) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(Str(SF2->F2_TCUSD)), ' TipoCambioUSD="' + Alltrim(Str(SF2->F2_TCUSD)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(Str(SF2->F2_TOTUSD)), ' TotalUSD="' + Alltrim(Str(SF2->F2_TOTUSD,14,2)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, '>' + ( chr(13)+chr(10) ), "")
(POS) _aTotal[094] := cNodoCCE

[XXX CFDIREL]
(PREREG) !Empty(SF2->F2_RELSAT).Or. !Empty(SF2->F2_SERMAN).Or. !Empty(SF2->F2_DOCMAN)
(PREREG) (_aTotal[001] := IIf(_aTotal[104] .And. Alltrim(SF2->F2_TIPODOC) == "21","",fGetFolRel("S")))
(PREREG) _aTotal[001]

[XXX FACTURA GLOBAL]
(PRE) (_aTotal[001] := IIF(SF2->F2_GLOBAL == "1",'    <cfdi:InformacionGlobal ',""))
(PRE) (_aTotal[001] += Iif(SF2->(ColumnPos("F2_IDCBAJA")) > 0 .and. SF2->F2_GLOBAL == "1" ,' Periodicidad="' + SF2->F2_IDCBAJA  + '"',""))
(PRE) (_aTotal[001] += Iif(SF2->(ColumnPos("F2_MODCONS")) > 0 .and. SF2->F2_GLOBAL == "1" ,' Meses="' + SF2->F2_MODCONS  + '"',""))
(PRE) (_aTotal[001] += Iif(SF2->(ColumnPos("F2_PTOEMIS")) > 0 .and. SF2->F2_GLOBAL == "1" ,' Año="' + SF2->F2_PTOEMIS  + '"',""))
(PRE) (_aTotal[001] += IIF(SF2->F2_GLOBAL == "1",'/>' ,""))
(PRE) (_aTotal[001] := IIF(SF2->F2_GLOBAL == "1",_aTotal[001] ,""))
(PREREG) _aTotal[001]

[XXX EMISOR]
(PRE) (_aTotal[001] := '    <cfdi:Emisor'  , .T.)
(PRE) (_aTotal[001] += ' Rfc="' + CFDCarEsp(AllTrim(SM0->M0_CGC))+ '"'  , .T.)
(PRE) (_aTotal[001] += ' Nombre="' + CFDCarEsp(_aTotal[075],.T.) + '"'  , .T.)
(PRE) (_aTotal[001] += ' RegimenFiscal="' + CFDCarEsp(Alltrim(SM0->M0_DSCCNA)) + '"'  , .T.)
(PRE) (_aTotal[001] += '/>'  , .T.)
(PRE) (_aTotal[001] := _aTotal[001]  , .T.)
(PREREG) _aTotal[001]

[XXX RECEPTOR_CLIENTE]
(PRE) lCCCE := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.)  .And. !Empty(SF2->F2_TIPOPE) .And. _aTotal[114], .T., .F.)
(PRE) cNodoCCE := ""

(PREREG) AllTrim(SF2->F2_ESPECIE) <> "NDI"
(PREREG) (SA1->(MSSeek(xFilial("SA1")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)
(PREREG) (SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS)) , .T.)
(PREREG) (_aTotal[001] := '    <cfdi:Receptor' , .T.)
(PREREG) (_aTotal[001] += ' Rfc="' + CFDCarEsp(IIf(!_aTotal[104] .And.((Alltrim(SF2->F2_TIPODOC) == "21" .And. !lCCCE) .Or. SF2->F2_GLOBAL == "1"), "XAXX010101000", _aTotal[108])) + '"' , .T.)
(PREREG) (_aTotal[001] += ' Nombre="' + iif(SF2->F2_GLOBAL == "1","PUBLICO EN GENERAL",CFDCarEsp(_aTotal[109],.T.)) + '"' , .T.)
(PREREG) (_aTotal[001] += ' DomicilioFiscalReceptor="' + _aTotal[110] + '"' , .T.)
(PREREG) (_aTotal[001] += Iif(AI0->(ColumnPos("AI0_REGFIS")) > 0,' RegimenFiscalReceptor="' + _aTotal[111] + '"',""), .T.)
(PREREG) (_aTotal[001] += ' UsoCFDI="' + Alltrim(SF2->F2_USOCFDI) + '"' , .T.)
(PREREG) IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(AllTrim(SF2->F2_IDTRIB)))) .And. !_aTotal[076], (_aTotal[001] += ' NumRegIdTrib="' + CFDCarEsp(AllTrim(AllTrim(SF2->F2_IDTRIB))) + '"' , .T.), "") 
(PREREG) IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(AllTrim(SF2->F2_RESIDE)))) .And. !_aTotal[076], (_aTotal[001] += ' ResidenciaFiscal="' + AllTrim(Posicione("SYA",1,xFilial("SYA")+SF2->F2_RESIDE,"YA_CCESAT")) + '"' , .T.), "")
(PREREG) (_aTotal[001] += '/>' ,.T.)
(PREREG) (_aTotal[001] := _aTotal[001] , .T.)
(PREREG) _aTotal[001]

(POS) cNodoCCE += IIf(lCCCE, '            <cce11:Emisor' , "")
(POS) cNodoCCE += IIf(lCCCE, '>' + ( chr(13)+chr(10) ), "") 
(POS) cNodoCCE += IIf(lCCCE, '                <cce11:Domicilio' , "")        
(POS) cNodoCCE += IIf(lCCCE, ' Calle="' + CFDCarEsp(AllTrim(SM0->M0_ENDCOB)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(CFDCarEsp(CFDCarEsp(AllTrim(SM0->M0_CEPENT)))), ' Colonia="' + CFDCarEsp(AllTrim(ObtColSAT("S015",AllTrim(SM0->M0_CODZOSE)+ALLTRIM(SM0->M0_CEPENT),1,9,1,4))) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(SM0->M0_CEPENT))), ' Municipio="' + CFDCarEsp(AllTrim(SM0->M0_CODMUN)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' Estado="' + CFDCarEsp(Alltrim(ObtColSAT("S004",AllTrim(SM0->M0_CEPENT),1,5,6,3))) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' Pais="' + AllTrim("MEX") + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' CodigoPostal="' + AllTrim(SM0->M0_CEPENT) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, '/>' + ( chr(13)+chr(10) ), "")
(POS) cNodoCCE += IIf(lCCCE, '            </cce11:Emisor>' + ( chr(13)+chr(10) ), "")
(POS) cNodoCCE += IIf(lCCCE, '            <cce11:Receptor ' + IIf(_aTotal[108]=="XEXX010101000", 'NumRegIdTrib="' + CFDCarEsp(AllTrim(SF2->F2_IDTRIB)) + '"',""), "")     
(POS) cNodoCCE += IIf(lCCCE, '>' + ( chr(13)+chr(10) ), "") 
(POS) cNodoCCE += IIf(lCCCE, '                <cce11:Domicilio' , "")        
(POS) cNodoCCE += IIf(lCCCE, ' Calle="' + CFDCarEsp(AllTrim(SA1->A1_END)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_NR_END)), ' NumeroExterior="' + AllTrim(SA1->A1_NR_END) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_NROINT)), ' NumeroInterior="' + AllTrim(SA1->A1_NROINT) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(SA1->A1_BAIRRO))), ' Colonia="' + CFDCarEsp(AllTrim(SA1->A1_BAIRRO)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_MUN)), ' Municipio="' + CFDCarEsp(AllTrim(SA1->A1_MUN),.T.) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' Estado="' + CFDCarEsp(Alltrim(Posicione("SX5",1,xFilial("SX5")+"12"+SA1->A1_EST,"X5_DESCRI"))) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' Pais="' + AllTrim(Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCESAT")) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' CodigoPostal="' + AllTrim(SA1->A1_CEP) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, '/>' + ( chr(13)+chr(10) ), "")
(POS) cNodoCCE += IIf(lCCCE, '            </cce11:Receptor>' + ( chr(13)+chr(10) ), "") 
//Destintarios
(POS) cNodoCCE += IIf(lCCCE .And. FindFunction("LxCEDest") .And. SF2->(ColumnPos("F2_ACOPLA")) > 0, LxCEDest(SF2->F2_CLIENTE,SF2->F2_LOJA,SF2->F2_ACOPLA,.F.),"")
(POS) (cNodoCCE += IIf(lCCCE, '            <cce11:Mercancias>' + ( chr(13)+chr(10) ), ""),.T.)
(POS) _aTotal[094] += cNodoCCE

[SD2 CONCEPTO]
(PRE) lCCCE    := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.)  .And. !Empty(SF2->F2_TIPOPE) .And. _aTotal[114] , .T., .F.)
(PRE) cNodoCCE := ""

(PRE) DbGoTop()

(PREREG) (cNodoCCE += IIf(lCCCE, '                  <cce11:Mercancia' , ""),.T.)      
(PREREG) (cNodoCCE += IIf(lCCCE , ' NoIdentificacion="' + Alltrim(SD2->D2_ITEM + SD2->D2_COD) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(SD2->D2_FRACCA), ' FraccionArancelaria="' + Alltrim(SD2->D2_FRACCA) + Alltrim(SD2->D2_NICO) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(Str(SD2->D2_CANADU)), ' CantidadAduana="' + Alltrim(Str(SD2->D2_CANADU)) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(SD2->D2_FRACCA), ' UnidadAduana="' + AllTrim(ObtColSAT("S014",AllTrim(SD2->D2_FRACCA),1,8,9,2)) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(Str(SD2->D2_VALADU)), ' ValorUnitarioAduana="' + Alltrim(Str(SD2->D2_VALADU,14,2)) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE, ' ValorDolares="' + Alltrim(Str(SD2->D2_USDADU,14,2)) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE, '>' + ( chr(13)+chr(10) ) , ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE, '                  </cce11:Mercancia>' + ( chr(13)+chr(10) ), ""),.T.)

(POS) (cNodoCCE += IIf(lCCCE, '            </cce11:Mercancias>' + ( chr(13)+chr(10) ), ""),.T.)
(POS) (cNodoCCE += IIf(lCCCE, '        </cce11:ComercioExterior>' , ""),.T.)
(POS) _aTotal[094] += cNodoCCE

(POS) (_aTotal[034] := fXMLFUN("CO",.F., IIf(ALLTRIM(SF2->F2_TIPODOC) == "21",.T.,.F.),_aTotal[104]),.T.)
 
[XXX CONCEPTOS]
(POS) FsQuery(_aTotal[097],2)

(PREREG) (_aTotal[001] := _aTotal[034] ,.T.)
(PREREG) _aTotal[001]

[XXX IMPUESTOS]
(PREREG) (_aTotal[002] := fXMLFUN("TI",.F.,IIf(ALLTRIM(SF2->F2_TIPODOC) == "21",.T.,.F.)),.T.)
(PREREG) _aTotal[002]

//IMPUESTOS LOCALES//
(PRE) (_aTotal[095] := fXMLFUN("IL",.F.),.T.)

[XXX COMPLEMENT]
(PREREG) IIf(_aTotal[011],_aTotal[105] := LxFunaCaPo(SF2->F2_FILIAL,SF2->F2_DOC,SF2->F2_SERIE,.F.,IIf(ALLTRIM(SF2->F2_TIPODOC) == "21",.T.,.F.),_aTotal[104]),"")
(PREREG) (_aTotal[001] := IIF(!EMPTY(_aTotal[094] ) .or. !EMPTY(_aTotal[095] ) .Or. !Empty(_aTotal[105]) .or. _aTotal[104] , '    <cfdi:Complemento', ""), .T.)
(PREREG) (_aTotal[001] += IIF(!EMPTY(_aTotal[094] ) .or. !EMPTY(_aTotal[095] ) .Or. !Empty(_aTotal[105]),'>',""),.T.)
(PREREG) _aTotal[001]
COMPLEMENT  C 021 0 ENCODEUTF8(XMLConv("",,,"cfdi:Complemento",.T.,.F.,4))


[XXX COMERCIOEX]
(PREREG) (_aTotal[001] := _aTotal[094],.T.)
(PREREG) _aTotal[001]

[XXX CARTAPORTE]
(PREREG) (_aTotal[001] := _aTotal[105],.T.)
(PREREG) _aTotal[001]

[XXX IMPUESTOLOC]
(PREREG) (_aTotal[001] := _aTotal[095],.T.)
(PREREG) _aTotal[001]

[XXX LEYENDASFIS]
(PREREG) lCCCE := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.)  .And. !Empty(SF2->F2_TIPOPE) .And. _aTotal[114], .T., .F.) .And. SF2->(FieldPos("F2_CONUNI")) > 0
(PREREG) lCCCE
(PREREG) (_aTotal[001] := IIF((!EMPTY(_aTotal[094] ) .or. !EMPTY(_aTotal[095])) .And. !EMPTY(SF2->F2_CONUNI) .And. SA1->A1_CONTRBE == "1" .And. Alltrim(SF2->F2_ESPECIE) == "NF" , '        <leyendasFisc:LeyendasFiscales version="1.0" >'+ ( chr(13)+chr(10) ), ""), .T.)
(PREREG) (_aTotal[001] += IIF((!EMPTY(_aTotal[094] ) .or. !EMPTY(_aTotal[095])) .And. !EMPTY(SF2->F2_CONUNI) .And. SA1->A1_CONTRBE == "1" .And. Alltrim(SF2->F2_ESPECIE) == "NF" , '            <leyendasFisc:Leyenda textoLeyenda=', ""), .T.)
(PREREG) (_aTotal[001] += IIF((!EMPTY(_aTotal[094] ) .or. !EMPTY(_aTotal[095])) .And. SF2->F2_CONUNI=="1" .And. SA1->A1_CONTRBE == "1" .And. Alltrim(SF2->F2_ESPECIE) == "NF", '"IMMEX:'+ AllTrim(SA1->A1_PFISICA) +' ' + _aTotal[101] +'" />', IIF((!EMPTY(_aTotal[094] ) .or. !EMPTY(_aTotal[095])) .And. SF2->F2_CONUNI=="2" .And. SA1->A1_CONTRBE == "1" .And. Alltrim(SF2->F2_ESPECIE) == "NF",'"IMMEX:'+ AllTrim(SA1->A1_PFISICA) + ' ' + _aTotal[102] +'" />',"")), .T.)
(PREREG) _aTotal[001]
(PREREG) (_aTotal[001] := IIF((!EMPTY(_aTotal[094] ) .or. !EMPTY(_aTotal[095])) .And. !EMPTY(SF2->F2_CONUNI) .And. SA1->A1_CONTRBE == "1" .And. Alltrim(SF2->F2_ESPECIE) == "NF",'        </leyendasFisc:LeyendasFiscales>', ""), .T.)
(PREREG) _aTotal[001]


[XXX COMPLEMENT]
(PREREG) (_aTotal[001] := IIF(!EMPTY(_aTotal[094]) .or. !EMPTY(_aTotal[095]) .or. !EMPTY(_aTotal[105]),'    </cfdi:Complemento>',""), .T.)
(PREREG) _aTotal[001]
COMPLEMENT  C 021 0 ENCODEUTF8(XMLConv("",,,"cfdi:Complemento",.F.,.T.,4))

//[XXX CAD_ORIG]
//(PREREG) _aTotal[033] 

[XXX FACTURA]
(PRE) _aTotal[095] := &(GetNewPar("MV_CFDNAF2","Lower(AllTrim(SF2->F2_ESPECIE)) + '_' + Lower(AllTrim(SF2->F2_SERIE)) + '_'  + Lower(AllTrim(SF2->F2_DOC)) + '.xml'"))
(ARQ) _aTotal[095]
FACTURA    C 019 0 ENCODEUTF8(XMLConv("",,,"cfdi:Comprobante",.F.,.T.,0))



Si se tiene la funcionalidad de uso del archivo de Generación de XML para Documentos de Entrada (FATEMEX.INI), se deben realizar los siguientes ajustes para hacer uso de la funcion FxDelExp().

Informações

//FATEMEX.INI V4.0 --- Modelo 2022
[XXX POSICIONAMENTOS]
(PRE) If(AllTrim(SF1->F1_ESPECIE)=="NCC",SA2->(MSSeek(xFilial("SA2")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)
(PRE) If(AllTrim(SF1->F1_ESPECIE)<>"NCC",SA1->(MSSeek(xFilial("SA1")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF1->F1_COND)) , .T.)
(PRE) (AI0->(MSSeek(xFilial("AI0")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)

[XXX INICIALIZACION]
(PRE) SD1->(DbSetOrder(1))
(PRE) SB1->(DbSetOrder(1))
(PRE) SYA->(DbSetOrder(1))
(PRE) SC6->(DbSetOrder(1))
(PRE) SE4->(DbSetOrder(1)) 
(PRE) CTO->(DbSetOrder(1)) 
(PRE) SAH->(DbSetOrder(1)) 
(PRE) _aTotal[094] := ""
(PRE) _aTotal[095] := ""
(PRE) _aTotal[033] := ""
(PRE) _aTotal[034] := ""
(PRE) _aTotal[035] := ""
(PRE) _aTotal[036] := 0
(PRE) _aTotal[037] := SuperGetMV("MV_CFDIEXP",.F.,.F.)
(PRE) _aTotal[075] := Alltrim(SM0->M0_NOMECOM)
(PRE) _aTotal[096] := DtoS(SF1->F1_EMISSAO)
(PRE) _aTotal[096] := Left(_aTotal[096],4) + "-" + Substr(_aTotal[096],5,2)+ "-" + Right(_aTotal[096],2)
(PRE) _aTotal[096] += "T" + SF1->F1_HORA
(PRE) _aTotal[097] := {"SD1",""}
(PRE) _aTotal[098] := "|"
(PRE) _aTotal[099] := "||"
(PRE) _aTotal[100] := ""
(PRE) _aTotal[101] := IIF(SuperGetMv("MV_DESCSAI",.T.,"2") == "1", .T., .F.) 
(PRE) _aTotal[102] := IIf(SF1->(ColumnPos("F1_TPDOC")) > 0,AllTrim(SF1->F1_TPDOC),AllTrim(AI0->AI0_MPAGO))                                                                                                          
(PRE) lCCCE := .F.
(PRE) cNodoCCE := ""
(PRE) _aTotal[103] := IIf(!_aTotal[037] .Or. (_aTotal[037] .And. Empty(SF1->F1_CVEPED)),"01",IIf(SF1->F1_CVEPED!="A1" .or. Alltrim(SF1->F1_TIPOPE)== "3","04","02"))
(PRE) _aTotal[104] := IIf(_aTotal[103] == "04" .And.( Empty(SF1->F1_CERORI) .Or. Empty(SF1->F1_INCOTER) .Or. Empty(SF1->F1_SUBDIV) .Or. Empty(SF1->F1_TCUSD) .Or. Empty(SF1->F1_TOTUSD)) ,.F.,.T.)
(PRE) _aTotal[105] := IIf(FindFunction("FxDelExp"),FxDelExp(SA1->A1_NOME),SA1->A1_NOME)    

(PREREG) FsQuery(_aTotal[097],1,"D1_DOC='" + SF1->F1_DOC + "' AND D1_SERIE='" + SF1->F1_SERIE + "' AND D1_FORNECE='" + SF1->F1_FORNECE + "' AND D1_LOJA='" + SF1->F1_LOJA + "'","SD1->D1_DOC=SF1->F1_DOC .AND. SD1->D1_SERIE=SF1->F1_SERIE .AND. SD1->D1_FORNECE=SF1->F1_FORNECE .AND. SD1->D1_LOJA=SF1->F1_LOJA","D1_ITEM") .And. .T.

(PRE) fImptosD(SF1->F1_DOC,SF1->F1_SERIE,SF1->F1_FORNECE,SF1->F1_LOJA, .F. , "SD1", .F., @(_aTotal[036]))

[SD1 CADENAORIGINAL_SELLO]
(PRE) If(AllTrim(SF1->F1_ESPECIE)=="NCC",SA1->(MSSeek(xFilial("SA1")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)
(PRE) If(AllTrim(SF1->F1_ESPECIE)=="NCC",SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS)) , .T.)
(PRE) If(AllTrim(SF1->F1_ESPECIE)=="NCC",CTO->(MsSeek(xFilial("CTO")+Strzero(SF1->F1_MOEDA,2))) , .T.)
(PRE) If(AllTrim(SF1->F1_ESPECIE)<>"NCC",SA2->(MSSeek(xFilial("SA2")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)
(PRE) If(AllTrim(SF1->F1_ESPECIE)<>"NCC",SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS)) , .T.)
(PRE) If(AllTrim(SF1->F1_ESPECIE)<>"NCC",CTO->(MsSeek(xFilial("CTO")+Strzero(SF1->F1_MOEDA,2))) , .T.)
//////////////////////////////////////////////CADENA ORIGINAL//////////////////////////////////////////////
(PRE) cCadOrig := _aTotal[099]
(PRE) lCCCE := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.) .And. !Empty(SF1->F1_TIPOPE) .And. _aTotal[104] , .T., .F.)
(PRE) cCadOriCCE := ""

//Cadena Original | Complemento de Comercio Exterior
(PREREG) IIf(lCCCE .And. !Empty(SD1->D1_ITEM + SD1->D1_COD), (cCadOriCCE += Alltrim(SD1->D1_ITEM + SD1->D1_COD) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(SD1->D1_FRACCA), (cCadOriCCE += Alltrim(SD1->D1_FRACCA) + Alltrim(SD1->D1_NICO) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(Str(SD1->D1_CANADU)), (cCadOriCCE += Alltrim(Str(SD1->D1_CANADU)) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(SD1->D1_FRACCA), (cCadOriCCE += AllTrim(ObtColSAT("S014",AllTrim(SD1->D1_FRACCA),1,8,9,2))  + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(Str(SD1->D1_VALADU)), (cCadOriCCE += Alltrim(Str(SD1->D1_VALADU,14,2)) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !Empty(Str(SD1->D1_USDADU)), (cCadOriCCE += Alltrim(Str(SD1->D1_USDADU,14,2)) + _aTotal[098],.T.), ("",,.T.))

//Cadena Original | Complemento de Comercio Exterior
(POS) IIf(lCCCE, cCadOrig += "1.1" + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF1->F1_TRASLA), cCadOrig += Alltrim(SF1->F1_TRASLA) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF1->F1_TIPOPE), cCadOrig += IIF(Alltrim(SF1->F1_TIPOPE)== "3","2",Alltrim(SF1->F1_TIPOPE)) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF1->F1_CVEPED), cCadOrig += Alltrim(SF1->F1_CVEPED) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF1->F1_CERORI), cCadOrig += Alltrim(SF1->F1_CERORI) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF1->F1_NUMCER), cCadOrig += Alltrim(SF1->F1_NUMCER) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF1->F1_EXPCONF), cCadOrig += Alltrim(SF1->F1_EXPCONF) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF1->F1_INCOTER), cCadOrig += Alltrim(SF1->F1_INCOTER) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SF1->F1_SUBDIV), cCadOrig += Alltrim(SF1->F1_SUBDIV) + _aTotal[098], "")
(POS) IIf(lCCCE .And. SF1->(ColumnPos("F1_OBSCE")) > 0 .And. !Empty(SF1->F1_OBSCE), cCadOrig += CFDCarEsp(Alltrim(SF1->F1_OBSCE),.F.) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(Str(SF1->F1_TCUSD)), cCadOrig += Alltrim(Str(SF1->F1_TCUSD)) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(Str(SF1->F1_TOTUSD)), cCadOrig += Alltrim(Str(SF1->F1_TOTUSD,14,2)) + _aTotal[098], "")

///////////DATOS DE LA FACTURA/////////////////
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF1->F1_COND)) , .T.)
(PRE) (AI0->(MSSeek(xFilial("AI0")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)
//Version
(PRE) cCadOrig += "4.0" + _aTotal[098]
//Serie
(PRE) cCadOrig += Alltrim(SF1->F1_SERIE) + _aTotal[098]
//Folio
(PRE) cCadOrig += Alltrim(SF1->F1_DOC) + _aTotal[098]
//Fecha
(PRE) cCadOrig += Alltrim(_aTotal[096]) + _aTotal[098]
//FormaPago
(PRE) cCadOrig += IIf(Empty(_aTotal[102]),"99",_aTotal[102]) + _aTotal[098]
//NoCertificado
(PRE) cCadOrig += Alltrim(SF1->F1_CERTFOL) + _aTotal[098]
//CondicionesDePago
(PRE) cCadOrig += CFDCarEsp(Alltrim(SE4->E4_DESCRI)) + _aTotal[098]
//Subtotal
(PRE) cCadOrig += Alltrim(STR((SF1->F1_VALMERC + IIF(_aTotal[101], SF1->F1_DESCONT, 0 )) - _aTotal[036],14,2)) + _aTotal[098]
//Descuento
(PRE) cCadOrig += IIf(SF1->F1_DESCONT==0, "", Alltrim(STR(SF1->F1_DESCONT,14,2)) + _aTotal[098])
//Moneda
(PRE) cCadOrig += Alltrim(CTO->CTO_MOESAT) + _aTotal[098]
//TipoCambio
(PRE) cCadOrig += IIf(!(Alltrim(CTO->CTO_MOESAT) $ "MXN|XXX"), Alltrim(STR(SF1->F1_TXMOEDA,14,2)), "1") + _aTotal[098]
//Total
(PRE) cCadOrig += Alltrim(STR(iif(GetSx3Cache("F1_VALBRUT","X3_DECIMAL")<= 2,SF1->F1_VALBRUT,Round(SF1->F1_VALBRUT,2)),14,2)) + _aTotal[098]
//TipoDeComprobante
(PRE) cCadOrig += IIf(Alltrim(SF1->F1_ESPECIE) == "NF", "I", "E") + _aTotal[098]
//Exportacion
(PRE) cCadOrig += IIf(!Empty(_aTotal[103]) .And. Alltrim(SF1->F1_ESPECIE) == "NCC",_aTotal[103],"01") + _aTotal[098]
//MetodoPago
(PRE) cCadOrig += IIf(Alltrim(SF1->F1_TIPODOC) == "21", "", Alltrim(SE4->E4_MPAGSAT) + _aTotal[098] )
//LugarExpedicion
(PRE) cCadOrig += CFDCarEsp(AllTrim(SM0->M0_CEPENT)) + _aTotal[098]
//Confirmacion
//(PRE) cCadOrig += "ClavePAC" + _aTotal[098]

//////////////////////CFDI Relacionados//////////////////////////
(PREREG) !Empty(SF1->F1_RELSAT).Or. !Empty(SF1->F1_SERMAN).Or. !Empty(SF1->F1_DOCMAN)
(PRE) fGetFolRel("E",.T.)

///////////DATOS DEL EMISOR///////////////////////
//Rfc
(PRE) cCadOrig += CFDCarEsp(AllTrim(SM0->M0_CGC),.F.) + _aTotal[098]
//Nombre
(PRE) cCadOrig += CFDCarEsp(_aTotal[075],.F.) + _aTotal[098]
//RegimenFiscal
(PRE) cCadOrig += CFDCarEsp(Alltrim(SM0->M0_DSCCNA)) + _aTotal[098]

//////////////////////DATOS DEL RECEPTOR//////////////////////////
(PRE) AllTrim(SF1->F1_ESPECIE) == "NCC"
(PRE) SA1->(MSSeek(xFilial("SA1")+SF1->F1_FORNECE+SF1->F1_LOJA))
(PRE) SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS))
//Rfc
(PRE) (cCadOrig += CFDCarEsp(AllTrim(SA1->A1_CGC), .F.) + _aTotal[098], .T.)
//Nombre
(PRE) (cCadOrig += CFDCarEsp(Alltrim(_aTotal[105]),.F.) + _aTotal[098], .T.)
//DomicilioFiscalReceptor
(PRE) (cCadOrig += CFDCarEsp(Alltrim(SA1->A1_CEP),.F.) + _aTotal[098], .T.)
//ResidenciaFiscal
(PRE) IIf(lCCCE,(cCadOrig += Alltrim(SYA->YA_CCESAT) + _aTotal[098], .T.),"")
//NumRegIdTrib
(PRE) IIf(lCCCE,(cCadOrig += Alltrim(AI0->AI0_IDFIS) + _aTotal[098], .T.),"")
//RegimenFiscalReceptor
(PRE) (cCadOrig += IIf(AI0->(ColumnPos("AI0_REGFIS")) > 0,CFDCarEsp(Alltrim(AI0->AI0_REGFIS),.F.) + _aTotal[098],""), .T.)
//UsoCFDI
(PRE) (cCadOrig += Alltrim(SF1->F1_USOCFDI) + _aTotal[098], .T.)

(PRE) (cCadOrig += fXMLFUN("CO",.T.,  .F. ,.F.))
(PRE) (cCadOrig += fXMLFUN("TI",.T.,  .F. ,.T.))
(PRE) (cCadOrig += fXMLFUN("IL",.T.,  .F. ,.T.))

//Cadena Original | Complemento de Comercio Exterior

//Emisor
(POS) IIf(lCCCE, cCadOrig += CFDCarEsp(AllTrim(SM0->M0_ENDCOB)) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SM0->M0_BAIRENT), cCadOrig += ObtColSAT("S015",AllTrim(SM0->M0_CEPENT),5,5,1,4) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(SM0->M0_CODMUN), cCadOrig += AllTrim(SM0->M0_CODMUN) + _aTotal[098], "")
(POS) IIf(lCCCE, cCadOrig += CFDCarEsp(Alltrim(ObtColSAT("S004",AllTrim(SM0->M0_CEPENT),1,5,6,3))) + _aTotal[098], "")
(POS) IIf(lCCCE, cCadOrig += "MEX" + _aTotal[098], "")
(POS) IIf(lCCCE, cCadOrig += AllTrim(SM0->M0_CEPENT) + _aTotal[098], "")

//Receptor Domicilio
(POS) IIf(lCCCE .And. AllTrim(SA1->A1_CGC) == "XEXX010101000", cCadOrig += CFDCarEsp(AllTrim(AllTrim(SF1->F1_IDTRIB))) + _aTotal[098], "")
(POS) IIf(lCCCE, cCadOrig += CFDCarEsp(AllTrim(SA1->A1_END)) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_NR_END)), cCadOrig += AllTrim(SA1->A1_NR_END) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_NROINT)), cCadOrig += AllTrim(SA1->A1_NROINT) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(SA1->A1_BAIRRO))), cCadOrig +=  CFDCarEsp(CFDCarEsp(AllTrim(SA1->A1_BAIRRO))) + _aTotal[098],"")
(POS) IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(SA1->A1_MUN))), cCadOrig +=  CFDCarEsp(AllTrim(SA1->A1_MUN),.F.) + _aTotal[098],"")
(POS) IIf(lCCCE, cCadOrig += CFDCarEsp(Alltrim(Posicione("SX5",1,xFilial("SX5")+"12"+SA1->A1_EST,"X5_DESCRI"))) + _aTotal[098],"")
(POS) IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_PAIS)), cCadOrig += AllTrim(Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCESAT")) + _aTotal[098], "")
(POS) IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_CEP)), cCadOrig += AllTrim(SA1->A1_CEP) + _aTotal[098], "")

(POS) cCadOrig += IIf(!Empty(cCadOriCCE), cCadOriCCE, "")

(POS) cCadOrig += _aTotal[098]
(POS) _aTotal[033] := cCadOrig

//SELLO
(POS) _aTotal[100] := EVPDigest(cCadOrig,5)
(POS) _aTotal[100] := PrivSignRSA(&(SuperGetMv("MV_CFDDIRS",,""))+SuperGetMv("MV_CFDARQS",,""),_aTotal[100],6,"assinatura")
(POS) _aTotal[100] := ENCODE64(_aTotal[100])

[XXX CABECERA]
Linha1     C 041 0 Chr(239) + Chr(187) + Chr(191) + '<?xml version="1.0" encoding="UTF-8"?>'

[XXX FACTURA]
//Certificado del SAT incluido para pruebas 
(PRE) cCert := "MIIF5TCCA82gAwIBAgIUMDAwMDEwMDAwMDA1MDI2MzYxOTcwDQYJKoZIhvcNAQEL"
(PRE) cCert += "BQAwggGEMSAwHgYDVQQDDBdBVVRPUklEQUQgQ0VSVElGSUNBRE9SQTEuMCwGA1UE"
(PRE) cCert += "CgwlU0VSVklDSU8gREUgQURNSU5JU1RSQUNJT04gVFJJQlVUQVJJQTEaMBgGA1UE"
(PRE) cCert += "CwwRU0FULUlFUyBBdXRob3JpdHkxKjAoBgkqhkiG9w0BCQEWG2NvbnRhY3RvLnRl"
(PRE) cCert += "Y25pY29Ac2F0LmdvYi5teDEmMCQGA1UECQwdQVYuIEhJREFMR08gNzcsIENPTC4g"
(PRE) cCert += "R1VFUlJFUk8xDjAMBgNVBBEMBTA2MzAwMQswCQYDVQQGEwJNWDEZMBcGA1UECAwQ"
(PRE) cCert += "Q0lVREFEIERFIE1FWElDTzETMBEGA1UEBwwKQ1VBVUhURU1PQzEVMBMGA1UELRMM"
(PRE) cCert += "U0FUOTcwNzAxTk4zMVwwWgYJKoZIhvcNAQkCE01yZXNwb25zYWJsZTogQURNSU5J"
(PRE) cCert += "U1RSQUNJT04gQ0VOVFJBTCBERSBTRVJWSUNJT1MgVFJJQlVUQVJJT1MgQUwgQ09O"
(PRE) cCert += "VFJJQlVZRU5URTAeFw0yMDAxMDYyMjIwMzhaFw0yNDAxMDYyMjIwMzhaMIGzMR4w"
(PRE) cCert += "HAYDVQQDExVUT1RWUyBNRVhJQ08gU0EgREUgQ1YxHjAcBgNVBCkTFVRPVFZTIE1F"
(PRE) cCert += "WElDTyBTQSBERSBDVjEeMBwGA1UEChMVVE9UVlMgTUVYSUNPIFNBIERFIENWMSUw"
(PRE) cCert += "IwYDVQQtExxUTUUwMzExMTJCQzAgLyBIRVJNNjcwODI4MkU0MR4wHAYDVQQFExUg"
(PRE) cCert += "LyBIRVJNNjcwODI4SERGUkJOMDMxCjAIBgNVBAsTATEwggEiMA0GCSqGSIb3DQEB"
(PRE) cCert += "AQUAA4IBDwAwggEKAoIBAQDSxcVwA52Ec5xakhUEyuaeozyzccDhukYJuXYDuLxH"
(PRE) cCert += "lDtiTdCE5Bof3c1wVN+EAvTvOBCvXcCOeLgo6EJlc6hArdFIKaiH+Ylf2xmq3u89"
(PRE) cCert += "X1JgwwbrqyTJoC6bw1fbyeDAGVsV7yGRs8YsZ65AU2RKK6L5GiyQKampRpaTiBoU"
(PRE) cCert += "pp5NR+B41+lc46rFI2wQrXGzry+vIkCnyJSH7w0XUgrDChyk8ORLdmQicUY0xkcy"
(PRE) cCert += "b3ql5Uvkd3AF+7RMck8gow8dby10rctjoCN4KY/wyWu5j7PHguH9rgbuOpo14hON"
(PRE) cCert += "Hx7720Eo1KA6GK3jPqVdpG7wfm6EVE0Kf9K7F471wZoRAgMBAAGjHTAbMAwGA1Ud"
(PRE) cCert += "EwEB/wQCMAAwCwYDVR0PBAQDAgbAMA0GCSqGSIb3DQEBCwUAA4ICAQBa+6i9/Qto"
(PRE) cCert += "ouwZNQIOZALwkAzEJfEasxQkm+Ggu2xhNJc75A1/qMxaKi84YCFDMr1eWwjQEs9H"
(PRE) cCert += "nfdwZKjkF/55vgQoTMEZBlemG5IJPwMDy01ho4FAShYG780sdPpa9RMYzjE1o82O"
(PRE) cCert += "226yv5ksy1yBySoGY7NWyRj1f5zCXQfyE8fAwAkaNiMmZYljztWg0cPvEG+gOgFl"
(PRE) cCert += "aLhy9YFMkFp3wEZjn/vZP5tbMvXCm3wRbf5ncJUCbr0xkpkDMIvgV/obTAfllvB0"
(PRE) cCert += "mQuVjLsTTA43NkvmpaV9+yYhvvzD24TOnZE8goB6C1bu8MooyMnVg6+RthZxLmzb"
(PRE) cCert += "syw+FkMzpjfMJU/J5nZL9VAZgdDX4H3wtmupAfKmL1hm95D9s0VA7sSFeAJkPvWG"
(PRE) cCert += "8ZcjlridsAFbSIFcfc8S8+NqBMKNFJsRF4X2Yj2Wxq3ZrNe9lPeq5skot9iJ9bz/"
(PRE) cCert += "1sfVTTqmqw1S3w13aCIqkwzU2aFpC7aMHT13Fx2SK5djvlnR0aHNycGxjA46iq+b"
(PRE) cCert += "vdHtC2Tqf/ZHJB/jeogiUeISbJ+uUHNEbXaE3YLsuhEsbNi7E++MRS/CtUeOxXZx"
(PRE) cCert += "FgnV6luIS1kzu+7aj4WR+m3Gweo6pOuz2s1MhtASDIucGWMyJm30DiWSZkrKmyTr"
(PRE) cCert += "OG6983CcMAhLkT16E0a32/Fn9OgZfiSMsg=="

(PRE) lCCCE := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.) .And. !Empty(SF1->F1_TIPOPE) .And. _aTotal[104], .T., .F.)
(PRE) cNodoCCE := ""

(PRE) If(AllTrim(SF1->F1_ESPECIE)=="NCC",SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS)) , .T.)
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF1->F1_COND)) , .T.)
(PRE) (AI0->(MSSeek(xFilial("AI0")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)
(PRE) _aTotal[001] := '<cfdi:Comprobante'
(PRE) _aTotal[001] += ' xmlns:cfdi="http://www.sat.gob.mx/cfd/4"'
(PRE) _aTotal[001] += ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
(PRE) _aTotal[001] += ' xmlns:implocal="http://www.sat.gob.mx/implocal"'
(PRE) _aTotal[001] += ' xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd http://www.sat.gob.mx/implocal http://www.sat.gob.mx/sitio_internet/cfd/implocal/implocal.xsd '
(PRE) _aTotal[001] += IIF(lCCCE,'http://www.sat.gob.mx/ComercioExterior11 http://www.sat.gob.mx/sitio_internet/cfd/ComercioExterior11/ComercioExterior11.xsd "','"')
(PRE) _aTotal[001] += IIf(lCCCE, ' xmlns:cce11="http://www.sat.gob.mx/ComercioExterior11"' , "")
(PRE) _aTotal[001] += ' Version="4.0"'
(PRE) _aTotal[001] += ' Serie="' + Alltrim(SF1->F1_SERIE) + '"'
(PRE) _aTotal[001] += ' Folio="' + Alltrim(SF1->F1_DOC) + '"'
(PRE) _aTotal[001] += ' Fecha="' + Alltrim(_aTotal[096]) + '"'
(PRE) _aTotal[001] += ' Sello="' + Alltrim(_aTotal[100]) + '"'
(PRE) _aTotal[001] += ' FormaPago="' + Iif(Empty(_aTotal[102]),"99",_aTotal[102]) + '"'
(PRE) _aTotal[001] += ' NoCertificado="' + Alltrim(SF1->F1_CERTFOL) + '"'
(PRE) _aTotal[001] += ' Certificado="' + cCert + '"'
(PRE) _aTotal[001] += ' CondicionesDePago="' + CFDCarEsp(Alltrim(SE4->E4_DESCRI)) + '"'
(PRE) _aTotal[001] += ' SubTotal="' + Alltrim(STR((SF1->F1_VALMERC + IIF(_aTotal[101], SF1->F1_DESCONT, 0 )) - _aTotal[036],14,2)) + '"'
(PRE) _aTotal[001] += IIf(SF1->F1_DESCONT==0, "", ' Descuento="' + Alltrim(STR(SF1->F1_DESCONT,14,2)) + '"')
(PRE) _aTotal[001] += ' Moneda="' + Alltrim(CTO->CTO_MOESAT) + '"'
(PRE) _aTotal[001] += ' TipoCambio="' + IIf(Alltrim(CTO->CTO_MOESAT) <> "MXN", Alltrim(STR(SF1->F1_TXMOEDA,14,2)), "1") + '"'
(PRE) _aTotal[001] += ' Total="' + Alltrim(STR(iif(GetSx3Cache("F1_VALBRUT","X3_DECIMAL")<= 2,SF1->F1_VALBRUT,Round(SF1->F1_VALBRUT,2)),14,2)) + '"'
(PRE) _aTotal[001] += ' TipoDeComprobante="' + IIf(Alltrim(SF1->F1_ESPECIE) == "NF", "I", "E") + '"'
(PRE) _aTotal[001] += ' Exportacion="'+ IIf(!Empty(_aTotal[103]) .And. Alltrim(SF1->F1_ESPECIE) == "NCC",_aTotal[103],"01") +'"'
(PRE) _aTotal[001] += IIf(Alltrim(SF1->F1_TIPODOC) == "21", "", ' MetodoPago="' + Alltrim(SE4->E4_MPAGSAT) + '"' )
(PRE) _aTotal[001] += ' LugarExpedicion="' + CFDCarEsp(AllTrim(SM0->M0_CEPENT)) + '"'
(PRE) _aTotal[001] += '>'
(PREREG) _aTotal[001]

(POS) cNodoCCE := IIf(lCCCE, '        <cce11:ComercioExterior' , "")
(POS) cNodoCCE += IIf(lCCCE, ' Version="1.1"' , "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF1->F1_TRASLA), ' MotivoTraslado="' + Alltrim(SF1->F1_TRASLA) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF1->F1_TIPOPE), ' TipoOperacion="' + IIF(Alltrim(SF1->F1_TIPOPE)== "3","2",Alltrim(SF1->F1_TIPOPE)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF1->F1_CVEPED), ' ClaveDePedimento="' + Alltrim(SF1->F1_CVEPED) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF1->F1_CERORI), ' CertificadoOrigen="' + Alltrim(SF1->F1_CERORI) +'"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF1->F1_NUMCER), ' NumCertificadoOrigen="' + Alltrim(SF1->F1_NUMCER) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF1->F1_EXPCONF), ' NumeroExportadorConfiable="' + Alltrim(SF1->F1_EXPCONF) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF1->F1_INCOTER), ' Incoterm="' + Alltrim(SF1->F1_INCOTER) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(SF1->F1_SUBDIV), ' Subdivision="' + Alltrim(SF1->F1_SUBDIV) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. SF1->(ColumnPos("F1_OBSCE")) > 0 .And. !Empty(SF1->F1_OBSCE), ' Observaciones="' + CFDCarEsp(Alltrim(SF1->F1_OBSCE), .F.) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(Str(SF1->F1_TCUSD)), ' TipoCambioUSD="' + Alltrim(Str(SF1->F1_TCUSD)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(Str(SF1->F1_TOTUSD)), ' TotalUSD="' + Alltrim(Str(SF1->F1_TOTUSD,14,2)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, '>' + ( chr(13)+chr(10) ), "")
(POS) _aTotal[094] := cNodoCCE

[XXX CFDIREL]
(PREREG) !Empty(SF1->F1_RELSAT).Or. !Empty(SF1->F1_SERMAN).Or. !Empty(SF1->F1_DOCMAN)
(PREREG) (_aTotal[001] := fGetFolRel("E"),.T.)
(PREREG) _aTotal[001]

[XXX EMISOR]
(PRE) _aTotal[001] := '    <cfdi:Emisor'
(PRE) _aTotal[001] += ' Rfc="' + CFDCarEsp(AllTrim(SM0->M0_CGC)) + '"'
(PRE) _aTotal[001] += ' Nombre="' + CFDCarEsp(_aTotal[075],.T.) + '"'
(PRE) _aTotal[001] += ' RegimenFiscal="' + CFDCarEsp(Alltrim(SM0->M0_DSCCNA)) + '"'
(PRE) _aTotal[001] += '/>'
(PREREG) _aTotal[001]

[XXX RECEPTOR_CLIENTE]
(PRE) lCCCE := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.)  .And. !Empty(SF1->F1_TIPOPE) .And. _aTotal[104], .T., .F.)
(PRE) cNodoCCE := ""

(PREREG) AllTrim(SF1->F1_ESPECIE) == "NCC"
(PREREG) (SA1->(MSSeek(xFilial("SA1")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)
(PREREG) (SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS)) , .T.)
(PREREG) (_aTotal[001] := '    <cfdi:Receptor' , .T.)
(PREREG) (_aTotal[001] += ' Rfc="' + CFDCarEsp(AllTrim(SA1->A1_CGC)) + '"' , .T.)
(PREREG) (_aTotal[001] += ' Nombre="' + CFDCarEsp(Alltrim(_aTotal[105]),.T.) + '"' , .T.)
(PREREG) (_aTotal[001] += ' DomicilioFiscalReceptor="' + Alltrim(SA1->A1_CEP) + '"' , .T.)
(PREREG) (_aTotal[001] += Iif(AI0->(ColumnPos("AI0_REGFIS")) > 0,' RegimenFiscalReceptor="' + Alltrim(AI0->AI0_REGFIS) + '"',""), .T.)
(PREREG) IIf(lCCCE,(_aTotal[001] += ' ResidenciaFiscal="' + Alltrim(SYA->YA_CCESAT) + '"' , .T.),"")
(PREREG) IIf(lCCCE,(_aTotal[001] += ' NumRegIdTrib="' + Alltrim(AI0->AI0_IDFIS) + '"' , .T.),"")
(PREREG) (_aTotal[001] += ' UsoCFDI="' + Alltrim(SF1->F1_USOCFDI) + '"' , .T.)
(PREREG) (_aTotal[001] += '/>' ,.T.)
(PREREG) _aTotal[001]

//Emisor
(POS) cNodoCCE += IIf(lCCCE, '            <cce11:Emisor' , "")
(POS) cNodoCCE += IIf(lCCCE, '>' + ( chr(13)+chr(10) ), "") 
(POS) cNodoCCE += IIf(lCCCE, '                <cce11:Domicilio' , "")        
(POS) cNodoCCE += IIf(lCCCE, ' Calle="' + CFDCarEsp(AllTrim(SM0->M0_ENDCOB)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(CFDCarEsp(CFDCarEsp(AllTrim(SM0->M0_CEPENT)))), ' Colonia="' + CFDCarEsp(AllTrim(ObtColSAT("S015",AllTrim(SM0->M0_CEPENT),5,5,1,4))) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(SM0->M0_CEPENT))), ' Municipio="' + CFDCarEsp(AllTrim(SM0->M0_CODMUN)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' Estado="' + CFDCarEsp(Alltrim(ObtColSAT("S004",AllTrim(SM0->M0_CEPENT),1,5,6,3))) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' Pais="' + AllTrim("MEX") + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' CodigoPostal="' + AllTrim(SM0->M0_CEPENT) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, '/>' + ( chr(13)+chr(10) ), "")
(POS) cNodoCCE += IIf(lCCCE, '            </cce11:Emisor>' + ( chr(13)+chr(10) ), "")

//Receptor
(POS) cNodoCCE += IIf(lCCCE, '            <cce11:Receptor ' + IIf(AllTrim(SA1->A1_CGC)=="XEXX010101000", 'NumRegIdTrib="' + CFDCarEsp(AllTrim(SF1->F1_IDTRIB)) + '"',""), "")  
(POS) cNodoCCE += IIf(lCCCE, '>' + ( chr(13)+chr(10) ), "") 

//Domicilio Receptor
(POS) cNodoCCE += IIf(lCCCE, '                <cce11:Domicilio' , "")        
(POS) cNodoCCE += IIf(lCCCE, ' Calle="' + CFDCarEsp(AllTrim(SA1->A1_END)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_NR_END)), ' NumeroExterior="' + AllTrim(SA1->A1_NR_END) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_NROINT)), ' NumeroInterior="' + AllTrim(SA1->A1_NROINT) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(CFDCarEsp(AllTrim(SA1->A1_BAIRRO))), ' Colonia="' + CFDCarEsp(AllTrim(SA1->A1_BAIRRO)) + '"', "")
(POS) cNodoCCE += IIf(lCCCE .And. !Empty(AllTrim(SA1->A1_MUN)), ' Municipio="' + CFDCarEsp(AllTrim(SA1->A1_MUN),.T.) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' Estado="' + CFDCarEsp(Alltrim(Posicione("SX5",1,xFilial("SX5")+"12"+SA1->A1_EST,"X5_DESCRI"))) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' Pais="' + AllTrim(Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCESAT")) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, ' CodigoPostal="' + AllTrim(SA1->A1_CEP) + '"', "")
(POS) cNodoCCE += IIf(lCCCE, '/>' + ( chr(13)+chr(10) ), "")
(POS) cNodoCCE += IIf(lCCCE, '            </cce11:Receptor>' + ( chr(13)+chr(10) ), "") 

(POS) (cNodoCCE += IIf(lCCCE, '            <cce11:Mercancias>' + ( chr(13)+chr(10) ), ""),.T.)
(POS) _aTotal[094] += cNodoCCE

[SD1 CONCEPTO]
(PRE) lCCCE := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.) .And. !Empty(SF1->F1_TIPOPE) .And. _aTotal[104], .T., .F.)
(PRE) cNodoCCE := ""

(PRE) DbGoTop()
 
(PREREG) (cNodoCCE += IIf(lCCCE, '                  <cce11:Mercancia' , ""),.T.)      
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(SD1->D1_ITEM + SD1->D1_COD), ' NoIdentificacion="' + Alltrim(SD1->D1_ITEM + SD1->D1_COD) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(SD1->D1_FRACCA), ' FraccionArancelaria="' + Alltrim(SD1->D1_FRACCA) + Alltrim(SD1->D1_NICO) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(Str(SD1->D1_CANADU)), ' CantidadAduana="' + Alltrim(Str(SD1->D1_CANADU)) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(SD1->D1_FRACCA), ' UnidadAduana="' + AllTrim(ObtColSAT("S014",AllTrim(SD1->D1_FRACCA),1,8,9,2))  + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(Str(SD1->D1_VALADU)), ' ValorUnitarioAduana="' + Alltrim(Str(SD1->D1_VALADU,14,2)) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE .And. !Empty(Str(SD1->D1_USDADU)), ' ValorDolares="' + Alltrim(Str(SD1->D1_USDADU,14,2)) + '"', ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE, '>' + ( chr(13)+chr(10) ) , ""),.T.)
(PREREG) (cNodoCCE += IIf(lCCCE, '                  </cce11:Mercancia>' + ( chr(13)+chr(10) ), ""),.T.)

(POS) (cNodoCCE += IIf(lCCCE, '            </cce11:Mercancias>' + ( chr(13)+chr(10) ), ""),.T.)
(POS) (cNodoCCE += IIf(lCCCE, '           </cce11:ComercioExterior>'  , ""),.T.)
(POS) _aTotal[094] += cNodoCCE

(POS) (_aTotal[034] := fXMLFUN("CO",.F.,  .F. ,.F.))
 
[XXX CONCEPTOS]
(POS) FsQuery(_aTotal[097],2)
(PREREG) (_aTotal[001] := _aTotal[034],.T.)
(PREREG) _aTotal[001]

[XXX IMPUESTOS]
(PREREG) (_aTotal[002] := fXMLFUN("TI",.F., .F. ,.T.))
(PREREG) _aTotal[002]

//IMPUESTOS LOCALES//
(PRE) (_aTotal[095] := fXMLFUN("IL",.F.),.T.)

[XXX COMPLEMENT]
(PREREG) (_aTotal[001] := IIF(!EMPTY(_aTotal[094] ) .or. !EMPTY(_aTotal[095]), '    <cfdi:Complemento', ""), .T.)
(PREREG) (_aTotal[001] += IIF(!EMPTY(_aTotal[094] ) .or. !EMPTY(_aTotal[095]),'>',""),.T.)
(PREREG) _aTotal[001]
COMPLEMENT  C 021 0 ENCODEUTF8(XMLConv("",,,"cfdi:Complemento",.T.,.F.,4))

[XXX COMERCIOEX]
(PREREG) (_aTotal[001] := _aTotal[094],.T.)
(PREREG) _aTotal[001]

[XXX IMPUESTOLOC]
(PREREG) (_aTotal[001] := _aTotal[095],.T.)
(PREREG) _aTotal[001]

[XXX COMPLEMENT]
(PREREG) (_aTotal[001] := IIF(!EMPTY(_aTotal[094]) .or. !EMPTY(_aTotal[095]) ,'    </cfdi:Complemento>',""), .T.)
(PREREG) _aTotal[001]
COMPLEMENT  C 021 0 ENCODEUTF8(XMLConv("",,,"cfdi:Complemento",.F.,.T.,4))

//[XXX CAD_ORIG]
//(PREREG) _aTotal[033]

[XXX FACTURA]
(PRE) _aTotal[095] := &(GetNewPar("MV_CFDNAF1","Lower(AllTrim(SF1->F1_ESPECIE)) + '_' + Lower(AllTrim(SF1->F1_SERIE)) + '_'  + Lower(AllTrim(SF1->F1_DOC)) + '.xml'"))
(ARQ) _aTotal[095]
FACTURA    C 019 0 ENCODEUTF8(XMLConv("",,,"cfdi:Comprobante",.F.,.T.,0))



Card documentos
InformacaoLa presente solución aplica para versión 12.1.2210 o superior.
Titulo¡IMPORTANTE!

...