From: Eileen McNaughton Date: Fri, 1 Dec 2023 06:11:49 +0000 (+1300) Subject: Fix online membership receipt to be form-independent X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=491c5db1c7b53f59c2ad641f1b0ba60e34b8d87e;p=civicrm-core.git Fix online membership receipt to be form-independent --- diff --git a/CRM/Financial/BAO/Order.php b/CRM/Financial/BAO/Order.php index bd934a62fb..fc2d59e61c 100644 --- a/CRM/Financial/BAO/Order.php +++ b/CRM/Financial/BAO/Order.php @@ -1241,6 +1241,8 @@ class CRM_Financial_BAO_Order { } else { $lineItem['line_total'] = $this->getOverrideTotalAmount(); + $lineItem['tax_amount'] = 0.0; + $lineItem['line_total_inclusive'] = $lineItem['line_total']; } if (!empty($lineItem['qty'])) { $lineItem['unit_price'] = $lineItem['line_total'] / $lineItem['qty']; diff --git a/CRM/Member/WorkflowMessage/Membership/Membership.php b/CRM/Member/WorkflowMessage/Membership/Membership.php index f12c594bcf..1169ea498f 100644 --- a/CRM/Member/WorkflowMessage/Membership/Membership.php +++ b/CRM/Member/WorkflowMessage/Membership/Membership.php @@ -106,7 +106,6 @@ class CRM_Member_WorkflowMessage_Membership_Membership extends WorkflowMessageEx 'contact_id' => 100, 'financial_type_id' => $example['membership_type']['financial_type_id'], 'receive_date' => '2021-07-23 15:39:20', - 'total_amount' => $example['membership_type']['minimum_amount'], 'fee_amount' => .99, 'net_amount' => $example['membership_type']['minimum_amount'] - .99, 'currency' => $example['currency'], @@ -131,8 +130,14 @@ class CRM_Member_WorkflowMessage_Membership_Membership extends WorkflowMessageEx $mockOrder->setTemplateContributionID(50); if (empty($example['is_show_line_items'])) { - $mockOrder->setPriceSetToDefault('membership'); - $mockOrder->setOverrideTotalAmount($example['membership_type']['minimum_fee']); + if (empty($example['contribution_page_id'])) { + $mockOrder->setOverrideTotalAmount($example['membership_type']['minimum_fee']); + $mockOrder->setPriceSetToDefault('membership'); + } + else { + $priceSet = $this->getPriceSet()[$example['price_set_id']]; + $mockOrder->setPriceSetID($priceSet['id']); + } $mockOrder->setDefaultFinancialTypeID($example['membership_type']['financial_type_id']); } else { @@ -144,15 +149,14 @@ class CRM_Member_WorkflowMessage_Membership_Membership extends WorkflowMessageEx } foreach (PriceField::get()->addWhere('price_set_id', '=', $mockOrder->getPriceSetID())->execute() as $index => $priceField) { $priceFieldValue = PriceFieldValue::get()->addWhere('price_field_id', '=', $priceField['id'])->execute()->first(); - if (empty($example['is_show_line_items'])) { - $priceFieldValue['amount'] = $contribution['total_amount']; - $priceFieldValue['financial_type_id'] = $contribution['financial_type_id']; - } $this->setLineItem($mockOrder, $priceField, $priceFieldValue, $index, $membership); } $contribution['total_amount'] = $mockOrder->getTotalAmount(); $contribution['tax_amount'] = $mockOrder->getTotalTaxAmount() ? round($mockOrder->getTotalTaxAmount(), 2) : 0; + $contribution['amount_level'] = $mockOrder->getAmountLevel(); + $contribution['address_id.name'] = 'Barbara Mary Jones'; + $contribution['address_id.display'] = "123 Main Street\nMega City"; $messageTemplate->setContribution($contribution); $messageTemplate->setOrder($mockOrder); $messageTemplate->setContribution($contribution); @@ -204,6 +208,7 @@ class CRM_Member_WorkflowMessage_Membership_Membership extends WorkflowMessageEx 'label' => $priceFieldValue['label'], 'financial_type_id' => $priceFieldValue['financial_type_id'], 'non_deductible_amount' => $priceFieldValue['non_deductible_amount'], + 'membership_type_id' => $priceFieldValue['membership_type_id'], ]; if (!empty($priceFieldValue['membership_type_id'])) { $lineItem['membership'] = ['start_date' => $membership['start_date'], 'end_date' => $membership['end_date']]; diff --git a/xml/templates/message_templates/membership_online_receipt_html.tpl b/xml/templates/message_templates/membership_online_receipt_html.tpl index 9375ed21ef..3f60042446 100644 --- a/xml/templates/message_templates/membership_online_receipt_html.tpl +++ b/xml/templates/message_templates/membership_online_receipt_html.tpl @@ -43,7 +43,7 @@ {ts}Membership Type{/ts} - {ts}{membership.membership_type_id:name}{/ts} + {ts}{membership.membership_type_id:label}{/ts} {if {membership.start_date|boolean}} @@ -67,38 +67,26 @@ {/if} {/if} - {if $amount} + {if {contribution.total_amount|boolean}} {ts}Membership Fee{/ts} {if !$isShowLineItems && {contribution.total_amount|boolean}} - - - {ts 1=$membership_name}%1 Membership{/ts} - - - {$membership_amount|crmMoney} - - - {if $amount && !$is_separate_payment} - - - {ts}Contribution Amount{/ts} - - - {$amount|crmMoney} - - + {foreach from=$lineItems item=line} - {ts}Total{/ts} + {if $line.membership_type_id} + {ts 1="{membership.membership_type_id:label}"}%1 Membership{/ts} + {else} + {ts}Contribution Amount{/ts} + {/if} - {contribution.total_amount} + {$line.line_total_inclusive|crmMoney:'{contribution.currency}'} - {/if} + {/foreach} {elseif $isShowLineItems} @@ -174,7 +162,7 @@ {ts}Amount{/ts} - {contribution.total_amount} {if isset($amount_level)} - {$amount_level}{/if} + {contribution.total_amount} {/if} @@ -190,28 +178,18 @@ {/if} - {if !empty($trxn_id)} + {if {contribution.trxn_id|boolean}} {ts}Transaction #{/ts} - {$trxn_id} - - - {/if} - - {if !empty($membership_trx_id)} - - - {ts}Membership Transaction #{/ts} - - - {$membership_trx_id} + {contribution.trxn_id} {/if} - {if !empty($is_recur)} + + {if {contribution.contribution_recur_id|boolean}} {ts}This membership will be renewed automatically.{/ts} @@ -301,7 +279,7 @@ {/foreach} {/if} - {if !empty($billingName)} + {if {contribution.address_id.display|boolean}} {ts}Billing Name and Address{/ts} @@ -309,12 +287,12 @@ - {$billingName}
- {$address|nl2br}
- {$email} + {contribution.address_id.name}
+ {contribution.address_id.display} - {elseif !empty($email)} + {/if} + {if {contact.email_primary.email|boolean}} {ts}Registered Email{/ts} @@ -322,7 +300,7 @@ - {$email} + {contact.email_primary.email} {/if}