'modelProps' => [
'contributionId' => $this->getCurrentRowContributionID(),
'contactId' => $form->_receiptContactId,
- 'membershipId' => $this->getCurrentRowMembershipID(),
+ 'membershipID' => $this->getCurrentRowMembershipID(),
],
]
);
<?php
+use Civi\Api4\Membership;
+
/**
* @method array getContribution()
* @method ?int getContributionID()
/**
* @var int
- * @scope tokenContext as contributionId
+ * @scope tokenContext as contributionId, tplParams as contributionID
*/
public $contributionId;
* Get bool for whether a line item breakdown be displayed.
*
* @return bool
+ * @noinspection PhpUnused
*/
public function getIsShowLineItems(): bool {
if (isset($this->isShowLineItems)) {
* Get the line items.
*
* @return array
+ * @throws \CRM_Core_Exception
*/
public function getLineItems(): array {
if (isset($this->lineItems)) {
// always have the contribution ID available as well as migrated ones.
return [];
}
- return $order->getLineItems();
+ $lineItems = $order->getLineItems();
+ foreach ($lineItems as $index => $lineItem) {
+ if ($lineItem['entity_table'] === 'civicrm_membership' && !empty($lineItem['entity_id'])) {
+ // Add in some per line membership details. This could also go in the Order class?
+ $lineItems[$index]['membership'] = Membership::get(FALSE)->addWhere('id', '=', $lineItem['entity_id'])->addSelect('start_date', 'end_date')->execute()->first();
+ }
+ }
+ return $lineItems;
}
/**
* Get the line items.
*
* @return array
+ * @throws \CRM_Core_Exception
+ *
+ * @noinspection PhpUnused
*/
public function getTaxRateBreakdown(): array {
if (isset($this->taxRateBreakdown)) {
* and tax are a package.
*
* @param array $export
+ *
+ * @noinspection PhpUnused
*/
protected function exportExtraTplParams(array &$export): void {
$export['isShowTax'] = (bool) Civi::settings()->get('invoicing');
'receiptText' => $this->getSubmittedValue('receipt_text'),
'contributionId' => $formValues['contribution_id'],
'contactId' => $this->_receiptContactId,
- 'membershipId' => $this->getMembershipID(),
+ 'membershipID' => $this->getMembershipID(),
],
]
);
'modelProps' => [
'receiptText' => $this->getSubmittedValue('receipt_text'),
'contactId' => $this->_receiptContactId,
- 'contributionID' => $this->getContributionID(),
+ 'contributionId' => $this->getContributionID(),
'membershipID' => $this->_membershipId,
],
]
--- /dev/null
+<?php
+
+use Civi\Api4\MembershipType;
+use Civi\Api4\PriceField;
+use Civi\Api4\PriceFieldValue;
+use Civi\Api4\PriceSet;
+use Civi\Api4\WorkflowMessage;
+use Civi\Test;
+use Civi\WorkflowMessage\GenericWorkflowMessage;
+use Civi\WorkflowMessage\WorkflowMessageExample;
+
+/**
+ * Examples for membership templates.
+ *
+ * @noinspection PhpUnused
+ */
+class CRM_Member_WorkflowMessage_Membership_Membership extends WorkflowMessageExample {
+
+ /**
+ * Get the examples this class is able to deliver.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function getExamples(): iterable {
+ if (!CRM_Core_Component::isEnabled('CiviMember')) {
+ return;
+ }
+ $membershipType = MembershipType::get(FALSE)->execute()->first();
+ if (empty($membershipType)) {
+ return;
+ }
+ $workflows = ['membership_online_receipt', 'membership_offline_receipt'];
+ $defaultCurrency = \Civi::settings()->get('defaultCurrency');
+ $priceSets = $this->getPriceSet();
+
+ foreach ($workflows as $workflow) {
+ foreach ($priceSets as $priceSet) {
+ yield [
+ 'name' => 'workflow/' . $workflow . '/' . strtolower($membershipType['name']) . '_' . strtolower($priceSet['name']) . '_' . strtolower($defaultCurrency),
+ 'title' => $priceSet['title'] . ' - ' . $membershipType['name'] . ' : ' . $defaultCurrency,
+ 'tags' => ['preview'],
+ 'workflow' => $workflow,
+ 'membership_type' => $membershipType,
+ 'currency' => $defaultCurrency,
+ 'price_set_id' => $priceSet['id'],
+ 'is_show_line_items' => !$priceSets['is_quick_config'],
+ ];
+ }
+ }
+ }
+
+ /**
+ * Build an example to use when rendering the workflow.
+ *
+ * @param array $example
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function build(array &$example): void {
+ $workFlow = WorkflowMessage::get(TRUE)->addWhere('name', '=', $example['workflow'])->execute()->first();
+ $this->setWorkflowName($workFlow['name']);
+ $messageTemplate = new $workFlow['class']();
+ $this->addExampleData($messageTemplate, $example);
+ $example['data'] = $this->toArray($messageTemplate);
+ }
+
+ /**
+ * Add relevant example data.
+ *
+ * @param \CRM_Member_WorkflowMessage_MembershipOfflineReceipt|\CRM_Member_WorkflowMessage_MembershipOnlineReceipt $messageTemplate
+ * @param array $example
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \Civi\API\Exception\UnauthorizedException
+ */
+ private function addExampleData(GenericWorkflowMessage $messageTemplate, array $example): void {
+ $messageTemplate->setContact(Test::example('entity/Contact/Barb'));
+
+ $membership = [
+ 'membership_type_id' => $example['membership_type']['id'],
+ 'membership_type_id:name' => $example['membership_type']['name'],
+ 'membership_type_id:label' => $example['membership_type']['name'],
+ 'status_id:name' => 'Current',
+ 'start_date' => date('Y-m-05', strtotime('-1 month')),
+ // Ideally we would leave blank for lifetime & maybe calculate more meaningfully.
+ 'end_date' => date('Y-m-05', strtotime('+ 11 months')),
+ ];
+ $messageTemplate->setMembership($membership);
+
+ $contribution = [
+ 'id' => 50,
+ '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'],
+ 'trxn_id' => 123,
+ 'invoice_id' => 'I-123',
+ 'contribution_status_id:name' => 'Completed',
+ 'contribution_status_id' => \CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'),
+ ];
+ $contribution['contribution_status_id:label'] = \CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contribution['contribution_status_id']);
+
+ if (isset($example['contribution_params'])) {
+ $contribution = array_merge($contribution, $example['contribution_params']);
+ }
+
+ $mockOrder = new CRM_Financial_BAO_Order();
+ $mockOrder->setTemplateContributionID(50);
+
+ if (empty($example['is_show_line_items'])) {
+ $mockOrder->setPriceSetToDefault('membership');
+ $mockOrder->setOverrideTotalAmount($example['membership_type']['minimum_fee']);
+ $mockOrder->setDefaultFinancialTypeID($example['membership_type']['financial_type_id']);
+ }
+ else {
+ $priceSet = $this->getPriceSet()[$example['price_set_id']];
+ $mockOrder->setPriceSetID($priceSet['id']);
+ if ($priceSet['financial_type_id']) {
+ $mockOrder->setDefaultFinancialTypeID($priceSet['financial_type_id']);
+ }
+ }
+ 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;
+ $messageTemplate->setContribution($contribution);
+ $messageTemplate->setOrder($mockOrder);
+ $messageTemplate->setContribution($contribution);
+ }
+
+ /**
+ * Get a non-quick-config price set.
+ *
+ * @return array|null
+ * @throws \CRM_Core_Exception
+ */
+ private function getPriceSet(): ?array {
+ // Permission check defaults to true - likely implicitly OK but may need to be false.
+ return (array) PriceSet::get()
+ ->addWhere('extends', '=', CRM_Core_Component::getComponentID('CiviMember'))
+ ->addOrderBy('is_quick_config', 'DESC')
+ ->execute()->indexBy('id');
+ }
+
+ /**
+ * @param \CRM_Financial_BAO_Order $mockOrder
+ * @param $priceField
+ * @param array|null $priceFieldValue
+ * @param $index
+ * @param $membership
+ *
+ * @throws \CRM_Core_Exception
+ */
+ private function setLineItem(CRM_Financial_BAO_Order $mockOrder, $priceField, ?array $priceFieldValue, $index, $membership): void {
+ $lineItem = [
+ 'price_field_id' => $priceField['id'],
+ 'price_field_id.label' => $priceField['label'],
+ 'price_field_value_id' => $priceFieldValue['id'],
+ 'qty' => $priceField['is_enter_qty'] ? 2 : 1,
+ 'unit_price' => $priceFieldValue['amount'],
+ 'line_total' => $priceField['is_enter_qty'] ? ($priceFieldValue['amount'] * 2) : $priceFieldValue['amount'],
+ 'label' => $priceFieldValue['label'],
+ 'financial_type_id' => $priceFieldValue['financial_type_id'],
+ 'non_deductible_amount' => $priceFieldValue['non_deductible_amount'],
+ ];
+ if (!empty($priceFieldValue['membership_type_id'])) {
+ $lineItem['membership'] = ['start_date' => $membership['start_date'], 'end_date' => $membership['end_date']];
+ }
+ $mockOrder->setLineItem($lineItem, $index);
+ }
+
+}
*/
class CRM_Member_WorkflowMessage_MembershipOfflineReceipt extends GenericWorkflowMessage {
use CRM_Member_WorkflowMessage_MembershipTrait;
+ use CRM_Contribute_WorkflowMessage_ContributionTrait;
public const WORKFLOW = 'membership_offline_receipt';
/**
*/
class CRM_Member_WorkflowMessage_MembershipOnlineReceipt extends GenericWorkflowMessage {
use CRM_Member_WorkflowMessage_MembershipTrait;
+ use CRM_Contribute_WorkflowMessage_ContributionTrait;
public const WORKFLOW = 'membership_online_receipt';
}
* @method array getMembership()
* @method ?int getMembershipID()
* @method $this setMembershipID(?int $membershipID)
- * @method ?int getContributionID()
- * @method $this setContributionID(?int $membershipID)
*/
trait CRM_Member_WorkflowMessage_MembershipTrait {
/**
*/
protected $membershipID;
- /**
- * Contribution ID.
- *
- * @var int
- *
- * @scope tokenContext as contributionId, tplParams as contributionID
- */
- protected $contributionID;
-
/**
* Set membership object.
*
'phone' => '393-7924',
'email_id' => '7',
'email' => 'barb@testing.net',
- 'on_hold' => '0',
- 'im_id' => NULL,
- 'provider_id' => NULL,
- 'im' => NULL,
'worldregion_id' => NULL,
'world_region' => NULL,
- 'languages' => NULL,
- 'individual_prefix' => NULL,
- 'individual_suffix' => NULL,
- 'communication_style' => NULL,
- 'gender' => 'Female',
- 'state_province_name' => NULL,
- 'state_province' => NULL,
- 'country' => NULL,
- 'email_greeting_id' => 1,
- 'email_greeting_custom' => NULL,
'email_greeting_display' => 'Dear Barb',
- 'postal_greeting_id' => 1,
- 'postal_greeting_custom' => NULL,
'postal_greeting_display' => 'Dear Barb',
];
}
*/
use Civi\Api4\FinancialType;
+use Civi\Api4\Membership;
use Civi\Api4\MembershipType;
use Civi\Api4\PriceFieldValue;
* @return string[]
*/
private function getExpectedEmailStrings(): array {
+ $membership = Membership::get()->execute()->first();
return [
+ '<td> ' . CRM_Utils_Date::formatDateOnlyLong($membership['start_date']) . ' </td> <td> ' . CRM_Utils_Date::formatDateOnlyLong($membership['end_date']) . ' </td>',
'<table id="crm-membership_receipt"',
+ 'AnnualFixed',
'Membership Fee',
'Financial Type',
'Member Dues </td>',
- '<tr> <td colspan="2" style="padding: 4px; border-bottom: 1px solid #999;"> <table> <tr> <th>Item</th> <th>Fee</th> <th>SubTotal</th> <th>Tax Rate</th> <th>Tax Amount</th> <th>Total</th> <th>Membership Start Date</th> <th>Membership Expiration Date</th> </tr> <tr> <td> Membership Amount - AnnualFixed </td>',
+ '<tr> <td colspan="2" style="padding: 4px; border-bottom: 1px solid #999;"> <table> <tr> <th>Item</th> <th>Fee</th> <th>SubTotal</th> <th>Tax Rate</th> <th>Tax Amount</th> <th>Total</th> <th>Membership Start Date</th> <th>Membership Expiration Date</th> </tr> <tr> <td>Membership Amount - AnnualFixed</td>',
'<td> $50.00 </td> <td> $50.00 </td> <td> 10.00% </td> <td> $5.00 </td> <td> $55.00 </td> <td>',
'Amount Before Tax: </td>',
'<td style="padding: 4px; border-bottom: 1px solid #999;"> $50.00 </td>',
- '<td> Sales Tax 10.00%</td> <td> $5.00</td>',
+ '<td style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"> Sales Tax 10.00%</td> <td style="padding: 4px; border-bottom: 1px solid #999;">$5.00</td>',
'Total Tax Amount </td> <td style="padding: 4px; border-bottom: 1px solid #999;"> $5.00 </td>',
'Amount </td> <td style="padding: 4px; border-bottom: 1px solid #999;"> $55.00 </td>',
'Paid By </td> <td style="padding: 4px; border-bottom: 1px solid #999;"> Check </td>',
<tr>
<td>
<table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
- {if empty($lineItem)}
+ {if !$isShowLineItems}
<tr>
<th {$headerStyle}>
{ts}Membership Information{/ts}
{ts}Membership Type{/ts}
</td>
<td {$valueStyle}>
- {$membership_name}
+ {membership.membership_type_id:name}
</td>
</tr>
{/if}
- {if empty($cancelled)}
- {if empty($lineItem)}
+ {if '{membership.status_id:name}' !== 'Cancelled'}
+ {if !$isShowLineItems}
<tr>
<td {$labelStyle}>
{ts}Membership Start Date{/ts}
</td>
<td {$valueStyle}>
- {$mem_start_date}
+ {membership.start_date|crmDate:"Full"}
</td>
</tr>
<tr>
{ts}Membership Expiration Date{/ts}
</td>
<td {$valueStyle}>
- {$mem_end_date}
+ {membership.end_date|crmDate:"Full"}
</td>
</tr>
{/if}
- {if $formValues.total_amount OR $formValues.total_amount eq 0 }
+ {if '{contribution.total_amount|raw}' !== '0.00'}
<tr>
<th {$headerStyle}>
{ts}Membership Fee{/ts}
</th>
</tr>
- {if !empty($formValues.contributionType_name)}
+ {if {contribution.financial_type_id|boolean}}
<tr>
<td {$labelStyle}>
{ts}Financial Type{/ts}
</td>
<td {$valueStyle}>
- {$formValues.contributionType_name}
+ {contribution.financial_type_id:label}
</td>
</tr>
{/if}
- {if !empty($lineItem)}
- {foreach from=$lineItem item=value key=priceset}
+ {if $isShowLineItems}
<tr>
<td colspan="2" {$valueStyle}>
<table>
<tr>
<th>{ts}Item{/ts}</th>
<th>{ts}Fee{/ts}</th>
- {if !empty($dataArray)}
+ {if $isShowTax && '{contribution.tax_amount|raw}' !== '0.00'}
<th>{ts}SubTotal{/ts}</th>
<th>{ts}Tax Rate{/ts}</th>
<th>{ts}Tax Amount{/ts}</th>
<th>{ts}Membership Start Date{/ts}</th>
<th>{ts}Membership Expiration Date{/ts}</th>
</tr>
- {foreach from=$value item=line}
+ {foreach from=$lineItems item=line}
<tr>
- <td>
- {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}
- <div>{$line.description|truncate:30:"..."}</div>{/if}
- </td>
+ <td>{$line.title}</td>
<td>
{$line.line_total|crmMoney}
</td>
- {if !empty($dataArray)}
+ {if $isShowTax && '{contribution.tax_amount|raw}' !== '0.00'}
<td>
- {$line.unit_price*$line.qty|crmMoney}
+ {$line.unit_price*$line.qty|crmMoney:'{contribution.currency}'}
</td>
{if $line.tax_rate || $line.tax_amount != ""}
<td>
{$line.tax_rate|string_format:"%.2f"}%
</td>
<td>
- {$line.tax_amount|crmMoney}
+ {$line.tax_amount|crmMoney:'{contribution.currency}'}
</td>
{else}
<td></td>
<td></td>
{/if}
<td>
- {$line.line_total+$line.tax_amount|crmMoney}
+ {$line.line_total+$line.tax_amount|crmMoney:'{contribution.currency}'}
</td>
{/if}
<td>
- {$line.start_date}
+ {$line.membership.start_date|crmDate:"Full"}
</td>
<td>
- {$line.end_date}
+ {$line.membership.end_date|crmDate:"Full"}
</td>
</tr>
{/foreach}
</table>
</td>
</tr>
- {/foreach}
- {if !empty($dataArray)}
- {if $formValues.total_amount and $totalTaxAmount}
+
+ {if $isShowTax && '{contribution.tax_amount|raw}' !== '0.00'}
<tr>
<td {$labelStyle}>
- {ts}Amount Before Tax:{/ts}
+ {ts}Amount Before Tax{/ts}:
</td>
<td {$valueStyle}>
- {$formValues.total_amount-$totalTaxAmount|crmMoney}
+ {contribution.tax_exclusive_amount}
</td>
</tr>
- {/if}
- {foreach from=$dataArray item=value key=priceset}
+ {foreach from=$taxRateBreakdown item=taxDetail key=taxRate}
<tr>
- {if $priceset}
- <td> {$taxTerm} {$priceset|string_format:"%.2f"}%</td>
- <td> {$value|crmMoney:$currency}</td>
- {elseif $priceset == 0}
- <td> {ts}No{/ts} {$taxTerm}</td>
- <td> {$value|crmMoney:$currency}</td>
- {/if}
+ <td {$labelStyle}>{if $taxRate == 0}{ts}No{/ts} {$taxTerm}{else} {$taxTerm} {$taxDetail.percentage}%{/if}</td>
+ <td {$valueStyle}>{$taxDetail.amount|crmMoney:'{contribution.currency}'}</td>
</tr>
{/foreach}
{/if}
{/if}
- {if $totalTaxAmount}
+ {if '{contribution.tax_amount|raw}' !== '0.00'}
<tr>
<td {$labelStyle}>
{ts}Total Tax Amount{/ts}
</td>
<td {$valueStyle}>
- {$totalTaxAmount|crmMoney:$currency}
+ {contribution.tax_amount}
</td>
</tr>
{/if}
{ts}Amount{/ts}
</td>
<td {$valueStyle}>
- {$formValues.total_amount|crmMoney}
+ {contribution.total_amount}
</td>
</tr>
- {if !empty($receive_date)}
+ {if {contribution.receive_date|boolean}}
<tr>
<td {$labelStyle}>
{ts}Date Received{/ts}
</td>
<td {$valueStyle}>
- {$receive_date|truncate:10:''|crmDate}
+ {contribution.receive_date}
</td>
</tr>
{/if}
- {if !empty($formValues.paidBy)}
+ {if {contribution.payment_instrument_id|boolean}}
<tr>
<td {$labelStyle}>
{ts}Paid By{/ts}
</td>
<td {$valueStyle}>
- {$formValues.paidBy}
+ {contribution.payment_instrument_id:label}
</td>
</tr>
- {if !empty($formValues.check_number)}
+ {if {contribution.check_number|boolean}}
<tr>
<td {$labelStyle}>
{ts}Check Number{/ts}
</td>
<td {$valueStyle}>
- {$formValues.check_number}
+ {contribution.check_number}
</td>
</tr>
{/if}
{$receipt_text}
{else}{ts}Thank you for this contribution.{/ts}{/if}
-{if empty($lineItem)}
+{if !$isShowLineItems}
===========================================================
{ts}Membership Information{/ts}
===========================================================
-{ts}Membership Type{/ts}: {$membership_name}
+{ts}Membership Type{/ts}: {membership.membership_type_id:name}
{/if}
-{if empty($cancelled)}
-{if empty($lineItem)}
-{ts}Membership Start Date{/ts}: {$mem_start_date}
-{ts}Membership Expiration Date{/ts}: {$mem_end_date}
+{if '{membership.status_id:name}' !== 'Cancelled'}
+{if !$isShowLineItems}
+{ts}Membership Start Date{/ts}: {membership.start_date|crmDate:"Full"}
+{ts}Membership Expiration Date{/ts}: {membership.end_date|crmDate:"Full"}
{/if}
-{if $formValues.total_amount OR $formValues.total_amount eq 0 }
+{if '{contribution.total_amount|raw}' !== '0.00'}
===========================================================
{ts}Membership Fee{/ts}
===========================================================
-{if !empty($formValues.contributionType_name)}
-{ts}Financial Type{/ts}: {$formValues.contributionType_name}
+{if {contribution.financial_type_id|boolean}}
+{ts}Financial Type{/ts}: {contribution.financial_type_id:label}
{/if}
-{if !empty($lineItem)}
-{foreach from=$lineItem item=value key=priceset}
+{if $isShowLineItems}
{capture assign=ts_item}{ts}Item{/ts}{/capture}
{capture assign=ts_total}{ts}Fee{/ts}{/capture}
-{if !empty($dataArray)}
+{if $isShowTax && '{contribution.tax_amount|raw}' !== '0.00'}
{capture assign=ts_subtotal}{ts}Subtotal{/ts}{/capture}
{capture assign=ts_taxRate}{ts}Tax Rate{/ts}{/capture}
{capture assign=ts_taxAmount}{ts}Tax Amount{/ts}{/capture}
{/if}
{capture assign=ts_start_date}{ts}Membership Start Date{/ts}{/capture}
{capture assign=ts_end_date}{ts}Membership Expiration Date{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_total|string_format:"%10s"} {if !empty($dataArray)} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate|string_format:"%10s"} {$ts_taxAmount|string_format:"%10s"} {$ts_total|string_format:"%10s"} {/if} {$ts_start_date|string_format:"%20s"} {$ts_end_date|string_format:"%20s"}
+{$ts_item|string_format:"%-30s"} {$ts_total|string_format:"%10s"} {if $isShowTax && '{contribution.tax_amount|raw}' !== '0.00'} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate|string_format:"%10s"} {$ts_taxAmount|string_format:"%10s"} {$ts_total|string_format:"%10s"} {/if} {$ts_start_date|string_format:"%20s"} {$ts_end_date|string_format:"%20s"}
--------------------------------------------------------------------------------------------------
-{foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.line_total|crmMoney|string_format:"%10s"} {if !empty($dataArray)} {$line.unit_price*$line.qty|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""} {$line.tax_rate|string_format:"%.2f"} % {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else} {/if} {$line.line_total+$line.tax_amount|crmMoney|string_format:"%10s"} {/if} {$line.start_date|string_format:"%20s"} {$line.end_date|string_format:"%20s"}
-{/foreach}
+{foreach from=$lineItems item=line}
+{line.title} {$line.line_total|crmMoney|string_format:"%10s"} {if $isShowTax && '{contribution.tax_amount|raw}' !== '0.00'} {$line.unit_price*$line.qty|crmMoney:'{contribution.currency}'|string_format:"%10s"} {if $line.tax_rate || $line.tax_amount != ""} {$line.tax_rate|string_format:"%.2f"} % {$line.tax_amount|crmMoney:'{contribution.currency}'|string_format:"%10s"} {else} {/if} {$line.line_total+$line.tax_amount|crmMoney|string_format:"%10s"} {/if} {$line.membership.start_date|string_format:"%20s"} {$line.membership.end_date|string_format:"%20s"}
{/foreach}
-{if !empty($dataArray)}
-{ts}Amount before Tax{/ts}: {$formValues.total_amount-$totalTaxAmount|crmMoney:$currency}
+{if $isShowTax && '{contribution.tax_amount|raw}' !== '0.00'}
+{ts}Amount before Tax{/ts}: {contribution.tax_exclusive_amount}
-{foreach from=$dataArray item=value key=priceset}
-{if $priceset}
-{$taxTerm} {$priceset|string_format:"%.2f"} %: {$value|crmMoney:$currency}
-{elseif $priceset == 0}
-{ts}No{/ts} {$taxTerm}: {$value|crmMoney:$currency}
-{/if}
+{foreach from=$taxRateBreakdown item=taxDetail key=taxRate}
+{if $taxRate == 0}{ts}No{/ts} {$taxTerm}{else} {$taxTerm} {$taxDetail.percentage}%{/if}: {$taxDetail.amount|crmMoney:'{contribution.currency}'}
{/foreach}
{/if}
--------------------------------------------------------------------------------------------------
{/if}
-{if $totalTaxAmount}
-{ts}Total Tax Amount{/ts}: {$totalTaxAmount|crmMoney:$currency}
+{if '{contribution.tax_amount|raw}' !== '0.00'}
+{ts}Total Tax Amount{/ts}: {contribution.tax_amount}
{/if}
-{ts}Amount{/ts}: {$formValues.total_amount|crmMoney}
-{if !empty($receive_date)}
-{ts}Date Received{/ts}: {$receive_date|truncate:10:''|crmDate}
+{ts}Amount{/ts}: {contribution.total_amount}
+{if {contribution.receive_date|boolean}}
+{ts}Date Received{/ts}: {contribution.receive_date}
{/if}
-{if !empty($formValues.paidBy)}
-{ts}Paid By{/ts}: {$formValues.paidBy}
-{if !empty($formValues.check_number)}
-{ts}Check Number{/ts}: {$formValues.check_number}
+{if {contribution.payment_instrument_id|boolean}}
+{ts}Paid By{/ts}: {contribution.payment_instrument_id:label}
+{if {contribution.check_number|boolean}}
+{ts}Check Number{/ts}: {contribution.check_number|boolean}
{/if}
{/if}
{/if}