<?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="detalle_costo_total" language="groovy" pageWidth="710" pageHeight="595" orientation="Landscape" columnWidth="710" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.8150000000000048"/>
	<property name="ireport.x" value="158"/>
	<property name="ireport.y" value="0"/>
	<parameter name="id_vigencia" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="id_orden_trabajo" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="id_cen_op" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="entidad_cliente" class="java.lang.String"/>
	<queryString>
		<![CDATA[select

tab0.id_vigencia ,
tab0.id_orden_trabajo ,
tab0.id_mae_ter ,
tab0.num_doc,
tab0.razon_soc,

tab0.id_anhos,
tab0.id_meses,
tab0.mes,

sum(tab0.cantidad_horas) as cantidad_horas,
sum(tab0.valor) as valor,
max(tab0.hora_mes) as hora_mes,
max(tab0.valor_deven + tab0.valor_cesan + tab0.valor_aporte + tab0.valor_provi) as valor_base

from(

    SELECT
    tab0.id_costo_orden_trabajo as id_costo_orden_trabajo,
    tab0.id_orden_trabajo as id_orden_trabajo,
    tab0.id_vigencia as id_vigencia,
    tab0.id_cen_op as id_cen_op,
    tab0.id_orden_trabajo||' - '||tab0.id_vigencia as completo_ord,
    tab0.id_mae_ter as id_mae_ter,
    tab0.id_anhos as id_anhos, tab0.id_meses as id_meses,
    tab0.cantidad_horas as cantidad_horas,
    tab0.valor as valor, tab0.hora_mes as hora_mes,
    tab0.valor_deven as valor_deven,
    tab0.valor_cesan as valor_cesan,
    tab0.valor_aporte as valor_aporte,
    tab0.valor_provi as valor_provi,
    tab1.id_tipo_servicio as id_tipo_servicio,
    tab1.fecha_orden as fecha_orden,
    tab1.nom_cen_op as nom_cen_op, tab1.prefijo as prefijo, tab1.desc_tipser as desc_tipser,
    tab1.abre_tipser as abre_tipser, tab1.estado as estado, tab1.anulado as anulado,
    tab2.num_doc as num_doc, tab2.razon_soc as razon_soc,
    tab2.num_doc||' - '||tab2.razon_soc as completo_persona, tab2.estado_ter as estado_ter,
    tab3.descripcion as mes

    FROM IN_COSTO_ORDEN_TRABAJO tab0

    JOIN IN_ORDEN_TRABAJO_V tab1
    ON tab0.id_orden_trabajo = tab1.id_orden_trabajo
    AND tab0.id_vigencia = tab1.id_vigencia
    AND tab0.id_cen_op = tab1.id_cen_op

    JOIN INTERCEROS_V tab2 ON tab0.id_mae_ter = tab2.id_mae_ter
    JOIN MESES tab3 ON tab0.id_meses = tab3.id_meses

    WHERE
    tab0.id_costo_orden_trabajo != '-1'
    and tab0.id_vigencia = $P{id_vigencia}
    AND tab0.id_cen_op  =  $P{id_cen_op}
    AND tab0.id_orden_trabajo = $P{id_orden_trabajo}

)tab0

group by
tab0.id_vigencia ,
tab0.id_orden_trabajo ,
tab0.id_mae_ter ,
tab0.num_doc,
tab0.razon_soc,

tab0.id_anhos,
tab0.id_meses,
tab0.mes

ORDER BY
tab0.id_vigencia ,
tab0.id_orden_trabajo ,
tab0.id_mae_ter ,
tab0.num_doc,
tab0.id_anhos,
tab0.id_meses]]>
	</queryString>
	<field name="ID_VIGENCIA" class="java.math.BigDecimal"/>
	<field name="ID_ORDEN_TRABAJO" class="java.math.BigDecimal"/>
	<field name="ID_MAE_TER" class="java.math.BigDecimal"/>
	<field name="NUM_DOC" class="java.lang.String"/>
	<field name="RAZON_SOC" class="java.lang.String"/>
	<field name="ID_ANHOS" class="java.math.BigDecimal"/>
	<field name="ID_MESES" class="java.math.BigDecimal"/>
	<field name="MES" class="java.lang.String"/>
	<field name="CANTIDAD_HORAS" class="java.math.BigDecimal"/>
	<field name="VALOR" class="java.math.BigDecimal"/>
	<field name="HORA_MES" class="java.math.BigDecimal"/>
	<field name="VALOR_BASE" class="java.math.BigDecimal"/>
	<variable name="total" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[$F{VALOR}]]></variableExpression>
	</variable>
	<variable name="cant" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[$F{CANTIDAD_HORAS}]]></variableExpression>
		<initialValueExpression><![CDATA[]]></initialValueExpression>
	</variable>
	<columnHeader>
		<band height="25">
			<staticText>
				<reportElement mode="Opaque" x="455" y="0" width="55" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[CANT. HR.]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="0" y="0" width="75" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[DOCUMENTO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="75" y="0" width="270" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[PERSONA]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="610" y="0" width="100" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[VALOR COSTO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="510" y="0" width="100" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[VALOR BASE]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="420" y="0" width="35" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[HORA MES]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="345" y="0" width="75" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[AÑO/MES]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="12" splitType="Stretch">
			<textField isBlankWhenNull="true">
				<reportElement x="0" y="0" width="75" height="12"/>
				<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="8"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{NUM_DOC}]]></textFieldExpression>
			</textField>
			<textField pattern="#,##0.00;(#,##0.00)" isBlankWhenNull="true">
				<reportElement x="510" y="0" width="100" height="12"/>
				<box 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="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{VALOR_BASE}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="420" y="0" width="35" height="12"/>
				<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">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{HORA_MES}]]></textFieldExpression>
			</textField>
			<textField pattern="###0.00;(-###0.00)" isBlankWhenNull="true">
				<reportElement x="455" y="0" width="55" height="12"/>
				<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">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{CANTIDAD_HORAS}]]></textFieldExpression>
			</textField>
			<textField pattern="#,##0.00;(-#,##0.00)" isBlankWhenNull="true">
				<reportElement x="610" y="0" width="100" height="12"/>
				<box 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="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{VALOR}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="75" y="0" width="270" height="12"/>
				<box>
					<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="8"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{RAZON_SOC}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="345" y="0" width="75" height="12"/>
				<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="8"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{ID_ANHOS} + "-" + $F{MES}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<summary>
		<band height="29">
			<staticText>
				<reportElement mode="Opaque" x="0" y="0" width="455" height="20" forecolor="#000000" backcolor="#E2D9D9"/>
				<box>
					<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[Total Personas]]></text>
			</staticText>
			<textField pattern="#,##0.00;(#,##0.00)" isBlankWhenNull="true">
				<reportElement mode="Opaque" x="610" y="0" width="100" height="20" backcolor="#E2D9D9"/>
				<box leftPadding="0" rightPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.0"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font size="8" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{total}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement mode="Opaque" x="510" y="0" width="100" height="20" forecolor="#000000" backcolor="#E2D9D9"/>
				<box>
					<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[]]></text>
			</staticText>
			<textField pattern="#,##0.00;(#,##0.00)" isBlankWhenNull="true">
				<reportElement mode="Opaque" x="455" y="0" width="55" height="20" backcolor="#E2D9D9"/>
				<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="Center" verticalAlignment="Middle">
					<font size="8" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{cant}]]></textFieldExpression>
			</textField>
		</band>
	</summary>
	<noData>
		<band height="58">
			<textField pattern="#,##0.00;(#,##0.00)" isBlankWhenNull="true">
				<reportElement mode="Opaque" x="610" y="25" width="100" height="20" backcolor="#E2D9D9"/>
				<box leftPadding="0" rightPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.0"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font size="8" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[0]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement mode="Opaque" x="-1" y="25" width="456" height="20" forecolor="#000000" backcolor="#E2D9D9"/>
				<box>
					<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[Total Personas]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="75" y="0" width="270" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[PERSONA]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="345" y="0" width="75" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[AÑO/MES]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="510" y="0" width="100" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[VALOR BASE]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="610" y="0" width="100" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[VALOR COSTO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="455" y="0" width="55" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[CANT. HR.]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="0" y="0" width="75" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[DOCUMENTO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="510" y="25" width="100" height="20" forecolor="#000000" backcolor="#E2D9D9"/>
				<box>
					<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[]]></text>
			</staticText>
			<textField pattern="#,##0.00;(#,##0.00)" isBlankWhenNull="true">
				<reportElement mode="Opaque" x="455" y="25" width="55" height="20" backcolor="#E2D9D9"/>
				<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="8" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[0]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement mode="Opaque" x="420" y="0" width="35" height="25" backcolor="#E2D9D9"/>
				<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" rotation="None"/>
				<text><![CDATA[HORA MES]]></text>
			</staticText>
		</band>
	</noData>
</jasperReport>
