<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="nota_debito_subreport1" language="groovy" pageWidth="652" pageHeight="555" orientation="Landscape" columnWidth="652" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.5"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="id_debito" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[select

tab0.id_debito,
tab0.id_anhos,

tab1.digitos,
tab1.nombre,
nvl(tab1.cod_aux,' ') as cod_aux,
nvl(tab1.auxiliar,' ') as auxiliar,
tab1.nitocc,
tab1.tercero,
tab1.tercero_completo,
tab1.DEBITO,
tab1.CREDITO

from ca_debito tab0

left join(

    select

    dig.digitos,
    dig.nombre,
    aux.cod_aux as cod_aux,
    aux.nombre as auxiliar,
    ter.nitocc,
    ter.nombre as tercero,
    nvl(ter.nitocc,'') || ' - ' || nvl(ter.nombre,'') as tercero_completo,

    --doc.doc_soporte as doc_mov,
    trim(
      replace(
      replace(
      replace(
      translate( doc.doc_soporte, 'QWERTYUIOPASDFGHJKLÑZXCVBNMqwertyuiopasdfghjklñzxcvbnm?¿`+-,.-;:_!¡{}[´]*=)(/@#~$\%', '0' ),
      ' ' ,
      '' )
      , chr(39) ,
      '' ),
      chr(38) , '')
    ) as doc_mov,

    mov.ID_MOV_CONT,
    mov.ID_DOCUMENTO,
    mov.ID_CAD,
    mov.ID_VIGENCIA,
    mov.ID_CEN_OP,
    mov.ID_CIA,
    mov.ID_CATALOGO,
    mov.ID_CUENTA_MAYOR,
    mov.ID_GRUPO_CUENTA,
    mov.ID_CLASE_CUENTA,
    mov.ID_MAE_TER,
    mov.ID_AUXILIAR,
    mov.ID_SUB_AUX,
    mov.ID_CENTRO_COSTO,
    mov.ID_SUB_CENTRO_COSTO,
    mov.DEBITO,
    mov.CREDITO,
    mov.VALOR_BASE

    from cn_movimiento_contable@CONTABILIDAD.ANM.LOCAL mov

    join cn_documento@CONTABILIDAD.ANM.LOCAL doc
    on doc.id_cad = mov.id_cad
    and doc.id_cen_op = mov.id_cen_op
    and doc.id_cia = mov.id_cia
    and doc.id_vigencia = mov.id_vigencia
    and doc.id_documento = mov.id_documento

    join cn_control_cad@CONTABILIDAD.ANM.LOCAL cad
    on mov.id_cad = cad.id_cad
    and mov.id_cen_op = cad.id_cen_op
    and mov.id_cia = cad.id_cia
    and mov.id_vigencia = cad.id_vigencia

    left join cn_subc_digitos@CONTABILIDAD.ANM.LOCAL dig
    on dig.id_cia = mov.id_cia
    and mov.id_clase_cuenta = dig.id_clase_cuenta
    and mov.id_grupo_cuenta = dig.id_grupo_cuenta
    and mov.id_cuenta_mayor = dig.id_cuenta_mayor
    and mov.id_catalogo = dig.id_catalogo

    left join cn_auxiliar@CONTABILIDAD.ANM.LOCAL aux
    on mov.id_auxiliar = aux.id_auxiliar
    and mov.id_catalogo = aux.id_catalogo
    and mov.id_cuenta_mayor = aux.id_cuenta_mayor
    and mov.id_grupo_cuenta = aux.id_grupo_cuenta
    and mov.id_clase_cuenta = aux.id_clase_cuenta
    and mov.id_cia = aux.id_cia

    left join cn_mae_ter@CONTABILIDAD.ANM.LOCAL ter
    on mov.id_mae_ter = ter.id_mae_ter

    where
    cad.id_tipo_comprobante in (31)
    --and mov.id_vigencia = 2016
    --and doc.doc_soporte = '133396'

)tab1
on tab0.sec_debito = tab1.doc_mov
and tab0.id_anhos = tab1.id_vigencia

where
tab0.id_debito = $P{id_debito}

order by
tab1.digitos,
tab1.cod_aux,
tab1.nitocc]]>
	</queryString>
	<field name="ID_DEBITO" class="java.math.BigDecimal"/>
	<field name="ID_ANHOS" class="java.math.BigDecimal"/>
	<field name="DIGITOS" class="java.lang.String"/>
	<field name="NOMBRE" class="java.lang.String"/>
	<field name="COD_AUX" class="java.lang.String"/>
	<field name="AUXILIAR" class="java.lang.String"/>
	<field name="NITOCC" class="java.lang.String"/>
	<field name="TERCERO" class="java.lang.String"/>
	<field name="TERCERO_COMPLETO" class="java.lang.String"/>
	<field name="DEBITO" class="java.math.BigDecimal"/>
	<field name="CREDITO" class="java.math.BigDecimal"/>
	<columnHeader>
		<band height="42" splitType="Stretch">
			<staticText>
				<reportElement mode="Opaque" x="0" y="12" width="652" height="18" forecolor="#000000" backcolor="#BBC4CD"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Contabilidad.]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="180" y="30" width="92" height="12" forecolor="#000000" backcolor="#A4CFF6"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Auxiliar]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="272" y="30" width="180" height="12" forecolor="#000000" backcolor="#A4CFF6"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Tercero]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="0" y="30" width="50" height="12" forecolor="#000000" backcolor="#A4CFF6"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Cuenta]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="452" y="30" width="100" height="12" forecolor="#000000" backcolor="#A4CFF6"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Débito]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="552" y="30" width="100" height="12" forecolor="#000000" backcolor="#A4CFF6"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Crédito]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="50" y="30" width="130" height="12" forecolor="#000000" backcolor="#A4CFF6"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Nombre Cuenta]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="10" splitType="Stretch">
			<textField pattern="#,##0.00" isBlankWhenNull="true">
				<reportElement x="552" y="0" width="100" height="10"/>
				<box leftPadding="0" rightPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{CREDITO}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="272" y="0" width="180" height="10"/>
				<box leftPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{TERCERO_COMPLETO}]]></textFieldExpression>
			</textField>
			<textField pattern="#,##0.00" isBlankWhenNull="true">
				<reportElement x="452" y="0" width="100" height="10"/>
				<box leftPadding="0" rightPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{DEBITO}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="180" y="0" width="92" height="10"/>
				<box leftPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{COD_AUX} + " " + $F{AUXILIAR}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="0" y="0" width="50" height="10"/>
				<box leftPadding="0">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{DIGITOS}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="50" y="0" width="130" height="10"/>
				<box leftPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{NOMBRE}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
</jasperReport>
