-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow decimal numbers in transaction collections #921
Conversation
@paroga's comment is still valid. Tested with these browsers:
Despite these browser specific issues I'm in favor of merging this commit: With the current field the Foodsoft silently changes comma seperated numbers to integer values. That's a big problem for Foodcoops that use this feature a lot and are not aware of this behaviour. |
Thanks for doing these tests! Entering numbers looks fine. I think a problem could be that when a validation fails, and Rails renders the number input, it may render the number in a locale-specific way, breaking the recognition of the number input when the page with error is shown. Not sure if this actually happens, but would be good to check. |
With |
When a rails validation would fail, e.g.when the amount is >100000 or <-100000. |
Would a rage prevent this failure? Like: number_field_tag 'financial_transactions[][amount]', nil, class: 'input-small', step: 0.01, in: -100000..100000 |
It would prevent this particular failure. But if anyone changes the financial transactions model (e.g. even with a plugin), the issue may still appear - and be hard to debug. I guess we could add it with a BIG WARNING in the model about this situation. But I'm not sure the issue I suspected could happen actually happens at all - would need to test! |
one problem with using |
You know the internals of the Foodsoft + Rails better than me - that is out of question. Though I want address some of your points: It think silently removing the decimal numbers (that's the case now) is much worse from a Foodcoop's point of view as it could mean to lost money in a significant amount (by not charging the decimal numbers for a lot of orders groups over a long period). Actually this issue is based on feedback from users of the global Foodsoft hosting that came across this behavoiur of the Foodsoft. Anyway: Could you explain what steps are necessary to replace the localize_input gem? Thanks a lot. |
please don't get me wrong. i really like your effort in improving it. i got a lot of feedback to for this issue too and it's very annoying. if you just want to fix the problem on exactly this page, then i'd suggest to do it in a similar ugly way, as we do in the other places. "just" add a call to the
i started to remove |
I just tested this: it is not an issue here, since the form is not validated by the backend at all (i.e. non-numeric strings are silently accepted and treated as zero). This is a separate issue, which I will not address in this proposal.
Correct me if I'm wrong: The financial_transaction model already localizes the amount. The specific form isn't part of the model, is it?
Thank you for the suggestion, unfortunately that goes beyond my knowledge of Rails at the moment.
While you are looking for a sustainable solution my approach is to address this particular issue. |
ok, sorry for the confusion. my bad.
yes, that's the problem here (as far as i understand it now)
I've done it for you in this commit. Can you do the rest?
100% agree and that's the reason why i proposed the "ugly" version. i think it's far better to have the same ugliness for parsing amounts everywhere, than to have to deal with different behavior on different pages. |
i don't think that my PR is a clean implementation, but it keeps the current behavior and should not introduce new compatibility problems, while still allowing localized input for transaction collections |
If fixes one of the issues of #722.
Tested with point and comma as delimeter.