Eileen has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/317745

Change subject: Switch receipt to use original amount & currency if provided.
......................................................................

Switch receipt to use original amount & currency if provided.

I'm not loving this as it turns out the custom group label & custom field 
labels (not machine names)
are assigned to the template. This makes it a little brittle as we could change 
those. However,
it does resolve the immediate problem.

I am inclined to use it for now but raise a ticket to do a second round of this 
to make it more
robust (perhaps with a token, or review what is assigned to the template).

BUG: T137496

Change-Id: I22858e972d240fa58b3f3d30208bbc183a5f2406
---
M sites/all/modules/wmf_civicrm/templates/offline_receipt.html
M sites/all/modules/wmf_civicrm/templates/offline_receipt.txt
M sites/all/modules/wmf_civicrm/wmf_civicrm.install
3 files changed, 64 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/45/317745/1

diff --git a/sites/all/modules/wmf_civicrm/templates/offline_receipt.html 
b/sites/all/modules/wmf_civicrm/templates/offline_receipt.html
index 75f62c1..b2b2eae 100644
--- a/sites/all/modules/wmf_civicrm/templates/offline_receipt.html
+++ b/sites/all/modules/wmf_civicrm/templates/offline_receipt.html
@@ -1,7 +1,22 @@
 <html>
+
+{assign var="amount" value=$formValues.total_amount}
+{foreach from=$customGroup item=value key=customName}
+  {if $customName === "Contribution Extra"}
+    {foreach from=$value item=v key=n}
+      {if $n == "Original Currency Received"}
+        {assign var="currency" value=$v}
+      {/if}
+      {if $n == "Original Amount Received (unconverted)"}
+        {assign var="amount" value=$v}
+      {/if}
+    {/foreach}
+  {/if}
+{/foreach}
+
 <p>Dear {contact.first_name},</p>
 
-<p>Thank you for your donation of 
{$formValues.total_amount-$totalTaxAmount|crmMoney:$currency} to the Wikimedia 
Foundation. The Wikimedia Foundation is the non-profit organization that 
supports Wikipedia and other free knowledge projects. Our mission is to build 
the most accessible and comprehensive source of free knowledge in the world.</p>
+<p>Thank you for your donation of {$amount|crmMoney:$currency} to the 
Wikimedia Foundation. The Wikimedia Foundation is the non-profit organization 
that supports Wikipedia and other free knowledge projects. Our mission is to 
build the most accessible and comprehensive source of free knowledge in the 
world.</p>
 
 <p>We believe that knowledge is a fundamental human right. As humanity rushes 
into our digital future, we need open, accessible, public spaces to access 
knowledge online. Wikimedia is such a space. Wikipedia delivers free knowledge 
to people, by people, in hundreds of languages around our planet.</p>
 
@@ -18,7 +33,7 @@
 <p>Many employers will match employee contributions: please check with your 
company to see if they have a <a class="external text" 
href=\"https://wikimediafoundation.org/wiki/Matching_Gifts/form\";>corporate 
matching gift program</a>.</p>
 
 <p>For your records: Your donation, number CNT-{$contactID}, on 
{$receive_date|truncate:10:\'\'|crmDate}
-    was {$formValues.total_amount-$totalTaxAmount|crmMoney:$currency}.</p>
+    was {$amount|crmMoney:$currency}.</p>
 
 
 <p>This letter may serve as a record of your donation. No goods or services 
were provided, in whole or in part, for this contribution. The Wikimedia 
Foundation, Inc. is a non-profit charitable corporation with 501(c)(3) tax 
exempt status in the United States. Our address is 149 New Montgomery, 6th 
Floor, San Francisco, CA, 94105. U.S. tax-exempt number: 20-0049703</p>
diff --git a/sites/all/modules/wmf_civicrm/templates/offline_receipt.txt 
b/sites/all/modules/wmf_civicrm/templates/offline_receipt.txt
index a22078b..50fb7d9 100644
--- a/sites/all/modules/wmf_civicrm/templates/offline_receipt.txt
+++ b/sites/all/modules/wmf_civicrm/templates/offline_receipt.txt
@@ -1,6 +1,18 @@
 Dear {contact.first_name},
-
-Thank you for your donation of 
{$formValues.total_amount-$totalTaxAmount|crmMoney:$currency} to the Wikimedia 
Foundation. The Wikimedia Foundation is the non-profit organization that 
supports Wikipedia and other free knowledge projects. Our mission is to build 
the most accessible and comprehensive source of free knowledge in the world.
+{assign var="amount" value=$formValues.total_amount}
+{foreach from=$customGroup item=value key=customName}
+  {if $customName === "Contribution Extra"}
+    {foreach from=$value item=v key=n}
+      {if $n == "Original Currency Received"}
+        {assign var="currency" value=$v}
+      {/if}
+      {if $n == "Original Amount Received (unconverted)"}
+        {assign var="amount" value=$v}
+      {/if}
+    {/foreach}
+  {/if}
+{/foreach}
+Thank you for your donation of {$amount|crmMoney:$currency} to the Wikimedia 
Foundation. The Wikimedia Foundation is the non-profit organization that 
supports Wikipedia and other free knowledge projects. Our mission is to build 
the most accessible and comprehensive source of free knowledge in the world.
 
 We believe that knowledge is a fundamental human right. As humanity rushes 
into our digital future, we need open, accessible, public spaces to access 
knowledge online. Wikimedia is such a space. Wikipedia delivers free knowledge 
to people, by people, in hundreds of languages around our planet.
 
@@ -16,7 +28,7 @@
 
 Many employers will match employee contributions: please check with your 
company to see if they have a corporate matching gift program 
(https://wikimediafoundation.org/wiki/Matching_Gifts/form).
 
-For your records: Your donation, number CNT-{$contactID}, on 
{$receive_date|truncate:10:\'\'|crmDate} was 
{$formValues.total_amount-$totalTaxAmount|crmMoney:$currency}.
+For your records: Your donation, number CNT-{$contactID}, on 
{$receive_date|truncate:10:\'\'|crmDate} was {$amount|crmMoney:$currency}.
 
 
 This letter may serve as a record of your donation. No goods or services were 
provided, in whole or in part, for this contribution. The Wikimedia Foundation, 
Inc. is a non-profit charitable corporation with 501(c)(3) tax exempt status in 
the United States. Our address is 149 New Montgomery, 6th Floor, San Francisco, 
CA, 94105. U.S. tax-exempt number: 20-0049703
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.install 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
index b459c13..137ef9f 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.install
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
@@ -60,6 +60,7 @@
     wmf_civicrm_update_7230();
     wmf_civicrm_update_7235();
     wmf_civicrm_update_7280();
+    wmf_civicrm_update_7290();
 }
 
 /**
@@ -2332,3 +2333,34 @@
   require_once 'update_receipt.php';
     _wmf_civicrm_update_offline_receipt();
 }
+
+/**
+ * Re-update the message template to fix:
+ *
+ *  - missing currency symbol on the second reference to the amount
+ *  - not using original currency/ amount where available.
+ *
+ * As noted in the commit message I have reservations about the approach
+ * (using smarty in the template) now that I realise the template
+ * only knows the label, not the machine name of the custom fields.
+ *
+ * This gives an immediate win but I don't think it's over.
+ *
+ * BUG: T137496
+ */
+function wmf_civicrm_update_7285() {
+    require_once 'update_receipt.php';
+    _wmf_civicrm_update_offline_receipt();
+}
+
+/**
+ * Update the currency display setting to not have a space between currency & 
amount.
+ *
+ * (based on feedback from Leanne on receipt).
+ *
+ * BUG: T137496
+ */
+function wmf_civicrm_update_7290() {
+  civicrm_initialize();
+  civicrm_api3('Setting', 'create', array('moneyformat' => '%c%a'));
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/317745
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I22858e972d240fa58b3f3d30208bbc183a5f2406
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to