Development issueshttps://lab.civicrm.org/groups/dev/-/issues2023-10-05T05:03:18Zhttps://lab.civicrm.org/dev/core/-/issues/2911Cannot test Contribution Form "Thank You" page in Development Mode (or with O...2023-10-05T05:03:18Zmartin.wCannot test Contribution Form "Thank You" page in Development Mode (or with Outbound Mail disabled)Overview
----------------------------------------
When you test a contribution form that is configured to send an email receipt and also display a "Thank You" page with CiviCRM in Development mode, the "Thank You" page is never displayed...Overview
----------------------------------------
When you test a contribution form that is configured to send an email receipt and also display a "Thank You" page with CiviCRM in Development mode, the "Thank You" page is never displayed because of an error attempting to send the receipt email.
The mail error occurs because Development mode changes the Outbound Mail setting to “Disable Outbound Email”.
By contrast, if `sendmail` is misconfigured in the Civi admin settings, the "Thank You" page is still displayed but with a short "**Mailing Error** sendmail returned error code 127" message at the top.
Reproduction steps
----------------------------------------
1. Configure a donation form in Test Mode to send an email receipt and display a “Thank You” page.
1. Configure Authorize.Net as a Payment Processor. (Alternatively, you may be able to use any other synchronous Payment Processor— e.g. Stripe. I did not test this. However, I saw that this error does not occur with the PayPal Payment Processor because of its different flow.)
1. Put CiviCRM into Development mode. (Alternatively, change the Outbound Mail setting to “Disable Outbound Email”.)
1. Make a test donation.
1. **Result:** no “Thank You” page is displayed. Instead:
- On my website, I’m redirected to the site home page. No error message is displayed to the user. (This may depend on the WordPress environment. Our site is built using Elementor for most theme elements.)
- An error is logged to Civi’s log: [info] Outbound mail has been disabled. Click <a href='https://nb.local/donate/ohm-fund/?civiwp=CiviCRM&q=civicrm%2F admin%2Fsetting%2Fsmtp&reset=1'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.
1. Within Civi, change the Outbound Mail settings to an invalid sendmail path such as “/usr/sbin/no_such_sendmail” and sendmail argument “-i”.
1. Make another test donation.
1. **Result:** the “Thank You” page is displayed with a useful "Mailing Error sendmail returned error code 127" message at the top.
Current behaviour
----------------------------------------
After completely filling out the Test Mode contribution form and clicking to submit the donation:
1. The WordPress site's "home page" is displayed.
1. Within CiviCRM, the test contribution is recorded as successful.
1. An error message is logged to Civi's log: [info] Outbound mail has been disabled. Click <a href='https://nb.local/donate/ohm-fund/?civiwp=CiviCRM&q=civicrm%2F admin%2Fsetting%2Fsmtp&reset=1'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.
Expected behaviour
----------------------------------------
To facilitate testing, Civi should display the "Thank You" page normally, with some kind of an error or warning message indicating no receipt was emailed because outbound mail is disabled.
As mentioned, if you intentionally misconfigure `sendmail` within Civi (for example, by configuring it with a nonexistent “/usr/sbin/no_such_sendmail” entry), then Civi **does** display a more helpful "**Mailing Error** sendmail returned error code 127" message, and **does** display the "Thank You" page.
Environment information
----------------------------------------
* __Browser:__ Chrome Version 94.0.4606.71
* __CiviCRM:__ CiviCRM 5.41.0.
* __PHP:__ PHP Version 7.3.28-1.
* __CMS:__ WordPress 5.8.1.
* __Database:__ mysql Ver 14.14 Distrib 5.7.34
* __Web Server:__ Apache/2.4.46 (Ubuntu)
Where does the actual error occur?
----------------------------------------
_wp-content/plugins/civicrm/civicrm/CRM/Utils/Mail.php_, line 102
```
public static function createMailer() {
...
CRM_Core_Error::debug_log_message(ts('Outbound mail has been disabled. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')]));
===> CRM_Core_Error::statusBounce(ts('Outbound mail has been disabled. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')]));
...
```
What code can be modified to fix this?
----------------------------------------
_wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Contribution.php_, around line 4217
Change the following: [fixNB20210923.patch](/uploads/a30c2f0d88e15f2de25a5c3c70e99c69/fixNB20210923.patch)
```
if (self::isEmailReceipt($input, $contributionID, $recurringContributionID)) {
civicrm_api3('Contribution', 'sendconfirmation', [
'id' => $contributionID,
'payment_processor_id' => $paymentProcessorId,
]);
\Civi::log()->info("Contribution {$contributionParams['id']} Receipt sent");
}
```
to
```
if (self::isEmailReceipt($input, $contributionID, $recurringContributionID)) {
$mailingInfo = Civi::settings()->get('mailing_backend');
if ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED) {
CRM_Core_Error::debug_log_message(ts('Outbound mail has been disabled. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')]));
CRM_Core_Error::debug_log_message(ts('Because outbound mail has been disabled, no contribution email receipt has been sent.'));
} else {
civicrm_api3('Contribution', 'sendconfirmation', [
'id' => $contributionID,
'payment_processor_id' => $paymentProcessorId,
]);
\Civi::log()->info("Contribution {$contributionParams['id']} Receipt sent");
}
}
```
It would be better still if the API v3 call threw an exception rather than redirecting. (It’s contrary to expectation that an API call produces a redirect upon failure!) Better logic might look like:
```
if (self::isEmailReceipt($input, $contributionID, $recurringContributionID)) {
try {
civicrm_api3('Contribution', 'sendconfirmation', [
'id' => $contributionID,
'payment_processor_id' => $paymentProcessorId,
]);
\Civi::log()->info("Contribution {$contributionParams['id']} Receipt sent");
} catch (Exception $ex) {
CRM_Core_Error::debug_log_message(ts('Failed to send contribution email receipt. Is Outbound Email disabled? Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to check the settings. Exception detail: %2', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'), 2 => $ex->getMessage() ]));
}
}
```
Alternatively, the error message from misconfiguring sendmail is raised by:
_wp-content/plugins/civicrm/civicrm/vendor/pear/mail/Mail/sendmail.php_ lines 191-195.
```
if ($result != 0) {
return PEAR::raiseError('sendmail returned error code ' . $result,
$result);
}
```
If the API v3 call displayed an error message like the misconfigured sendmail scenario does, it would still be possible to test the "Thank You" page with Development Mode turned on (or equivalently Outbound Mail turned off).https://lab.civicrm.org/dev/core/-/issues/2910Remove the CiviCRM Connections functionality (Task 1 of 2) - Remove the menu ...2022-08-09T14:44:38Zjustinfreeman (Agileware)Remove the CiviCRM Connections functionality (Task 1 of 2) - Remove the menu item**CiviCRM Connections** is available under the System Settings menu. From what I can tell this feature is an artefact that is no longer being used. Happy to be educated on the subject if this is not the case.
Cannot find any references ...**CiviCRM Connections** is available under the System Settings menu. From what I can tell this feature is an artefact that is no longer being used. Happy to be educated on the subject if this is not the case.
Cannot find any references to it in the documentation:
- https://docs.civicrm.org/user/en/latest/
- https://docs.civicrm.org/sysadmin/en/latest/
Googling doesn't reveal anything relevant either.
So can we remove this code from the system?
![Screenshot_20211013_091315](/uploads/724bb11ee0a345f31be5b369b22af959/Screenshot_20211013_091315.png)
Agileware Ref: CIVIBLD-2865.44.0https://lab.civicrm.org/dev/core/-/issues/2909Repair "Norwegian Bokmål"2021-11-04T17:48:03ZhaystackRepair "Norwegian Bokmål"Overview
----------------------------------------
"Norwegian Bokmål" is corrupted in [this file](https://github.com/civicrm/civicrm-core/blob/5db0bc3c1f54eaca4307f103a73bda596ae914d6/install/langs.php#L32) and [this one](https://github.c...Overview
----------------------------------------
"Norwegian Bokmål" is corrupted in [this file](https://github.com/civicrm/civicrm-core/blob/5db0bc3c1f54eaca4307f103a73bda596ae914d6/install/langs.php#L32) and [this one](https://github.com/civicrm/civicrm-core/blob/5db0bc3c1f54eaca4307f103a73bda596ae914d6/xml/templates/languages.tpl#L136).
Current behaviour
----------------------------------------
"Norwegian Bokmål" renders as "Norwegian BokmÃ¥l"
Expected behaviour
----------------------------------------
"Norwegian Bokmål" FTW.5.44.0haystackhaystackhttps://lab.civicrm.org/dev/core/-/issues/2908Contributions on recurring view are not sorted based on received date descending2023-10-20T05:03:17ZyashodhaContributions on recurring view are not sorted based on received date descendingContributions on recurring view are not sorted based on received date descending but alphabetically
![recur](/uploads/529cb945bcdb316e1292a314a728dcf3/recur.png)
Confirmed on dmasterContributions on recurring view are not sorted based on received date descending but alphabetically
![recur](/uploads/529cb945bcdb316e1292a314a728dcf3/recur.png)
Confirmed on dmasteryashodhayashodhahttps://lab.civicrm.org/dev/core/-/issues/2907Some contact core tokens stopped working in 5.43 RC2023-09-25T22:40:57Zmagnolia61Some contact core tokens stopped working in 5.43 RCSome contact core tokens stopped working in scheduled reminders & send email in the 5.43 RC
**Does render in subject:**<BR>
```
{contact.id}
{contact.contact_type:label}
{contact.display_name}
{contact.middle_name}
{contact.last_name}
{...Some contact core tokens stopped working in scheduled reminders & send email in the 5.43 RC
**Does render in subject:**<BR>
```
{contact.id}
{contact.contact_type:label}
{contact.display_name}
{contact.middle_name}
{contact.last_name}
{contact.email_greeting_display}
{contact.phone}
{contact.city}
```
**Does NOT render in subject:**<BR>
```
{contact.first_name}
{contact.birth_date}
(and maybe more)
```
**Does not render in the body:**<BR>
```
{contact.id}
{contact.contact_type:label}
{contact.display_name}
{contact.middle_name}
{contact.last_name}
{contact.email_greeting_display}
{contact.phone}
{contact.city}
```
...
I actually cannot get any contact core token to render in the body field of the template
All my contact custom tokens work fine in subject and body thoughhttps://lab.civicrm.org/dev/core/-/issues/2906CiviCRM 5.41.0 - CiviCase 2.x duplicates Custom Fields when a mandatory field...2021-10-18T00:31:51Zjustinfreeman (Agileware)CiviCRM 5.41.0 - CiviCase 2.x duplicates Custom Fields when a mandatory field validation error occurs. Case cannot be saved.CiviCase 2.x duplicates Custom Fields when a mandatory field validation error occurs. Case cannot be saved.
Steps to reproduce the problems:
1. Set up a new CiviCase Type ("Complaint")
1. Create a Custom Fieldset ("Complaint Details") f...CiviCase 2.x duplicates Custom Fields when a mandatory field validation error occurs. Case cannot be saved.
Steps to reproduce the problems:
1. Set up a new CiviCase Type ("Complaint")
1. Create a Custom Fieldset ("Complaint Details") for that CiviCase Type.
1. Set some of the Custom Fields in the Custom Fieldset to Mandatory.
1. Create new Case and select the Case Type ("Complaint").
1. Note that the Custom Fieldset, "Complaint Details" are displayed
1. Do not complete all the mandatory fields.
1. Save the Case.
1. Validation error message triggers the "Complaint Details" Custom Fields to be displayed twice on the form
1. The "Complaint Details" Custom Fields have both the values submitted and empty values
1. If the Case, "Complaint" is saved again after completing the mandatory fields. A validation error occurs on the empty, duplicate "Complaint Details" Custom Fields which are empty.
The workaround at this time is to ensure all mandatory fields are completed before saving.
Environment:
* CiviCRM 5.41.0
* CiviCase 2.2.0 https://github.com/compucorp/uk.co.compucorp.civicase/archive/refs/tags/2.2.0.zip
* WordPress
Agileware Ref: CIVICRM-1867https://lab.civicrm.org/dev/core/-/issues/2905Defining cg_extend_objects subtypes dynamically does not work as described2022-05-20T07:21:19ZjensschuppeDefining cg_extend_objects subtypes dynamically does not work as describedThe `cg_extend_objects` option group is used to define entity types that can receive custom fields. This can be optionally refined for sub types of entity types, in which case the option value description can contain a static method with...The `cg_extend_objects` option group is used to define entity types that can receive custom fields. This can be optionally refined for sub types of entity types, in which case the option value description can contain a static method with optional arguments that is supposed to return all sub types for the respective entity type, as is done for CiviCase case types (note the `description`):
```json
{
"id": "608",
"option_group_id": "57",
"label": "Cases",
"value": "Case",
"name": "civicrm_case",
"filter": "0",
"weight": "7",
"description": "CRM_Case_PseudoConstant::caseType;",
"is_optgroup": "0",
"is_reserved": "0",
"is_active": "1"
}
```
The argument part (everything after the `;`), however, does not work as described in the code:
https://github.com/civicrm/civicrm-core/blob/8766a2e7d07cecadb2816fc415e6a44fe9bc5271/CRM/Core/BAO/CustomGroup.php#L2075-L2093
```php
foreach ($extendObjs as $ovId => $ovValues) {
if ($ovValues['description']) {
// description is expected to be a callback func to subtypes
list($callback, $args) = explode(';', trim($ovValues['description']));
if (empty($args)) {
$args = [];
}
if (!is_array($args)) {
throw new CRM_Core_Exception('Arg is not of type array');
}
list($className) = explode('::', $callback);
require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
$objTypes[$ovValues['value']] = call_user_func_array($callback, $args);
}
}
```
`$args` can never be an array when it's not empty, as `explode()` always returns an array of strings. So this code will always fail when there's something after the `;`.
There should be a format defined for how arguments are to be passed (comma-separated, serialized, json, ...).
And yes, this is "esoteric" in the first place, but currently the only way to pass e.g. the entity type itself for generating a list of sub types, which makes sense for contrib stuff. As an explanation: My extension's entity types do not have their own PHP classes, but share a generic controller, so the entity type name needs to be passed here for each entity type having dedicated custom fields.colemanwcolemanwhttps://lab.civicrm.org/dev/financial/-/issues/188Financial Items incorrectly recorded when using Payment API2021-10-27T16:53:49ZhaystackFinancial Items incorrectly recorded when using Payment APIFinally found the time to return to the Order & Payment API and test the changes that @eileen and @KarinG have worked on. So much better now that I can update a contribution without the tax amounts being recalculated!
Warning, this is g...Finally found the time to return to the Order & Payment API and test the changes that @eileen and @KarinG have worked on. So much better now that I can update a contribution without the tax amounts being recalculated!
Warning, this is going to be a long issue because it seems to involve two (maybe overlapping) issues which I haven't been able to separate. So... the scenario that I'm testing is where:
* I create multiple Line Items in an Order that are a mix of taxable and non-taxable.
* They are also a mix of Participant and Membership Line Items.
* The Line Items can be in any sequence when the Order is created.
To tease out what's going on, I tested the following:
1. Taxable Participant ($25) followed by Non-taxable Membership ($50)
2. Non-taxable Membership ($50) followed by Taxable Participant ($25)
3. Taxable Participant ($50) followed by Non-taxable Membership ($50)
4. Non-taxable Membership ($50) followed by Taxable Participant ($50)
These happen to be for Events ("Summer Solstice Festival Day Concert" and "Fall Fundraiser Dinner") and Membership Types (Student) in the CiviCRM Sample Data - though if you want to use those to replicate then it should be noted that "Summer Solstice Festival Day Concert" is incorrectly set to the "Member Dues" Financial Type. @kcristiano was invaluable in setting up CiviCRM's Sample Data with correct Financial Types and I assume there's nothing amiss in that regard.
## Taxable Participant ($25) followed by Non-taxable Membership ($50)
The procedure is commented upon in full for this first test. I'll just post the annotated logs for the subsequent tests since the procedure is identical.
![civicrm-E25-M50-order](/uploads/74c5bdb91fb8ee46d73a0f525a7552ad/civicrm-E25-M50-order.png)
The params for Order.create are as follows:
```
[params] => Array
(
[contact_id] => 210
[financial_type_id] => 1 <-- Non-taxable Financial Type
[payment_instrument_id] => 4
[trxn_id] => WooCommerce Order - 2247
[invoice_id] => 2247_woocommerce
[receive_date] => 2021-10-11 11:28:21
[contribution_status_id] => Pending
[is_pay_later] => 1
[total_amount] => 79.84 <-- Note: Total Amount has 2 decimal places
[source] => Shop
[campaign_id] => 3
[note] => Solstice Ticket x 1, Student Membership x 1
[line_items] => Array
(
[17] => Array
(
[params] => Array
(
[event_id] => 2
[contact_id] => 210
[role_id] => 1
[source] => Shop: Solstice Ticket
[status_id] => Pending from pay later
)
[line_item] => Array
(
[0] => Array
(
[price_field_id] => 1
[unit_price] => 25.00
[qty] => 1
[line_total] => 25.00
[tax_amount] => 4.84 <-- Note: Tax Amount has 2 decimal places
[label] => Solstice Ticket
[entity_table] => civicrm_participant
[financial_type_id] => 5 <-- Taxable Financial Type
)
)
)
[18] => Array
(
[params] => Array
(
[membership_type_id] => 2
[source] => Shop
[contact_id] => 210
[skipStatusCal] => 1
[status_id] => Pending
)
[line_item] => Array
(
[0] => Array
(
[price_field_id] => 1
[unit_price] => 50.00
[qty] => 1
[line_total] => 50.00
[tax_amount] => 0.00
[label] => Student Membership
[entity_table] => civicrm_membership
[financial_type_id] => 2 <-- Non-taxable Financial Type
[membership_type_id] => 2
)
)
)
)
)
```
The CiviCRM API (yeah, I know I should convert to API4 but that's another story) returns:
```
[result] => Array
(
[is_error] => 0
[version] => 3
[count] => 1
[id] => 103
[values] => Array
(
[103] => Array
(
[id] => 103
[contact_id] => 210
[financial_type_id] => 1
[contribution_page_id] =>
[payment_instrument_id] => 4
[receive_date] => 20211011112821
[non_deductible_amount] =>
[total_amount] => 79.844775 <-- Note: Total has 6 decimal places
[fee_amount] => 0
[net_amount] => 79.844775 <-- Note: Net Amount has 6 decimal places
[trxn_id] => WooCommerce Order - 2247
[invoice_id] => 2247_woocommerce
[invoice_number] => INV_103
[currency] => USD
[cancel_date] =>
[cancel_reason] =>
[receipt_date] =>
[thankyou_date] =>
[source] => Shop
[amount_level] =>
[contribution_recur_id] =>
[is_test] =>
[is_pay_later] => 1
[contribution_status_id] => 2
[address_id] =>
[check_number] =>
[campaign_id] => 3
[creditnote_id] =>
[tax_amount] => 4.84 <-- Note: Tax Amount has 2 decimal places
[revenue_recognition_date] =>
[is_template] =>
[contribution_type_id] => 1
[line_item] => Array
(
[0] => Array
(
[qty] => 1
[price_field_id] => 1
[price_field_value_id] => 1
[entity_table] => civicrm_participant
[unit_price] => 25.00
[label] => Solstice Ticket
[line_total] => 25.00
[tax_amount] => 4.844775 <-- Note: Tax Amount has 6 decimal places
[financial_type_id] => 5
[entity_id] => 56
)
[1] => Array
(
[qty] => 1
[price_field_id] => 1
[price_field_value_id] => 1
[entity_table] => civicrm_membership
[unit_price] => 50.00
[label] => Student Membership
[line_total] => 50.00
[tax_amount] => 0
[financial_type_id] => 2
[membership_type_id] => 2
[entity_id] => 35
)
)
)
)
)
```
So far so good - though it seems odd that the Total Amount, Net Amount and Tax Amount are reported as having 6 decimal places given that a pre-calculated Tax Amount to 2 decimal places was passed in.
Let's have a look at the Bookkeeping Report at this stage:
![civicrm-E25-M50-pre](/uploads/0fa2ceec4ca463ce50a38bb0ff8b96ae/civicrm-E25-M50-pre.png)
Looks good. The database looks good too:
```
SELECT id, total_amount, fee_amount, net_amount, tax_amount FROM `civicrm_contribution` WHERE id = '103';
+-----+--------------+------------+------------+------------+
| id | total_amount | fee_amount | net_amount | tax_amount |
+-----+--------------+------------+------------+------------+
| 103 | 79.84 | 0.00 | 79.84 | 4.84 |
+-----+--------------+------------+------------+------------+
SELECT id, entity_table, qty, unit_price, line_total, financial_type_id, tax_amount FROM `civicrm_line_item` WHERE contribution_id = '103';
+-----+---------------------+------+------------+------------+-------------------+------------+
| id | entity_table | qty | unit_price | line_total | financial_type_id | tax_amount |
+-----+---------------------+------+------------+------------+-------------------+------------+
| 107 | civicrm_participant | 1.00 | 25.00 | 25.00 | 5 | 4.84 |
| 108 | civicrm_membership | 1.00 | 50.00 | 50.00 | 2 | 0.00 |
+-----+---------------------+------+------------+------------+-------------------+------------+
SELECT * FROM `civicrm_financial_item` WHERE contact_id = '210';
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| id | created_date | transaction_date | contact_id | description | amount | currency | financial_account_id | status_id | entity_table | entity_id |
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| 104 | 2021-10-11 11:28:23 | 2021-10-11 11:28:21 | 210 | Solstice Ticket | 25.00 | USD | 15 | 3 | civicrm_line_item | 107 |
| 105 | 2021-10-11 11:28:23 | 2021-10-11 11:28:21 | 210 | Sales Tax | 4.84 | USD | 17 | 3 | civicrm_line_item | 107 |
| 106 | 2021-10-11 11:28:23 | 2021-10-11 11:28:21 | 210 | Student Membership | 50.00 | USD | 2 | 3 | civicrm_line_item | 108 |
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
SELECT id, from_financial_account_id, to_financial_account_id, trxn_date, total_amount, net_amount, is_payment, status_id, payment_instrument_id FROM `civicrm_financial_trxn` WHERE id > '100';
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| id | from_financial_account_id | to_financial_account_id | trxn_date | total_amount | net_amount | is_payment | status_id | payment_instrument_id |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| 101 | NULL | 7 | 2021-10-11 11:28:21 | 79.84 | 79.84 | 0 | 2 | 4 |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
SELECT * FROM `civicrm_entity_financial_trxn` WHERE financial_trxn_id > '100';
+-----+------------------------+-----------+-------------------+--------+
| id | entity_table | entity_id | financial_trxn_id | amount |
+-----+------------------------+-----------+-------------------+--------+
| 203 | civicrm_contribution | 103 | 101 | 79.84 | <-- Correct Entity ID.
| 204 | civicrm_financial_item | 104 | 101 | 25.00 | <-- Correct Entity ID.
| 205 | civicrm_financial_item | 105 | 101 | 4.84 | <-- Correct Entity ID.
| 206 | civicrm_financial_item | 106 | 101 | 50.00 | <-- Correct Entity ID.
+-----+------------------------+-----------+-------------------+--------+
```
Submit the `Payment.create` with:
```
[params] => Array
(
[contribution_id] => 103
[total_amount] => 79.84
[trxn_date] => 2021-10-11 11:30:58
[trxn_id] => WooCommerce Order - 2247
[payment_instrument_id] => 4
)
```
And the logs show:
```
PHP Notice: Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromEvent in /Users/interactivist/Sites/civicrm/civicrm.events.tec.latest/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Contribution.php on line 2724
PHP Notice: Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromEvent in /Users/interactivist/Sites/civicrm/civicrm.events.tec.latest/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Contribution.php on line 2724
```
The API result is:
```
[result] => Array
(
[is_error] => 0
[version] => 3
[count] => 1
[id] => 102
[values] => Array
(
[102] => Array
(
[id] => 102
[from_financial_account_id] => 7
[to_financial_account_id] => 6
[trxn_date] => 2021-10-11 11:30:58
[total_amount] => 79.84
[fee_amount] => 0.00
[net_amount] => 79.84
[currency] => USD
[is_payment] => 1
[trxn_id] => WooCommerce Order - 2247
[trxn_result_code] =>
[status_id] => 1
[payment_processor_id] =>
)
)
)
```
Nice. So what's in the database?
```
SELECT id, total_amount, fee_amount, net_amount, tax_amount FROM `civicrm_contribution` WHERE id = '103';
+-----+--------------+------------+------------+------------+
| id | total_amount | fee_amount | net_amount | tax_amount |
+-----+--------------+------------+------------+------------+
| 103 | 79.84 | 0.00 | 79.84 | 4.84 |
+-----+--------------+------------+------------+------------+
SELECT id, entity_table, qty, unit_price, line_total, financial_type_id, tax_amount FROM `civicrm_line_item` WHERE contribution_id = '103';
+-----+---------------------+------+------------+------------+-------------------+------------+
| id | entity_table | qty | unit_price | line_total | financial_type_id | tax_amount |
+-----+---------------------+------+------------+------------+-------------------+------------+
| 107 | civicrm_participant | 1.00 | 25.00 | 25.00 | 5 | 4.84 |
| 108 | civicrm_membership | 1.00 | 50.00 | 50.00 | 2 | 0.00 |
+-----+---------------------+------+------------+------------+-------------------+------------+
SELECT * FROM `civicrm_financial_item` WHERE contact_id = '210';
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| id | created_date | transaction_date | contact_id | description | amount | currency | financial_account_id | status_id | entity_table | entity_id |
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| 104 | 2021-10-11 11:28:23 | 2021-10-11 11:28:21 | 210 | Solstice Ticket | 25.00 | USD | 15 | 1 | civicrm_line_item | 107 |
| 105 | 2021-10-11 11:28:23 | 2021-10-11 11:28:21 | 210 | Sales Tax | 4.84 | USD | 17 | 3 | civicrm_line_item | 107 |
| 106 | 2021-10-11 11:28:23 | 2021-10-11 11:28:21 | 210 | Student Membership | 50.00 | USD | 2 | 3 | civicrm_line_item | 108 |
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
SELECT id, from_financial_account_id, to_financial_account_id, trxn_date, total_amount, net_amount, is_payment, status_id, payment_instrument_id FROM `civicrm_financial_trxn` WHERE id > '100';
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| id | from_financial_account_id | to_financial_account_id | trxn_date | total_amount | net_amount | is_payment | status_id | payment_instrument_id |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| 101 | NULL | 7 | 2021-10-11 11:28:21 | 79.84 | 79.84 | 0 | 2 | 4 |
| 102 | 7 | 6 | 2021-10-11 11:30:58 | 79.84 | 79.84 | 1 | 1 | 4 |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
SELECT * FROM `civicrm_entity_financial_trxn` WHERE financial_trxn_id > '100';
+-----+------------------------+-----------+-------------------+--------+
| id | entity_table | entity_id | financial_trxn_id | amount |
+-----+------------------------+-----------+-------------------+--------+
| 203 | civicrm_contribution | 103 | 101 | 79.84 |
| 204 | civicrm_financial_item | 104 | 101 | 25.00 |
| 205 | civicrm_financial_item | 105 | 101 | 4.84 |
| 206 | civicrm_financial_item | 106 | 101 | 50.00 |
| 207 | civicrm_contribution | 103 | 102 | 79.84 | <-- Correct Entity ID.
| 208 | civicrm_financial_item | 104 | 102 | 25.00 | <-- Correct Entity ID.
| 209 | civicrm_financial_item | 105 | 102 | 4.84 | <-- Duplicated in 211?
| 210 | civicrm_financial_item | 104 | 102 | 50.00 | <-- Wrong Entity ID.
| 211 | civicrm_financial_item | 105 | 102 | 4.84 | <-- Duplicate of 209?
+-----+------------------------+-----------+-------------------+--------+
```
The Bookkeeping Report seems to reflect the odd assignment of Financial Items:
![civicrm-E25-M50-post](/uploads/2e550b6a4893a9d8960ec4b0a2bcff14/civicrm-E25-M50-post.png)
As you can see, it lists all of the `1100` entries as "Event Fee Taxable". The "Member Dues" item seems to have been switched to "Event Fee Taxable". There also seems to be a duplicate Tax Amount entry. This may be important below when the Financial Item amounts are identical.
## Non-taxable Membership ($50) followed by Taxable Participant ($25)
Sequence of Line Items is reversed:
![civicrm-M50-E25-order](/uploads/3fb49ce43318c51ba2da2f6cd8be3470/civicrm-M50-E25-order.png)
Order API params:
```
[params] => Array
(
[contact_id] => 210
[financial_type_id] => 1 <-- Non-taxable Financial Type
[payment_instrument_id] => 4
[trxn_id] => WooCommerce Order - 2247
[invoice_id] => 2247_woocommerce
[receive_date] => 2021-10-11 11:36:49
[contribution_status_id] => Pending
[is_pay_later] => 1
[total_amount] => 79.84 <-- Note: Total Amount has 2 decimal places
[source] => Shop
[campaign_id] => 3
[note] => Student Membership x 1, Solstice Ticket x 1
[line_items] => Array
(
[17] => Array
(
[params] => Array
(
[membership_type_id] => 2
[source] => Shop
[contact_id] => 210
[skipStatusCal] => 1
[status_id] => Pending
)
[line_item] => Array
(
[0] => Array
(
[price_field_id] => 1
[unit_price] => 50.00
[qty] => 1
[line_total] => 50.00
[tax_amount] => 0.00
[label] => Student Membership
[entity_table] => civicrm_membership
[financial_type_id] => 2 <-- Non-taxable Financial Type
[membership_type_id] => 2
)
)
)
[18] => Array
(
[params] => Array
(
[event_id] => 2
[contact_id] => 210
[role_id] => 1
[source] => Shop: Solstice Ticket
[status_id] => Pending from pay later
)
[line_item] => Array
(
[0] => Array
(
[price_field_id] => 1
[unit_price] => 25.00
[qty] => 1
[line_total] => 25.00
[tax_amount] => 4.84 <-- Note: Tax Amount has 2 decimal places
[label] => Solstice Ticket
[entity_table] => civicrm_participant
[financial_type_id] => 5 <-- Taxable Financial Type
)
)
)
)
)
```
API returns:
```
[result] => Array
(
[is_error] => 0
[version] => 3
[count] => 1
[id] => 103
[values] => Array
(
[103] => Array
(
[id] => 103
[contact_id] => 210
[financial_type_id] => 1
[contribution_page_id] =>
[payment_instrument_id] => 4
[receive_date] => 20211011113649
[non_deductible_amount] =>
[total_amount] => 79.844775 <-- Note: Total has 6 decimal places
[fee_amount] => 0
[net_amount] => 79.844775 <-- Note: Net Amount has 6 decimal places
[trxn_id] => WooCommerce Order - 2247
[invoice_id] => 2247_woocommerce
[invoice_number] => INV_103
[currency] => USD
[cancel_date] =>
[cancel_reason] =>
[receipt_date] =>
[thankyou_date] =>
[source] => Shop
[amount_level] =>
[contribution_recur_id] =>
[is_test] =>
[is_pay_later] => 1
[contribution_status_id] => 2
[address_id] =>
[check_number] =>
[campaign_id] => 3
[creditnote_id] =>
[tax_amount] => 4.84 <-- Note: Tax Amount has 2 decimal places
[revenue_recognition_date] =>
[is_template] =>
[contribution_type_id] => 1
[line_item] => Array
(
[0] => Array
(
[qty] => 1
[price_field_id] => 1
[price_field_value_id] => 1
[entity_table] => civicrm_membership
[unit_price] => 50.00
[label] => Student Membership
[line_total] => 50.00
[tax_amount] => 0
[financial_type_id] => 2
[membership_type_id] => 2
[entity_id] => 35
)
[1] => Array
(
[qty] => 1
[price_field_id] => 1
[price_field_value_id] => 1
[entity_table] => civicrm_participant
[unit_price] => 25.00
[label] => Solstice Ticket
[line_total] => 25.00
[tax_amount] => 4.844775 <-- Note: Tax Amount has 6 decimal places
[financial_type_id] => 5
[entity_id] => 56
)
)
)
)
)
```
Database looks good:
```
SELECT id, total_amount, fee_amount, net_amount, tax_amount FROM `civicrm_contribution` WHERE id = '103';
+-----+--------------+------------+------------+------------+
| id | total_amount | fee_amount | net_amount | tax_amount |
+-----+--------------+------------+------------+------------+
| 103 | 79.84 | 0.00 | 79.84 | 4.84 |
+-----+--------------+------------+------------+------------+
SELECT id, entity_table, qty, unit_price, line_total, financial_type_id, tax_amount FROM `civicrm_line_item` WHERE contribution_id = '103';
+-----+---------------------+------+------------+------------+-------------------+------------+
| id | entity_table | qty | unit_price | line_total | financial_type_id | tax_amount |
+-----+---------------------+------+------------+------------+-------------------+------------+
| 107 | civicrm_membership | 1.00 | 50.00 | 50.00 | 2 | 0.00 |
| 108 | civicrm_participant | 1.00 | 25.00 | 25.00 | 5 | 4.84 |
+-----+---------------------+------+------------+------------+-------------------+------------+
SELECT * FROM `civicrm_financial_item` WHERE contact_id = '210';
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| id | created_date | transaction_date | contact_id | description | amount | currency | financial_account_id | status_id | entity_table | entity_id |
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| 104 | 2021-10-11 11:36:51 | 2021-10-11 11:36:49 | 210 | Student Membership | 50.00 | USD | 2 | 3 | civicrm_line_item | 107 |
| 105 | 2021-10-11 11:36:51 | 2021-10-11 11:36:49 | 210 | Solstice Ticket | 25.00 | USD | 15 | 3 | civicrm_line_item | 108 |
| 106 | 2021-10-11 11:36:51 | 2021-10-11 11:36:49 | 210 | Sales Tax | 4.84 | USD | 17 | 3 | civicrm_line_item | 108 |
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
SELECT id, from_financial_account_id, to_financial_account_id, trxn_date, total_amount, net_amount, is_payment, status_id, payment_instrument_id FROM `civicrm_financial_trxn` WHERE id > '100';
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| id | from_financial_account_id | to_financial_account_id | trxn_date | total_amount | net_amount | is_payment | status_id | payment_instrument_id |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| 101 | NULL | 7 | 2021-10-11 11:36:49 | 79.84 | 79.84 | 0 | 2 | 4 |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
SELECT * FROM `civicrm_entity_financial_trxn` WHERE financial_trxn_id > '100';
+-----+------------------------+-----------+-------------------+--------+
| id | entity_table | entity_id | financial_trxn_id | amount |
+-----+------------------------+-----------+-------------------+--------+
| 203 | civicrm_contribution | 103 | 101 | 79.84 | <-- Correct Entity ID.
| 204 | civicrm_financial_item | 104 | 101 | 50.00 | <-- Correct Entity ID.
| 205 | civicrm_financial_item | 105 | 101 | 25.00 | <-- Correct Entity ID.
| 206 | civicrm_financial_item | 106 | 101 | 4.84 | <-- Correct Entity ID.
+-----+------------------------+-----------+-------------------+--------+
```
Bookkeeping confirms this:
![civicrm-M50-E25-pre](/uploads/87857b96e6fb0b8b2379c29e832da746/civicrm-M50-E25-pre.png)
Submit the `Payment.create` with:
```
[params] => Array
(
[contribution_id] => 103
[total_amount] => 79.84
[trxn_date] => 2021-10-11 11:38:59
[trxn_id] => WooCommerce Order - 2247
[payment_instrument_id] => 4
)
```
Logs again show:
```
[11-Oct-2021 10:39:00 UTC] PHP Notice: Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromEvent in /Users/interactivist/Sites/civicrm/civicrm.events.tec.latest/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Contribution.php on line 2724
[11-Oct-2021 10:39:01 UTC] PHP Notice: Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromEvent in /Users/interactivist/Sites/civicrm/civicrm.events.tec.latest/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Contribution.php on line 2724
```
API result:
```
[result] => Array
(
[is_error] => 0
[version] => 3
[count] => 1
[id] => 102
[values] => Array
(
[102] => Array
(
[id] => 102
[from_financial_account_id] => 7
[to_financial_account_id] => 6
[trxn_date] => 2021-10-11 11:38:59
[total_amount] => 79.84
[fee_amount] => 0.00
[net_amount] => 79.84
[currency] => USD
[is_payment] => 1
[trxn_id] => WooCommerce Order - 2247
[trxn_result_code] =>
[status_id] => 1
[payment_processor_id] =>
)
)
)
```
Database again shows the wrongly assigned Financial Items:
```
SELECT id, total_amount, fee_amount, net_amount, tax_amount FROM `civicrm_contribution` WHERE id = '103';
+-----+--------------+------------+------------+------------+
| id | total_amount | fee_amount | net_amount | tax_amount |
+-----+--------------+------------+------------+------------+
| 103 | 79.84 | 0.00 | 79.84 | 4.84 |
+-----+--------------+------------+------------+------------+
SELECT id, entity_table, qty, unit_price, line_total, financial_type_id, tax_amount FROM `civicrm_line_item` WHERE contribution_id = '103';
+-----+---------------------+------+------------+------------+-------------------+------------+
| id | entity_table | qty | unit_price | line_total | financial_type_id | tax_amount |
+-----+---------------------+------+------------+------------+-------------------+------------+
| 107 | civicrm_membership | 1.00 | 50.00 | 50.00 | 2 | 0.00 |
| 108 | civicrm_participant | 1.00 | 25.00 | 25.00 | 5 | 4.84 |
+-----+---------------------+------+------------+------------+-------------------+------------+
SELECT * FROM `civicrm_financial_item` WHERE contact_id = '210';
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| id | created_date | transaction_date | contact_id | description | amount | currency | financial_account_id | status_id | entity_table | entity_id |
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| 104 | 2021-10-11 11:36:51 | 2021-10-11 11:36:49 | 210 | Student Membership | 50.00 | USD | 2 | 1 | civicrm_line_item | 107 |
| 105 | 2021-10-11 11:36:51 | 2021-10-11 11:36:49 | 210 | Solstice Ticket | 25.00 | USD | 15 | 3 | civicrm_line_item | 108 |
| 106 | 2021-10-11 11:36:51 | 2021-10-11 11:36:49 | 210 | Sales Tax | 4.84 | USD | 17 | 3 | civicrm_line_item | 108 |
+-----+---------------------+---------------------+------------+--------------------+--------+----------+----------------------+-----------+-------------------+-----------+
SELECT id, from_financial_account_id, to_financial_account_id, trxn_date, total_amount, net_amount, is_payment, status_id, payment_instrument_id FROM `civicrm_financial_trxn` WHERE id > '100';
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| id | from_financial_account_id | to_financial_account_id | trxn_date | total_amount | net_amount | is_payment | status_id | payment_instrument_id |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| 101 | NULL | 7 | 2021-10-11 11:36:49 | 79.84 | 79.84 | 0 | 2 | 4 |
| 102 | 7 | 6 | 2021-10-11 11:38:59 | 79.84 | 79.84 | 1 | 1 | 4 |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
SELECT * FROM `civicrm_entity_financial_trxn` WHERE financial_trxn_id > '100';
+-----+------------------------+-----------+-------------------+--------+
| id | entity_table | entity_id | financial_trxn_id | amount |
+-----+------------------------+-----------+-------------------+--------+
| 203 | civicrm_contribution | 103 | 101 | 79.84 |
| 204 | civicrm_financial_item | 104 | 101 | 50.00 |
| 205 | civicrm_financial_item | 105 | 101 | 25.00 |
| 206 | civicrm_financial_item | 106 | 101 | 4.84 |
| 207 | civicrm_contribution | 103 | 102 | 79.84 | <-- Correct Entity ID.
| 208 | civicrm_financial_item | 104 | 102 | 50.00 | <-- Correct Entity ID.
| 209 | civicrm_financial_item | 106 | 102 | 4.84 | <-- Duplicated in 211?
| 210 | civicrm_financial_item | 104 | 102 | 25.00 | <-- Wrong Entity ID.
| 211 | civicrm_financial_item | 106 | 102 | 4.84 | <-- Duplicate of 209?
+-----+------------------------+-----------+-------------------+--------+
```
Again, there also seems to be a duplicate Tax Amount entry.
Bookkeeping Report confirmation of the odd assignment:
![civicrm-M50-E25-post](/uploads/7124d730e050f3f288de87ed29bfeb1b/civicrm-M50-E25-post.png)
The "Event Fee Taxable" item seems to have been switched to "Member Dues".
## Taxable Participant ($50) followed by Non-taxable Membership ($50)
Sequence as per first test:
![civicrm-E50-M50-order](/uploads/3cadc61cf6ecceeb570c7298ae0aafb5/civicrm-E50-M50-order.png)
Order API params:
```
[params] => Array
(
[contact_id] => 210
[financial_type_id] => 1 <-- Non-taxable Financial Type
[payment_instrument_id] => 4
[trxn_id] => WooCommerce Order - 2247
[invoice_id] => 2247_woocommerce
[receive_date] => 2021-10-11 12:01:02
[contribution_status_id] => Pending
[is_pay_later] => 1
[total_amount] => 109.69 <-- Note: Total Amount has 2 decimal places
[source] => Shop
[campaign_id] => 3
[note] => Fundraiser Dinner Ticket x 1, Student Membership x 1
[line_items] => Array
(
[17] => Array
(
[params] => Array
(
[event_id] => 1
[contact_id] => 210
[role_id] => 1
[source] => Shop: Fundraiser Dinner Ticket
[status_id] => Pending from pay later
)
[line_item] => Array
(
[0] => Array
(
[price_field_id] => 1
[unit_price] => 50.00
[qty] => 1
[line_total] => 50.00
[tax_amount] => 9.69 <-- Note: Tax Amount has 2 decimal places
[label] => Fundraiser Dinner Ticket
[entity_table] => civicrm_participant
[financial_type_id] => 5 <-- Taxable Financial Type
)
)
)
[18] => Array
(
[params] => Array
(
[membership_type_id] => 2
[source] => Shop
[contact_id] => 210
[skipStatusCal] => 1
[status_id] => Pending
)
[line_item] => Array
(
[0] => Array
(
[price_field_id] => 1
[unit_price] => 50.00
[qty] => 1
[line_total] => 50.00
[tax_amount] => 0.00
[label] => Student Membership
[entity_table] => civicrm_membership
[financial_type_id] => 2 <-- Non-taxable Financial Type
[membership_type_id] => 2
)
)
)
)
)
```
API return:
```
[result] => Array
(
[is_error] => 0
[version] => 3
[count] => 1
[id] => 103
[values] => Array
(
[103] => Array
(
[id] => 103
[contact_id] => 210
[financial_type_id] => 1
[contribution_page_id] =>
[payment_instrument_id] => 4
[receive_date] => 20211011120102
[non_deductible_amount] =>
[total_amount] => 109.68955 <-- Note: Total has 6 decimal places
[fee_amount] => 0
[net_amount] => 109.68955 <-- Note: Net Amount has 6 decimal places
[trxn_id] => WooCommerce Order - 2247
[invoice_id] => 2247_woocommerce
[invoice_number] => INV_103
[currency] => USD
[cancel_date] =>
[cancel_reason] =>
[receipt_date] =>
[thankyou_date] =>
[source] => Shop
[amount_level] =>
[contribution_recur_id] =>
[is_test] =>
[is_pay_later] => 1
[contribution_status_id] => 2
[address_id] =>
[check_number] =>
[campaign_id] => 3
[creditnote_id] =>
[tax_amount] => 9.69 <-- Note: Tax Amount has 2 decimal places
[revenue_recognition_date] =>
[is_template] =>
[contribution_type_id] => 1
[line_item] => Array
(
[0] => Array
(
[qty] => 1
[price_field_id] => 1
[price_field_value_id] => 1
[entity_table] => civicrm_participant
[unit_price] => 50.00
[label] => Fundraiser Dinner Ticket
[line_total] => 50.00
[tax_amount] => 9.68955 <-- Note: Tax Amount has 6 decimal places
[financial_type_id] => 5
[entity_id] => 56
)
[1] => Array
(
[qty] => 1
[price_field_id] => 1
[price_field_value_id] => 1
[entity_table] => civicrm_membership
[unit_price] => 50.00
[label] => Student Membership
[line_total] => 50.00
[tax_amount] => 0
[financial_type_id] => 2
[membership_type_id] => 2
[entity_id] => 35
)
)
)
)
)
```
Again, database looks good:
```
SELECT id, total_amount, fee_amount, net_amount, tax_amount FROM `civicrm_contribution` WHERE id = '103';
+-----+--------------+------------+------------+------------+
| id | total_amount | fee_amount | net_amount | tax_amount |
+-----+--------------+------------+------------+------------+
| 103 | 109.69 | 0.00 | 109.69 | 9.69 |
+-----+--------------+------------+------------+------------+
SELECT id, entity_table, qty, unit_price, line_total, financial_type_id, tax_amount FROM `civicrm_line_item` WHERE contribution_id = '103';
+-----+---------------------+------+------------+------------+-------------------+------------+
| id | entity_table | qty | unit_price | line_total | financial_type_id | tax_amount |
+-----+---------------------+------+------------+------------+-------------------+------------+
| 107 | civicrm_participant | 1.00 | 50.00 | 50.00 | 5 | 9.69 |
| 108 | civicrm_membership | 1.00 | 50.00 | 50.00 | 2 | 0.00 |
+-----+---------------------+------+------------+------------+-------------------+------------+
SELECT * FROM `civicrm_financial_item` WHERE contact_id = '210';
+-----+---------------------+---------------------+------------+--------------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| id | created_date | transaction_date | contact_id | description | amount | currency | financial_account_id | status_id | entity_table | entity_id |
+-----+---------------------+---------------------+------------+--------------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| 104 | 2021-10-11 12:01:04 | 2021-10-11 12:01:02 | 210 | Fundraiser Dinner Ticket | 50.00 | USD | 15 | 3 | civicrm_line_item | 107 |
| 105 | 2021-10-11 12:01:04 | 2021-10-11 12:01:02 | 210 | Sales Tax | 9.69 | USD | 17 | 3 | civicrm_line_item | 107 |
| 106 | 2021-10-11 12:01:04 | 2021-10-11 12:01:02 | 210 | Student Membership | 50.00 | USD | 2 | 3 | civicrm_line_item | 108 |
+-----+---------------------+---------------------+------------+--------------------------+--------+----------+----------------------+-----------+-------------------+-----------+
SELECT id, from_financial_account_id, to_financial_account_id, trxn_date, total_amount, net_amount, is_payment, status_id, payment_instrument_id FROM `civicrm_financial_trxn` WHERE id > '100';
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| id | from_financial_account_id | to_financial_account_id | trxn_date | total_amount | net_amount | is_payment | status_id | payment_instrument_id |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| 101 | NULL | 7 | 2021-10-11 12:01:02 | 109.69 | 109.69 | 0 | 2 | 4 |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
SELECT * FROM `civicrm_entity_financial_trxn` WHERE financial_trxn_id > '100';
+-----+------------------------+-----------+-------------------+--------+
| id | entity_table | entity_id | financial_trxn_id | amount |
+-----+------------------------+-----------+-------------------+--------+
| 203 | civicrm_contribution | 103 | 101 | 109.69 | <-- Correct Entity ID.
| 204 | civicrm_financial_item | 104 | 101 | 50.00 | <-- Correct Entity ID.
| 205 | civicrm_financial_item | 105 | 101 | 9.69 | <-- Correct Entity ID.
| 206 | civicrm_financial_item | 106 | 101 | 50.00 | <-- Correct Entity ID.
+-----+------------------------+-----------+-------------------+--------+
```
Bookkeeping Report confirms:
![civicrm-E50-M50-pre](/uploads/728d5845348f0f8bf289f5a7fbcb84f6/civicrm-E50-M50-pre.png)
This is where things get a bit weird(er).
Call `Payment.create` with:
```
[params] => Array
(
[contribution_id] => 103
[total_amount] => 109.69
[trxn_date] => 2021-10-11 12:04:49
[trxn_id] => WooCommerce Order - 2247
[payment_instrument_id] => 4
)
```
Logs (as usual) show:
```
[11-Oct-2021 11:04:50 UTC] PHP Notice: Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromEvent in /Users/interactivist/Sites/civicrm/civicrm.events.tec.latest/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Contribution.php on line 2724
[11-Oct-2021 11:04:51 UTC] PHP Notice: Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromEvent in /Users/interactivist/Sites/civicrm/civicrm.events.tec.latest/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Contribution.php on line 2724
```
API result is:
```
[result] => Array
(
[is_error] => 0
[version] => 3
[count] => 1
[id] => 102
[values] => Array
(
[102] => Array
(
[id] => 102
[from_financial_account_id] => 7
[to_financial_account_id] => 6
[trxn_date] => 2021-10-11 12:04:49
[total_amount] => 109.69
[fee_amount] => 0.00
[net_amount] => 109.69
[currency] => USD
[is_payment] => 1
[trxn_id] => WooCommerce Order - 2247
[trxn_result_code] =>
[status_id] => 1
[payment_processor_id] =>
)
)
)
```
Database has the same pattern of mis-assignment:
```
SELECT id, total_amount, fee_amount, net_amount, tax_amount FROM `civicrm_contribution` WHERE id = '103';
+-----+--------------+------------+------------+------------+
| id | total_amount | fee_amount | net_amount | tax_amount |
+-----+--------------+------------+------------+------------+
| 103 | 109.69 | 0.00 | 109.69 | 9.69 |
+-----+--------------+------------+------------+------------+
SELECT id, entity_table, qty, unit_price, line_total, financial_type_id, tax_amount FROM `civicrm_line_item` WHERE contribution_id = '103';
+-----+---------------------+------+------------+------------+-------------------+------------+
| id | entity_table | qty | unit_price | line_total | financial_type_id | tax_amount |
+-----+---------------------+------+------------+------------+-------------------+------------+
| 107 | civicrm_participant | 1.00 | 50.00 | 50.00 | 5 | 9.69 |
| 108 | civicrm_membership | 1.00 | 50.00 | 50.00 | 2 | 0.00 |
+-----+---------------------+------+------------+------------+-------------------+------------+
SELECT * FROM `civicrm_financial_item` WHERE contact_id = '210';
+-----+---------------------+---------------------+------------+--------------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| id | created_date | transaction_date | contact_id | description | amount | currency | financial_account_id | status_id | entity_table | entity_id |
+-----+---------------------+---------------------+------------+--------------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| 104 | 2021-10-11 12:01:04 | 2021-10-11 12:01:02 | 210 | Fundraiser Dinner Ticket | 50.00 | USD | 15 | 1 | civicrm_line_item | 107 |
| 105 | 2021-10-11 12:01:04 | 2021-10-11 12:01:02 | 210 | Sales Tax | 9.69 | USD | 17 | 3 | civicrm_line_item | 107 |
| 106 | 2021-10-11 12:01:04 | 2021-10-11 12:01:02 | 210 | Student Membership | 50.00 | USD | 2 | 3 | civicrm_line_item | 108 |
+-----+---------------------+---------------------+------------+--------------------------+--------+----------+----------------------+-----------+-------------------+-----------+
SELECT id, from_financial_account_id, to_financial_account_id, trxn_date, total_amount, net_amount, is_payment, status_id, payment_instrument_id FROM `civicrm_financial_trxn` WHERE id > '100';
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| id | from_financial_account_id | to_financial_account_id | trxn_date | total_amount | net_amount | is_payment | status_id | payment_instrument_id |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| 101 | NULL | 7 | 2021-10-11 12:01:02 | 109.69 | 109.69 | 0 | 2 | 4 |
| 102 | 7 | 6 | 2021-10-11 12:04:49 | 109.69 | 109.69 | 1 | 1 | 4 |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
SELECT * FROM `civicrm_entity_financial_trxn` WHERE financial_trxn_id > '100';
+-----+------------------------+-----------+-------------------+--------+
| id | entity_table | entity_id | financial_trxn_id | amount |
+-----+------------------------+-----------+-------------------+--------+
| 203 | civicrm_contribution | 103 | 101 | 109.69 |
| 204 | civicrm_financial_item | 104 | 101 | 50.00 |
| 205 | civicrm_financial_item | 105 | 101 | 9.69 |
| 206 | civicrm_financial_item | 106 | 101 | 50.00 |
| 207 | civicrm_contribution | 103 | 102 | 109.69 | <-- Correct Entity ID.
| 208 | civicrm_financial_item | 104 | 102 | 50.00 | <-- Correct Entity ID.
| 209 | civicrm_financial_item | 105 | 102 | 9.69 | <-- Duplicated in 211?
| 210 | civicrm_financial_item | 104 | 102 | 50.00 | <-- Wrong Entity ID.
| 211 | civicrm_financial_item | 105 | 102 | 9.69 | <-- Duplicate of 209?
+-----+------------------------+-----------+-------------------+--------+
```
However, this time the consequences of this combination of mismatch and duplicate entry gives a different result in the Bookkeeping Report:
![civicrm-E50-M50-post](/uploads/afb612896bb51e3db2afd7b67b176c9d/civicrm-E50-M50-post.png)
This time, it seems, there are only 5 Financial Items visible.
## Non-taxable Membership ($50) followed by Taxable Participant ($50)
![civicrm-M50-E50-order](/uploads/0f34a882ab9bfb12322254183951b89a/civicrm-M50-E50-order.png)
I'll skip the API calls for this one - if you want them, I'm happy to provide.
The `Order.create` process goes fine, but we're left with the following in the database:
```
+-----+--------------+------------+------------+------------+
| id | total_amount | fee_amount | net_amount | tax_amount |
+-----+--------------+------------+------------+------------+
| 103 | 109.69 | 0.00 | 109.69 | 9.69 |
+-----+--------------+------------+------------+------------+
SELECT id, entity_table, qty, unit_price, line_total, financial_type_id, tax_amount FROM `civicrm_line_item` WHERE contribution_id = '103';
+-----+---------------------+------+------------+------------+-------------------+------------+
| id | entity_table | qty | unit_price | line_total | financial_type_id | tax_amount |
+-----+---------------------+------+------------+------------+-------------------+------------+
| 107 | civicrm_membership | 1.00 | 50.00 | 50.00 | 2 | 0.00 |
| 108 | civicrm_participant | 1.00 | 50.00 | 50.00 | 5 | 9.69 |
+-----+---------------------+------+------------+------------+-------------------+------------+
SELECT * FROM `civicrm_financial_item` WHERE contact_id = '210';
+-----+---------------------+---------------------+------------+--------------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| id | created_date | transaction_date | contact_id | description | amount | currency | financial_account_id | status_id | entity_table | entity_id |
+-----+---------------------+---------------------+------------+--------------------------+--------+----------+----------------------+-----------+-------------------+-----------+
| 104 | 2021-10-11 12:21:33 | 2021-10-11 12:21:31 | 210 | Student Membership | 50.00 | USD | 2 | 1 | civicrm_line_item | 107 |
| 105 | 2021-10-11 12:21:33 | 2021-10-11 12:21:31 | 210 | Fundraiser Dinner Ticket | 50.00 | USD | 15 | 3 | civicrm_line_item | 108 |
| 106 | 2021-10-11 12:21:33 | 2021-10-11 12:21:31 | 210 | Sales Tax | 9.69 | USD | 17 | 3 | civicrm_line_item | 108 |
+-----+---------------------+---------------------+------------+--------------------------+--------+----------+----------------------+-----------+-------------------+-----------+
SELECT id, from_financial_account_id, to_financial_account_id, trxn_date, total_amount, net_amount, is_payment, status_id, payment_instrument_id FROM `civicrm_financial_trxn` WHERE id > '100';
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| id | from_financial_account_id | to_financial_account_id | trxn_date | total_amount | net_amount | is_payment | status_id | payment_instrument_id |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
| 101 | NULL | 7 | 2021-10-11 12:21:31 | 109.69 | 109.69 | 0 | 2 | 4 |
| 102 | 7 | 6 | 2021-10-11 12:25:19 | 109.69 | 109.69 | 1 | 1 | 4 |
+-----+---------------------------+-------------------------+---------------------+--------------+------------+------------+-----------+-----------------------+
SELECT * FROM `civicrm_entity_financial_trxn` WHERE financial_trxn_id > '100';
+-----+------------------------+-----------+-------------------+--------+
| id | entity_table | entity_id | financial_trxn_id | amount |
+-----+------------------------+-----------+-------------------+--------+
| 203 | civicrm_contribution | 103 | 101 | 109.69 |
| 204 | civicrm_financial_item | 104 | 101 | 50.00 |
| 205 | civicrm_financial_item | 105 | 101 | 50.00 |
| 206 | civicrm_financial_item | 106 | 101 | 9.69 |
| 207 | civicrm_contribution | 103 | 102 | 109.69 | <-- Correct Entity ID.
| 208 | civicrm_financial_item | 104 | 102 | 50.00 | <-- Correct Entity ID.
| 209 | civicrm_financial_item | 106 | 102 | 9.69 | <-- Duplicated in 211?
| 210 | civicrm_financial_item | 104 | 102 | 50.00 | <-- Wrong Entity ID.
| 211 | civicrm_financial_item | 106 | 102 | 9.69 | <-- Duplicate of 209?
+-----+------------------------+-----------+-------------------+--------+
```
The Bookkeeping Report shows the end result:
![civicrm-M50-E50-post](/uploads/4cefa4c34c1b02956fdc9ac3e62c8d4c/civicrm-M50-E50-post.png)
## Final thought
My best guess at the moment is that the combination of the mis-assigned `entity_id`s for the Financial Items _plus_ the effect of the extra entry in the `civicrm_entity_financial_trxn` table leads to the mix of 5 or 6 Items visible in the Bookkeeping Report.
If you've got to here, thanks for reading! Hope this helps fix what seemed to be mind-bending symptoms.https://lab.civicrm.org/dev/core/-/issues/2904Date fields are empty on memberships created with Order API Pending2021-10-14T06:25:33ZFrancis (Agileware)Date fields are empty on memberships created with Order API PendingSame problem as #2902.
Example Order.create API Call to reproduce:
```json
{
"contact_id": 202,
"total_amount": 100.00,
"financial_type_id": "Member Dues",
"contribution_status_id": "Pending",
"line_items" : [
{
"p...Same problem as #2902.
Example Order.create API Call to reproduce:
```json
{
"contact_id": 202,
"total_amount": 100.00,
"financial_type_id": "Member Dues",
"contribution_status_id": "Pending",
"line_items" : [
{
"params": {
"membership_type_id": "General",
"contact_id": 202,
"status_id": "Pending",
"skipStatusCal":1
},
"line_item": [
{
"entity_table":"civicrm_membership",
"price_field_id":"4",
"price_field_value_id":"7",
"qty":"1",
"unit_price":"100.00",
"line_total":"100.00"
}
]
}
]
}
```
Result on 5.39 is a pending Contribution and Membership with join_date, start_date, and end_date
Result on 5.40+ is a pending Contribution and Membership with *NO* join_date, start_date, or end_date
Including 5.43alpha with @eileen's [patch for #2902](https://github.com/civicrm/civicrm-core/pull/21784) applied
5.42+ works correctly *without* skipStatusCal set, however for backwards compatibility it should work with it also.5.42.1https://lab.civicrm.org/dev/drupal/-/issues/167Drupal service 'site.path' is deprecated in drupal 9 and will be removed in d...2022-06-11T19:26:30ZDaveDDrupal service 'site.path' is deprecated in drupal 9 and will be removed in drupal 10In https://github.com/civicrm/civicrm-core/blob/master/setup/src/Setup/DrupalUtil.php#L23 it calls `\Drupal::service('site.path');`.
But I'm wondering why that function getDrupalSiteDir() even exists and why it's not part of CRM_Utils_S...In https://github.com/civicrm/civicrm-core/blob/master/setup/src/Setup/DrupalUtil.php#L23 it calls `\Drupal::service('site.path');`.
But I'm wondering why that function getDrupalSiteDir() even exists and why it's not part of CRM_Utils_System_X. Maybe a timing issue since civi isn't installed yet at that point?
Anyway the relevant drupal issue is https://www.drupal.org/project/drupal/issues/3074585#comment-13220446.
Because of the (bleep) `@trigger_error` usage that drupal uses though it only comes up when running unit tests in drupal's own testing environment (until drupal 10 when it will hard fail, effectively nulling the effect of outputting a deprecation for most people).5.52.0https://lab.civicrm.org/dev/core/-/issues/2903Remove reference to CiviCRM forum in HTTP error message2021-10-16T20:48:04ZBradley TaylorRemove reference to CiviCRM forum in HTTP error messageIn the extension browser code there is the following error message:
> The CiviCRM public extensions directory at %1 could not be contacted - please check your webserver can make external HTTP requests or contact CiviCRM team on <a href=...In the extension browser code there is the following error message:
> The CiviCRM public extensions directory at %1 could not be contacted - please check your webserver can make external HTTP requests or contact CiviCRM team on <a href="http://forum.civicrm.org/">CiviCRM forum</a>
_https://github.com/civicrm/civicrm-core/blob/5db0bc3c1f54eaca4307f103a73bda596ae914d6/CRM/Extension/Browser.php#L246_
I recently saw this error message as a result of SSL issues on our server and given that the forum has been archived for several years, this is not a great experience. I suggest this a different action is suggested instead of the forums. Options that I can see:
1. Simply remove the "or contact CiviCRM team on CiviCRM forum"
2. Link to StackExhange (I think I'd be less keen on CiviCRM linking to externally-controlled domains)
3. Create a troubleshooting section on https://docs.civicrm.org/sysadmin/ and link to that
I could open a pull request but would like a steer from the core team on what wording should be used instead.https://lab.civicrm.org/dev/core/-/issues/2902Date fields are empty on memberships (created with pay later OR with an API c...2021-10-14T04:08:04ZjitendraDate fields are empty on memberships (created with pay later OR with an API call)To replicate -
- Create a contribution page with Membership + Pay later.
- Submit the page in live mode.
- Date fields (join, start & end) are empty for the membership.
Found while writing this test - https://github.com/colemanw/webfor...To replicate -
- Create a contribution page with Membership + Pay later.
- Submit the page in live mode.
- Date fields (join, start & end) are empty for the membership.
Found while writing this test - https://github.com/colemanw/webform_civicrm/pull/622
Probably related to https://github.com/civicrm/civicrm-core/pull/20759 merge where api/v3 code used to calculate the dates for all NEW memberships. https://github.com/civicrm/civicrm-core/pull/20759/files#diff-74f06c64d06b6b6c191ff86ab31113f7198e73c0a1f8c5487116e7b3faef26fcL95
Now, in BAO, the membership date calculation is avoided if `skipStatusCal` is set in the params. See https://github.com/civicrm/civicrm-core/blob/master/CRM/Member/BAO/Membership.php#L260
I think a test with below API should be able to replicate it in the test
```
$membership = civicrm_api3('Membership', 'create', [
'membership_type_id' => "General",
'contact_id' => 2,
'status_id' => "Current", (or Pending, New, etc)
'skipStatusCal' => 1,
]);
// Verify if membership dates are correctly set. Currently, they're not.
```
I've confirmed that CiviCRM v5.35 sets the date on the above API call, but >5.40 does NOT. Does that seem to be an unintentional change of behavior?
Not sure what should be the desired result - Does the API call need to set start_date separately when `skipStatusCal` is enabled?
OR
`skipStatusCal` should only skip the calculation of "status" on the membership and continue to set the dates as it used to do in previous versions?
fyi - @KarinG @eileen5.42.1https://lab.civicrm.org/dev/core/-/issues/2901Find Activities + Send Email task always says the contact is on hold or decea...2021-10-10T12:48:05ZDaveDFind Activities + Send Email task always says the contact is on hold or deceased etcEven if all the communication prefs are good and the email is valid it still gives the warning message and doesn't let you send.
1. Find Activities.
2. Select one that has a valid With Contact who isn't deceased and doesn't have email o...Even if all the communication prefs are good and the email is valid it still gives the warning message and doesn't let you send.
1. Find Activities.
2. Select one that has a valid With Contact who isn't deceased and doesn't have email on hold etc.
3. From the actions dropdown choose send email
4. Choose With Contact.
5. Warning comes up and redirects you back to search. `Selected contact(s) do not have a valid email address, or communication preferences specify DO NOT EMAIL, or they are deceased or Primary email address is On Hold.`
I'm putting regression but not 100% sure it is recent.5.43.0https://lab.civicrm.org/dev/core/-/issues/2900Getting a Contribution via API 3 does not return "tax_amount" and "financial_...2023-10-05T05:03:18ZhaystackGetting a Contribution via API 3 does not return "tax_amount" and "financial_type_id"Overview
----------------------------------------
When getting a Contribution via API 3, the result does not contain "tax_amount" or "financial_type_id".
Reproduction steps
----------------------------------------
Query for a Contributi...Overview
----------------------------------------
When getting a Contribution via API 3, the result does not contain "tax_amount" or "financial_type_id".
Reproduction steps
----------------------------------------
Query for a Contribution:
```php
$result = civicrm_api3('Contribution', 'get', [
'sequential' => 1,
'id' => 103,
]);
```
Current behaviour
----------------------------------------
The result of the query above is something like:
```
{
"is_error": 0,
"version": 3,
"count": 1,
"id": 103,
"values": [
{
"contact_id": "210",
"contribution_id": "103",
"currency": "USD",
"contribution_recur_id": "",
"contribution_status_id": "1",
"contribution_campaign_id": "2",
"payment_instrument_id": "4",
"receive_date": "2021-10-08 15:51:23",
"non_deductible_amount": "0.00",
"total_amount": "109.69",
"fee_amount": "0.00",
"net_amount": "109.69",
"trxn_id": "Order - 2247",
"invoice_id": "2247_woocommerce",
"invoice_number": "INV_103",
"contribution_cancel_date": "",
"cancel_reason": "",
"receipt_date": "2021-10-08 14:53:00",
"thankyou_date": "",
"contribution_source": "Shop",
"amount_level": "",
"is_test": "0",
"is_pay_later": "1",
"contribution_check_number": "",
"civicrm_value_donor_information_3_id": "6",
"contribution_recur_status": "Completed",
"payment_instrument": "Check",
"contribution_status": "Completed",
"check_number": "",
"instrument_id": "4",
"cancel_date": "",
"id": "103"
}
]
}
```
Expected behaviour
----------------------------------------
I would expect "tax_amount" and "financial_type_id" to be present in the set of Contribution data.
It is, of course, possible to retrieve the "tax_amount" and/or "financial_type_id" by specifying them as the returned params - for example:
```php
$result = civicrm_api3('Contribution', 'get', [
'sequential' => 1,
'return' => ["financial_type_id", "tax_amount"],
'id' => 103,
]);
```
Returns:
```
{
"is_error": 0,
"version": 3,
"count": 1,
"id": 103,
"values": [
{
"contact_id": "210",
"contribution_id": "103",
"financial_type_id": "4",
"tax_amount": "9.69",
"id": "103",
"contribution_type_id": "4"
}
]
}
```
But this means an extra query is required to construct the full set of data for a Contribution.
Environment information
----------------------------------------
Issue exists CiviCRM 5.42.0, though it's probably always been like this.https://lab.civicrm.org/dev/core/-/issues/2899DB error on updating multiple cases from the search form2022-09-20T10:50:03ZjitendraDB error on updating multiple cases from the search formTo replicate -
1. Navigate to https://dmaster.demo.civicrm.org/civicrm/case/search?reset=1
2. Search for cases. Select all results (ts_all radio button) => Update multiple cases action
![image](/uploads/fcbb716228f064c5cde2f8231a534e15...To replicate -
1. Navigate to https://dmaster.demo.civicrm.org/civicrm/case/search?reset=1
2. Search for cases. Select all results (ts_all radio button) => Update multiple cases action
![image](/uploads/fcbb716228f064c5cde2f8231a534e15/image.png)
3. Select Profile on the next step and hit Continue;
![image](/uploads/cb5fb171efd98f5014e5c822f367f717/image.png)https://lab.civicrm.org/dev/core/-/issues/2898URL Tokens - CiviMail BAO and FlexMailer disagree over duplicate `http://`2022-12-19T22:45:31ZtottenURL Tokens - CiviMail BAO and FlexMailer disagree over duplicate `http://`Overview
--------
CiviMail BAO and Flexmailer provide two mechanisms to rendering/delivering mail-blasts. To phase out BAO-rendering, we should eventually migrate existing sites to Flexmailer. However, small discrepancies between them c...Overview
--------
CiviMail BAO and Flexmailer provide two mechanisms to rendering/delivering mail-blasts. To phase out BAO-rendering, we should eventually migrate existing sites to Flexmailer. However, small discrepancies between them can be an obstacle. This issue asks how to deal with a discrepancy when handling certain URL tokens.
(The issue is an off-shoot from the review discussion on https://github.com/civicrm/civicrm-core/pull/21522. However, they are somewhat distinct as 21522 applies to new-sites and this problem is more pressing on upgrade-sites.)
Background
-----------
Suppose you have an email token which generates a URL (eg `{action.forward}` or `{action.unsubscribeUrl}`) . The most correct way to use this token in an HTML-email is to place it in a hyperlink (`<a href="{action.forward}>`).
However, if you use CKEditor to compose a message, the hyperlink dialog strongly encourages you to put `http://` at the front of any hyperlink. Thus, you can organically produce expressions like `<a href="http://{action.forward}">`.
![CkeditorHttpToken](/uploads/e2d9bbf4ab6ba12a6cdcd936955277a9/CkeditorHttpToken.mov)
CiviMail BAO has a feature which mitigates this - in effect, both notations give the same output. However, Flexmailer (TokenProcessor) does not have a similar mitigation. Thus:
| HTML Email Expression | BAO Output | Flexmailer Output |
| -- | -- | -- |
| `<a href="{action.forward}>` | `<a href="https://example.com/civicrm/mailing/forward?...` | `<a href="https://example.com/civicrm/mailing/forward?...` |
| `<a href="http://{action.forward}>` | `<a href="https://example.com/civicrm/mailing/forward?...` | `<a href="http://https://example.com/civicrm/mailing/forward?...` |
Note the duplicate URL scheme (`http://http://`).
Scenarios: Good
---------
There are several scenarios wherein this discrepancy does not matter:
* You use CKEditor + BAO-renderer. (*The BAO renderer mitigates extraneous `http://`.*)
* You use Mosaico + Flexmailer. (*Mosaico's UI doesn't create extraneous `http://`.*)
(I suspect these two cohorts are the largest.)
Scenarios: Bad
---------
The potential for difficulty arises when mixing CKEditor with Flexmailer -- you take some HTML that was composed with CKEditor, run it through Flexmailer, and now you have invalid URLs with `http://https://`.
If we flip over more existing sites to Flexmailer, then it is foreseeable that more sites will be in this mixed scenario.
There's a secondary consideration in who may experience problems -- templates. Most users are not in the habit of typing `{action.forward}` or `{action.unsubscribeUrl}` regularly. Anecdotally, the typical practice is to put these kinds of tokens into a template, eg
* (A) Add a "User-Defined Template" (edited w/CKEditor in web; stored in `civicrm_msg_template`), or...
* (B) Reuse/copy a previous "Mailing" (edited w/CKEditor in web; stored in `civicrm_mailing`), or...
* (C) Configure default header/footer (no CKEditor; stored in `civicrm_mailing_component`)
Practical recap: today, if you enable Flexmailer on a site that uses CKEditor for mailings, then either:
* Your mailings and templates will have broken links -- because they use `<a href="http://{action.unsubscribeUrl}">`.
* This seems more likely if you use (A)/(B) - because the web UI uses CKEditor.
* Your mailings and templates will be cleanly interoperable -- because they use `<a href="{action.unsubscribeUrl}">`.
* This seems more likely if you use (C) header/footer because the web UI uses textarea.
Approaches
----------
1. Add a mitigation to Flexmailer or TokenProcessor which removes extraneous schema during the rendering phase.
* _Strength_: Best interoperability
* _Criticism_: Adds quirky bits to rendering.
* _Variations_: Patch Flexmailer vs patch TokenProcessor.
* _Variations_: Apply cleanup before rendering (`http://{action.*}` => `{action.*}`) or after rendering (`http://https?://` => `https?://`).
2. Add an upgrade-task to remove extra `http://` in front of tokens.
* _Strength_: No quirky bits in rendering.
* _Criticism_: CKEditor is still there. Can only upgrade core tables. Rewrites history (`civicrm_mailing.body_html` of past mailings).
3. Do nothing - Downstream users should manually convert their mailings/templates.
* _Strength_: Look, ma, no hands!
* _Criticism_: We cannot measure how many users will be impacted by break. For users with a "Reuse/Copy" workflow, they cannot fix historical mailings in UI.5.57.0https://lab.civicrm.org/dev/core/-/issues/2897Send an email activity is weird -possible unreleased regression in 5.43/master2021-10-10T01:01:55ZeileenSend an email activity is weird -possible unreleased regression in 5.43/masterhttps://lab.civicrm.org/dev/core/-/issues/2896Add some tests for case email using new url2021-10-18T14:19:42ZDaveDAdd some tests for case email using new urlThe url has changed to get to the form but I don't think there's any tests on the new url.
v5.43The url has changed to get to the form but I don't think there's any tests on the new url.
v5.43https://lab.civicrm.org/dev/core/-/issues/2895Emails can't resolve tokens for non-contact components for recipients added t...2021-10-13T20:23:45ZDaveDEmails can't resolve tokens for non-contact components for recipients added to the list after email form was openedhttps://github.com/civicrm/civicrm-core/pull/21745#discussion_r724286717
Affects 5.43 only.
e.g.
1. Create a case email, e.g. clicking on the mail icon in the roles section.
1. Add a recipient to the recipient field.
1. In the body pu...https://github.com/civicrm/civicrm-core/pull/21745#discussion_r724286717
Affects 5.43 only.
e.g.
1. Create a case email, e.g. clicking on the mail icon in the roles section.
1. Add a recipient to the recipient field.
1. In the body put something like `Dear {contact.display_name} Case {case.id}`
1. The email sent to the original recipient will resolve case.id. The added recipient will have it blank.
See below this also applies to other non-contact components, e.g. event tokens.5.43.0https://lab.civicrm.org/dev/core/-/issues/2894Activity redirects to search instead of view2023-10-18T05:03:24Zqwerty1234Activity redirects to search instead of viewSome activities after cliking `view` button redirect to search form instead od view. It happens if activity type is not defined in hardcoced list in `CRM/Activity/Selector/Activity.php` file in method `actionLinks`. Such action type is m...Some activities after cliking `view` button redirect to search form instead od view. It happens if activity type is not defined in hardcoced list in `CRM/Activity/Selector/Activity.php` file in method `actionLinks`. Such action type is managed by `default` case.