Modify

Opened 4 years ago

Closed 4 years ago

#7703 closed defect (fixed)

Totals not accurate when values are not integers

Reported by: danielnfi Owned by: robguttman
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 danielnfi 4 years ago.

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by danielnfi

comment:1 Changed 4 years ago by danielnfi

--- 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 4 years ago by danielnfi

--- 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 4 years ago by robguttman

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

comment:4 Changed 4 years ago by robguttman

  • Resolution set to fixed
  • Status changed from new to closed

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.