<?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="inf_hist_depre_son" language="groovy" pageWidth="917" pageHeight="100" orientation="Landscape" columnWidth="917" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.3636363636363635"/>
	<property name="ireport.x" value="139"/>
	<property name="ireport.y" value="0"/>
	<property name="ireport.jasperserver.reportUnit" value="/reports/inventario/inf_hist_elemento_depre"/>
	<property name="ireport.jasperserver.url" value="http://localhost:18091/jasperserver/services/repository"/>
	<parameter name="id_meses" class="java.lang.String">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="vigencia" class="java.lang.String">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="wherePlaqueta" class="java.lang.String">
		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>
	</parameter>
	<parameter name="whereInventarioDV" class="java.lang.String">
		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>
	</parameter>
	<parameter name="whereSerie" class="java.lang.String">
		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>
	</parameter>
	<parameter name="vigencia_mes" class="java.lang.String">
		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>
	</parameter>
	<parameter name="wherePlaca" class="java.lang.String">
		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>
	</parameter>
	<parameter name="ID_INVENTARIO_DV" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[select
si.id_inventario_dv,
si.id_vigencia,
si.id_meses,
si.costo_inicial,
nvl(si.vida_util,idv.vida_util) as vida_util,
ope.nom_cen_op, nvl(dep.num_dias,0) as num_dias,
nvl(dep.valor_depreciado,0) as valor_depreciado,

(select sum(nvl(t.num_dias,0)) from in_depreciacion t where t.id_inventario_dv=si.id_inventario_dv
and t.id_vigencia||lpad(t.id_meses,2,'0')  <  si.id_vigencia||lpad(si.id_meses,2,'0')) as num_dias_acum,

(select sum(nvl(t.valor_depreciado,0)) from in_depreciacion t where t.id_inventario_dv=si.id_inventario_dv
and t.id_vigencia||lpad(t.id_meses,2,'0')  <  si.id_vigencia||lpad(si.id_meses,2,'0')) as valor_depreciado_acum,

nvl(si.costo_inicial,idv.nuevo_costo_inicial) - ((select sum(nvl(t.valor_depreciado,0)) from in_depreciacion t where t.id_inventario_dv=si.id_inventario_dv
and t.id_vigencia||lpad(t.id_meses,2,'0')  <  si.id_vigencia||lpad(si.id_meses,2,'0'))+nvl(dep.valor_depreciado,0)) as valor_libros,

almac.descripcion as desc_almac

from in_saldo_inventario_dv si

left join in_depreciacion dep  on si.id_inventario_dv=dep.id_inventario_dv and si.id_vigencia=dep.id_vigencia and si.id_meses=dep.id_meses
left join centro_operacion ope on si.id_cen_op = ope.id_cen_op
join in_inventario_dv idv on si.id_inventario_dv=idv.id_inventario_dv
join in_tipo_almacenamiento almac on si.id_tipo_almacenamiento=almac.id_tipo_almacenamiento

where
si.id_inventario_dv =$P{ID_INVENTARIO_DV}
and si.id_vigencia||lpad(si.id_meses,2,'0')  <=  $P{vigencia}||lpad($P{id_meses},2,'0')

order by
si.id_inventario_dv desc,
si.id_vigencia desc,
si.id_meses desc]]>
	</queryString>
	<field name="ID_INVENTARIO_DV" class="java.math.BigDecimal"/>
	<field name="ID_VIGENCIA" class="java.math.BigDecimal"/>
	<field name="ID_MESES" class="java.math.BigDecimal"/>
	<field name="COSTO_INICIAL" class="java.math.BigDecimal"/>
	<field name="VIDA_UTIL" class="java.math.BigDecimal"/>
	<field name="NOM_CEN_OP" class="java.lang.String"/>
	<field name="NUM_DIAS" class="java.math.BigDecimal"/>
	<field name="VALOR_DEPRECIADO" class="java.math.BigDecimal"/>
	<field name="NUM_DIAS_ACUM" class="java.math.BigDecimal"/>
	<field name="VALOR_DEPRECIADO_ACUM" class="java.math.BigDecimal"/>
	<field name="VALOR_LIBROS" class="java.math.BigDecimal"/>
	<field name="DESC_ALMAC" class="java.lang.String"/>
	<background>
		<band splitType="Stretch"/>
	</background>
	<columnHeader>
		<band height="50" splitType="Stretch">
			<staticText>
				<reportElement x="0" y="0" width="281" height="20" isRemoveLineWhenBlank="true"/>
				<box>
					<bottomPen lineWidth="0.75"/>
				</box>
				<textElement verticalAlignment="Middle">
					<font size="12" isBold="true"/>
				</textElement>
				<text><![CDATA[Depreciaciones           :]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="96" y="32" width="185" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Centro Operación]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="756" y="32" width="75" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Depreciación Acumulada]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="0" y="32" width="48" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Vigencia]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="48" y="32" width="48" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Mes]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="606" y="32" width="75" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Depreciación Mes]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="831" y="32" width="86" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Valor Libros]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="531" y="32" width="75" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Días Depre. Mes]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="681" y="32" width="75" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Días Depre. Acum.]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="381" y="32" width="75" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Costo Histórico]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="456" y="32" width="75" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Vida Útil]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="281" y="32" width="100" height="18" backcolor="#88C2F9"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[Tipo Almacenamiento]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="20" splitType="Stretch">
			<textField isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="48" height="20"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{ID_VIGENCIA}]]></textFieldExpression>
			</textField>
			<textField pattern="$ #,##0.00" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="606" y="0" width="75" height="20"/>
				<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="7"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{VALOR_DEPRECIADO}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="96" y="0" width="185" height="20"/>
				<box leftPadding="2" rightPadding="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="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{NOM_CEN_OP}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="48" y="0" width="48" height="20"/>
				<box leftPadding="2" 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="Center" verticalAlignment="Middle">
					<font size="7"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{ID_MESES}]]></textFieldExpression>
			</textField>
			<textField pattern="###0;-###0" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="681" y="0" width="75" height="20"/>
				<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="7"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{NUM_DIAS_ACUM}]]></textFieldExpression>
			</textField>
			<textField pattern="$ #,##0.00" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="831" y="0" width="86" height="20"/>
				<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="7"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{VALOR_LIBROS}]]></textFieldExpression>
			</textField>
			<textField pattern="###0;-###0" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="531" y="0" width="75" height="20"/>
				<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="7"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{NUM_DIAS}]]></textFieldExpression>
			</textField>
			<textField pattern="$ #,##0.00" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="756" y="0" width="75" height="20"/>
				<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="7"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{VALOR_DEPRECIADO_ACUM}]]></textFieldExpression>
			</textField>
			<textField pattern="$ #,##0.00" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="381" y="0" width="75" height="20"/>
				<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="7"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{COSTO_INICIAL}]]></textFieldExpression>
			</textField>
			<textField pattern="###0;-###0" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="456" y="0" width="75" height="20"/>
				<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="7"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{VIDA_UTIL}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToTallestObject" x="281" y="0" width="100" height="20"/>
				<box leftPadding="2" rightPadding="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="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{DESC_ALMAC}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
</jasperReport>
