Unverified Commit c8d9dc20 authored by JonGold's avatar JonGold
Browse files

Version 2.3.1 - CiviCRM 5.54+ compatibility

parent 371f8b48
# CHANGELOG
## Version 2.3.1
* CiviCRM 5.54+ compatibility.
## Version 2.3
* Fix bug: Recurring contributions were adding two soft credits per person instead of one on contributions after the first.
## Version 2.2
* Switch from API3 to API4 (for forward compatibility/easier to read).
## Version 2.1.1
* PHP 7.4 compatibility.
## Version 2.1
* Use the new "relationship cache" to reduce the number of queries, improving speed (and reducing extension size).
......
......@@ -21,17 +21,17 @@ function automaticsoftcredit_civicrm_postCommit($op, $objectName, $objectId, &$o
}
//Look up whether this person has a relationship_type_id that's automatically soft credited
$relationshipsRaw = \Civi\Api4\RelationshipCache::get(FALSE)
->addSelect('relationship_type.automaticsoftcredit.softcreditrelationshiptype', 'relationship_type.automaticsoftcredit.softcreditdirection', 'far_contact_id', 'orientation')
->addSelect('relationship_type_id.automaticsoftcredit.softcreditrelationshiptype', 'relationship_type_id.automaticsoftcredit.softcreditdirection', 'far_contact_id', 'orientation')
->addWhere('is_active', '=', TRUE)
->addWhere('near_contact_id', '=', $objectRef->contact_id)
->addWhere('relationship_type.automaticsoftcredit.softcreditrelationshiptype', 'IS NOT NULL', '')
->addWhere('relationship_type_id.automaticsoftcredit.softcreditrelationshiptype', 'IS NOT NULL', '')
->execute();
// Add a soft credit, skipping any relationships that go in the wrong direction.
foreach ($relationshipsRaw as $k => $relationship) {
if ($relationship['orientation'] === 'a_b' && $relationship['relationship_type.automaticsoftcredit.softcreditdirection'] === 2) {
if ($relationship['orientation'] === 'a_b' && $relationship['relationship_type_id.automaticsoftcredit.softcreditdirection'] === 2) {
continue;
}
if ($relationship['orientation'] === 'b_a' && $relationship['relationship_type.automaticsoftcredit.softcreditdirection'] === 1) {
if ($relationship['orientation'] === 'b_a' && $relationship['relationship_type_id.automaticsoftcredit.softcreditdirection'] === 1) {
continue;
}
\Civi\Api4\ContributionSoft::create(FALSE)
......@@ -39,7 +39,7 @@ function automaticsoftcredit_civicrm_postCommit($op, $objectName, $objectId, &$o
->addValue('amount', $objectRef->total_amount)
->addValue('currency', $objectRef->currency)
->addValue('contact_id', $relationship['far_contact_id'])
->addValue('soft_credit_type_id', $relationship['relationship_type.automaticsoftcredit.softcreditrelationshiptype'])
->addValue('soft_credit_type_id', $relationship['relationship_type_id.automaticsoftcredit.softcreditrelationshiptype'])
->execute();
}
}
......
......@@ -15,10 +15,10 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2022-07-08</releaseDate>
<version>2.3</version>
<version>2.3.1</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.35</ver>
<ver>5.54</ver>
</compatibility>
<comments/>
<civix>
......
Supports Markdown
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