Modify

Opened 18 months ago

Last modified 18 months ago

#13405 new defect

sum totalhours returns int instead decimal

Reported by: Rochi Owned by: Russ Tyndall
Priority: normal Component: TimingAndEstimationPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.2

Description (last modified by Rochi)

Trac 1.2.2

TimingAndEstimationPlugin 1.5.7b0

MariaDB 10.0.34

If I enter a decimal value for hours like 0.5 the totalhours field is always increased to the next integer value (here 1).

The code casts the newvalue with

CAST( newvalue AS DECIMAL)

But if you look to the mysql or mariadb documentation "DECIMAL" is used as "DECIMAL(10,0)" so the scale is 0 (number of digits after the decimal point).

see

https://mariadb.com/kb/en/library/decimal/

https://dev.mysql.com/doc/refman/5.5/en/fixed-point-types.html

So the cast have to look like

CAST( newvalue AS DECIMAL(10,2))

I've attached a patch.

Attachments (1)

ticket_daemon.py.patch (1.8 KB) - added by Rochi 18 months ago.
Patch sum totalhours

Download all attachments as: .zip

Change History (7)

Changed 18 months ago by Rochi

Attachment: ticket_daemon.py.patch added

Patch sum totalhours

comment:1 Changed 18 months ago by Rochi

Description: modified (diff)

comment:2 Changed 18 months ago by Russ Tyndall

Thanks so much for the patch.

I am in a multi trac environment and never actually use the default reports (as we have trac integrated with our billing system), so I would never have caught that. I also have been using postgres instead of mysql.

I will apply the patch as that makes perfect sense.

comment:3 Changed 18 months ago by Russ Tyndall

In 17096:

Fix hour summing in reports to not round partial hours

version 1.5.8(b)

re #13405

comment:4 Changed 18 months ago by Rochi

Never mind. But please apply my patch (see attached patch) also to ticket_daemon.py to fix the issue in the ticket view.

comment:5 Changed 18 months ago by Russ Tyndall

Sorry, I missed that -- it does make me wonder how I have never hit this bug.

I will apply a patch in a moment

comment:6 Changed 18 months ago by Russ Tyndall

In 17107:

1.5.9(b) - fixed Decimal cast in ticket_daemon re #13405

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Russ Tyndall.

Add Comment


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

 
Note: See TracTickets for help on using tickets.