[Bug 43059] New: Remove C4::Biblio::GetMarcPrice in favor of MetadataExtractor
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43059 Bug ID: 43059 Summary: Remove C4::Biblio::GetMarcPrice in favor of MetadataExtractor Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: trivial Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org Depends on: 43058 Target Milestone: --- GetMarcPrice extracts a price from MARC fields and normalizes it via MungeMarcPrice. This is a straightforward MetadataExtractor candidate: - MARC21: 345$c, 020$c - UNIMARC: 345$d, 010$d, 071$d Callers to migrate: - acqui/addorderiso2709.pl - acqui/neworderempty.pl - Koha/MarcOrder.pm All callers pass a MARC::Record and marcflavour explicitly, making them direct fits for the extractor pattern. MungeMarcPrice (price normalization) should be inlined into the extractor method as a private helper. Steps: 1. Add get_marc_price to MARC21 and UNIMARC extractors 2. Expose as $biblio->marc_price (convenience) 3. Migrate callers 4. Remove GetMarcPrice and MungeMarcPrice from C4::Biblio Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43058 [Bug 43058] Remove C4::Items::get_hostitemnumbers_of in favor of Koha::Biblio->host_items -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43059 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | Patch complexity|--- |Small patch -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43059 --- Comment #1 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 201904 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201904&action=edit Bug 43059: Add get_marc_price to MetadataExtractor Adds get_marc_price() to both MARC21 and UNIMARC extractors: - MARC21: extracts from 345$c, 020$c - UNIMARC: extracts from 345$d, 010$d, 071$d The price normalization logic (MungeMarcPrice) is implemented as a shared _munge_price helper in the base MARC extractor class. It handles currency symbol detection, thousand separators, and decimal normalization. Test plan: 1. Apply this patch 2. Run: prove t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t prove t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/UNIMARC.t => SUCCESS: All tests pass 3. Note the new get_marc_price() subtests covering: - Price extraction from each relevant field - Field priority order - Thousands separator removal - Comma to dot conversion (UNIMARC) - Returns 0 when no price present -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43059 --- Comment #2 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 201905 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201905&action=edit Bug 43059: Add normalized_price convenience method to Koha::Biblio Adds $biblio->normalized_price which delegates to the metadata extractor's get_normalized_price method. Test plan: 1. Apply this patch 2. Run: prove t/db_dependent/Koha/Biblio.t => SUCCESS: All 45 tests pass 3. Note the new normalized_price() subtest verifying: - Returns 0 when no price field present - Extracts and normalizes price from 020$c -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43059 --- Comment #3 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 201906 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201906&action=edit Bug 43059: Migrate callers and remove GetMarcPrice/MungeMarcPrice Migrates all callers of C4::Biblio::GetMarcPrice to use Koha::Biblio::Metadata::Extractor->get_normalized_price: - acqui/addorderiso2709.pl - acqui/neworderempty.pl - Koha/MarcOrder.pm Removes GetMarcPrice and MungeMarcPrice from C4::Biblio. The existing MungeMarcPrice.t test (11 currency-aware price parsing cases) is preserved and migrated to test the extractor's _munge_price method directly. The original test in t/db_dependent/Biblio.t is updated to use the extractor as well. Test plan: 1. Apply this patch 2. Run: prove t/Biblio.t t/db_dependent/Biblio.t t/db_dependent/MungeMarcPrice.t => SUCCESS: All tests pass 3. Verify no remaining callers: grep -rn 'GetMarcPrice\|MungeMarcPrice' --include='*.pm' --include='*.pl' => No results 4. Test acquisitions workflow: import a MARC file with price data in 020$c (MARC21) or 010$d (UNIMARC) => SUCCESS: Price is correctly extracted into order form -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org