<?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="invoiceA5" pageWidth="421" pageHeight="595" columnWidth="361" leftMargin="30" rightMargin="30" topMargin="19" bottomMargin="14">
	<property name="ireport.scriptlethandling" value="0"/>
	<property name="ireport.encoding" value="UTF-8"/>
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<import value="org.openvpms.component.business.domain.im.party.Party"/>
	<import value="net.sf.jasperreports.engine.*"/>
	<import value="java.util.*"/>
	<import value="org.openvpms.archetype.function.party.PartyFunctions"/>
	<import value="net.sf.jasperreports.engine.data.*"/>
	<parameter name="dataSource" class="org.openvpms.report.jasper.IMObjectCollectionDataSource" isForPrompting="false"/>
	<parameter name="IsEmail" class="java.lang.Boolean" isForPrompting="false">
		<parameterDescription><![CDATA[If true, indicates the report is being emailed, to enable different formatting]]></parameterDescription>
		<defaultValueExpression><![CDATA[Boolean.FALSE]]></defaultValueExpression>
	</parameter>
	<field name="author.entity.name" class="java.lang.String"/>
	<field name="customer.entity.name" class="java.lang.String"/>
	<field name="customer.entity" class="org.openvpms.component.business.domain.im.party.Party"/>
	<field name="startTime" class="java.util.Date"/>
	<field name="id" class="java.lang.Long"/>
	<field name="tax" class="java.math.BigDecimal"/>
	<field name="notes" class="java.lang.String"/>
	<field name="[party:getBillingAddress(.)]" class="java.lang.String"/>
	<field name="[party:getAccountBalance(.)]" class="java.math.BigDecimal"/>
	<field name="[party:getFullName(party:getPractice())]" class="java.lang.String"/>
	<field name="[party:getBillingAddress(party:getPractice())]" class="java.lang.String"/>
	<field name="allocatedAmount" class="java.math.BigDecimal"/>
	<field name="customer.entity.type.generalMessage" class="java.lang.String"/>
	<field name="[party:getPartyFullName(.)]" class="java.lang.String"/>
	<field name="customer.entity.companyName" class="java.lang.String"/>
	<field name="customer.entity.lastName" class="java.lang.String"/>
	<field name="customer.entity.title" class="java.lang.String"/>
	<field name="customer.entity.initials" class="java.lang.String"/>
	<variable name="TOTAL_DISCOUNT" class="java.math.BigDecimal"/>
	<variable name="customerFullName" class="java.lang.String" resetType="None">
		<variableExpression><![CDATA[(($F{customer.entity.title} == null) ? "": $F{customer.entity.title}) + " " + (($F{customer.entity.initials} == null) ? "": $F{customer.entity.initials}) + " " + $F{customer.entity.lastName}]]></variableExpression>
	</variable>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="130" splitType="Stretch">
			<staticText>
				<reportElement x="10" y="34" width="335" height="47">
					<printWhenExpression><![CDATA[$P{IsEmail}.equals(Boolean.TRUE)]]></printWhenExpression>
				</reportElement>
				<textElement/>
				<text><![CDATA[This is automatically hidden when printing. See the "Print When Expression" property for more details.]]></text>
			</staticText>
			<staticText>
				<reportElement x="10" y="10" width="341" height="24">
					<printWhenExpression><![CDATA[$P{IsEmail}.equals(Boolean.TRUE)]]></printWhenExpression>
				</reportElement>
				<textElement/>
				<text><![CDATA[Email Letterhead. Replace this label with the practice logo and details.]]></text>
			</staticText>
		</band>
	</title>
	<pageHeader>
		<band height="118" splitType="Stretch">
			<staticText>
				<reportElement key="staticText-1" x="121" y="0" width="117" height="29"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Center">
					<font size="18" isBold="true" pdfFontName="Helvetica-Bold"/>
				</textElement>
				<text><![CDATA[Tax Invoice]]></text>
			</staticText>
			<textField pattern="dd/MM/yyyy" isBlankWhenNull="false">
				<reportElement key="textField-3" x="278" y="54" width="73" height="16"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement verticalAlignment="Bottom">
					<font size="10"/>
				</textElement>
				<textFieldExpression class="java.util.Date"><![CDATA[$F{startTime}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement key="staticText-2" x="221" y="70" width="57" height="16"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement verticalAlignment="Middle">
					<font size="10"/>
				</textElement>
				<text><![CDATA[Transaction No]]></text>
			</staticText>
			<staticText>
				<reportElement key="staticText-3" x="221" y="54" width="59" height="16"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement verticalAlignment="Bottom">
					<font size="10"/>
				</textElement>
				<text><![CDATA[Date]]></text>
			</staticText>
			<textField isBlankWhenNull="false">
				<reportElement key="textField-4" x="278" y="70" width="73" height="16"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement verticalAlignment="Middle">
					<font size="10"/>
				</textElement>
				<textFieldExpression class="java.lang.Long"><![CDATA[$F{id}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="false">
				<reportElement key="textField-1" x="36" y="54" width="167" height="18"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement verticalAlignment="Middle">
					<font size="10"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{customerFullName}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false">
				<reportElement key="textField-2" x="36" y="70" width="167" height="45"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{[party:getBillingAddress(.)]}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="false">
				<reportElement key="textField" x="277" y="85" width="27" height="14"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Left">
					<font size="10"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{PAGE_NUMBER} + " of "]]></textFieldExpression>
			</textField>
			<textField evaluationTime="Report" isBlankWhenNull="false">
				<reportElement key="textField" x="304" y="85" width="44" height="14"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Left">
					<font size="10"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER} + ""]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement key="staticText-5" x="221" y="85" width="56" height="14"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10"/>
				</textElement>
				<text><![CDATA[Page]]></text>
			</staticText>
			<textField isBlankWhenNull="false">
				<reportElement key="textField-9" x="36" y="40" width="167" height="13"/>
				<textElement verticalAlignment="Bottom"/>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{customer.entity.companyName}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement key="staticText-11" x="278" y="9" width="81" height="13"/>
				<textElement>
					<font size="8"/>
				</textElement>
				<text><![CDATA[ABN: 00 000 000 000]]></text>
			</staticText>
		</band>
	</pageHeader>
	<columnHeader>
		<band splitType="Stretch"/>
	</columnHeader>
	<detail>
		<band height="13" splitType="Stretch">
			<subreport isUsingCache="true">
				<reportElement key="subreport-1" x="0" y="0" width="355" height="10"/>
				<dataSourceExpression><![CDATA[$P{dataSource}.getDataSource("items", new String[]{"target.patient.entity.name", "target.startTime"})]]></dataSourceExpression>
				<returnValue subreportVariable="SUM_target.discount" toVariable="TOTAL_DISCOUNT" calculation="Sum"/>
				<subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA["invoiceItemsA5.jrxml"]]></subreportExpression>
			</subreport>
		</band>
	</detail>
	<columnFooter>
		<band splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band height="132" splitType="Stretch">
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField-5" x="12" y="88" width="333" height="20" isRemoveLineWhenBlank="true"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{notes}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement key="staticText-4" x="12" y="45" width="121" height="17"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10"/>
				</textElement>
				<text><![CDATA[This Invoice is inclusive of ]]></text>
			</staticText>
			<textField pattern="¤ #,##0.00" isBlankWhenNull="false">
				<reportElement key="textField-6" x="132" y="45" width="43" height="17"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Center">
					<font size="10" isBold="true" pdfFontName="Helvetica-Bold"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{tax}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement key="staticText-6" x="169" y="54" width="0" height="0"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement/>
				<text><![CDATA[Static text]]></text>
			</staticText>
			<staticText>
				<reportElement key="staticText-7" x="175" y="45" width="33" height="17"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10"/>
				</textElement>
				<text><![CDATA[GST]]></text>
			</staticText>
			<textField pattern="¤ #,##0.00" isBlankWhenNull="false">
				<reportElement key="textField-7" x="310" y="15" width="49" height="14"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right">
					<font size="10" isBold="true" pdfFontName="Helvetica-Bold"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{[party:getAccountBalance(.)]}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement key="staticText-8" x="195" y="15" width="112" height="14"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10" isBold="true" pdfFontName="Helvetica-Bold"/>
				</textElement>
				<text><![CDATA[CURRENT BALANCE]]></text>
			</staticText>
			<staticText>
				<reportElement key="staticText-9" x="195" y="0" width="112" height="14"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10" isBold="true" pdfFontName="Helvetica-Bold"/>
				</textElement>
				<text><![CDATA[AMOUNT PAID]]></text>
			</staticText>
			<textField pattern="¤ #,##0.00" isBlankWhenNull="false">
				<reportElement key="textField-8" x="310" y="0" width="49" height="14"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right">
					<font size="10" isBold="true" pdfFontName="Helvetica-Bold"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{allocatedAmount}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement key="staticText-10" x="12" y="61" width="163" height="17" isRemoveLineWhenBlank="true">
					<printWhenExpression><![CDATA[new Boolean($V{TOTAL_DISCOUNT}.compareTo(BigDecimal.ZERO) != 0)]]></printWhenExpression>
				</reportElement>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10"/>
				</textElement>
				<text><![CDATA[You have been given a discount of :]]></text>
			</staticText>
			<textField pattern="¤ #,##0.00" isBlankWhenNull="false">
				<reportElement key="textField" x="175" y="62" width="49" height="16" isRemoveLineWhenBlank="true">
					<printWhenExpression><![CDATA[new Boolean($V{TOTAL_DISCOUNT}.compareTo(BigDecimal.ZERO) != 0)]]></printWhenExpression>
				</reportElement>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Left"/>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{TOTAL_DISCOUNT}]]></textFieldExpression>
			</textField>
			<subreport isUsingCache="false">
				<reportElement x="0" y="118" width="345" height="11"/>
				<dataSourceExpression><![CDATA[$P{dataSource}.getExpressionDataSource("reminder:getReminders(., 1, 'YEARS')")]]></dataSourceExpression>
				<subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA["invoiceRemindersA5.jrxml"]]></subreportExpression>
			</subreport>
		</band>
	</summary>
</jasperReport>