Skip to content

Conversation

@mpellegrin
Copy link
Contributor

The test used in the Cash Control report of TakePOS was using float approximation between equality tests, leading to incoherent information shown in cash report. On the first test, string/float mix was also used.

This commit changes the test to use the displayed value for testing, to show the "Declared" red label only if a difference is actually visible to the user.

image
print '<div class="inline-block amount width100">'.price($cash).'</div>';
}
if (!$summaryonly && $object->status == $object::STATUS_VALIDATED && $newcash != $object->cash) {
if (!$summaryonly && $object->status == $object::STATUS_VALIDATED && price($newcash) != price($object->cash)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

price is a text formating function.
For comparison of amount, it should be smantically better to do
prcie2num( ) != price2num()
Can you check this way ?
Of you can also try
if (float) $newcash != (float) $object->cash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with price2num but not with the (float) cast.

By the way, I have an instinctive fear of using floats for equality test (moreover, transtyped floats) so I tend to prefer using price2num that returns strings. If the solution is acceptable to you, I would add another commit replacing price() with price2num() in my changes.

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Discussion Some questions or discussions are opened and wait answers of author or other people to be processed

2 participants