Bug 38360

Summary: Price extraction from MungeMarcPrice should be improved
Product: Koha Reporter: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Component: AcquisitionsAssignee: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 38360: Cosmetics
Bug 38360: Add unit tests
Bug 38360: Price extraction from MungeMarcPrice should be improved

Description Baptiste Wojtkowski (bwoj) 2024-11-05 15:37:58 UTC
MungeMarcPrice's "rescue mode", tries and catch the whole possible number patterns in one regexp, which leads to very curious authorized values, and can leave some price unmatched for curious reasons.


Unmatched price that should be:
49.3 ; 555,555.3 (only 1 digit after separator)
50 (no digit)

Matched prices that should not:
,,,,,,,35 ; ,.,..,.45 ; 99,999.999,99
Comment 1 Baptiste Wojtkowski (bwoj) 2024-11-05 16:31:46 UTC
Created attachment 173990 [details] [review]
Bug 38360: Cosmetics
Comment 2 Baptiste Wojtkowski (bwoj) 2024-11-05 16:31:48 UTC
Created attachment 173991 [details] [review]
Bug 38360: Add unit tests

Add unit tests to prove case not taken in account py MungeMarcPrice
Comment 3 Baptiste Wojtkowski (bwoj) 2024-11-05 16:31:51 UTC
Created attachment 173992 [details] [review]
Bug 38360: Price extraction from MungeMarcPrice should be improved

MungeMarcPrice's "rescue mode", tries and catch the whole possible number patterns in one regexp, which leads to very curious authorized values, and can leave some price unmatched for curious reasons.

Unmatched price that should be:
49.3 ; 555,555.3 (only 1 digit after separator)
50 (no digit)

Matched prices that should not:
,,,,,,,35 ; ,.,..,.45 ; 99,999.999,99

TEST PLAN (for UNIMARC):
1 - Apply first commit, run tests (prove t/db_dependent/MungeMarcPrice.t) -> they should fail
1 - Export a MARC NOTICE in marxml with a 010d filled with 49.3
2 - On acquisition, register a new vendor
3 - Add a Basket to this vendor
4 - Add an order -> from a file -> select the exported marc notice
5 - Check the checkbox associated with this item -> there is no price
  field filled
6 - APPLY PATCH
7 - Repeat 4 & 5 -> the price is now displayed
8 - Run tests -> all tests pass