Unverified Commit 093af21b authored by JonGold's avatar JonGold
Browse files

soft credit is in the same currency as the contribution, not the default currency

parent 0dca6007
......@@ -23,12 +23,13 @@ function automaticsoftcredit_civicrm_postCommit($op, $objectName, $objectId, &$o
if ($relationship['orientation'] === 'b_a' && $relationship['relationship_type.automaticsoftcredit.softcreditdirection'] === 1) {
continue;
}
// TODO: Civi 5.33 should support ContributionSoft in API4.
civicrm_api3('ContributionSoft', 'create', [
'contribution_id' => $objectId,
'amount' => $objectRef->total_amount,
'contact_id' => $relationship['far_contact_id'],
]);
\Civi\Api4\ContributionSoft::create(FALSE)
->addValue('contribution_id', $objectId)
->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'])
->execute();
}
}
......@@ -37,7 +38,6 @@ function automaticsoftcredit_civicrm_fieldOptions($entity, $field, &$options, $p
return;
}
$softCreditTypeField = 'custom_' . CRM_Core_BAO_CustomField::getCustomFieldID('softcreditrelationshiptype');
$softCreditDirectionField = 'custom_' . CRM_Core_BAO_CustomField::getCustomFieldID('softcreditdirection');
if ($field == $softCreditTypeField) {
$softCreditOptions = civicrm_api3('OptionValue', 'get', ['option_group_id' => "soft_credit_type"])['values'];
foreach ($softCreditOptions as $softCreditOption) {
......
......@@ -15,10 +15,10 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-06-01</releaseDate>
<version>2.1.1</version>
<version>2.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.31</ver>
<ver>5.35</ver>
</compatibility>
<comments></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