CRM-16632 Cannot save contributions with certain fee amounts

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.6.3
    • Fix Version/s: 4.6.4
    • Component/s: CiviContribute
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      The processing of fee amounts is done inconsistently in the backend.
      There are two issues:
      1. in the contribution form, the "net amount" is auto-populated incorrectly when the total amount decimal value ends in 0 (e.g. $1.00, $1.10)
      2. Upon saving, the CRM_Utils_Rule::cleanMoney wrapper is not used everywhere, hence the validation net_amount + fee = total amount fails when the total amount ends in a 0.

      To replicate, do this (bug confirmed on Wordpress 4.6.3 demo site):

      • go to create contribution page, fill out contact field with any contact name and contribution type.
      • Under total amount, type "158.10" or any amount that ends with a in the decimal.
      • scroll down, and under additional details, enter "8.83" for the Fee amount
      • CiviCRM will automatically fill in "149.26999999999998" under the Net amount
      • try saving, it will complain about the format of the net amount.
      • Correct net amount to "149.27", save. CiviCRM will refuse to save saying that net amount + fee amount needs to be equal to the total amount

        Attachments

          Activity

          [CRM-16632] Cannot save contributions with certain fee amounts
          Rares P added a comment - - edited

          I've been able to fix #2 as follows.
          in CRM/Contribute/Form/Contribution.php, around line 952

          -      if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) {
          +      if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != CRM_Utils_Rule::cleanMoney($sum)) {
          

          But #1 is coming from JS and I don't even know where to look

          Coleman Watts added a comment -

          Thanks for debugging this Rares P that got me on the right track. This PR includes your fix plus a fix for the js bug.

          https://github.com/civicrm/civicrm-core/pull/5967

            People

            • Assignee:
              David Greenberg
              Reporter:
              Rares P

              Dates

              • Created:
                Updated:
                Resolved: