<?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="Archivo_contaduria_chip" language="groovy" pageWidth="612" pageHeight="792" columnWidth="572" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
	<property name="ireport.zoom" value="1.4641000000000013"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="nom_periodo_fin" class="java.lang.String"/>
	<parameter name="nom_periodo_ini" class="java.lang.String"/>
	<parameter name="vig_ini" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="per_ini" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="per_fin" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="vig_fin" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="id_cia" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="cifras" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[1]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[select

id_clase_cuenta,
id_grupo_cuenta,
id_cuenta_mayor,
id_catalogo,
CUENTA_CHIP,
cuenta,
nombre_cuenta,
naturaleza,
floor(sum(saldo_anterior)/$P{cifras}) as saldo_anterior,
floor(sum(mvto_debito)/$P{cifras}) as mvto_debito,
floor(sum(mvto_credito)/$P{cifras}) as mvto_credito,
ceil(sum(nuevo_saldo)/$P{cifras}) as nuevo_saldo,
ceil(sum(saldo_corriente)/$P{cifras}) as saldo_corriente,
ceil(sum(saldo_nocorriente)/$P{cifras}) as saldo_nocorriente,
/**Llave de la vista*/
ID_CIA/*,
ID_VIGENCIA,
ID_PERIODO_CONTABLE*/

from (

SELECT
arc.id_clase_cuenta,
arc.id_grupo_cuenta,
arc.id_cuenta_mayor,
arc.id_catalogo,
arc.CUENTA_CHIP,
arc.cuenta,
arc.nombre_cuenta,
arc.naturaleza,
--arc.saldo_anterior,
CASE
    WHEN arc.ID_PERIODO_CONTABLE = $P{per_ini}
    THEN arc.saldo_anterior
   ELSE 0
END AS saldo_anterior,
arc.mvto_debito,
arc.mvto_credito,
--arc.nuevo_saldo,
CASE
    WHEN arc.ID_PERIODO_CONTABLE = $P{per_fin}
    THEN arc.nuevo_saldo
   ELSE 0
END AS nuevo_saldo,
--0 as saldo_corriente,
CASE
    WHEN arc.ID_PERIODO_CONTABLE = $P{per_fin}
    THEN arc.saldo_corriente
   ELSE 0
END AS saldo_corriente,
--0 as saldo_nocorriente,
CASE
    WHEN arc.ID_PERIODO_CONTABLE = $P{per_fin}
    THEN arc.saldo_nocorriente
   ELSE 0
END AS saldo_nocorriente,
/**Llave de la vista*/
arc.ID_CIA,
arc.ID_VIGENCIA,
arc.ID_PERIODO_CONTABLE
FROM cn_archivo_contaduria arc

where
id_cia = $P{id_cia}
and arc.id_vigencia = $P{vig_fin}
and arc.id_periodo_contable between $P{per_ini} and $P{per_fin}

)

group by
id_clase_cuenta,
id_grupo_cuenta,
id_cuenta_mayor,
id_catalogo,
CUENTA_CHIP,
cuenta,
nombre_cuenta,
naturaleza,
/**Llave de la vista*/
ID_CIA/*,
ID_VIGENCIA,
ID_PERIODO_CONTABLE*/

order by
cuenta]]>
	</queryString>
	<field name="ID_CLASE_CUENTA" class="java.math.BigDecimal"/>
	<field name="ID_GRUPO_CUENTA" class="java.math.BigDecimal"/>
	<field name="ID_CUENTA_MAYOR" class="java.math.BigDecimal"/>
	<field name="ID_CATALOGO" class="java.math.BigDecimal"/>
	<field name="CUENTA_CHIP" class="java.lang.String"/>
	<field name="CUENTA" class="java.lang.String"/>
	<field name="NOMBRE_CUENTA" class="java.lang.String"/>
	<field name="NATURALEZA" class="java.lang.String"/>
	<field name="SALDO_ANTERIOR" class="java.math.BigDecimal"/>
	<field name="MVTO_DEBITO" class="java.math.BigDecimal"/>
	<field name="MVTO_CREDITO" class="java.math.BigDecimal"/>
	<field name="NUEVO_SALDO" class="java.math.BigDecimal"/>
	<field name="SALDO_CORRIENTE" class="java.math.BigDecimal"/>
	<field name="SALDO_NOCORRIENTE" class="java.math.BigDecimal"/>
	<field name="ID_CIA" class="java.math.BigDecimal"/>
	<variable name="sumAnteriorDeb" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6

    && $F{NATURALEZA}.toString().equals("D")  ? $F{SALDO_ANTERIOR} : 0 )]]></variableExpression>
	</variable>
	<variable name="sumAnteriorCre" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6

    && $F{NATURALEZA}.toString().equals("C")  ? $F{SALDO_ANTERIOR} : 0 )]]></variableExpression>
	</variable>
	<variable name="sumActualDeb" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6

    && $F{NATURALEZA}.toString().equals("D")  ?$F{NUEVO_SALDO}:0)]]></variableExpression>
	</variable>
	<variable name="sumActualCre" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6

    && $F{NATURALEZA}.toString().equals("C")  ?$F{NUEVO_SALDO}:0)]]></variableExpression>
	</variable>
	<variable name="sumDebito" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6 ? 0 : $F{MVTO_DEBITO})]]></variableExpression>
	</variable>
	<variable name="sumCredito" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6 ? 0 : $F{MVTO_CREDITO})]]></variableExpression>
	</variable>
	<variable name="sumCorriente" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6 ? 0 : $F{SALDO_CORRIENTE})]]></variableExpression>
	</variable>
	<variable name="sumNoCorriente" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6 ? 0 : $F{SALDO_NOCORRIENTE})]]></variableExpression>
	</variable>
	<variable name="sumAnterior" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6 ? 0 : $F{SALDO_ANTERIOR})]]></variableExpression>
	</variable>
	<variable name="sumNuevo" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[($F{ID_CATALOGO}.toString().equals("null")

    && $F{CUENTA}.length() == 6 ? 0 : $F{NUEVO_SALDO})]]></variableExpression>
	</variable>
	<background>
		<band splitType="Stretch"/>
	</background>
	<pageHeader>
		<band height="20" splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="12" splitType="Stretch">
			<staticText>
				<reportElement mode="Opaque" x="62" y="0" width="85" height="12" forecolor="#000000" backcolor="#BEBEBE"/>
				<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" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[SALANT]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="317" y="0" width="85" height="12" forecolor="#000000" backcolor="#BEBEBE"/>
				<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" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[SALACT]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="232" y="0" width="85" height="12" forecolor="#000000" backcolor="#BEBEBE"/>
				<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" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[CREDITO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="22" y="0" width="40" height="12" forecolor="#000000" backcolor="#BEBEBE"/>
				<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" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[CODCTA]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="0" y="0" width="22" height="12" forecolor="#000000" backcolor="#BEBEBE"/>
				<box leftPadding="3">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement 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[S]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="147" y="0" width="85" height="12" forecolor="#000000" backcolor="#BEBEBE"/>
				<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" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[DEBITO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="402" y="0" width="85" height="12" forecolor="#000000" backcolor="#BEBEBE"/>
				<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" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[CORRIENTE]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="487" y="0" width="85" height="12" forecolor="#000000" backcolor="#BEBEBE"/>
				<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" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[NOCORRIENTE]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="10" splitType="Stretch">
			<textField pattern="###0;-###0" isBlankWhenNull="true">
				<reportElement x="62" y="0" width="85" height="10"/>
				<box leftPadding="0" rightPadding="3">
					<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{SALDO_ANTERIOR}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="0" y="0" width="22" height="10"/>
				<box leftPadding="3">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement verticalAlignment="Middle" markup="none">
					<font size="6"/>
				</textElement>
				<text><![CDATA[D]]></text>
			</staticText>
			<textField>
				<reportElement x="22" y="0" width="40" height="10"/>
				<box leftPadding="3">
					<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{CUENTA_CHIP}]]></textFieldExpression>
			</textField>
			<textField pattern="###0;-###0" isBlankWhenNull="true">
				<reportElement x="147" y="0" width="85" height="10"/>
				<box leftPadding="0" rightPadding="3">
					<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{MVTO_DEBITO}]]></textFieldExpression>
			</textField>
			<textField pattern="###0;-###0" isBlankWhenNull="true">
				<reportElement x="232" y="0" width="85" height="10"/>
				<box leftPadding="0" rightPadding="3">
					<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{MVTO_CREDITO}]]></textFieldExpression>
			</textField>
			<textField pattern="###0;-###0" isBlankWhenNull="true">
				<reportElement x="317" y="0" width="85" height="10"/>
				<box leftPadding="0" rightPadding="3">
					<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{NUEVO_SALDO}]]></textFieldExpression>
			</textField>
			<textField pattern="###0;-###0" isBlankWhenNull="true">
				<reportElement x="402" y="0" width="85" height="10"/>
				<box leftPadding="0" rightPadding="3">
					<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{SALDO_CORRIENTE}]]></textFieldExpression>
			</textField>
			<textField pattern="###0;-###0" isBlankWhenNull="true">
				<reportElement x="487" y="0" width="85" height="10"/>
				<box leftPadding="0" rightPadding="3">
					<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{SALDO_NOCORRIENTE}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="14" splitType="Stretch"/>
	</columnFooter>
	<noData>
		<band height="20">
			<staticText>
				<reportElement x="0" y="0" width="572" height="20"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font isBold="true"/>
				</textElement>
				<text><![CDATA[No hay objetos a mostrar.]]></text>
			</staticText>
		</band>
	</noData>
</jasperReport>
