<?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="CommInvDet" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="842" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="206"/>
	<property name="ireport.y" value="0"/>
	<parameter name="InvoiceIdFrom" class="java.lang.String"/>
	<parameter name="InvoiceIdTo" class="java.lang.String"/>
	<queryString>
		<![CDATA[select d.invoice_id as desp_id,
d.item_code as item_code,
i.descr as item_descr,
(case when i.harmonization_no is null then ' ' else i.harmonization_no end )as har_no,
(case when DDF_GET_GEN_DESCR('harmonization_no', 'W_ITEM', i.harmonization_no,'D') is null then ' '  else DDF_GET_GEN_DESCR('harmonization_no', 'W_ITEM', i.harmonization_no,'D') end) as har_descr,
(case when i.count_code__mfg is null then ' '  else i.count_code__mfg end ) count_code__mfg,
d.quantity__stduom as quantity,
(case when d1.nett_weight is null then 0 else d1.nett_weight end ) as nett_weight,
d.rate__stduom as rate,
(d.quantity__stduom * d.rate__stduom ) as amount,
d.unit__std as unit,
d1.line_no
from invoice_trace d,  item i, despatchdet d1
where i.item_code  = d.item_code
and d1.desp_id = d.DESP_ID
and d1.line_no = d.DESP_LINE_NO
and d.invoice_id >= '$P!{InvoiceIdFrom}' and d.invoice_id <= '$P!{InvoiceIdTo}']]>
	</queryString>
	<field name="DESP_ID" class="java.lang.String"/>
	<field name="ITEM_CODE" class="java.lang.String"/>
	<field name="ITEM_DESCR" class="java.lang.String"/>
	<field name="HAR_NO" class="java.lang.String"/>
	<field name="HAR_DESCR" class="java.lang.String"/>
	<field name="COUNT_CODE__MFG" class="java.lang.String"/>
	<field name="QUANTITY" class="java.lang.Double"/>
	<field name="NETT_WEIGHT" class="java.lang.Double"/>
	<field name="RATE" class="java.lang.Double"/>
	<field name="AMOUNT" class="java.lang.Double"/>
	<field name="UNIT" class="java.lang.String"/>
	<field name="line_no" class="java.lang.Integer"/>
	<variable name="totnetweight" class="java.lang.Double" calculation="Sum">
		<variableExpression><![CDATA[new java.lang.Double($F{NETT_WEIGHT}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="totquantity" class="java.lang.Double" calculation="Sum">
		<variableExpression><![CDATA[new java.lang.Double($F{QUANTITY}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="variable1" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("PCLS     "+($F{line_no}.intValue()))]]></variableExpression>
	</variable>
	<group name="despatch">
		<groupExpression><![CDATA[$F{DESP_ID}]]></groupExpression>
	</group>
	<summary>
		<band height="22" splitType="Stretch">
			<staticText>
				<reportElement x="235" y="0" width="120" height="17"/>
				<textElement>
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[TOTALS]]></text>
			</staticText>
			<textField isBlankWhenNull="true">
				<reportElement x="473" y="0" width="99" height="17"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{totnetweight}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="554" y="0" width="100" height="17"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{totquantity}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="418" y="0" width="1" height="22" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="207" y="0" width="1" height="22" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="502" y="0" width="1" height="22" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="575" y="0" width="1" height="22" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="654" y="0" width="1" height="22" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="722" y="0" width="1" height="22" isRemoveLineWhenBlank="true"/>
			</line>
			<textField isBlankWhenNull="true">
				<reportElement x="657" y="0" width="69" height="17"/>
				<textElement textAlignment="Left">
					<font fontName="Courier New"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{variable1}]]></textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>
