Modify

Opened 14 years ago

Closed 14 years ago

#7703 closed defect (fixed)

Totals not accurate when values are not integers

Reported by: Daniel Smith Owned by: Rob Guttman
Priority: normal Component: SumFieldsPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

If the numbers for a given column are not integers (say they are floats) the sum field will be incorrect.

Patch file with suggested fix is attached

Attachments (1)

patch.diff (523 bytes) - added by Daniel Smith 14 years ago.

Download all attachments as: .zip

Change History (5)

Changed 14 years ago by Daniel Smith

Attachment: patch.diff added

comment:1 Changed 14 years ago by Daniel Smith

--- templates/sumfields.html (revision 8998) +++ templates/sumfields.html (working copy) @@ -%ld,%ld +%ld,%ld @@

sum up each row jQuery('.${field}', this).each(function(){

  • var num = parseInt($(this).text());

+ var num = parseFloat($(this).text());

if (!isNaN(num)){

sums${field}? += num;

}

comment:2 Changed 14 years ago by Daniel Smith

--- templates/sumfields.html    (revision 8998)
+++ templates/sumfields.html    (working copy)
@@ -%ld,%ld +%ld,%ld @@
             
             // sum up each row
             jQuery('.${field}', this).each(function(){
-                var num = parseInt($(this).text());
+                var num = parseFloat($(this).text());
                 if (!isNaN(num)){
                     sums['${field}'] += num;
                 }

comment:3 Changed 14 years ago by Rob Guttman

(In [9475]) refs #7703: now handles float values. thanks to danielnfi for his patch.

comment:4 Changed 14 years ago by Rob Guttman

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Rob Guttman.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.