dev/core#778 Do not increment tax on validation error
authoreileen <emcnaughton@wikimedia.org>
Mon, 22 Feb 2021 04:34:44 +0000 (17:34 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 22 Feb 2021 05:41:54 +0000 (18:41 +1300)
After digging into & cleaning up the code that handles tax on the membership form
I concluded that we can fix https://lab.civicrm.org/dev/core/-/issues/778 without
regressing https://issues.civicrm.org/jira/browse/CRM-18827 by simply doing less.
If the form has been already submitted, just load up what was submitted, do not
call the script to mess with stuff.

The script does 3 things
1) checks or unchecks the record_contribution checkbox. This is fine
to leave alone as it will have the right values on new & reload
without intervention
2) sets financial type id - ditto - only needs to be changed
when something else changes
3) sets total_amount - ditto
4) sets the text that says how much tax is included

With this patch 4 will not happen on a validation error. I think
this is OK as it is a bit of an edge case and no message is
better than the 2 previous issues of the amount being wrong.

I did think about fixing but it adds a lot of complexity that
will be easy to do once other changes are done to make
accessing the tax_amount easier, but which are relatively hard
now & my guess is that no-one will notice it not being there

CRM/Member/Form/Membership.php
templates/CRM/Member/Form/Membership.tpl
templates/CRM/Member/Form/MembershipCommon.tpl

index 212c0c67ba2a03ec592bd5444c2d56d56697ca95..6199d779d84f2ae9b66b636d118fd745f8411b2f 100644 (file)
@@ -479,10 +479,6 @@ DESC limit 1");
         }
       }
       $totalAmount = $values['minimum_fee'] ?? NULL;
-      //CRM-18827 - override the default value if total_amount is submitted
-      if (!empty($this->_submitValues['total_amount'])) {
-        $totalAmount = CRM_Utils_Rule::cleanMoney($this->_submitValues['total_amount']);
-      }
       // build membership info array, which is used when membership type is selected to:
       // - set the payment information block
       // - set the max related block
index cdc3bdb7e9f6c2fa322e5f6b05ae0e1ed0851d34..68c056f63550e19b8e4dba2908954a06f835c6f0 100644 (file)
       cj('#num_terms').change( function( ) {
         setPaymentBlock(mode);
       });
-      setPaymentBlock(mode);
 
       // show/hide different contact section
       setDifferentContactBlock();
index c47fb31712c977020ea4a0b8c406f2a2de9559c2..ae2e4eb1d09f669cf1452e37f6f4a745f7a6a849 100644 (file)
@@ -76,8 +76,7 @@
   <tr class="crm-{$formClass}-form-block-total_amount">
     <td class="label">{$form.total_amount.label}</td>
     <td>{$form.total_amount.html}<br />
-      <span class="description">{ts}Membership payment amount.{/ts}</span>
-      <div class="totaltaxAmount" data-tax_amount_raw=0></div>
+      <span class="description">{ts}Membership payment amount.{/ts}</span><div class="totaltaxAmount"></div>
     </td>
   </tr>
   <tr class="crm-membership-form-block-contribution-contact">