Árvore de páginas

Versões comparadas

Chave

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

...

Painel
borderWidth2
titleBGColorlightblue
borderStylesolid
titleFATSMEX.INI

//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[075] := Alltrim(SM0->M0_NOMECOM)
(PRE) _aTotal[076] := ((SuperGetMV("MV_CFDIEXP",.F.,.F.) .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(_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) 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] ) 

[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.)
(PRE) SB1->(DbGoTop())
(PREREG) (SB1->(DbSeek(xFilial("SB1")+SD2->D2_COD)) , .T.)
//////////////////////////////////////////////CADENA ORIGINAL//////////////////////////////////////////////
(PRE) cCadOrig   := _aTotal[099]
(PRE) lCCCE      := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.)  .And. !Empty(SF2->F2_TIPOPE), .T., .F.)
(PRE) cCadOriCCE := ""

//Cadena Original | Complemento de Comercio Exterior (Mercancias)
(PREREG) IIf(lCCCE .And. !(SB1->B1_TIPO == "SV") .And. !Empty(SD2->D2_ITEM + SD2->D2_COD), (cCadOriCCE += Alltrim(SD2->D2_ITEM + SD2->D2_COD) + _aTotal[098],.T.),("",,.T.))
(PREREG) IIf(lCCCE .And. !(SB1->B1_TIPO == "SV") .And. !Empty(SD2->D2_FRACCA), (cCadOriCCE += Alltrim(SD2->D2_FRACCA) + Alltrim(SD2->D2_NICO) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !(SB1->B1_TIPO == "SV") .And. !Empty(Str(SD2->D2_CANADU)), (cCadOriCCE += Alltrim(Str(SD2->D2_CANADU)) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !(SB1->B1_TIPO == "SV") .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. !(SB1->B1_TIPO == "SV") .And. !Empty(Str(SD2->D2_VALADU)), (cCadOriCCE += Alltrim(Str(SD2->D2_VALADU,14,2)) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !(SB1->B1_TIPO == "SV") .And. !Empty(Str(SD2->D2_USDADU)), (cCadOriCCE += Alltrim(Str(SD2->D2_USDADU,14,2)) + _aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !(SB1->B1_TIPO == "SV") . And. SA1->A1_CONTRBE=="1" .And. Alltrim(SF2->F2_ESPECIE) == "NF", (cCadOriCCE += '1.0' +_aTotal[098],.T.), ("",,.T.))
(PREREG) IIf(lCCCE .And. !(SB1SA1->B1>A1_TIPO CONTRBE=="SV1" ) .And. SA1->A1_CONTRBE=="1" .And. SF2-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',FormPagGlo(SF2->F2_DOC,SF2->F2_SERIE),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],Round(SF2->F2_VALBRUT,2) + _aTotal[103] - _aTotal[037])),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(lCCCE .And. Alltrim(SF2->F2_ESPECIE) == "NF","02", "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]

//////////////////////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. Empty(SF2->F2_TRASLA)) .Or. SF2->F2_GLOBAL == "1"), "XAXX010101000", CFDCarEsp(_aTotal[108], .F.)) + _aTotal[098])
//Nombre
(PRE) (cCadOrig += IIf(SF2->F2_GLOBAL <> "1",CFDCarEsp(_aTotal[109],.F.) + _aTotal[098],""), .T.)
//DomicilioFiscalReceptor
(PRE) (cCadOrig += IIf(SF2->F2_GLOBAL <> "1",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(SF2->F2_GLOBAL <> "1" .And. 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.)
(PRE) (cCadOrig += fXMLFUN("IL",.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 += 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], "")

(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 += _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 := "MIIFyDCCA7CgAwIBAgIUMzAwMDEwMDAwMDA0MDAwMDI0NDMwDQYJKoZIhvcNAQEL"
(PRE) cCert += "BQAwggErMQ8wDQYDVQQDDAZBQyBVQVQxLjAsBgNVBAoMJVNFUlZJQ0lPIERFIEFE"
(PRE) cCert += "TUlOSVNUUkFDSU9OIFRSSUJVVEFSSUExGjAYBgNVBAsMEVNBVC1JRVMgQXV0aG9y"
(PRE) cCert += "aXR5MSgwJgYJKoZIhvcNAQkBFhlvc2Nhci5tYXJ0aW5lekBzYXQuZ29iLm14MR0w"
(PRE) cCert += "GwYDVQQJDBQzcmEgY2VycmFkYSBkZSBjYWRpejEOMAwGA1UEEQwFMDYzNzAxCzAJ"
(PRE) cCert += "BgNVBAYTAk1YMRkwFwYDVQQIDBBDSVVEQUQgREUgTUVYSUNPMREwDwYDVQQHDAhD"
(PRE) cCert += "T1lPQUNBTjERMA8GA1UELRMIMi41LjQuNDUxJTAjBgkqhkiG9w0BCQITFnJlc3Bv"
(PRE) cCert += "bnNhYmxlOiBBQ0RNQS1TQVQwHhcNMTkwNjE3MjA0MDUxWhcNMjMwNjE3MjA0MDUx"
(PRE) cCert += "WjCB7zEqMCgGA1UEAxMhWEVOT04gSU5EVVNUUklBTCBBUlRJQ0xFUyBTIERFIENW"
(PRE) cCert += "MSowKAYDVQQpEyFYRU5PTiBJTkRVU1RSSUFMIEFSVElDTEVTIFMgREUgQ1YxKjAo"
(PRE) cCert += "BgNVBAoTIVhFTk9OIElORFVTVFJJQUwgQVJUSUNMRVMgUyBERSBDVjElMCMGA1UE"
(PRE) cCert += "LRMcWElBMTkwMTI4SjYxIC8gS0FITzY0MTEwMUIzOTEeMBwGA1UEBRMVIC8gS0FI"
(PRE) cCert += "TzY0MTEwMUhOVExLUzA2MSIwIAYDVQQLExlYZW5vbiBJbmR1c3RyaWFsIEFydGlj"
(PRE) cCert += "bGVzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiJQ5YcSgjwsGf29+"
(PRE) cCert += "3go7VGdtMZCcH9wUpn46ZMAlFwUojnCPTvwJ3+cSwjqJnw8ahr3DuRwekvGR4BJA"
(PRE) cCert += "b5b9Xi8kyoiWtwcGOSWxO38Bp9J1e/BO9HMbQBPAtLDuG47oqnH8zWLOeaoYRJDp"
(PRE) cCert += "ARw4RX1ko2+9tbj0ntBtM7Vk1E8EWiA/h2Meq0LIv1+ySGTUrEW46FM01J5pzELv"
(PRE) cCert += "5XupBghuJxR5DG9fiOW7u3dR5s3tZoVLwA1KdjJtY0mmnfCwxg6i5AqhvY+FAI5D"
(PRE) cCert += "6CF6/lHA8PWg63WasvrhuIv70xCLjgPT/j00ZcPrLvBf1DefGVic980Ch/SDvC+M"
(PRE) cCert += "dJ1F5wIDAQABox0wGzAMBgNVHRMBAf8EAjAAMAsGA1UdDwQEAwIGwDANBgkqhkiG"
(PRE) cCert += "9w0BAQsFAAOCAgEACjfTPoKY2N5MxjmAMltd5XZCV1vgAwEtrIRYTodhE8R0Tp1Q"
(PRE) cCert += "anAXb0luPyBv5hIXWK4VqAI4fcTtP+n7kkrwfha6ErkPWFNJWJm8ZsMmby/3WgVo"
(PRE) cCert += "JkOFyRYQqr5Il3N6wMa5kiDBtDRbqB3iEXmvtrvjWSHyxAER+zo3jWGFlhBZ0nQN"
(PRE) cCert += "Rtjx8sPFihVc5TUH682HJiU4oWvT63Dnra8ncqiW/uCuY86crnUq0fW7Lw/3+PY5"
(PRE) cCert += "xXjNxR/Hh3sUPITfJrGaLWurD1J9npr9yGAJ6t9zrhhZnepIC0DUMc5+j4pg1DrO"
(PRE) cCert += "32jzwUOLQqErDizh84NoJCWwbg+US8wi3zD0ZKiDv7XsTNWAW2Ap2JkzykKHjFTZ"
(PRE) cCert += "iEm3uZOkJNfcu3o+kefr5HfXFT+iN9K5FUEhaQwgUeZBRJ8V5F6gmhz3d6ixVbiZ"
(PRE) cCert += "oFNhYR8e2k8gF9gGrVMrEbJGQrl+6+ZYQLFiauXeG7fu1svk19PuyredRJGnseJq"
(PRE) cCert += "yV4RzcRGhJA+cLnmpdDOTEhignnvnhEuY6HVRYYXhOTyeeluET7KRCxbJGqO7TdW"
(PRE) cCert += "gjrHL3HRbNE4NY5GAdOZuLaWxElG5ZVCHqtG0Nh7UQAhcz+EKyZBAewv5XuH0Oom"
(PRE) cCert += "ZXw6mM2mY2soL6z1224NusM8/BbJcYTQUlAEKblEChhGK1XlxiVOU2nc9KE="

(PRE) lCCCE := IIf(SuperGetMV("MV_CFDIEXP",.F.,.F.) .And. !Empty(SF2->F2_TIPOPE), .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',FormPagGlo(SF2->F2_DOC,SF2->F2_SERIE),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] ,Round(SF2->F2_VALBRUT,2) + _aTotal[103] - _aTotal[037] - _aTotal[038])),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(lCCCE .And. Alltrim(SF2->F2_ESPECIE) == "NF","02","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="' + 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 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), .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. Empty(SF2->F2_TRASLA)) .Or. SF2->F2_GLOBAL == "1"), "XAXX010101000", _aTotal[108])) + '"' , .T.)
(PREREG) (_aTotal[001] += IIf(SF2->F2_GLOBAL <> "1",' Nombre="' + 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) ), "") 

(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), .T., .F.)
(PRE) cNodoCCE := ""

(PRE) SD2->( DbGoTop())
(PRE) SB1->(DbGoTop())
(PREREG) (SB1->(DbSeek(xFilial("SB1")+SD2->D2_COD)) , .T.)

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

...