<?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="792" pageHeight="612" orientation="Landscape" columnWidth="790" leftMargin="0" rightMargin="2" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="272"/>
	<property name="ireport.y" value="0"/>
	<parameter name="InvoiceId" 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 i.harmonization_descr is null then ' ' else i.harmonization_descr end )as har_descr,
(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,
(select count(distinct piss.pallet_no) from pick_iss_hdr piss , wave_task_det w1, Despatch desp where desp.desp_id = d1.desp_id AND w1.wave_id = desp.wave_id  AND piss.pick_order = W1.ref_id) as 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!{InvoiceId}']]>
	</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="totAmount" class="java.lang.Double" resetType="Group" resetGroup="despatch" calculation="Sum">
		<variableExpression><![CDATA[$F{AMOUNT}]]></variableExpression>
		<initialValueExpression><![CDATA[new java.lang.Double(0)]]></initialValueExpression>
	</variable>
	<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>
	<group name="despatch">
		<groupExpression><![CDATA[$F{DESP_ID}]]></groupExpression>
	</group>
	<columnHeader>
		<band height="21">
			<staticText>
				<reportElement x="218" y="1" width="196" height="20"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[SPECIFICATIONS OF COMMODITIES
(IN HARMONIZED CODE AND/OR IN FULL)]]></text>
			</staticText>
			<staticText>
				<reportElement x="5" y="1" width="197" height="20"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[MARKS, NUMBERS AND KIND OF PACKAGES]]></text>
			</staticText>
			<staticText>
				<reportElement x="428" y="1" width="70" height="17"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[COUNTRY OF ORIGIN]]></text>
			</staticText>
			<staticText>
				<reportElement x="508" y="1" width="66" height="17"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[NET WEIGHT
(Lbs)]]></text>
			</staticText>
			<staticText>
				<reportElement x="578" y="1" width="76" height="14"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[QUANTITY]]></text>
			</staticText>
			<staticText>
				<reportElement x="658" y="1" width="62" height="14"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[UNIT PRICE]]></text>
			</staticText>
			<staticText>
				<reportElement x="725" y="1" width="47" height="14"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[AMOUNT]]></text>
			</staticText>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="418" y="0" width="1" height="21"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="207" y="0" width="1" height="21" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="502" y="0" width="1" height="21" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="575" y="0" width="1" height="21" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="654" y="0" width="1" height="21" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="722" y="0" width="1" height="21" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement x="0" y="0" width="780" height="1"/>
			</line>
			<line>
				<reportElement x="0" y="20" width="780" height="1"/>
			</line>
		</band>
	</columnHeader>
	<detail>
		<band height="22" splitType="Stretch">
			<textField isBlankWhenNull="true">
				<reportElement x="21" y="3" width="181" height="12" isRemoveLineWhenBlank="true"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{ITEM_CODE}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="21" y="10" width="181" height="12" isRemoveLineWhenBlank="true"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{ITEM_DESCR}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="209" y="3" width="205" height="12" isRemoveLineWhenBlank="true"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{HAR_NO}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement x="209" y="10" width="211" height="12" isRemoveLineWhenBlank="true"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{HAR_DESCR}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="423" y="3" width="70" height="12" isRemoveLineWhenBlank="true"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{COUNT_CODE__MFG}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="504" y="3" width="66" height="12" isRemoveLineWhenBlank="true"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{NETT_WEIGHT}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="577" y="3" width="70" height="12" isRemoveLineWhenBlank="true"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{QUANTITY}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="659" y="3" width="56" height="12" isRemoveLineWhenBlank="true"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{RATE}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="714" y="3" width="56" height="12" isRemoveLineWhenBlank="true"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{AMOUNT}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="418" y="0" width="1" height="22"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="207" y="0" width="1" height="22"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="502" y="0" width="1" height="22"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="575" y="0" width="1" height="22"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="654" y="0" width="1" height="22"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="722" y="0" width="1" height="22"/>
			</line>
		</band>
	</detail>
	<columnFooter>
		<band height="1">
			<printWhenExpression><![CDATA[new Boolean($V{PAGE_NUMBER}.intValue() > 1?true:false)]]></printWhenExpression>
			<line>
				<reportElement x="0" y="0" width="780" height="1"/>
			</line>
		</band>
	</columnFooter>
	<summary>
		<band height="13" splitType="Stretch">
			<staticText>
				<reportElement x="234" y="2" width="120" height="11"/>
				<textElement>
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[TOTALS]]></text>
			</staticText>
			<textField isBlankWhenNull="true">
				<reportElement x="471" y="2" width="99" height="11"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{totnetweight}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="548" y="2" width="100" height="11"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{totquantity}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="689" y="2" width="32" height="11"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.Integer"><![CDATA[$F{line_no}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="418" y="0" width="1" height="13"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="207" y="0" width="1" height="13" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="502" y="0" width="1" height="13" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="575" y="0" width="1" height="13" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="654" y="0" width="1" height="13" isRemoveLineWhenBlank="true"/>
			</line>
			<line>
				<reportElement stretchType="RelativeToBandHeight" x="722" y="0" width="1" height="13" isRemoveLineWhenBlank="true"/>
			</line>
			<staticText>
				<reportElement x="656" y="2" width="22" height="11"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[PCLS]]></text>
			</staticText>
		</band>
	</summary>
</jasperReport>
