Árvore de páginas

Versões comparadas

Chave

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

...

  • En el Encabezado informar del Documento informar los campos:
    • Cliente (F2_CLIENTE)
    • Tienda (F2_LOJA)
    • Serie Docto. (F2_SERIE)
    • N. Documento (F2_DOC)
  • En los Ítems del Documento informar los siguientes campos:
    • Producto (D2_COD) - campo ¿Imp Salud?  igual a "S - Si"
    • Cantidad (D2_QUANT)
    • Valor Unit. (D2_PRCVEN)
    • Valor Total (D2_TOTAL)
    • Tipo Salida (D2_TES)
  • En la pestaña "Impuestos" en el pie del Documento, validar el cálculo de impuestos saludables ICUI/IBUA

2.19 Rechazos  al transmitir una Factura de Exportación (ZE02,FAR02,FAR03).


Producto

Solucoes_espanhol
SolucaoTOTVS Backoffice

Línea de producto: 

Linhas_totvs_espanhol
LinhaLínea Protheus

Segmento:

Segmentos_totvs_espanhol
SegmentoBackoffice

Módulo:SIGAFAT - Facturación
Función:
RutinaNombre TécnicoFecha
M486XFUNCOFunciones Genéricas de Facturación Electrónica - Colombia07/05/2024
FATSECOLScript de generación de archivos XML; NF y NDC de exportación08/05/2024
País:Colombia (COL)
Ticket:20049456
Requisito/Story/Issue (informe el requisito vinculado):DMINA-23201


SITUACIÓN/REQUISITO

En la rutina de Documentos Electrónicos (MATA486), al intentar transmitir una Factura de Exportación (NF)  se presenta las siguientes reglas de rechazo:

    • ZE02 ,Valor de la Firma inválido.
    • FAR02, Descargo de Responsabilidad - "Remítase a regla FAD15b ya que al cumplirse dicha regla verifica que este elemento corresponder al mismo valor informado en DocumentCurrencyCode.
    • FAR03, Descargo de Responsabilidad - "SourceCurrencyBaseRate trae valor diferente a 1.00.

SOLUCION

En la rutina de Funciones Genéricas de Facturación Electrónica - Colombia (M486XFUNCO):

En la función Función para llenado de oWSfactura solicitado por TheFactory HKA, se realiza el ajuste para cuando el documento es una Factura de Exportación, envié en los Datos adicionales (oWSextras) el valor del campo extra "FEXP2".

Regla de Rechazo ZE02- Mensaje: Valor de la Firma inválido


En la INI de Script de generación de archivos XML; NF y NDC de exportación (FATSECOL):

Para las reglas de rechazo FAR02 y FAR03 se requiere modificar las siguientes lineas en al archivo INI.

Nota
titleFATSECOL

(PRE) _aTotal[001] += ' <cbc:SourceCurrencyCode>' + "COP" + '</cbc:SourceCurrencyCode>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += ' <cbc:SourceCurrencyBaseRate>' + Alltrim(Str(SF2->F2_TXMOEDA,11,2)) + '</cbc:SourceCurrencyBaseRate>' + ( chr(13)+chr(10) ) 

(PRE) _aTotal[001] += ' <cbc:TargetCurrencyCode>' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '</cbc:TargetCurrencyCode>' + ( chr(13)+chr(10) ) 

2.20 Transmisión de Factura de Venta (NF), Nota de Crédito (NCC) y Nota de Débito con Cliente Nacional con Moneda diferente de 1-Pesos (Anexo 1.9)


Producto

Solucoes_espanhol
SolucaoTOTVS Backoffice

Línea de producto: 

Linhas_totvs_espanhol
LinhaLínea Protheus

Segmento:

Segmentos_totvs_espanhol
SegmentoBackoffice

Módulo:SIGAFAT - Facturación
Función:
RutinaNombre TécnicoFecha
M486XFUNFunciones Genéricas de Documentos Electrónicos27/06/2024
M486XFUNCOFunciones Genéricas de Facturación Electrónica de Colombia25/06/2024
FATSCOL.INIEstructura del XML de Documentos de Salida26/06/2024
FATECOL.INIEstructura del XML de Documentos de Entrada26/06/2024
FATSECOL.INIEstructura del XML de Documentos de Exportación26/06/2024
País:Colombia (COL)
Ticket:20240417
Requisito/Story/Issue (informe el requisito vinculado):DMINA-23601


SITUACIÓN/REQUISITO

En la rutina de Documentos Electrónicos (MATA486), al realizar la transmisión de una Factura de Venta (NF), Nota de Crédito de Cliente (NCC) o Nota de Débito de Cliente (NDC) con Cliente Nacional no está realizando la conversión de los montos a Pesos Colombianos (COP) y los atributos MonedaOrigen, MonedaDestino, BaseMonedaOrigen y BaseMonedaDestino se envían invertidos, lo cual presenta los siguientes rechazos:

FAR02, Descargo de Responsabilidad - "Remítase a regla FAD15b ya que al cumplirse dicha regla verifica que este elemento corresponder al mismo valor informado en DocumentCurrencyCode.

FAR03, Descargo de Responsabilidad - "SourceCurrencyBaseRate trae valor diferente a 1.00

Al realizar la transmisión de una Factura de Venta de Exportación (Cliente Extranjero), en el SoapRequest en los nodos direccionCliente y direccionFiscal, se solicita que sólo se envíen los atributos Dirección y País.

SOLUCION

En la rutina de Funciones Genéricas de Documentos Electrónicos (M486XFUN):

En las Funciones que generan los nodos de Impuestos a nivel encabezado y detalle (fGetTaxas/fGetTaxDet), se desactivó el uso del parámetro MV_ANEXO19, que permitía desactivar la funcionalidad del Anexo 1.9, el cual ya es obligatorio a partir del 01 de Mayo del 2024, y se eliminó condición de que el Cliente sea Extranjero (A1_EST igual a 'EX') para que la conversión a moneda Pesos Colombianos (COP) de los Impuestos y la conversión se realizará si la especie del documento es Factura de Venta (NF), Nota de Crédito de Cliente (NDC) o Nota de Débito de Cliente (NDC) y la Moneda (F1_MOEDA/F2_MOEDA) es diferente de 1.

En la rutina de Funciones Genéricas de Facturación Electrónica de Colombia (M486XFUNCO):

Se realizaron los siguientes ajuste, que aplican si el Cliente es Extranjero (A1_EST = 'EX') o Nacional, y la Moneda DIAN (CTO_MOESAT) de la Moneda es diferente de (COP) :

  • El atributo moneda se envía con el valor COP.
  • Se envían los campos extras FEXP1, FEXP2 y FEXP3, para activar el UBL Extensión y enviar los valores en la moneda original del Documento.
  • Se realiza ajuste para que no se envié en los campos extras la tasa de cambio para las Facturas de Exportación o Nacional.

Se realiza ajuste para que al transmitir una Factura de Venta (NF), Nota de Crédito de Cliente (NCC) o Nota de Débito de Cliente (NDC), si el Cliente es Extranjero (A1_EST igual a 'EX') en los nodos direccionCliente y direccionFiscal del Soap Request, se envien únicamente los atributos Direccion y Pais.

En los archivos de la Estructura del XML de Documentos de Salida y Estructura del XML de Documentos de Entrada (FATSCOL.INI/FATECOL.INI):

Se realizaron los siguientes ajustes, para cuando la moneda del documento es diferente de la moneda local:

  • Informar el atributo SourceCurrencyCode con el valor COP.
  • Informar el atributo SourceCurrencyBaseRate con el valor del campo Tasa Moneda (F1_TXMOEDA/F2_TXMOEDA).
  • Informar el atributo TargetCurrencyCode con el valor del campo Moneda DIAN (CTO_MOESAT) de la moneda del documento.
  • Realizar la conversión del Descuento y Precio de Venta para cada uno de los ítems. 

    En el archivo de la Estructura del XML de Documentos de Exportación (FATSECOL.INI):
  • Se elimina el uso del parámetro MV_ANEXO19, que permitía desactivar la funcionalidad del Anexo 1.9, el cual ya es obligatorio a partir del 01 de Mayo del 2024.
  • Se realiza conversión del atributo LineExtensionAmount del nodo InvoiceLine/DebitNoteLine, para enviar de manera correcta el atributo MontoBase del nodo Descuentos del Soap Request.

2.20.1 Configuraciones Previas

Realizar los ajustes que se indican en color azul para cada uno de los archivos FATSCOL.INI ,FATECOL.INI y FATSECOL.INI:

Informações
titleFATSCOL.INI

FATSCOL.INI

//FATSCOL.INI -- NFE Colombia v2 - Resolucion 0019 / FEB. 2016
[XXX POSICIONAMENTOS]
(PRE) SA2->(DbSetOrder(1))
(PRE) _aTotal[116] := If(SF2->(ColumnPos("F2_MARK")) > 0 ,If(SF2->F2_MARK=='S'.AND. Alltrim(SF2->F2_TIPOPE) $'10|11', .T.,.F. ) , .F.)
(PRE) If(_aTotal[116] ,SA2->(MSSeek(xFilial("SA2")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)
(PRE) If(_aTotal[116] ,SA1->(MSSeek(xFilial("SA1")+SA2->A2_CLIENTE+SA2->A2_LOJCLI)) , .T.)
(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" .AND. !_aTotal[116] ,SA1->(MSSeek(xFilial("SA1")+SF2->F2_CLIENTE+SF2->F2_LOJA)) , .T.)
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF2->F2_COND)) , .T.)
(PRE) ( If(!_aTotal[116],AI0->(MSSeek(xFilial("AI0")+SF2->F2_CLIENTE+SF2->F2_LOJA)), AI0->(MSSeek(xFilial("AI0")+SA2->(A2_CLIENTE+A2_LOJCLI)))), .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) SE1->(DbSetOrder(2))

(PRE) _aTotal[117] := IIF(_aTotal[116] .AND. SF2->(ColumnPos("F2_TIPNOTA")) > 0, SF2->F2_TIPNOTA , "")
(PRE) _aTotal[033] := ALLTRIM (SF2->F2_ESPECIE)
(PRE) _aTotal[075] := Alltrim(SM0->M0_NOMECOM)
(PRE) _aTotal[093] := ""
(PRE) _aTotal[094] := ""
(PRE) _aTotal[095] := DtoS(SF2->F2_EMISSAO)
(PRE) _aTotal[095] := Left(_aTotal[095],4) + "-" + Substr(_aTotal[095],5,2)+ "-" + Right(_aTotal[095],2)
(PRE) _aTotal[096] := SF2->F2_HORA
(PRE) _aTotal[097] := fGetTaxas(SF2->F2_DOC, SF2->F2_SERIE, SF2->F2_CLIENTE, SF2->F2_LOJA,SF2->F2_ESPECIE )
(PRE) _aTotal[098] := ALLTRIM( GETNEWPAR( "MV_ID_PROV" , "" ) )
(PRE) _aTotal[099] := ALLTRIM( GETNEWPAR( "MV_ID_SOFT" , "" ) )
(PRE) _aTotal[100] := ALLTRIM( GETNEWPAR( "MV_CODESEC" , "" ) ) 
(PRE) _aTotal[101] := {"SD2",""}
(PRE) _aTotal[102] := IIF( _aTotal[033] == "NF" , "1" , IIF( _aTotal[033] == "NCC" , "2" , IIF( _aTotal[033] == "NDC" , "3" , IIF( _aTotal[033] == "NDI" , "4" , IIF( _aTotal[033] == "NCI" , "5" , "" ) ) ) ) )
(PRE) _aTotal[103] := ""
(PRE) _aTotal[104] := PADR( Alltrim(SM0->M0_CGC) , 10 , "0" )
(PRE) _aTotal[105] := IIF( _aTotal[033] == "NF" , "f" , IIF( _aTotal[033] == "NCC"  .or. _aTotal[033] == "NCI" , "c" , IIF( _aTotal[033] == "NDC" .or. _aTotal[033] == "NDI" , "d" , IIF( _aTotal[116] , "n" , "f" ) ) ) )
(PRE) _aTotal[106] := M486XHEX(PADR( ALLTRIM( substr( SF2->F2_DOC , 4 , Len(SF2->F2_DOC) - 3 ) ) , 10 , "0" ),10)
(PRE) _aTotal[107] := IIF(AllTrim(SF2->F2_ESPECIE)=="NDC" .OR. _aTotal[116],fGetRef(SF2->F2_DOC, SF2->F2_SERIE, SF2->F2_CLIENTE, SF2->F2_LOJA,SF2->F2_ESPECIE,_aTotal[117]),"")
(PRE) _aTotal[108] := ""
(PRE) _aTotal[109] := Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT")
(PRE) _aTotal[110] := {"SFP",""}
(PRE) _aTotal[111] := ""
(PRE) _aTotal[112] := ""
(PRE) _aTotal[113] := ""
(PRE) _aTotal[114] := "FP_FILUSO='" + cFilAnt + "' AND FP_SERIE='" + SF2->F2_SERIE + "' AND FP_ESPECIE= '" + IIf(_aTotal[033] == "NF","1",IIf(_aTotal[116] ,"8","3")) + "' AND FP_NUMINI <='" + SF2->F2_DOC + "' AND FP_NUMFIM >='" + SF2->F2_DOC + "' AND FP_ATIVO ='1'"
(PRE) _aTotal[115] := "SFP->FP_FILUSO=cFilAnt .AND. SFP->FP_SERIE=SF2->F2_SERIE .AND. SFP->FP_ESPECIE='" + IIf(_aTotal[033] == "NF","1",IIf(_aTotal[116] ,"8","3")) + "' .AND. SFP->FP_NUMINI<=SF2->F2_DOC .AND. FP_NUMFIM >=SF2->F2_DOC .AND. SFP->FP_ATIVO = '1'","FP_ATIVO"

(PREREG) FsQuery(_aTotal[101],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.
(PREREG) FsQuery(_aTotal[110],1,_aTotal[114],_aTotal[115]) .And. .T.

[SFP CONTROL FOMULARIOS]
(PRE) _aTotal[103] := Dtos( SFP->FP_DTRESOL )
(PRE) _aTotal[103] := Left(_aTotal[103],4) + "-" + Substr(_aTotal[103],5,2)+ "-" + Right(_aTotal[103],2)
(PRE) _aTotal[111] := Alltrim( SFP->FP_NUMINI )
(PRE) _aTotal[112] := Alltrim( SFP->FP_NUMFIM )
(PRE) _aTotal[113] := Alltrim( SFP->FP_CAI )

[SD2 GENERANDO_XML]
(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",IIf(_aTotal[116], SA1->(MSSeek(xFilial("SA1")+SA2->A2_CLIENTE+SA2->A2_LOJCLI)), 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.)

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

[XXX FACTURA]
(PRE) Iif(AllTrim(SF2->F2_ESPECIE)=="NDI",SYA->(MsSeek(xFilial("SYA")+SA2->A2_PAIS)) , .T.)
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF2->F2_COND)) , .T.)
(PRE) _aTotal[001] := IIF(AllTrim(SF2->F2_ESPECIE)=="NF" .OR. _aTotal[116] ,'<fe:Invoice ','<fe:DebitNote ')
(PRE) _aTotal[001] += 'xmlns:fe="http://www.dian.gov.co/contratos/facturaelectronica/v1" '
(PRE) _aTotal[001] += 'xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" '
(PRE) _aTotal[001] += 'xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" '
(PRE) _aTotal[001] += 'xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001" '
(PRE) _aTotal[001] += 'xmlns:clm66411="urn:un:unece:uncefact:codelist:specification:66411:2001" '
(PRE) _aTotal[001] += 'xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003" '
(PRE) _aTotal[001] += 'xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" '
(PRE) _aTotal[001] += 'xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" '
(PRE) _aTotal[001] += 'xmlns:sts="http://www.dian.gov.co/contratos/facturaelectronica/v1/Structures" '
(PRE) _aTotal[001] += 'xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" '
(PRE) _aTotal[001] += 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
(PRE) _aTotal[001] += 'xsi:schemaLocation="http://www.dian.gov.co/contratos/facturaelectronica/v1 ../xsd/DIAN_UBL.xsd '
(PRE) _aTotal[001] += 'urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2 ../../ubl2/common/UnqualifiedDataTypeSchemaModule-2.0.xsd '
(PRE) _aTotal[001] += 'urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2 ../../ubl2/common/UBL-QualifiedDatatypes-2.0.xsd" '
(PRE) _aTotal[001] += '>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <ext:UBLExtensions>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <ext:UBLExtension>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <ext:ExtensionContent>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <sts:DianExtensions>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:InvoiceControl>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:InvoiceAuthorization>'+ _aTotal[113] +'</sts:InvoiceAuthorization>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:AuthorizationPeriod>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <cbc:StartDate>'+ _aTotal[103] +'</cbc:StartDate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <cbc:EndDate>'+ _aTotal[103] +'</cbc:EndDate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        </sts:AuthorizationPeriod>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:AuthorizedInvoices>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <sts:Prefix>'+ SF2->F2_SERIE2 +'</sts:Prefix>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <sts:From>'+ _aTotal[111] +'</sts:From>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <sts:To>'+ _aTotal[112] +'</sts:To>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        </sts:AuthorizedInvoices>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </sts:InvoiceControl>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:InvoiceSource>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:IdentificationCode listAgencyID="6" listAgencyName="United Nations Economic Commission for Europe" listSchemeURI="urn:oasis:names:specification:ubl:codelist:gc:CountryIdentificationCode-2.0">CO</cbc:IdentificationCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </sts:InvoiceSource>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:SoftwareProvider>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:ProviderID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)">'+ _aTotal[098] +'</sts:ProviderID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:SoftwareID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)">'+ _aTotal[099] +'</sts:SoftwareID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </sts:SoftwareProvider>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:SoftwareSecurityCode schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)">'+ _aTotal[100] +'</sts:SoftwareSecurityCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </sts:DianExtensions>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </ext:ExtensionContent>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </ext:UBLExtension>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <ext:UBLExtension>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <ext:ExtensionContent>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </ext:ExtensionContent>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </ext:UBLExtension>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </ext:UBLExtensions>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:UBLVersionID>UBL 2.0</cbc:UBLVersionID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:ProfileID>DIAN 1.0</cbc:ProfileID>'  + ( chr(13)+chr(10) )

// Manual con serie
//(PRE) _aTotal[001] += '    <cbc:ID>'+ SF2->F2_SERIE2 + Alltrim( Str( Val( Substr( SF2->F2_DOC , 4 , 10) ) ) ) +'</cbc:ID>'  + ( chr(13)+chr(10) )
// Manual sin serie
(PRE) _aTotal[001] += '    <cbc:ID>'+ Alltrim( Str( Val( Substr( SF2->F2_DOC , 4 , 10) ) ) ) +'</cbc:ID>'  + ( chr(13)+chr(10) )
(PRE) FsQuery(_aTotal[110],2)
// CUFE Aplica solo para NF
(PRE) _aTotal[093] := ""
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF" .OR. _aTotal[016],'    <cbc:UUID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)">'+  _aTotal[093] +'</cbc:UUID>'  + ( chr(13)+chr(10) ),"")

(PRE) _aTotal[001] += '    <cbc:IssueDate>'+ _aTotal[095] +'</cbc:IssueDate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:IssueTime>'+ _aTotal[096] +'</cbc:IssueTime>'  + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '    <cbc:InvoiceTypeCode listAgencyID="195" listAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" listSchemeURI="http://www.dian.gov.co/contratos/facturaelectronica/v1/InvoiceType">'+ IIF(AllTrim(SF2->F2_ESPECIE)=="NF","01","92") +'</cbc:InvoiceTypeCode>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '    <cbc:Note><![CDATA['+ IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",SF2->F2_MOTIVO,"") + ']]></cbc:Note>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:DocumentCurrencyCode>'+ Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) +'</cbc:DocumentCurrencyCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:CustomizationID>'+ Alltrim(SF2->F2_TIPOPE) +'</cbc:CustomizationID>' + ( chr(13)+chr(10) )

//Documentos referenciados (solo facturas)
(PRE) _aTotal[001] += IIf(SF2->(ColumnPos("F2_UUIDREL")) > 0 .And. AllTrim(SF2->F2_ESPECIE)=="NF",M486DRCOL(SF2->F2_UUIDREL,1),"")
// Orden de Compra 
(PRE) _aTotal[001] += IIf(SF2->(ColumnPos("F2_UUIDREL")) > 0 .And. AllTrim(SF2->F2_ESPECIE)=="NF",M486DRCOL(SF2->F2_UUIDREL,2),"")
//  DiscrepancyResponse Solo para la Nota de Débito
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",'    <cac:DiscrepancyResponse>' +  chr(13)+chr(10),"")
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",'        <cbc:ReferenceID/>' + chr(13)+chr(10),"")
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",'        <cbc:ResponseCode listName="concepto de notas débito" listSchemeURI="http://www.dian.gov.co/micrositios/fac_electronica/documentos/Anexo_Tecnico_001_Formatos_de_los_Documentos_XML_de_Facturacion_Electron.pdf" name="1:= intereses">' + SF2->F2_TIPREF + "</cbc:ResponseCode>"+ chr(13)+chr(10),"")
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",'    </cac:DiscrepancyResponse>' + chr(13)+chr(10),"")

// BillingReference solo para la Nota de Débito
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC" .OR. _aTotal[116], _aTotal[107],"")
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX EMISOR]
(PRE) _aTotal[001] := '    <fe:AccountingSupplierParty>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:AdditionalAccountID>'+ "1" +'</cbc:AdditionalAccountID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <fe:Party>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:PartyIdentification>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:ID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeID="31">'+ Alltrim(SM0->M0_CGC) +'</cbc:ID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:PartyIdentification>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:PartyName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:Name><![CDATA['+ _aTotal[075] +']]></cbc:Name>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:PartyName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PhysicalLocation>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <fe:Address>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:Department><![CDATA['+ AllTrim(SM0->M0_BAIRENT) +']]></cbc:Department>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CitySubdivisionName><![CDATA['+ AllTrim(SM0->M0_CODMUN) +']]></cbc:CitySubdivisionName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CityName><![CDATA['+ Alltrim(SM0->M0_CIDENT) +']]></cbc:CityName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:Line><![CDATA['+ Alltrim(SM0->M0_ENDENT) + " " + Alltrim(SM0->M0_COMPENT) +']]></cbc:Line>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:IdentificationCode>'+ "CO" +'</cbc:IdentificationCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </fe:Address>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PhysicalLocation>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PartyTaxScheme>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:TaxLevelCode>'+ AllTrim(SM0->M0_DSCCNA) +'</cbc:TaxLevelCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cac:TaxScheme/>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PartyTaxScheme>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PartyLegalEntity>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:RegistrationName><![CDATA['+ _aTotal[075] +']]></cbc:RegistrationName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PartyLegalEntity>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </fe:Party>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </fe:AccountingSupplierParty>'  
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX RECEPTOR]
(PRE) AllTrim(SF2->F2_ESPECIE) <> "NDI"
(PRE) IIf(_aTotal[116], SA1->(MSSeek(xFilial("SA1")+SA2->A2_CLIENTE+SA2->A2_LOJCLI)),SA1->(MSSeek(xFilial("SA1")+SF2->F2_CLIENTE+SF2->F2_LOJA)))
(PRE) SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS))

(PRE) _aTotal[001] := '    <fe:AccountingCustomerParty>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:AdditionalAccountID>'+ IIF( AllTrim(SA1->A1_PESSOA) == "F" , "2" , "1" ) +'</cbc:AdditionalAccountID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <fe:Party>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '           <fe:PartyTaxScheme>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                   <cbc:RegistrationName><![CDATA['+ Alltrim(SA1->A1_NOME) +']]></cbc:RegistrationName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CompanyID schemeID="' + Right( Alltrim(SA1->A1_CGC), 1 ) + '" schemeName="' + AllTrim(SA1->A1_TIPDOC)+ '" schemeAgencyName="CO, DIAN (Dirección de Impuestos y Aduanas Nacionales)" schemeAgencyID="195">'+ IIF(AllTrim(SA1->A1_TIPDOC) == "31",Left(Alltrim(SA1->A1_CGC),Len(Alltrim(SA1->A1_CGC))-1),AllTrim(SA1->A1_PFISICA))+'</cbc:CompanyID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '             <cbc:TaxLevelCode listName="' + Alltrim(AI0->AI0_TPREG) + '">' + AllTrim(M486RESOBL(SA1->A1_COD,SA1->A1_LOJA,"R")) + '</cbc:TaxLevelCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '             <cac:RegistrationAddress>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:ID>' + Alltrim(SA1->A1_COD_MUN) + '</cbc:ID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CityName><![CDATA[' + Alltrim(POSICIONE("CC2",3,xFilial("CC2") + SA1->A1_COD_MUN,"CC2_MUN")) + ']]></cbc:CityName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:PostalZone>' + Alltrim(SA1->A1_CEP) + '</cbc:PostalZone>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CountrySubentity><![CDATA[' + Alltrim(M486VALSX5('12' + SA1->A1_EST)) + ']]></cbc:CountrySubentity>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CountrySubentityCode>' + Alltrim(SA1->A1_EST) + '</cbc:CountrySubentityCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                       <cbc:Line><![CDATA[' + Alltrim(SA1->A1_END) + ']]></cbc:Line>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                       <cbc:IdentificationCode>'+Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCEDIAN")+'</cbc:IdentificationCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </cac:RegistrationAddress>'  + ( chr(13)+chr(10) )     
(PRE) _aTotal[001] += '            </fe:PartyTaxScheme>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:PartyIdentification>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CompanyID schemeID="' + Right( Alltrim(SA1->A1_CGC), 1 ) + '" schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeName="' + AllTrim(SA1->A1_TIPDOC)+ '">'+ IIF(AllTrim(SA1->A1_TIPDOC) == "31",Left(Alltrim(SA1->A1_CGC),Len(Alltrim(SA1->A1_CGC))-1),AllTrim(SA1->A1_PFISICA))+'</cbc:CompanyID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:PartyIdentification>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            <cac:PartyName>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '                <cbc:Name><![CDATA['+ Alltrim(SA1->A1_NOME) +']]></cbc:Name>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            </cac:PartyName>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += '            <fe:PhysicalLocation>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <fe:Address>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:Department><![CDATA['+ AllTrim(SA1->A1_BAIRRO) +']]></cbc:Department>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CitySubdivisionName><![CDATA['+ AllTrim(SA1->A1_MUN) +']]></cbc:CitySubdivisionName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CityName><![CDATA[' + Alltrim(Posicione("SX5",1,xFilial("SX5")+"12"+SA1->A1_EST,"X5_DESCRI")) + ']]></cbc:CityName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:Line><![CDATA['+ AllTrim(SA1->A1_END) +']]></cbc:Line>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:IdentificationCode>'+Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCEDIAN")+'</cbc:IdentificationCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </fe:Address>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PhysicalLocation>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            <fe:PartyLegalEntity>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '                <cbc:RegistrationName><![CDATA['+ Alltrim(SA1->A1_NOME) +']]></cbc:RegistrationName>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            </fe:PartyLegalEntity>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += '            <cac:Contact>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:ElectronicMail>' + AllTrim(SA1->A1_EMAIL) + '</cbc:ElectronicMail>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:Telephone>' + AllTrim(SA1->A1_TEL) + '</cbc:Telephone>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:Contact>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '            <fe:Person>'  + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '                <cbc:FirstName><![CDATA[' + Alltrim(SA1->A1_NOMEPRI) +']]></cbc:FirstName>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '                <cbc:MiddleName><![CDATA[' + Alltrim(SA1->A1_NOMEPES) +']]></cbc:MiddleName>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '                <cbc:FamilyName><![CDATA[' + Alltrim(SA1->A1_NOMEPAT) + ' ' + Alltrim(SA1->A1_NOMEMAT) +']]></cbc:FamilyName>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '            </fe:Person>'  + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += '        </fe:Party>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </fe:AccountingCustomerParty>'  + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '    <cac:PaymentTerms>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:Amount currencyID="' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '">' + Alltrim(Str(SF2->F2_VALBRUT,14,2)) + '</cbc:Amount>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cac:SettlementPeriod>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cbc:StartDate>' + Transform( DtoS( Posicione("SE1",2,xFilial("SE1")+SF2->(F2_CLIENTE+F2_LOJA+F2_SERIE+F2_DOC),"E1_EMISSAO") ) , "@R 9999-99-99") + '</cbc:StartDate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cbc:EndDate>' + Transform( DtoS( Posicione("SE1",2,xFilial("SE1")+SF2->(F2_CLIENTE+F2_LOJA+F2_SERIE+F2_DOC),"E1_VENCTO") ) , "@R 9999-99-99") + '</cbc:EndDate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </cac:SettlementPeriod>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </cac:PaymentTerms>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '    <cac:PaymentExchangeRate>'  + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:SourceCurrencyCode>' + "COP"  + '</cbc:SourceCurrencyCode>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:SourceCurrencyBaseRate>' +  Alltrim(Str(SF2->F2_TXMOEDA,11,2)) + '</cbc:SourceCurrencyBaseRate>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:TargetCurrencyCode>' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '</cbc:TargetCurrencyCode>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:TargetCurrencyBaseRate>1.00</cbc:TargetCurrencyBaseRate>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:CalculationRate>' +  Alltrim(Str(SF2->F2_TXMOEDA,11,2)) + '</cbc:CalculationRate>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:Date>' + _aTotal[095] + '</cbc:Date>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '    </cac:PaymentExchangeRate>'  + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX IMPUESTOS]
(PRE) _aTotal[001] := _aTotal[097][1]
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX TOTALES]
(PRE) _aTotal[001] := _aTotal[097][2]
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[SD2 INVOICE]
(PRE) DbGoTop()
(PREREG) (SB1->(DbSeek(xFilial("SB1") + SD2->D2_COD)),.T.)
(PREREG) (SAH->(DbSeek(xFilial("SAH") + SB1->B1_UM)),.T.)
(PREREG) _aTotal[108] := fGetTaxDet(SD2->D2_DOC,SD2->D2_SERIE,SD2->D2_CLIENTE,SD2->D2_LOJA,SD2->D2_TES,IIF(!_aTotal[116],AllTrim(SF2->F2_ESPECIE),"NDC"))
(PREREG) (_aTotal[001] := IIF(AllTrim(SF2->F2_ESPECIE)=="NF" .OR. _aTotal[116],'    <fe:InvoiceLine>'  + ( chr(13)+chr(10) ),'    <cac:DebitNoteLine>'  + ( chr(13)+chr(10) )),.T.)
(PREREG) (_aTotal[001] += '        <cbc:ID>'+ Alltrim(Str(Val(SD2->D2_ITEM))) +'</cbc:ID>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF"  .OR. _aTotal[116],'        <cbc:InvoicedQuantity unitCode="' + Alltrim(_aTotal[108][3]) + '">'+ Alltrim(Str(SD2->D2_QUANT, 14, 2)) +'</cbc:InvoicedQuantity>'  + ( chr(13)+chr(10) ),'        <cbc:DebitedQuantity unitCode="' + Alltrim(_aTotal[108][3]) + '">'+ Alltrim(Str(SD2->D2_QUANT)) +'</cbc:DebitedQuantity>'  + ( chr(13)+chr(10) )),.T.)
(PREREG) (_aTotal[001] += '        <cbc:LineExtensionAmount currencyID=' + '"' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '"' + '>' + Alltrim(Str(IIf(AllTrim(SF2->F2_ESPECIE)$"NF|NDC" .And. SF2->F2_MOEDA<>1,Round(xMoeda(SD2->D2_TOTAL,SF2->F2_MOEDA,1,,MsDecimais(1)+1,SF2->F2_TXMOEDA),MsDecimais(1)),SD2->D2_TOTAL),14,2)) +'</cbc:LineExtensionAmount>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += _aTotal[108][1],.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '        <cac:AllowanceCharge>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '            <cbc:ChargeIndicator>false</cbc:ChargeIndicator>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '            <cbc:AllowanceChargeReason><![CDATA[Aplicación de descuento]]></cbc:AllowanceChargeReason>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '            <cbc:MultiplierFactorNumeric>' + Alltrim(Str(SD2->D2_DESC,5,2)) + '</cbc:MultiplierFactorNumeric>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '            <cbc:Amount currencyID="' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '">' + Alltrim(Str(IIf(SF2->F2_MOEDA<>1,Round(xMoeda(SD2->D2_DESCON,SF2->F2_MOEDA,1,,MsDecimais(1)+1,SF2->F2_TXMOEDA),MsDecimais(1)),SD2->D2_DESCON),14,2)) + '</cbc:Amount>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '        </cac:AllowanceCharge>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += _aTotal[108][2],.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF" .OR. _aTotal[116],'        <fe:Item>', '        <cac:Item>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:Description><![CDATA['+ Alltrim(SB1->B1_DESC) +']]></cbc:Description>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:PackSizeNumeric>'+ IIf(!Empty(SB1->B1_CONV),Alltrim(STR(SB1->B1_CONV)),"1") +'</cbc:PackSizeNumeric>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cac:SellersItemIdentification>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '                <cbc:ID>' + Alltrim(SD2->D2_COD) + '</cbc:ID>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            </cac:SellersItemIdentification>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF" .OR. _aTotal[116],'        </fe:Item>', '        </cac:Item>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF" .OR. _aTotal[116],'        <fe:Price>','        <cac:Price>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:PriceAmount currencyID=' + '"' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '"' + '>' + Alltrim(Str(IIf(SF2->F2_MOEDA<>1,Round(xMoeda(SD2->D2_PRCVEN,SF2->F2_MOEDA,1,,MsDecimais(1)+1,SF2->F2_TXMOEDA),MsDecimais(1)),SD2->D2_PRCVEN),14,2)) +'</cbc:PriceAmount>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:BaseQuantity unitCode="' + Alltrim(_aTotal[108][3]) + '">'+ Alltrim(Str(SD2->D2_QUANT)) +'</cbc:BaseQuantity>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF" .OR. _aTotal[116]    ,'        </fe:Price>', '        </cac:Price>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF" .OR. _aTotal[116],'    </fe:InvoiceLine>' ,'    </cac:DebitNoteLine>') ,.T.)
(PREREG) ENCODEUTF8(_aTotal[001])

[XXX INVOICE_FIN]
(POS) FsQuery(_aTotal[101],2)

[XXX FACTURA]
(PRE) _aTotal[094] := &("Lower('face') + '_' + Lower(_aTotal[105]) + Lower(_aTotal[104]) + Lower(_aTotal[106]) + '.xml'")

(ARQ) _aTotal[094]
FACTURA    C 019 0 ENCODEUTF8( IIF(AllTrim(SF2->F2_ESPECIE)=="NF" .OR. _aTotal[116], '</fe:Invoice>','</fe:DebitNote>'))

Informações
titleFATECOL.INI

FATECOL.INI

//FATECOL.INI -- NFE Colombia v2 - Resolucion 0019 / FEB. 2016
[XXX POSICIONAMENTOS]
(PRE) SA2->(DbSetOrder(1))
(PRE) _aTotal[116] := If(SF1->(ColumnPos("F1_SOPORT")) > 0 ,If(SF1->F1_SOPORT =='S'.AND. Alltrim(SF1->F1_TIPOPE) $'10|11', .T.,.F. ) , .F.)
(PRE) _aTotal[117] := If(SF1->(ColumnPos("F1_MARK")) > 0 ,If(SF1->F1_MARK =='S'.AND. Alltrim(SF1->F1_TIPOPE) $'10|11', .T.,.F. ) , .F.)
(PRE) _aTotal[089] := If(_aTotal[117] .AND. SF1->(ColumnPos("F1_TIPNOTA")) > 0, SF1->F1_TIPNOTA , "")
(PRE) _aTotal[090] := ""
(PRE) _aTotal[091] := SuperGetMV("MV_ANEXO19",.F.,.F.) Se debe eliminar
(PRE) If(_aTotal[116] .OR. _aTotal[117] ,SA2->(MSSeek(xFilial("SA2")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)
(PRE) If(_aTotal[116] .OR. _aTotal[117] ,SA1->(MSSeek(xFilial("SA1")+SA2->A2_CLIENTE+SA2->A2_LOJCLI)) , .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" .AND. !_aTotal[116] .AND. !_aTotal[117] ,SA1->(MSSeek(xFilial("SA1")+SF1->F1_FORNECE+SF1->F1_LOJA)) , .T.)
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF1->F1_COND)) , .T.)
(PRE) IF( _aTotal[116] .OR. _aTotal[117], AI0->(MSSeek(xFilial("AI0")+SA2->(A2_CLIENTE+A2_LOJCLI))) , AI0->(MSSeek(xFilial("AI0")+SF1->(F1_FORNECE+F1_LOJA))) )

[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) SE1->(DbSetOrder(2))

(PRE) _aTotal[033] := ALLTRIM (SF1->F1_ESPECIE)
(PRE) _aTotal[075] := Alltrim(SM0->M0_NOMECOM)
(PRE) _aTotal[092] := IIF(_aTotal[116] .OR. _aTotal[117], Posicione("SA1",1,xFilial("SA1")+SA2->A2_CLIENTE+SA2->A2_LOJCLI,"A1_EST") ,Posicione("SA1",1,xFilial("SA1")+SF1->F1_FORNECE+SF1->F1_LOJA,"A1_EST"))
(PRE) _aTotal[093] := ""
(PRE) _aTotal[094] := ""
(PRE) _aTotal[095] := DtoS(SF1->F1_EMISSAO)
(PRE) _aTotal[095] := Left(_aTotal[095],4) + "-" + Substr(_aTotal[095],5,2)+ "-" + Right(_aTotal[095],2)
(PRE) _aTotal[096] := SF1->F1_HORA
(PRE) _aTotal[097] := fGetTaxas(SF1->F1_DOC, SF1->F1_SERIE, SF1->F1_FORNECE, SF1->F1_LOJA, If(_aTotal[116], "NCC",SF1->F1_ESPECIE))
(PRE) _aTotal[098] := ALLTRIM( GETNEWPAR( "MV_ID_PROV" , "" ) )
(PRE) _aTotal[099] := ALLTRIM( GETNEWPAR( "MV_ID_SOFT" , "" ) )
(PRE) _aTotal[100] := ALLTRIM( GETNEWPAR( "MV_CODESEC" , "" ) )
(PRE) _aTotal[101] := {"SD1",""}
(PRE) _aTotal[102] := IIF( _aTotal[033] == "NF" , "1" , IIF( _aTotal[033] == "NCC" , "2" , IIF( _aTotal[033] == "NDC" , "3" , IIF( _aTotal[033] == "NDI" , "4" , IIF( _aTotal[033] == "NCI" , "5" , "" ) ) ) ) )
(PRE) _aTotal[103] := ""
(PRE) _aTotal[104] := PADR( Alltrim(SM0->M0_CGC) , 10 , "0" )
(PRE) _aTotal[105] := IIF( _aTotal[033] == "NF" , "f" , IIF( _aTotal[033] == "NCC"  .or. _aTotal[033] == "NCI" , "c" , IIF( _aTotal[033] == "NDC" .or. _aTotal[033] == "NDI" , "d" , IIF( _aTotal[033] == "NDP" , "n" , "f" )) ) )
(PRE) _aTotal[106] := M486XHEX(PADR( ALLTRIM( substr( SF1->F1_DOC , 4 , Len(SF1->F1_DOC) - 3 ) ) , 10 , "0" ),10)
(PRE) _aTotal[107] := fGetRef(SF1->F1_DOC, SF1->F1_SERIE, SF1->F1_FORNECE, SF1->F1_LOJA, SF1->F1_ESPECIE,_aTotal[089])
(PRE) _aTotal[108] := ""
(PRE) _aTotal[109] := Posicione("CTO",1,xFilial("CTO")+Strzero(SF1->F1_MOEDA,2),"CTO_MOESAT")
(PRE) _aTotal[110] := {"SFP",""}
(PRE) _aTotal[111] := ""
(PRE) _aTotal[112] := ""
(PRE) _aTotal[113] := ""
(PRE) _aTotal[114] := "FP_FILUSO='" + cFilAnt + "' AND FP_SERIE='" + SF1->F1_SERIE + "' AND FP_ESPECIE= " +  If(_aTotal[116], "'1'",IIf(_aTotal[117] ,"'9'","'2'")) + " AND FP_NUMINI <='" + SF1->F1_DOC + "' AND FP_NUMFIM >='" + SF1->F1_DOC + "' AND FP_ATIVO ='1'"
(PRE) _aTotal[115] := "SFP->FP_FILUSO=cFilAnt .AND. SFP->FP_SERIE=SF1->F1_SERIE .AND. SFP->FP_ESPECIE=" +  If(_aTotal[116], "'1'",IIf(_aTotal[117] ,"'9'","'2'")) + ".AND. SFP->FP_NUMINI<=SF1->F1_DOC .AND. FP_NUMFIM >=SF1->F1_DOC .AND. SFP->FP_ATIVO = '1'","FP_ATIVO"

(PREREG) FsQuery(_aTotal[101],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.
(PREREG) FsQuery(_aTotal[110],1,_aTotal[114],_aTotal[115]) .And. .T.

[SFP CONTROL FOMULARIOS]
(PRE) _aTotal[103] := Dtos( SFP->FP_DTRESOL )
(PRE) _aTotal[103] := Left(_aTotal[103],4) + "-" + Substr(_aTotal[103],5,2)+ "-" + Right(_aTotal[103],2)
(PRE) _aTotal[111] := Alltrim( SFP->FP_NUMINI )
(PRE) _aTotal[112] := Alltrim( SFP->FP_NUMFIM )
(PRE) _aTotal[113] := Alltrim( SFP->FP_CAI )

[SD1 GENERANDO_XML]
(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")+SA2->A2_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",If(_aTotal[116] .OR. _aTotal[117], SA1->(MSSeek(xFilial("SA1")+SA2->A2_CLIENTE+SA2->A2_LOJCLI)),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.)

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

[XXX FACTURA]
(PRE) IIf(AllTrim(SF1->F1_ESPECIE)=="NCC",SYA->(MsSeek(xFilial("SYA")+SA2->A2_PAIS)) , .T.)
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF1->F1_COND)) , .T.)

(PRE) _aTotal[001] := IIF(_aTotal[116] .OR. _aTotal[117],'<fe:Invoice ','<fe:CreditNote ')
(PRE) _aTotal[001] += 'xmlns:fe="http://www.dian.gov.co/contratos/facturaelectronica/v1" '
(PRE) _aTotal[001] += 'xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" '
(PRE) _aTotal[001] += 'xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" '
(PRE) _aTotal[001] += 'xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001" '
(PRE) _aTotal[001] += 'xmlns:clm66411="urn:un:unece:uncefact:codelist:specification:66411:2001" '
(PRE) _aTotal[001] += 'xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003" '
(PRE) _aTotal[001] += 'xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" '
(PRE) _aTotal[001] += 'xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" '
(PRE) _aTotal[001] += 'xmlns:sts="http://www.dian.gov.co/contratos/facturaelectronica/v1/Structures" '
(PRE) _aTotal[001] += 'xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" '
(PRE) _aTotal[001] += 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
(PRE) _aTotal[001] += 'xsi:schemaLocation="http://www.dian.gov.co/contratos/facturaelectronica/v1 ../xsd/DIAN_UBL.xsd '
(PRE) _aTotal[001] += 'urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2 ../../ubl2/common/UnqualifiedDataTypeSchemaModule-2.0.xsd '
(PRE) _aTotal[001] += 'urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2 ../../ubl2/common/UBL-QualifiedDatatypes-2.0.xsd" '
(PRE) _aTotal[001] += '>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '    <ext:UBLExtensions>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <ext:UBLExtension>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <ext:ExtensionContent>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <sts:DianExtensions>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:InvoiceControl>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:InvoiceAuthorization>'+ _aTotal[113] +'</sts:InvoiceAuthorization>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:AuthorizationPeriod>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <cbc:StartDate>'+ _aTotal[103] +'</cbc:StartDate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <cbc:EndDate>'+ _aTotal[103] +'</cbc:EndDate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        </sts:AuthorizationPeriod>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:AuthorizedInvoices>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <sts:Prefix>'+ SF1->F1_SERIE2 +'</sts:Prefix>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <sts:From>'+ _aTotal[111] +'</sts:From>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <sts:To>'+ _aTotal[112] +'</sts:To>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        </sts:AuthorizedInvoices>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </sts:InvoiceControl>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:InvoiceSource>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:IdentificationCode listAgencyID="6" listAgencyName="United Nations Economic Commission for Europe" listSchemeURI="urn:oasis:names:specification:ubl:codelist:gc:CountryIdentificationCode-2.0">CO</cbc:IdentificationCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </sts:InvoiceSource>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '                    <sts:SoftwareProvider>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '                        <sts:ProviderID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeURI="http://www.unece.org/trade/untdid/d08a/tred/tred3055.htm" schemeName="NIT, RUT" schemeDataURI="http://www.unece.org/trade/untdid/d08a/tred/tred3055.htm" schemeName="NIT, RUT" schemeDataURI="www.dian.gov.co/contenidos/servicios/rut_preguntasfrecuentes.html"+ _aTotal[098] +'</sts:ProviderID>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '                        <sts:SoftwareID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeURI="http://www.unece.org/trade/untdid/d08a/tred/tred3055.htm" schemeName="Código de Activación" schemeDataURI="http://www.dian.gov.co/micrositios/fac_electronica/documentos/Guia_del_usuario_Habilitacion_Adquirente.pdf" >'+ _aTotal[099] +'</sts:SoftwareID>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '                    </sts:SoftwareProvider>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '                    <sts:SoftwareSecurityCode schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeURI="http://www.unece.org/trade/untdid/d08a/tred/tred3055.htm" schemeName="Código de Seguridad del Software" schemeDataURI="http://www.dian.gov.co/micrositios/fac_electronica/documentos/Anexo_Tecnico_003_Mecanismos_Sistema_Tecnico_de_Control.pdf">'+ _aTotal[100] +'</sts:SoftwareSecurityCode>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '                </sts:DianExtensions>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </ext:ExtensionContent>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </ext:UBLExtension>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <ext:UBLExtension>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <ext:ExtensionContent>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </ext:ExtensionContent>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </ext:UBLExtension>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </ext:UBLExtensions>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:UBLVersionID>UBL 2.0</cbc:UBLVersionID>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:ProfileID>DIAN 1.0</cbc:ProfileID>' + ( chr(13)+chr(10) )
// Manual con serie
//(PRE) _aTotal[001] += '    <cbc:ID>'+ SF1->F1_SERIE2 + Alltrim( Str( Val( Substr( SF1->F1_DOC , 4 , 10) ) ) ) +'</cbc:ID>' + ( chr(13)+chr(10) )
// Manual sin serie
(PRE) _aTotal[001] += '    <cbc:ID>'+ Alltrim( Str( Val( Substr( SF1->F1_DOC , 4 , 10) ) ) ) +'</cbc:ID>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:IssueDate>'+ _aTotal[095] +'</cbc:IssueDate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:IssueTime>'+ _aTotal[096] +'</cbc:IssueTime>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:Note><![CDATA['+ Alltrim(SF1->F1_MOTIVO) + ']]></cbc:Note>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:InvoiceTypeCode listAgencyID="195" listAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" listSchemeURI="http://www.dian.gov.co/contratos/facturaelectronica/v1/InvoiceType">91</cbc:InvoiceTypeCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:DocumentCurrencyCode>'+ Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF1->F1_MOEDA,2),"CTO_MOESAT") ) +'</cbc:DocumentCurrencyCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:CustomizationID>'+ Alltrim(SF1->F1_TIPOPE) +'</cbc:CustomizationID>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cac:DiscrepancyResponse>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:ReferenceID/>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:ResponseCode>' + Alltrim(SF1->F1_TIPREF) + '</cbc:ResponseCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </cac:DiscrepancyResponse>' + ( chr(13)+chr(10) )

// BillingReference
(PRE) _aTotal[001] += _aTotal[107]
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX EMISOR]
(PRE) _aTotal[001] := '    <fe:AccountingSupplierParty>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:AdditionalAccountID>'+ "1" +'</cbc:AdditionalAccountID>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <fe:Party>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:PartyIdentification>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:ID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeID="31">'+ Alltrim(SM0->M0_CGC) +'</cbc:ID>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:PartyIdentification>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:PartyName>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:Name><![CDATA['+ _aTotal[075] +']]></cbc:Name>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:PartyName>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PhysicalLocation>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <fe:Address>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:Department><![CDATA['+ AllTrim(SM0->M0_BAIRENT) +']]></cbc:Department>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CitySubdivisionName><![CDATA['+ AllTrim(SM0->M0_CODMUN) +']]></cbc:CitySubdivisionName>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CityName><![CDATA['+ Alltrim(SM0->M0_CIDENT) +']]></cbc:CityName>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:AddressLine>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:Line><![CDATA['+ Alltrim(SM0->M0_ENDENT) + " " + Alltrim(SM0->M0_COMPENT) +']]></cbc:Line>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:AddressLine>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:Country>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:IdentificationCode>'+ "CO" +'</cbc:IdentificationCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:Country>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </fe:Address>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PhysicalLocation>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PartyTaxScheme>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:TaxLevelCode>'+ AllTrim(SM0->M0_DSCCNA) +'</cbc:TaxLevelCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cac:TaxScheme/>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PartyTaxScheme>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PartyLegalEntity>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:RegistrationName><![CDATA['+ _aTotal[075] + ']]></cbc:RegistrationName>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PartyLegalEntity>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </fe:Party>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </fe:AccountingSupplierParty>'
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX RECEPTOR]
(PRE) AllTrim(SF1->F1_ESPECIE) <> "NCC"
(PRE) If(_aTotal[116] .OR. _aTotal[117], SA1->(MSSeek(xFilial("SA1")+SA2->A2_CLIENTE+SA2->A2_LOJCLI)) ,SA1->(MSSeek(xFilial("SA1")+SF1->F1_FORNECE+SF1->F1_LOJA)))
(PRE) SYA->(MsSeek(xFilial("SYA")+SA1->A1_PAIS))

(PRE) _aTotal[001] := '<fe:AccountingCustomerParty>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:AdditionalAccountID>'+ IIF( AllTrim(SA1->A1_PESSOA) == "F" , "2" , "1" ) +'</cbc:AdditionalAccountID>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <fe:Party>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PartyTaxScheme>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cbc:RegistrationName><![CDATA['+ Alltrim(SA1->A1_NOME) +']]></cbc:RegistrationName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cbc:CompanyID schemeID="' + Right( Alltrim(SA1->A1_CGC), 1 ) + '" schemeName="' + AllTrim(SA1->A1_TIPDOC)+ '" schemeAgencyName="CO, DIAN (Dirección de Impuestos y Aduanas Nacionales)" schemeAgencyID="195">'+ IIF(AllTrim(SA1->A1_TIPDOC) == "31",Left(Alltrim(SA1->A1_CGC),Len(Alltrim(SA1->A1_CGC))-1),AllTrim(SA1->A1_PFISICA))+'</cbc:CompanyID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cbc:TaxLevelCode listName="' + Alltrim(AI0->AI0_TPREG) + '">' + AllTrim(M486RESOBL(SA1->A1_COD,SA1->A1_LOJA,"R")) + '</cbc:TaxLevelCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:RegistrationAddress>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:ID>' + Alltrim(SA1->A1_COD_MUN) + '</cbc:ID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CityName><![CDATA[' + Alltrim(POSICIONE("CC2",3,xFilial("CC2") + SA1->A1_COD_MUN,"CC2_MUN")) + ']]></cbc:CityName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:PostalZone>' + Alltrim(SA1->A1_CEP) + '</cbc:PostalZone>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CountrySubentity><![CDATA[' + Alltrim(M486VALSX5('12' + SA1->A1_EST)) + ']]></cbc:CountrySubentity>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CountrySubentityCode>' + Alltrim(SA1->A1_EST) + '</cbc:CountrySubentityCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:Line><![CDATA[' + Alltrim(SA1->A1_END) + ']]></cbc:Line>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:IdentificationCode>'+Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCEDIAN")+'</cbc:IdentificationCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:RegistrationAddress>'  + ( chr(13)+chr(10) )  
(PRE) _aTotal[001] += '            </fe:PartyTaxScheme>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:PartyIdentification>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CompanyID schemeID="' + Right( Alltrim(SA1->A1_CGC), 1 ) + '" schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeName="' + AllTrim(SA1->A1_TIPDOC)+ '">'+ IIF(AllTrim(SA1->A1_TIPDOC) == "31",Left(Alltrim(SA1->A1_CGC),Len(Alltrim(SA1->A1_CGC))-1),AllTrim(SA1->A1_PFISICA))+'</cbc:CompanyID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:PartyIdentification>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            <cac:PartyName>' + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '                <cbc:Name><![CDATA['+ Alltrim(SA1->A1_NOME) +']]></cbc:Name>' + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            </cac:PartyName>' + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += '            <fe:PhysicalLocation>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <fe:Address>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:Department><![CDATA['+ AllTrim(SA1->A1_BAIRRO) +']]></cbc:Department>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CitySubdivisionName><![CDATA['+ AllTrim(SA1->A1_MUN) +']]></cbc:CitySubdivisionName>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CityName><![CDATA['+ Alltrim(Posicione("SX5",1,xFilial("SX5")+"12"+SA1->A1_EST,"X5_DESCRI")) +']]></cbc:CityName>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:AddressLine>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:Line><![CDATA['+ AllTrim(SA1->A1_END) +']]></cbc:Line>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:AddressLine>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:Country>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:IdentificationCode>'+Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCEDIAN")+'</cbc:IdentificationCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:Country>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </fe:Address>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PhysicalLocation>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:Contact>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:ElectronicMail>' + AllTrim(SA1->A1_EMAIL) + '</cbc:ElectronicMail>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:Telephone>' + AllTrim(SA1->A1_TEL) + '</cbc:Telephone>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:Contact>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            <fe:PartyLegalEntity>' + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '                <cbc:RegistrationName><![CDATA['+ Alltrim(SA1->A1_NOME) +']]></cbc:RegistrationName>' + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            </fe:PartyLegalEntity>' + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '            <fe:Person>'  + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '                <cbc:FirstName><![CDATA[' + Alltrim(SA1->A1_NOMEPRI) +']]></cbc:FirstName>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '                <cbc:MiddleName><![CDATA[' + Alltrim(SA1->A1_NOMEPES) +']]></cbc:MiddleName>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '                <cbc:FamilyName><![CDATA[' + Alltrim(SA1->A1_NOMEPAT) + ' ' + Alltrim(SA1->A1_NOMEMAT) +']]></cbc:FamilyName>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '            </fe:Person>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += '        </fe:Party>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </fe:AccountingCustomerParty>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '    <cac:PaymentTerms>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:Amount currencyID="' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF1->F1_MOEDA,2),"CTO_MOESAT") ) + '">' + Alltrim(Str(SF1->F1_VALBRUT,14,2)) + '</cbc:Amount>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cac:SettlementPeriod>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cbc:StartDate>' + Transform( DtoS( Posicione("SE1",2,xFilial("SE1")+SF1->(F1_FORNECE+F1_LOJA+F1_SERIE+F1_DOC),"E1_EMISSAO") ) , "@R 9999-99-99") + '</cbc:StartDate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cbc:EndDate>' + Transform( DtoS( Posicione("SE1",2,xFilial("SE1")+SF1->(F1_FORNECE+F1_LOJA+F1_SERIE+F1_DOC),"E1_VENCTO") ) , "@R 9999-99-99") + '</cbc:EndDate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </cac:SettlementPeriod>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </cac:PaymentTerms>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '    <cac:PaymentExchangeRate>'  + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:SourceCurrencyCode>' + "COP" + '</cbc:SourceCurrencyCode>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:SourceCurrencyBaseRate>' +  Alltrim(Str(SF1->F1_TXMOEDA,11,2)) + '</cbc:SourceCurrencyBaseRate>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:TargetCurrencyCode>' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF1->F1_MOEDA,2),"CTO_MOESAT") ) + '</cbc:TargetCurrencyCode>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:TargetCurrencyBaseRate>1.00</cbc:TargetCurrencyBaseRate>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:CalculationRate>' +  Alltrim(Str(SF1->F1_TXMOEDA,11,2)) + '</cbc:CalculationRate>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '        <cbc:Date>' + _aTotal[095] + '</cbc:Date>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIf( _aTotal[109] <> "COP" , '    </cac:PaymentExchangeRate>'  + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX IMPUESTOS]
(PRE) _aTotal[001] := _aTotal[097][1]
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX TOTALES]
(PRE) _aTotal[001] := _aTotal[097][2]
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[SD1 INVOICE]
(PRE) DbGoTop()
(PREREG) (SB1->(DbSeek(xFilial("SB1") + SD1->D1_COD)),.T.)
(PREREG) (SAH->(DbSeek(xFilial("SAH") + SB1->B1_UM)),.T.)

(PREREG) _aTotal[108] := fGetTaxDet(SD1->D1_DOC,SD1->D1_SERIE,SD1->D1_FORNECE,SD1->D1_LOJA,SD1->D1_TES,If(_aTotal[116] .OR. _aTotal[117], "NCC",AllTrim(SF1->F1_ESPECIE)))
(PREREG) (_aTotal[001] := IIF( _aTotal[116] .OR. _aTotal[117],'    <fe:InvoiceLine>'  + ( chr(13)+chr(10) ),'    <cac:CreditNoteLine>'  + ( chr(13)+chr(10) )),.T.)
(PREREG) (_aTotal[001] += '        <cbc:ID>' + Alltrim(Str(Val(SD1->D1_ITEM))) + '</cbc:ID>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(_aTotal[116] .OR. _aTotal[117],'        <cbc:InvoicedQuantity unitCode="' + Alltrim(_aTotal[108][3]) + '">'+ Alltrim(Str(SD1->D1_QUANT, 14, 2)) +'</cbc:InvoicedQuantity>'  + ( chr(13)+chr(10) ),'        <cbc:CreditedQuantity unitCode="' + Alltrim(_aTotal[108][3]) + '">'+ Alltrim(Str(SD1->D1_QUANT)) +'</cbc:CreditedQuantity>'  + ( chr(13)+chr(10) )),.T.)
(PREREG) (_aTotal[001] += '        <cbc:LineExtensionAmount currencyID=' + '"' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF1->F1_MOEDA,2),"CTO_MOESAT") ) + '"' + '>' + Alltrim(Str(IIf(Alltrim(SF1->F1_ESPECIE)=="NCC" .And. SF1->F1_MOEDA<>1,Round(xMoeda(SD1->D1_TOTAL,SF1->F1_MOEDA,1,,MsDecimais(1)+1,SF1->F1_TXMOEDA),MsDecimais(1)),SD1->D1_TOTAL))) +'</cbc:LineExtensionAmount>' + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += _aTotal[108][1],.T.)
(PREREG) (_aTotal[001] += IIF(SD1->D1_VALDESC > 0, '        <cac:AllowanceCharge>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD1->D1_VALDESC > 0, '            <cbc:ChargeIndicator>false</cbc:ChargeIndicator>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD1->D1_VALDESC > 0, '                <cbc:AllowanceChargeReason><![CDATA[Aplicación de descuento]]></cbc:AllowanceChargeReason>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD1->D1_VALDESC > 0, '                <cbc:MultiplierFactorNumeric>' + Alltrim(Str(SD1->D1_DESC,5,2)) + '</cbc:MultiplierFactorNumeric>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD1->D1_VALDESC > 0, '            <cbc:Amount currencyID="' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF1->F1_MOEDA,2),"CTO_MOESAT") ) + '">' + Alltrim(Str(IIf(Alltrim(SF1->F1_ESPECIE)=="NCC" .And. SF1->F1_MOEDA<>1,Round(xMoeda(SD1->D1_VALDESC,SF1->F1_MOEDA,1,,MsDecimais(1)+1,SF1->F1_TXMOEDA),MsDecimais(1)),SD1->D1_VALDESC))) + '</cbc:Amount>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD1->D1_VALDESC > 0, '        </cac:AllowanceCharge>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += _aTotal[108][2],.T.)
(PREREG) (_aTotal[001] += IIF(_aTotal[116] .OR. _aTotal[117] ,'        <fe:Item>', '        <cac:Item>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:Description><![CDATA[' + Alltrim(SB1->B1_DESC) +']]></cbc:Description>' + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:PackSizeNumeric>'+ IIf(!Empty(SB1->B1_CONV),Alltrim(STR(SB1->B1_CONV)),"1") +'</cbc:PackSizeNumeric>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cac:SellersItemIdentification>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '                <cbc:ID>' + Alltrim(SD1->D1_COD) + '</cbc:ID>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            </cac:SellersItemIdentification>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF( _aTotal[116] .OR. _aTotal[117],'        </fe:Item>', '        </cac:Item>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF( _aTotal[116] .OR. _aTotal[117],'        <fe:Price>','        <cac:Price>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) _aTotal[090] := Alltrim(IIf(AllTrim(SF1->F1_ESPECIE)=="NCC" .And. SF1->F1_MOEDA<>1,Str(Round(xMoeda(SD1->D1_VUNIT,SF1->F1_MOEDA,1,,MsDecimais(1)+1,SF1->F1_TXMOEDA),MsDecimais(1)),14,2),Str(SD1->D1_VUNIT,14,2)))
(PREREG) (_aTotal[001] += '            <cbc:PriceAmount currencyID=' + '"' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF1->F1_MOEDA,2),"CTO_MOESAT") ) + '"' + '>' + _aTotal[090] +'</cbc:PriceAmount>' + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:BaseQuantity unitCode="' + Alltrim(_aTotal[108][3]) + '">' + Alltrim(Str(SD1->D1_QUANT)) + '</cbc:BaseQuantity>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(_aTotal[116] .OR. _aTotal[117],'        </fe:Price>', '        </cac:Price>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF( _aTotal[116] .OR. _aTotal[117],'    </fe:InvoiceLine>' ,'    </cac:CreditNoteLine>') ,.T.)
(PREREG) ENCODEUTF8(_aTotal[001])

[XXX INVOICE_FIN]
(POS) FsQuery(_aTotal[101],2)

[XXX FACTURA]
(PRE) _aTotal[094] := &("Lower('face') + '_' + Lower(_aTotal[105]) + Lower(_aTotal[104]) + Lower(_aTotal[106]) + '.xml'")

(ARQ) _aTotal[094]
FACTURA    C 019 0 ENCODEUTF8( IIF( _aTotal[116] .OR. _aTotal[117], '</fe:Invoice>','</fe:CreditNote>'))


Informações
titleFATSECOL.INI

FATSECOL.INI

//FATSCOL.INI -- NFE Colombia v2 - Resolucion 0019 / FEB. 2016
[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) SE1->(DbSetOrder(2))

(PRE) _aTotal[033] := ALLTRIM (SF2->F2_ESPECIE)
(PRE) _aTotal[075] := Alltrim(SM0->M0_NOMECOM)
(PRE) _aTotal[093] := ""
(PRE) _aTotal[094] := ""
(PRE) _aTotal[095] := DtoS(SF2->F2_EMISSAO)
(PRE) _aTotal[095] := Left(_aTotal[095],4) + "-" + Substr(_aTotal[095],5,2)+ "-" + Right(_aTotal[095],2)
(PRE) _aTotal[096] := SF2->F2_HORA
(PRE) _aTotal[097] := fGetTaxas(SF2->F2_DOC, SF2->F2_SERIE, SF2->F2_CLIENTE, SF2->F2_LOJA,SF2->F2_ESPECIE )
(PRE) _aTotal[098] := ALLTRIM( GETNEWPAR( "MV_ID_PROV" , "" ) )
(PRE) _aTotal[099] := ALLTRIM( GETNEWPAR( "MV_ID_SOFT" , "" ) )
(PRE) _aTotal[100] := ALLTRIM( GETNEWPAR( "MV_CODESEC" , "" ) ) 
(PRE) _aTotal[101] := {"SD2",""}
(PRE) _aTotal[102] := IIF( _aTotal[033] == "NF" , "1" , IIF( _aTotal[033] == "NCC" , "2" , IIF( _aTotal[033] == "NDC" , "3" , IIF( _aTotal[033] == "NDI" , "4" , IIF( _aTotal[033] == "NCI" , "5" , "" ) ) ) ) )
(PRE) _aTotal[103] := ""
(PRE) _aTotal[104] := PADR( Alltrim(SM0->M0_CGC) , 10 , "0" )
(PRE) _aTotal[105] := IIF( _aTotal[033] == "NF" , "f" , IIF( _aTotal[033] == "NCC"  .or. _aTotal[033] == "NCI" , "c" , IIF( _aTotal[033] == "NDC" .or. _aTotal[033] == "NDI" , "d" , "f" ) ) )
(PRE) _aTotal[106] := M486XHEX(PADR( ALLTRIM( substr( SF2->F2_DOC , 4 , Len(SF2->F2_DOC) - 3 ) ) , 10 , "0" ),10)
(PRE) _aTotal[107] := IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",fGetRef(SF2->F2_DOC, SF2->F2_SERIE, SF2->F2_CLIENTE, SF2->F2_LOJA,SF2->F2_ESPECIE),"")
(PRE) _aTotal[108] := ""
(PRE) _aTotal[109] := {"SFP",""}
(PRE) _aTotal[110] := ""
(PRE) _aTotal[111] := ""
(PRE) _aTotal[112] := ""
(PRE) _aTotal[113] := "FP_FILUSO='" + cFilAnt + "' AND FP_SERIE='" + SF2->F2_SERIE + "' AND FP_ESPECIE= '" + IIf(_aTotal[033] == "NF","1","3") + "' AND FP_NUMINI <='" + SF2->F2_DOC + "' AND FP_NUMFIM >='" + SF2->F2_DOC + "' AND FP_ATIVO ='1'"
(PRE) _aTotal[114] := "SFP->FP_FILUSO=cFilAnt .AND. SFP->FP_SERIE=SF2->F2_SERIE .AND. SFP->FP_ESPECIE='" + IIf(_aTotal[033] == "NF","1","3") + "' .AND. SFP->FP_NUMINI<=SF2->F2_DOC .AND. FP_NUMFIM >=SF2->F2_DOC .AND. SFP->FP_ATIVO = '1'","FP_ATIVO"

(PRE) _aTotal[115] := SuperGetMV("MV_ANEXO19",.F.,.F.) Se debe eliminar

(PREREG) FsQuery(_aTotal[101],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.
(PREREG) FsQuery(_aTotal[109],1,_aTotal[113],_aTotal[114]) .And. .T.

[SFP CONTROL FOMULARIOS]
(PRE) _aTotal[103] := Dtos( SFP->FP_DTRESOL )
(PRE) _aTotal[103] := Left(_aTotal[103],4) + "-" + Substr(_aTotal[103],5,2)+ "-" + Right(_aTotal[103],2)
(PRE) _aTotal[110] := Alltrim( SFP->FP_NUMINI )
(PRE) _aTotal[111] := Alltrim( SFP->FP_NUMFIM )
(PRE) _aTotal[112] := Alltrim( SFP->FP_CAI )

[SD2 GENERANDO_XML]
(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.)

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

[XXX FACTURA]
(PRE) Iif(AllTrim(SF2->F2_ESPECIE)=="NDI",SYA->(MsSeek(xFilial("SYA")+SA2->A2_PAIS)) , .T.)
(PRE) (SE4->(MSSeek(xFilial("SE4")+SF2->F2_COND)) , .T.)

(PRE) _aTotal[001] := IIF(AllTrim(SF2->F2_ESPECIE)=="NF",'<fe:Invoice ','<fe:DebitNote ')
(PRE) _aTotal[001] += 'xmlns:fe="http://www.dian.gov.co/contratos/facturaelectronica/v1" '
(PRE) _aTotal[001] += 'xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" '
(PRE) _aTotal[001] += 'xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" '
(PRE) _aTotal[001] += 'xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001" '
(PRE) _aTotal[001] += 'xmlns:clm66411="urn:un:unece:uncefact:codelist:specification:66411:2001" '
(PRE) _aTotal[001] += 'xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003" '
(PRE) _aTotal[001] += 'xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" '
(PRE) _aTotal[001] += 'xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" '
(PRE) _aTotal[001] += 'xmlns:sts="http://www.dian.gov.co/contratos/facturaelectronica/v1/Structures" '
(PRE) _aTotal[001] += 'xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" '
(PRE) _aTotal[001] += 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
(PRE) _aTotal[001] += 'xsi:schemaLocation="http://www.dian.gov.co/contratos/facturaelectronica/v1 ../xsd/DIAN_UBL.xsd '
(PRE) _aTotal[001] += 'urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2 ../../ubl2/common/UnqualifiedDataTypeSchemaModule-2.0.xsd '
(PRE) _aTotal[001] += 'urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2 ../../ubl2/common/UBL-QualifiedDatatypes-2.0.xsd" '
(PRE) _aTotal[001] += '>' + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '    <ext:UBLExtensions>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <ext:UBLExtension>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <ext:ExtensionContent>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <sts:DianExtensions>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:InvoiceControl>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:InvoiceAuthorization>'+ _aTotal[112] +'</sts:InvoiceAuthorization>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:AuthorizationPeriod>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <cbc:StartDate>'+ _aTotal[103] +'</cbc:StartDate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <cbc:EndDate>'+ _aTotal[103] +'</cbc:EndDate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        </sts:AuthorizationPeriod>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:AuthorizedInvoices>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <sts:Prefix>'+ SF2->F2_SERIE2 +'</sts:Prefix>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <sts:From>'+ _aTotal[110] +'</sts:From>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                            <sts:To>'+ _aTotal[111] +'</sts:To>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        </sts:AuthorizedInvoices>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </sts:InvoiceControl>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:InvoiceSource>'  + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '                        <cbc:IdentificationCode listAgencyID="6" listAgencyName="United Nations Economic Commission for Europe" listSchemeURI="urn:oasis:names:specification:ubl:codelist:gc:CountryIdentificationCode-2.0">CO</cbc:IdentificationCode>'  + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '                    </sts:InvoiceSource>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:SoftwareProvider>'  + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '                        <sts:ProviderID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)">'+ _aTotal[098] +'</sts:ProviderID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <sts:SoftwareID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)">'+ _aTotal[099] +'</sts:SoftwareID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </sts:SoftwareProvider>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <sts:SoftwareSecurityCode schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)">'+ _aTotal[100] +'</sts:SoftwareSecurityCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </sts:DianExtensions>'  + ( chr(13)+chr(10) )

(PRE) _aTotal[001] += '            </ext:ExtensionContent>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </ext:UBLExtension>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <ext:UBLExtension>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <ext:ExtensionContent>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </ext:ExtensionContent>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </ext:UBLExtension>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </ext:UBLExtensions>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:UBLVersionID>UBL 2.0</cbc:UBLVersionID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:ProfileID>DIAN 1.0</cbc:ProfileID>'  + ( chr(13)+chr(10) )
// Manual con serie
//(PRE) _aTotal[001] += '    <cbc:ID>'+ SF2->F2_SERIE2 + Alltrim( Str( Val( Substr( SF2->F2_DOC , 4 , 10) ) ) ) +'</cbc:ID>'  + ( chr(13)+chr(10) )
// Manual sin serie
(PRE) _aTotal[001] += '    <cbc:ID>'+ Alltrim( Str( Val( Substr( SF2->F2_DOC , 4 , 10) ) ) ) +'</cbc:ID>'  + ( chr(13)+chr(10) )
(PRE) FsQuery(_aTotal[109],2)
// CUFE Aplica solo para NF
(PRE) _aTotal[093] := ""
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF",'    <cbc:UUID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)">'+  _aTotal[093] +'</cbc:UUID>'  + ( chr(13)+chr(10) ),"")

(PRE) _aTotal[001] += '    <cbc:IssueDate>'+ _aTotal[095] +'</cbc:IssueDate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cbc:IssueTime>'+ _aTotal[096] +'</cbc:IssueTime>'  + ( chr(13)+chr(10) )

//  DiscrepancyResponse Solo para la Nota de Débito
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",'    <cac:DiscrepancyResponse>' +  chr(13)+chr(10),"")
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",'        <cbc:ReferenceID/>' + chr(13)+chr(10),"")
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",'        <cbc:ResponseCode listName="concepto de notas débito" listSchemeURI="http://www.dian.gov.co/micrositios/fac_electronica/documentos/Anexo_Tecnico_001_Formatos_de_los_Documentos_XML_de_Facturacion_Electron.pdf" name="1:= intereses">' + SF2->F2_TIPREF + "</cbc:ResponseCode>"+ chr(13)+chr(10),"")
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",'    </cac:DiscrepancyResponse>' + chr(13)+chr(10),"")

// BillingReference solo para la Nota de Débito
(PRE) _aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NDC",_aTotal[107],"")
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX EMISOR]
(PRE) _aTotal[001] := '    <fe:AccountingSupplierParty>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:AdditionalAccountID>'+ "1" +'</cbc:AdditionalAccountID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <fe:Party>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:PartyIdentification>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:ID schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeID="31">'+ Alltrim(SM0->M0_CGC) +'</cbc:ID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:PartyIdentification>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:PartyName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:Name><![CDATA['+ _aTotal[075] +']]></cbc:Name>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:PartyName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PhysicalLocation>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <fe:Address>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:Department><![CDATA['+ AllTrim(SM0->M0_BAIRENT) +']]></cbc:Department>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CitySubdivisionName><![CDATA['+ AllTrim(SM0->M0_CODMUN) +']]></cbc:CitySubdivisionName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CityName><![CDATA['+ Alltrim(SM0->M0_CIDENT) +']]></cbc:CityName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:Line><![CDATA['+ Alltrim(SM0->M0_ENDENT) + " " + Alltrim(SM0->M0_COMPENT) +']]></cbc:Line>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:IdentificationCode>'+ "CO" +'</cbc:IdentificationCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </fe:Address>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PhysicalLocation>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PartyTaxScheme>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:TaxLevelCode>'+ AllTrim(SM0->M0_DSCCNA) +'</cbc:TaxLevelCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cac:TaxScheme/>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PartyTaxScheme>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <fe:PartyLegalEntity>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:RegistrationName><![CDATA['+ _aTotal[075] +']]></cbc:RegistrationName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PartyLegalEntity>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </fe:Party>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </fe:AccountingSupplierParty>'  
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX 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))

(PRE) _aTotal[001] := '    <fe:AccountingCustomerParty>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:AdditionalAccountID>'+ IIF( AllTrim(SA1->A1_PESSOA) == "F" , "2" , "1" ) +'</cbc:AdditionalAccountID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <fe:Party>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '           <fe:PartyTaxScheme>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '           <cbc:RegistrationName><![CDATA['+ Alltrim(SA1->A1_NOME) +']]></cbc:RegistrationName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:CompanyID schemeID="' + Right( Alltrim(SA1->A1_CGC), 1 ) + '" schemeName="' + AllTrim(SA1->A1_TIPDOC)+ '" schemeAgencyName="CO, DIAN (Dirección de Impuestos y Aduanas Nacionales)" schemeAgencyID="195">'+ IIF(AllTrim(SA1->A1_TIPDOC) == "31",Left(Alltrim(SA1->A1_CGC),Len(Alltrim(SA1->A1_CGC))-1),AllTrim(SA1->A1_PFISICA))+'</cbc:CompanyID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:TaxLevelCode listName="' + Alltrim(AI0->AI0_TPREG) + '">' + AllTrim(M486RESOBL(SA1->A1_COD,SA1->A1_LOJA,"R")) + '</cbc:TaxLevelCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cac:RegistrationAddress>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:ID>' + Alltrim(SA1->A1_COD_MUN) + '</cbc:ID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CityName><![CDATA[' + Alltrim(POSICIONE("CC2",3,xFilial("CC2") + SA1->A1_COD_MUN,"CC2_MUN")) + ']]></cbc:CityName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:PostalZone>' + Alltrim(SA1->A1_CEP) + '</cbc:PostalZone>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CountrySubentity><![CDATA[' + Alltrim(M486VALSX5('12' + SA1->A1_EST)) + ']]></cbc:CountrySubentity>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CountrySubentityCode>' + Alltrim(SA1->A1_EST) + '</cbc:CountrySubentityCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:Line><![CDATA[' + Alltrim(SA1->A1_END) + ']]></cbc:Line>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:IdentificationCode>'+Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCEDIAN")+'</cbc:IdentificationCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:RegistrationAddress>'  + ( chr(13)+chr(10) )     
(PRE) _aTotal[001] += '        </fe:PartyTaxScheme>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cac:PartyIdentification>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:CompanyID schemeID="' + Right( Alltrim(SA1->A1_CGC), 1 ) + '" schemeAgencyID="195" schemeAgencyName="CO, DIAN (Direccion de Impuestos y Aduanas Nacionales)" schemeName="' + AllTrim(SA1->A1_TIPDOC)+ '">'+ IIF(AllTrim(SA1->A1_TIPDOC) == "31",Left(Alltrim(SA1->A1_CGC),Len(Alltrim(SA1->A1_CGC))-1),AllTrim(SA1->A1_PFISICA))+'</cbc:CompanyID>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:PartyIdentification>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            <cac:PartyName>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '                <cbc:Name><![CDATA['+ Alltrim(SA1->A1_NOME) +']]></cbc:Name>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            </cac:PartyName>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += '            <fe:PhysicalLocation>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <fe:Address>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:Department><![CDATA['+ AllTrim(SA1->A1_BAIRRO) +']]></cbc:Department>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CitySubdivisionName><![CDATA['+ AllTrim(SA1->A1_MUN) +']]></cbc:CitySubdivisionName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cbc:CityName><![CDATA['+ Alltrim(Posicione("SX5",1,xFilial("SX5")+"12"+SA1->A1_EST,"X5_DESCRI")) +']]></cbc:CityName>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:Line><![CDATA['+ AllTrim(SA1->A1_END) +']]></cbc:Line>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:AddressLine>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    <cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                        <cbc:IdentificationCode>'+Posicione("SYA",1,xFilial("SYA")+SA1->A1_PAIS,"YA_CCEDIAN")+'</cbc:IdentificationCode>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                    </cac:Country>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                </fe:Address>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </fe:PhysicalLocation>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            <fe:PartyLegalEntity>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '                <cbc:RegistrationName><![CDATA['+ Alltrim(SA1->A1_NOME) +']]></cbc:RegistrationName>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , "" , '            </fe:PartyLegalEntity>'  + ( chr(13)+chr(10) ) )
(PRE) _aTotal[001] += '            <cac:Contact>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:ElectronicMail>' + AllTrim(SA1->A1_EMAIL) + '</cbc:ElectronicMail>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '                <cbc:Telephone>' + AllTrim(SA1->A1_TEL) + '</cbc:Telephone>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            </cac:Contact>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '            <fe:Person>'  + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '                <cbc:FirstName><![CDATA[' + Alltrim(SA1->A1_NOMEPRI) +']]></cbc:FirstName>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '                <cbc:MiddleName><![CDATA[' + Alltrim(SA1->A1_NOMEPES) +']]></cbc:MiddleName>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '                <cbc:FamilyName><![CDATA[' + Alltrim(SA1->A1_NOMEPAT) + ' ' + Alltrim(SA1->A1_NOMEMAT) +']]></cbc:FamilyName>' + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += IIF( AllTrim(SA1->A1_PESSOA) == "F" , '            </fe:Person>'  + ( chr(13)+chr(10) ) , "" )
(PRE) _aTotal[001] += '        </fe:Party>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </fe:AccountingCustomerParty>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cac:PaymentTerms>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:Amount currencyID="' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '">' + Alltrim(Str(SF2->F2_VALBRUT,14,2)) + '</cbc:Amount>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cac:SettlementPeriod>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cbc:StartDate>' + Transform( DtoS( Posicione("SE1",2,xFilial("SE1")+SF2->(F2_CLIENTE+F2_LOJA+F2_SERIE+F2_DOC),"E1_EMISSAO") ) , "@R 9999-99-99") + '</cbc:StartDate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '            <cbc:EndDate>' + Transform( DtoS( Posicione("SE1",2,xFilial("SE1")+SF2->(F2_CLIENTE+F2_LOJA+F2_SERIE+F2_DOC),"E1_VENCTO") ) , "@R 9999-99-99") + '</cbc:EndDate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        </cac:SettlementPeriod>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </cac:PaymentTerms>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    <cac:PaymentExchangeRate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:SourceCurrencyCode>' + "COP" + '</cbc:SourceCurrencyCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:SourceCurrencyBaseRate>' +  Alltrim(Str(SF2->F2_TXMOEDA,11,2)) + '</cbc:SourceCurrencyBaseRate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:TargetCurrencyCode>' +  Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '</cbc:TargetCurrencyCode>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:TargetCurrencyBaseRate>1.00</cbc:TargetCurrencyBaseRate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:CalculationRate>' +  Alltrim(Str(SF2->F2_TXMOEDA,11,2)) + '</cbc:CalculationRate>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '        <cbc:Date>' + _aTotal[095] + '</cbc:Date>' + ( chr(13)+chr(10) )
(PRE) _aTotal[001] += '    </cac:PaymentExchangeRate>'  + ( chr(13)+chr(10) )
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX IMPUESTOS]
(PRE) _aTotal[001] := _aTotal[097][1]
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[XXX TOTALES]
(PRE) _aTotal[001] := _aTotal[097][2]
(PRE) _aTotal[001] := ENCODEUTF8(_aTotal[001])
(PREREG) _aTotal[001]

[SD2 INVOICE]
(PRE) DbGoTop()
(PREREG) (SB1->(DbSeek(xFilial("SB1") + SD2->D2_COD)),.T.)
(PREREG) (SAH->(DbSeek(xFilial("SAH") + SB1->B1_UM)),.T.)
(PREREG) _aTotal[108] := fGetTaxDet(SD2->D2_DOC,SD2->D2_SERIE,SD2->D2_CLIENTE,SD2->D2_LOJA,SD2->D2_TES,AllTrim(SF2->F2_ESPECIE))
(PREREG) (_aTotal[001] := IIF(AllTrim(SF2->F2_ESPECIE)=="NF",'    <fe:InvoiceLine>'  + ( chr(13)+chr(10) ),'    <cac:DebitNoteLine>'  + ( chr(13)+chr(10) )),.T.)
(PREREG) (_aTotal[001] += '        <cbc:ID>' + Alltrim(Str(Val(SD2->D2_ITEM))) + '</cbc:ID>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF",'        <cbc:InvoicedQuantity unitCode="' + Alltrim(_aTotal[108][3]) + '">'+ Alltrim(Str(SD2->D2_QUANT)) +'</cbc:InvoicedQuantity>'  + ( chr(13)+chr(10) ),'        <cbc:DebitedQuantity unitCode="' + Alltrim(_aTotal[108][3]) + '">'+ Alltrim(Str(SD2->D2_QUANT)) +'</cbc:DebitedQuantity>'  + ( chr(13)+chr(10) )),.T.)
(PREREG) (_aTotal[001] += '        <cbc:LineExtensionAmount currencyID=' + '"' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '"' + '>' + Alltrim(Str(IIf(AllTrim(SF2->F2_ESPECIE)$"NF|NDC" .And. SF2->F2_MOEDA<>1,Round(xMoeda(SD2->D2_TOTAL,SF2->F2_MOEDA,1,,MsDecimais(1)+1,SF2->F2_TXMOEDA),MsDecimais(1)),SD2->D2_TOTAL),14,2)) +'</cbc:LineExtensionAmount>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += _aTotal[108][1],.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '        <cac:AllowanceCharge>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '            <cbc:ChargeIndicator>false</cbc:ChargeIndicator>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '            <cbc:AllowanceChargeReason><![CDATA[Aplicación de descuento]]></cbc:AllowanceChargeReason>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '            <cbc:MultiplierFactorNumeric>' + Alltrim(Str(SD2->D2_DESC,5,2)) + '</cbc:MultiplierFactorNumeric>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '            <cbc:Amount currencyID="' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '">' + Alltrim(Str(IIf(AllTrim(SF2->F2_ESPECIE)$"NF|NDC" .And. SF2->F2_MOEDA<>1,Round(xMoeda(SD2->D2_DESCON,SF2->F2_MOEDA,1,,MsDecimais(1)+1,SF2->F2_TXMOEDA),MsDecimais(1)),SD2->D2_DESCON),14,2)) + '</cbc:Amount>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += IIF(SD2->D2_DESCON > 0, '        </cac:AllowanceCharge>' + chr(13)+chr(10), ""),.T.)
(PREREG) (_aTotal[001] += _aTotal[108][2],.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF",'        <fe:Item>', '        <cac:Item>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:Description><![CDATA['+ Alltrim(SB1->B1_DESC) +']]></cbc:Description>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:PackSizeNumeric>'+ IIf(!Empty(SB1->B1_CONV),Alltrim(STR(SB1->B1_CONV)),"1") +'</cbc:PackSizeNumeric>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cac:SellersItemIdentification>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '                <cbc:ID>' + Alltrim(SD2->D2_COD) + '</cbc:ID>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            </cac:SellersItemIdentification>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF",'        </fe:Item>', '        </cac:Item>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF",'        <fe:Price>','        <cac:Price>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:PriceAmount currencyID=' + '"' + Alltrim( Posicione("CTO",1,xFilial("CTO")+Strzero(SF2->F2_MOEDA,2),"CTO_MOESAT") ) + '"' + '>' + Alltrim(Str(IIf(AllTrim(SF2->F2_ESPECIE)$"NF|NDC" .And. SF2->F2_MOEDA<>1,Round(xMoeda(SD2->D2_PRCVEN,SF2->F2_MOEDA,1,,MsDecimais(1)+1,SF2->F2_TXMOEDA),MsDecimais(1)),SD2->D2_PRCVEN),14,2)) +'</cbc:PriceAmount>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += '            <cbc:BaseQuantity unitCode="' + Alltrim(_aTotal[108][3]) + '">'+ Alltrim(Str(SD2->D2_QUANT)) +'</cbc:BaseQuantity>'  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF",'        </fe:Price>', '        </cac:Price>')  + ( chr(13)+chr(10) ),.T.)
(PREREG) (_aTotal[001] += IIF(AllTrim(SF2->F2_ESPECIE)=="NF",'    </fe:InvoiceLine>' ,'    </cac:DebitNoteLine>') ,.T.)
(PREREG) ENCODEUTF8(_aTotal[001])

[XXX INVOICE_FIN]
(POS) FsQuery(_aTotal[101],2)

[XXX FACTURA]
(PRE) _aTotal[094] := &("Lower('face') + '_' + Lower(_aTotal[105]) + Lower(_aTotal[104]) + Lower(_aTotal[106]) + '.xml'")

(ARQ) _aTotal[094]
FACTURA    C 019 0 ENCODEUTF8( IIF(AllTrim(SF2->F2_ESPECIE)=="NF", '</fe:Invoice>','</fe:DebitNote>'))


2.20.2 Ejemplo de utilización

En el módulo Facturación (SIGAFAT): 

Desde el Actualizaciones | Archivos | Clientes, configurar un Cliente Nacional para la Factura de Venta/Nota de Crédito de Cliente.

Desde el Actualizaciones | Archivos | Productos, configurar el o los Productos para la Factura de Venta/Nota de Crédito de Cliente.

Desde el Actualizaciones | Archivos | Tipos de Entrada y Salida, configurar el Tipo de Salida (TES) para la Factura de Venta y Tipo de Entrada (TES) para la Nota de Crédito de Cliente.


En el módulo Facturación (SIGAFAT): 

  • Ir al menú Actualizaciones | Facturación | Facturaciones (MATA467N).
    • Incluir una nueva Factura de Venta (NF).
    • Informar en el encabezado el Cliente Nacional configurado previamente.
    • Informar en el detalle el o los Productos (D2_COD), Cantidad (D2_QUANT),  Valor Unit. (D2_PRCVEN), Valor Total D2_TOTAL) y Tipo Salida (D2_TES). 
  • Ir al menú Actualizaciones | Facturación | Transmisión Electrónica (MATA486).
    • Realizar la transmisión de la Factura de Venta (Validar que la transmisión haya sido exitosa)
    • Desde Otras acciones ejecutar la acción Imprimir PDF.
    • Validar que en el formato PDF, los montos se muestren en moneda COP, y que se visualice la información en la moneda origen del Documento.

3. PROBLEMAS COMUNES

3.1 Facturas de Venta

...

Aviso
titleIMPORTANTE

Debido a que se aplazó la obligatoriedad del Anexo 1.9 para el 01 de Mayo de 2024, se activó el parámetro MV_ANEXO19, para activar la funcionalidad, el cual deberá ser configurado con el valor .T..

Para tener activo el parámetro se deben tener en el repositorio las siguientes rutinas, con fecha igual o superior:

RutinaNombre TécnicoFecha
M486XFUNFunciones Genéricas de Documentos Electrónicos
27
28/02/2024
M486XFUNCOFunciones Genéricas de Facturación Electrónica de Colombia27/02/2024
LOCXCOLFunciones localizadas de Documentos fiscales - Colombia27/02/2024
INPUTFIELDSCOLEstructura de campos documentos de entrada para país Colombia28/02/2024
OUTPUTFIELDSCOLEstructura de campos documentos de salida para país Colombia
28
01/
02
03/2024
FATSECOL.INIEstructura del XML de Facturas de Exportación
27
29/02/2024
FATECOL.INIEstructura del XML de Notas de Crédito
27
29/02/2024

Creación del parámetro en la tabla SX6 - Parámetros:

Ajustes en el Estructura del XML de Facturas de Exportación:

Campo

Valor

Nombre de Var.MV_ANEXO19
Tipo3 - Lógico
Cont. Esp
DescripciónPermite activar la funcionalidad del Anexo 1.9 para el país Colombia, con el valor .T. se activa, en caso contrario queda desactivado.


5.1 Generales

  • Separación de catálogos del anexo técnico
  • Se elimina el redondeo al total de impuesto a nivel de detalle y total para facturas, notas crédito y débito.
  • Se elimina la regla de 10 días posterior e inferior a la fecha y se ha incorporado una nueva regla de rechazo.
  • Medios de pago.
  • Nombre o razón social del emisor debe coincidir al informado en el RUT.
  • Se crea el tipo de documento PPT.
  • Factura de exportación.
  • Nuevos tipos de operación.
  • Cambios incorporados en las notas crédito.

...

Tabla SF2- Encabezado Doc. de Salida.

FATSECOL

CampoF2_PTOEMIS
TipoC
Tamaño7
Decimal0
Formato99-9999
TítuloPeriod Fact
DescripciónPeriodo de Facturación
Nivel1
UtilizadoSi
ObligatorioNo
BrowseNo
Opciones
When
Relación
Val. Sistema

Vazio() .Or. (FindFunction("LxVldPeri") .And. LxVldPeri('SF2'))

HelpDigite el mes y año del periodo de facturación en formato "MM-YYYY.

...