Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Extensions
automaticsoftcredit
Commits
c8d9dc20
Unverified
Commit
c8d9dc20
authored
Oct 11, 2022
by
JonGold
Browse files
Version 2.3.1 - CiviCRM 5.54+ compatibility
parent
371f8b48
Changes
3
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
c8d9dc20
# 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).
...
...
automaticsoftcredit.php
View file @
c8d9dc20
...
...
@@ -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
();
}
}
...
...
info.xml
View file @
c8d9dc20
...
...
@@ -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.
3
5
</ver>
<ver>
5.5
4
</ver>
</compatibility>
<comments/>
<civix>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment