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
}
}
$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
cj('#num_terms').change( function( ) {
setPaymentBlock(mode);
});
- setPaymentBlock(mode);
// show/hide different contact section
setDifferentContactBlock();
<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">