<?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="sub2" pageWidth="612" pageHeight="300" columnWidth="612" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="138"/>
	<property name="ireport.y" value="0"/>
	<parameter name="PGNO" class="java.lang.Integer"/>
	<parameter name="AS_TRAN_ID" class="java.lang.String" isForPrompting="false"/>
	<queryString>
		<![CDATA[select MISC_PAYMENT_TRAN_ID,
MISC_PAYABLES_TRAN_SER,
MISC_PAYABLES_REF_NO,
MISC_PAYABLES_BILL_NO,
MISC_PAYABLES_BILL_DATE,
MISC_PAYDET_PAY_AMT,
MISC_PAYMENT_REF_DATE,
MISC_PAYMENT_SUNDRY_CODE,
MISC_PAYMENT_SUNDRY_TYPE,
remarks,
supp_bill_amt,
pagecnt,
SITE_DESCR,
CASE WHEN MISC_PAYABLES_TRAN_SER = 'VOUCH' THEN (select (nvl(disc_amt,0)) from vouchrcp where tran_id='$P!{AS_TRAN_ID}') ELSE 0 END as DISC_AMT,
'' AS CHQ_NO,
sunname,
sundrydet,
(select sum(MISC_PAYDET.PAY_AMT) - (CASE WHEN MISC_PAYABLES_TRAN_SER = 'VOUCH' THEN (select sum(nvl(disc_amt,0)) from vouchrcp where tran_id='$P!{AS_TRAN_ID}') ELSE 0 END) from
     MISC_PAYABLES MISC_PAYABLES,
     MISC_VOUCHER MISC_VOUCHER,
     VOUCHER VOUCHER,
     misc_paydet misc_paydet,
     misc_payment misc_payment
WHERE
     (MISC_PAYMENT.TRAN_ID = MISC_PAYDET.TRAN_ID)
	and ( misc_paydet.vouch_no = misc_voucher.tran_id (+))
	and ( misc_paydet.vouch_no = voucher.tran_id (+))
     and (MISC_PAYDET.TRAN_SER = MISC_PAYABLES.TRAN_SER)
     and (MISC_PAYDET.VOUCH_NO = MISC_PAYABLES.REF_NO)
 AND misc_payment.tran_id = '$P!{AS_TRAN_ID}' group by MISC_PAYDET.tran_id) as SUM_AMT,
CASE WHEN MISC_PAYABLES_TRAN_SER = 'VOUCH' THEN (select sum(nvl(disc_amt,0)) from vouchrcp where tran_id='$P!{AS_TRAN_ID}') ELSE 0 END as SUM_DIS,
(select sum(MISC_PAYDET.PAY_AMT) FROM
     MISC_PAYABLES MISC_PAYABLES,
     MISC_VOUCHER MISC_VOUCHER,
     VOUCHER VOUCHER,
     misc_paydet misc_paydet,
     misc_payment misc_payment
WHERE
     (MISC_PAYMENT.TRAN_ID = MISC_PAYDET.TRAN_ID)
	and ( misc_paydet.vouch_no = misc_voucher.tran_id (+))
	and ( misc_paydet.vouch_no = voucher.tran_id (+))
     and (MISC_PAYDET.TRAN_SER = MISC_PAYABLES.TRAN_SER)
     and (MISC_PAYDET.VOUCH_NO = MISC_PAYABLES.REF_NO)
 AND misc_payment.tran_id = '$P!{AS_TRAN_ID}' group by MISC_PAYDET.tran_id) as SUM__NETAMT,
(select
max(pagecnt)
from
(
SELECT

     CEIL((ROWNUM/13)) as pagecnt

FROM
     MISC_PAYABLES MISC_PAYABLES,
     MISC_VOUCHER MISC_VOUCHER,
     VOUCHER VOUCHER,
     misc_paydet misc_paydet,
     misc_payment misc_payment
WHERE
     (MISC_PAYMENT.TRAN_ID = MISC_PAYDET.TRAN_ID)
	and ( misc_paydet.vouch_no = misc_voucher.tran_id (+))
	and ( misc_paydet.vouch_no = voucher.tran_id (+))
     and (MISC_PAYDET.TRAN_SER = MISC_PAYABLES.TRAN_SER)
     and (MISC_PAYDET.VOUCH_NO = MISC_PAYABLES.REF_NO)
 AND misc_payment.tran_id = '$P!{AS_TRAN_ID}'
) t ) as maxpage,
ROWNUM AS RNO
from
(
SELECT
     MISC_PAYMENT.TRAN_ID AS MISC_PAYMENT_TRAN_ID,
     MISC_PAYABLES.TRAN_SER AS MISC_PAYABLES_TRAN_SER,
     MISC_PAYABLES.REF_NO AS MISC_PAYABLES_REF_NO,
     MISC_PAYABLES.BILL_NO AS MISC_PAYABLES_BILL_NO,
     MISC_PAYABLES.BILL_DATE AS MISC_PAYABLES_BILL_DATE,
     MISC_PAYDET.PAY_AMT AS MISC_PAYDET_PAY_AMT,
     MISC_PAYMENT.REF_DATE AS MISC_PAYMENT_REF_DATE,
     MISC_PAYMENT.SUNDRY_CODE AS MISC_PAYMENT_SUNDRY_CODE,
     MISC_PAYMENT.SUNDRY_TYPE AS MISC_PAYMENT_SUNDRY_TYPE,
     decode(ltrim(rtrim(misc_payables.tran_ser)),'M-VOUC',nvl(MISC_VOUCHER.REMARKS,'  '),'VOUCH',nvl(VOUCHER.REMARKS,'  ')) as remarks,
     decode(ltrim(rtrim(misc_payables.tran_ser)),'M-VOUC',nvl(misc_voucher.tot_amt,0)+nvl(misc_voucher.tax_amt,0),'VOUCH',nvl(voucher.tot_amt,0)+nvl(voucher.tax_amt,0)) as supp_bill_amt,
     CEIL((ROWNUM/13)) as pagecnt,
     DDF_GET_SITE_DESCR(misc_payment.SITE_CODE) AS SITE_DESCR,
    FN_SUNDRY_NAME(misc_payment.SUNDRY_TYPE,misc_payment.SUNDRY_CODE,'C') as sunname,
  FDF_GET_SUNDRY_DETAILS_tarochq( misc_payment.SUNDRY_TYPE,misc_payment.SUNDRY_CODE,'D') as sundrydet
FROM
     MISC_PAYABLES MISC_PAYABLES,
     MISC_VOUCHER MISC_VOUCHER,
     VOUCHER VOUCHER,
     misc_paydet misc_paydet,
     misc_payment misc_payment
WHERE
     (MISC_PAYMENT.TRAN_ID = MISC_PAYDET.TRAN_ID)
	and ( misc_paydet.vouch_no = misc_voucher.tran_id (+))
	and ( misc_paydet.vouch_no = voucher.tran_id (+))
     and (MISC_PAYDET.TRAN_SER = MISC_PAYABLES.TRAN_SER)
     and (MISC_PAYDET.VOUCH_NO = MISC_PAYABLES.REF_NO)
 AND misc_payment.tran_id = '$P!{AS_TRAN_ID}' order by MISC_PAYABLES_BILL_DATE, MISC_PAYABLES_BILL_NO
) t
where t.pagecnt = $P{PGNO}]]>
	</queryString>
	<field name="MISC_PAYMENT_TRAN_ID" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="MISC_PAYABLES_TRAN_SER" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="MISC_PAYABLES_REF_NO" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="MISC_PAYABLES_BILL_NO" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="MISC_PAYABLES_BILL_DATE" class="java.util.Date">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="MISC_PAYDET_PAY_AMT" class="java.lang.Double">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="MISC_PAYMENT_REF_DATE" class="java.util.Date">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="MISC_PAYMENT_SUNDRY_CODE" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="MISC_PAYMENT_SUNDRY_TYPE" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="REMARKS" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="SUPP_BILL_AMT" class="java.lang.Double">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="PAGECNT" class="java.lang.Double">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="DISC_AMT" class="java.lang.Double">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="SITE_DESCR" class="java.lang.String"/>
	<field name="CHQ_NO" class="java.lang.Double"/>
	<field name="sunname" class="java.lang.String"/>
	<field name="sundrydet" class="java.lang.String"/>
	<field name="SUM_AMT" class="java.lang.Double"/>
	<field name="SUM_DIS" class="java.lang.Double"/>
	<field name="SUM__NETAMT" class="java.lang.Double"/>
	<field name="maxpage" class="java.lang.Double"/>
	<field name="RNO" class="java.lang.Integer"/>
	<variable name="COMPUTE_1" class="java.lang.Double">
		<variableExpression><![CDATA[new java.lang.Double($F{MISC_PAYDET_PAY_AMT}.doubleValue() - $F{DISC_AMT}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="COMPUTE_2" class="java.lang.Double" resetType="Group" resetGroup="TRAN_ID" calculation="Sum">
		<variableExpression><![CDATA[new java.lang.Double($F{DISC_AMT}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="COMPUTE_3" class="java.lang.Double" resetType="Group" resetGroup="TRAN_ID" calculation="Sum">
		<variableExpression><![CDATA[new java.lang.Double($F{MISC_PAYDET_PAY_AMT}.doubleValue() - $F{DISC_AMT}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="COMPUTE_4" class="java.lang.Double" resetType="Group" resetGroup="TRAN_ID" calculation="Sum">
		<variableExpression><![CDATA[new java.lang.Double($F{MISC_PAYDET_PAY_AMT}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="COMPUTE_5" class="java.lang.Double" resetType="None">
		<variableExpression><![CDATA[new java.lang.Double($F{CHQ_NO}.doubleValue()+$F{PAGECNT}.doubleValue()-1)]]></variableExpression>
	</variable>
	<variable name="COMPUTE_6" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String($F{sunname} + "\n" + $F{sundrydet})]]></variableExpression>
	</variable>
	<variable name="variable1" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n\n\n\n\n\n\n\n\n")]]></variableExpression>
	</variable>
	<variable name="variable2" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n\n\n\n\n\n\n\n")]]></variableExpression>
	</variable>
	<variable name="variable3" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n\n\n\n\n\n\n\n")]]></variableExpression>
	</variable>
	<variable name="variable4" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n\n\n\n\n\n\n")]]></variableExpression>
	</variable>
	<variable name="variable5" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n\n\n\n\n\n")]]></variableExpression>
	</variable>
	<variable name="variable6" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n\n\n\n\n\n")]]></variableExpression>
	</variable>
	<variable name="variable7" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n\n\n\n\n")]]></variableExpression>
	</variable>
	<variable name="variable8" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n\n\n\n")]]></variableExpression>
	</variable>
	<variable name="variable9" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n\n")]]></variableExpression>
	</variable>
	<variable name="variable10" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n")]]></variableExpression>
	</variable>
	<variable name="variable11" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n")]]></variableExpression>
	</variable>
	<variable name="variable12" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("\n")]]></variableExpression>
	</variable>
	<group name="TRAN_ID">
		<groupExpression><![CDATA[$P{AS_TRAN_ID}]]></groupExpression>
		<groupHeader>
			<band height="48" splitType="Stretch">
				<textField isStretchWithOverflow="true" isBlankWhenNull="true">
					<reportElement x="46" y="24" width="248" height="15"/>
					<textElement>
						<font fontName="Times New Roman" size="9" isBold="true"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{SITE_DESCR}]]></textFieldExpression>
				</textField>
				<textField pattern="MM/dd/yy" isBlankWhenNull="true">
					<reportElement x="355" y="22" width="57" height="15"/>
					<textElement>
						<font fontName="Times New Roman" size="9"/>
					</textElement>
					<textFieldExpression class="java.util.Date"><![CDATA[$F{MISC_PAYMENT_REF_DATE}]]></textFieldExpression>
				</textField>
				<textField isBlankWhenNull="true">
					<reportElement x="532" y="21" width="56" height="15"/>
					<textElement textAlignment="Left">
						<font fontName="Times New Roman" size="9"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{MISC_PAYMENT_SUNDRY_CODE}]]></textFieldExpression>
				</textField>
			</band>
		</groupHeader>
		<groupFooter>
			<band height="1" splitType="Stretch">
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==1?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable1}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==2?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable2}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==3?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable3}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==4?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable4}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==5?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable5}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==6?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable6}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==7?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable7}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==8?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable8}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==9?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable9}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==10?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable10}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==11?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable11}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="5" y="0" width="20" height="0">
						<printWhenExpression><![CDATA[new Boolean($F{RNO}.intValue()==12?true:false)]]></printWhenExpression>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{variable12}]]></textFieldExpression>
				</textField>
			</band>
		</groupFooter>
	</group>
	<detail>
		<band height="11" splitType="Stretch">
			<textField isBlankWhenNull="true">
				<reportElement x="11" y="0" width="65" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{MISC_PAYABLES_BILL_NO}]]></textFieldExpression>
			</textField>
			<textField pattern="0.00" isBlankWhenNull="true">
				<reportElement x="168" y="0" width="81" height="11"/>
				<textElement textAlignment="Right">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{COMPUTE_1}]]></textFieldExpression>
			</textField>
			<textField pattern="MM/dd/yy" isBlankWhenNull="true">
				<reportElement x="99" y="0" width="73" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.util.Date"><![CDATA[$F{MISC_PAYABLES_BILL_DATE}]]></textFieldExpression>
			</textField>
			<textField pattern="0.00" isBlankWhenNull="true">
				<reportElement x="283" y="0" width="70" height="11"/>
				<textElement textAlignment="Right">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{DISC_AMT}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="399" y="0" width="73" height="11"/>
				<textElement textAlignment="Right">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{MISC_PAYABLES_REF_NO}]]></textFieldExpression>
			</textField>
			<textField pattern="0.00" isBlankWhenNull="true">
				<reportElement x="489" y="0" width="75" height="11"/>
				<textElement textAlignment="Right">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{MISC_PAYDET_PAY_AMT}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<pageFooter>
		<band height="26">
			<textField pattern="0.00" isBlankWhenNull="true">
				<reportElement x="283" y="8" width="70" height="15">
					<printWhenExpression><![CDATA[new Boolean(($F{PAGECNT}.doubleValue()!=$F{maxpage}.doubleValue())?false:true)]]></printWhenExpression>
				</reportElement>
				<textElement textAlignment="Right">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{SUM_DIS}]]></textFieldExpression>
			</textField>
			<textField pattern="0.00" isBlankWhenNull="true">
				<reportElement x="489" y="8" width="75" height="15">
					<printWhenExpression><![CDATA[new Boolean(($F{PAGECNT}.doubleValue()!=$F{maxpage}.doubleValue())?false:true)]]></printWhenExpression>
				</reportElement>
				<textElement textAlignment="Right">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{SUM__NETAMT}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="502" y="8" width="62" height="15" isRemoveLineWhenBlank="true">
					<printWhenExpression><![CDATA[new Boolean(($F{PAGECNT}.doubleValue()==$F{maxpage}.doubleValue())?false:true)]]></printWhenExpression>
				</reportElement>
				<textElement textAlignment="Center">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<text><![CDATA[Continued]]></text>
			</staticText>
			<textField pattern="0.00" isBlankWhenNull="true">
				<reportElement x="168" y="8" width="81" height="15">
					<printWhenExpression><![CDATA[new Boolean(($F{PAGECNT}.doubleValue()!=$F{maxpage}.doubleValue())?false:true)]]></printWhenExpression>
				</reportElement>
				<textElement textAlignment="Right">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{SUM_AMT}]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
</jasperReport>
