Bug 20625

Summary: Cannot add new patron category without currency
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: Staff interfaceAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: alexbuckley, gmcharlt, jonathan.druart, liz, martin.renvoize, mtompset
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18888
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 4078    
Bug Blocks:    
Attachments: Bug 20625: Add tests
Bug 20625: Handle non existing of active currency
Bug 20625: Add tests
Bug 20625: Handle non existing of active currency
Bug 20625: Add tests
Bug 20625: Handle non existing of active currency

Description Marcel de Rooy 2018-04-20 07:07:22 UTC
Internal server errror on clicking New category in Admin/Patron categories

Template process failed: undef error - Can't call method "p_sep_by_space" on an undefined value at /usr/share/koha/devclone/Koha/Number/Price.pm line 126.

Sub _format_params assumes that there is an active currency. (Which was not there yet in a new installed system.) 
Since we are showing an empty page here, I do not see the need of a currency for just formatting a zero or null value ??
Comment 1 Liz Rea 2018-04-22 23:31:18 UTC
Maybe add the currency selection into the onboarder, before you add a patron category (if the "currency" sample data isn't selected)
Comment 2 Jonathan Druart 2018-04-23 15:06:10 UTC
Caused by
  commit 18e72e31957a51206875ac27d92929909a90ef34
  Bug 4078: Add the ability to display and configure the symbol for prices
Comment 3 Jonathan Druart 2018-04-23 15:11:29 UTC
Created attachment 74737 [details] [review]
Bug 20625: Add tests
Comment 4 Jonathan Druart 2018-04-23 15:11:32 UTC
Created attachment 74738 [details] [review]
Bug 20625: Handle non existing of active currency

This patch avoid the explosion in the air when creating a new patron
category and no active currency is defined.

Test plan:
Remove the currencies, create a new patron category
Without this patch applied you will get
  Can't call method "p_sep_by_space" on an undefined value

With this patch the form will be displayed correctly and you will be
able to create the patron category
Comment 5 Mark Tompsett 2018-04-23 15:43:26 UTC
Created attachment 74740 [details] [review]
Bug 20625: Add tests

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 6 Mark Tompsett 2018-04-23 15:43:29 UTC
Created attachment 74741 [details] [review]
Bug 20625: Handle non existing of active currency

This patch avoid the explosion in the air when creating a new patron
category and no active currency is defined.

Test plan:
Remove the currencies, create a new patron category
Without this patch applied you will get
  Can't call method "p_sep_by_space" on an undefined value

With this patch the form will be displayed correctly and you will be
able to create the patron category

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 7 Mark Tompsett 2018-04-23 15:44:18 UTC
Test only applied, kaboom. With patch, no kaboom. And code change eyeballs well.
Comment 8 Katrin Fischer 2018-04-24 06:07:41 UTC
Created attachment 74774 [details] [review]
Bug 20625: Add tests

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 9 Katrin Fischer 2018-04-24 06:09:02 UTC
Created attachment 74775 [details] [review]
Bug 20625: Handle non existing of active currency

This patch avoid the explosion in the air when creating a new patron
category and no active currency is defined.

Test plan:
Remove the currencies, create a new patron category
Without this patch applied you will get
  Can't call method "p_sep_by_space" on an undefined value

With this patch the form will be displayed correctly and you will be
able to create the patron category

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 10 Jonathan Druart 2018-04-24 15:36:59 UTC
Pushed to master for 18.05, thanks to everybody involved!