CiviCRM

Cannot edit negative Contribution amount

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed/Completed
  • Affects Version/s: 3.1.3
  • Fix Version/s: 3.1.4
  • Component/s: CiviContribute
  • Labels:
    None

Description

Occasionally we create a negative $ amount (i.e. -$10) Contribution because of a refund, error, overpayment or credit. This is necessary and helpful use-case for our bookkeeping. CiviCRM allows the negative Contribution to be created, but once it is created, there is an error "Please enter a valid amount" if you try to edit the Contribution afterward. Please allow negative values to be edited.

Bug verifiable on Demo site.
http://drupal.demo.civicrm.org/civicrm/contact/view/contribution?reset=1&id=16&cid=103&action=view&context=contribution&selectedChild=contribute
  1. negative-contrib.png
    10/Mar/10 6:11 PM
    18 kB
    Stoob
  2. Rule.patch
    16/Mar/10 8:03 PM
    0.5 kB
    jason bertolacci

Activity

Hide
jason bertolacci added a comment -
The problem is actually with CRM/Utils/Rules.php and the money amount being entered. The money() function allows "-10" as a valid money amount but not "-10.00". "-10" gets evaluated by the integer() function, which allows negative integers, while "-10.00" gets evaluated by preg_match and the regular expression does not allow for the negative sign.

A patch for version 3.0.0 is attached, but I am not a regular expression expert so please verify my code.
Show
jason bertolacci added a comment - The problem is actually with CRM/Utils/Rules.php and the money amount being entered. The money() function allows "-10" as a valid money amount but not "-10.00". "-10" gets evaluated by the integer() function, which allows negative integers, while "-10.00" gets evaluated by preg_match and the regular expression does not allow for the negative sign. A patch for version 3.0.0 is attached, but I am not a regular expression expert so please verify my code.
Hide
jason bertolacci added a comment -
CRM/Utils/Rule.php patch for negative money value
Show
jason bertolacci added a comment - CRM/Utils/Rule.php patch for negative money value
Hide
David Greenberg added a comment -
Moving to 3.1.4 since patch has been submitted by J Bertolacci (per conversation w/ lobo)
Show
David Greenberg added a comment - Moving to 3.1.4 since patch has been submitted by J Bertolacci (per conversation w/ lobo)
Hide
Priya Prajapati added a comment -
tested for rev-26824
Show
Priya Prajapati added a comment - tested for rev-26824

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: