I have the following object -
Reckoner Load (0.2ms) SELECT "reckoners".* FROM "reckoners" WHERE
"reckoners"."id" = ? LIMIT 1 [["id", 2]]
=> #<Reckoner id: 2, group: "test FTEProrated", description: "try new calc",
leave: 28, abscence: #<BigDecimal:7fab221cf438,'0.1E2',9(27)>,
created_at: "2014-10-06 15:56:10", updated_at: "2014-10-06 16:14:32",
FTEProRated: #<BigDecimal:7fab221ca1e0,'0.0',9(27)>>
If I've done my calculation correctly, FTEProRated should be about 0.8 - but it's being displayed as 0.0. Where am I going wrong?
The calculation is carried out in the controller before the object is saved -
in update -
pro_rate_this @reckoner
...
def pro_rate_this(reckoner)
reckoner.FTEProRated = (260-reckoner.leave)/260
end
when I change the calc to test what's being saved, it all seems okay - for example, this -
def pro_rate_this(reckoner)
reckoner.FTEProRated = (260-reckoner.leave)
end
gives a value of 232 when reckoner.leave == 28. It's only when the value becomes < 1 that it seems to be a problem, though that could be coincidence.