Gift Aid Claim (No Addresses)
###
Financial
###
2707/Any rev02
###
Donors with donations qualifying for gift aid between two dates (without addresses).
###
en_GB
###
$VAR from DATE Enter from date$
$VAR to DATE Enter to date$

SELECT owner.ID, OwnerName, HomeTelephone, SUM(Donation) AS Amount, 
(SELECT MAX(od.Date) FROM ownerdonation od 
WHERE od.Date >= '$@from$' AND
od.Date <= '$@to$' AND od.IsGiftAid = 1 AND od.OwnerID = owner.ID) AS LastDate
FROM ownerdonation
INNER JOIN owner ON ownerdonation.OwnerID = owner.ID
WHERE ownerdonation.IsGiftAid = 1 AND
ownerdonation.Date >= '$@from$' AND ownerdonation.Date <= '$@to$'
GROUP BY owner.ID, OwnerName, HomeTelephone
###
$$HEADER
<table border=1>
<thead>
<tr>
<th><b>Last Donation</b></th>
<th><b>Name</b></th>
<th><b>Telephone</b></th>
<th><b>Donated</b></th>
</tr>
</thead>
<tbody>
HEADER$$

$$BODY<tr>
<td>$LASTDATE</td>
<td><a target="_blank" href="person?id=$ID">$OWNERNAME</a></td>
<td>$HOMETELEPHONE</td>
<td>$AMOUNT</td>
</tr>
BODY$$

$$FOOTER
</tbody>
</table>
<p>Total qualifying for gift aid in period: <b>{SUM.AMOUNT.2}</b></p>
FOOTER$$

