Skip to content

Commit

Permalink
Fix error from different compensation prediction and result
Browse files Browse the repository at this point in the history
Compensation prediction doesn't persist rows into database, thus the
values that Provision provided weren't rounded at all: their excess
digits were just chopped off.
E.g. a value 1.006 from Provision calculation would be persisted as 1.01
in database, but predicition would've had a value of 1.00.
  • Loading branch information
jlaunonen committed Jul 21, 2024
1 parent 58f9c17 commit a1116a8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kirppu/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@


def decimal_to_transport(value):
return int(value * Item.FRACTION)
# round(): Database provides a rounded value anyway, so use the same
# to avoid having different value for database-rows and in-memory-rows (provision pre-calculation).
return int(round(value * Item.FRACTION))


class UserAdapterBase(object):
Expand Down

0 comments on commit a1116a8

Please sign in to comment.