This happens with 21.11 with us. "Issue refund" on a paid transaction. In the field "Returned to patron" there is a prefilled text "NaN", i don't know why yet. "Confirming" that without correcting it to the amount in numbers that you want to refund, you get an Internal Server Error.
Confirmed on master with CurrencyFormat FR. It works ok with US. NaN = Not a Number often a JavaScript related error
The problem is not an easy fix on first glance. This is all done in JS, but I have a feeling it should use template variables with the unformatted data instead: var amount = button.data('amount'); var amountoutstanding = button.data('amountoutstanding') || 0; var paid = amount - amountoutstanding; $("#paid + span").replaceWith(paid); $("#returned").attr({ "value": paid, "max": paid, "min": 0 });
The Payout has the same issues :( We really ought to add testing with other CurrencyFormats to our normal test plans for all money related patches. Maybe also test with != EN to start with. If it works then, it is likely to always work. Tempted to mark this major actually... this breaks central money related workflows for a lot of libraries.
Created attachment 140405 [details] [review] Bug 31513: Remove price formatting form data- attributes We cannot use data formatted with a decimal comma for calculations. So we need to make sure that the data- attributes passed to the modals are in 'database format' with decimal . This will fix the NaN errors on the forms, but might also negatively effect formatting in some spots. Formatting should be fixed separately as this is for sure the right first step, but we need to put in more work for displays. To test: * Set CurrencyFormat system preference to FR * Go to any patron account > accounting tab * Create a credit * On Transactions tab: Payout amount at bottom = Verify NaN in input * On Transactions tab: Issue payout on the credit line = Verify NaN in input * Create a manual debit and pay it * On Transactions tab: Issue refund = Verify NaN in input * Apply patch * Repeat test plan * Now all input fields should be set with the correct amounts https://bugs.koha-community.org/show_bug.cgi?id=31486
This fixes calculations, but we might pay with formatting... I am not sure if there is JS way to format prices yet? For example, if we stick with the JS, we'd want to format paid here for displaying it in the span: $("#paid + span").replaceWith(paid);
Created attachment 140612 [details] [review] Bug 31513: Remove price formatting form data- attributes We cannot use data formatted with a decimal comma for calculations. So we need to make sure that the data- attributes passed to the modals are in 'database format' with decimal . This will fix the NaN errors on the forms, but might also negatively effect formatting in some spots. Formatting should be fixed separately as this is for sure the right first step, but we need to put in more work for displays. To test: * Set CurrencyFormat system preference to FR * Go to any patron account > accounting tab * Create a credit * On Transactions tab: Payout amount at bottom = Verify NaN in input * On Transactions tab: Issue payout on the credit line = Verify NaN in input * Create a manual debit and pay it * On Transactions tab: Issue refund = Verify NaN in input * Apply patch * Repeat test plan * Now all input fields should be set with the correct amounts https://bugs.koha-community.org/show_bug.cgi?id=31486 Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Created attachment 140684 [details] [review] Bug 31513: Remove price formatting form data- attributes We cannot use data formatted with a decimal comma for calculations. So we need to make sure that the data- attributes passed to the modals are in 'database format' with decimal . This will fix the NaN errors on the forms, but might also negatively effect formatting in some spots. Formatting should be fixed separately as this is for sure the right first step, but we need to put in more work for displays. To test: * Set CurrencyFormat system preference to FR * Go to any patron account > accounting tab * Create a credit * On Transactions tab: Payout amount at bottom = Verify NaN in input * On Transactions tab: Issue payout on the credit line = Verify NaN in input * Create a manual debit and pay it * On Transactions tab: Issue refund = Verify NaN in input * Apply patch * Repeat test plan * Now all input fields should be set with the correct amounts https://bugs.koha-community.org/show_bug.cgi?id=31486 Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Created attachment 140685 [details] [review] Bug 31513: (QA follow-up) Keep price formatting on non-editable text fields Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Thanks for the follow-up, Joonas! I'll keep that in mind for some other places I spotted issues with the formatting!
Pushed to master for 22.11. Nice work everyone, thanks!
Please backport!
Thanks Tomas :)
Backported to 22.05.x for upcoming 22.05.07 release
applied to 21.11 for 21.11.14
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed. Nothing to document it seems, marking resolved.