Commit 61fbadc4 authored by mattwire's avatar mattwire
Browse files

Merge branch 'dontaddfuturereceivedatetobatch' into 'master'

Don't add contributions with a future "receive date" to batch. HMRC does not allow this!

See merge request extensions/ukgiftaid!21
parents 407994cb e9be5347
......@@ -346,7 +346,6 @@ class CRM_Civigiftaid_Utils_Contribution {
public static function validateContributionToBatch($contributionIDs) {
$contributionsAdded = [];
$contributionsAlreadyAdded = [];
$contributionsNotValid = [];
// Get all contributions from found IDs that are not already in a batch
$contributionParams = [
......@@ -361,10 +360,14 @@ class CRM_Civigiftaid_Utils_Contribution {
CRM_Civigiftaid_Utils::getCustomByName('Gift_Aid_Amount', 'Gift_Aid'),
CRM_Civigiftaid_Utils::getCustomByName('Amount', 'Gift_Aid'),
],
'receive_date' => ['<=' => 'now'],
'options' => ['limit' => 0],
];
$contributions = civicrm_api3('Contribution', 'get', $contributionParams)['values'];
// Add contribution IDs that were not matched (eg. receive_date is in the future)
$contributionsNotValid = array_diff($contributionIDs, array_keys($contributions));
foreach ($contributions as $contribution) {
if (!empty($contribution[CRM_Civigiftaid_Utils::getCustomByName('batch_name', 'Gift_Aid')])) {
$contributionsAlreadyAdded[] = $contribution['id'];
......
......@@ -9,9 +9,10 @@ Releases use the following numbering system:
* **[BC]**: Items marked with [BC] indicate a breaking change that will require updates to your code if you are using that code in your extension.
## Release 3.4.7 (not yet released 2020-12-04)
## Release 3.4.7 (not yet released 2021-02-25)
* When upgrading check and update customfield datatypes (`eligible_for_gift_aid` was `varchar` instead of `int` on some old installs).
* Don't add contributions with a future "receive date" to batch. HMRC does not allow this!
## Release 3.4.6
......
......@@ -18,7 +18,7 @@
<author>MJW Consulting, Rich Lott (Artful Robot) Erawat Chamanont, Jamie Novick, Guanhuan Chen, Robin Mitra</author>
<email>mjw@mjwconsult.co.uk, https://artfulrobot.uk, jamie@compucorp.co.uk, guanhuan@compucorp.co.uk</email>
</maintainer>
<releaseDate>2020-12-04</releaseDate>
<releaseDate>2021-02-25</releaseDate>
<version>3.4.7-dev</version>
<develStage>beta</develStage>
<compatibility>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment