Bug 7516 - Create Subroutine For GetMarcPrice that will discern the actual price from a given price field value.
Summary: Create Subroutine For GetMarcPrice that will discern the actual price from a ...
Status: CLOSED DUPLICATE of bug 7112
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Henri-Damien LAURENT
QA Contact: Ian Walls
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-09 14:51 UTC by Kyle M Hall
Modified: 2012-10-26 00:51 UTC (History)
0 users

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2012-02-09 14:51:51 UTC
The acquisitions system in Koha uses GetMarcPrice to get the price from a bib record, but unless it is in a very specific format ( e.g. 123.45 ), the data passed back is often no processed, and and no value is used. Currently, there is no single function that attempts to find a good value if the field is not in this particular format. I propose a new subroutine, MungeMarcPrice, that would make a best attempt at finding a real number value in the price field. It should do the following.

1) First, look to see if there are *any* numbers in the field, if not, fail out.
2) Check for multiple price-like substrings in the price string, if multiple are found, use the first.
3) Convert decimal commas, to decimal periods, as that is the format Koha uses.


Here is a question; do all common currency formats use only two trailing digits?

Examples:
"$1.95" => "1.95"

"$5.99 ($7.75 CAN)" => "5.99"

"Rs15.76 ($5.60 U.S.)" => "15.75" 
Here, we could use the currency and exchange rates table to attempt to fine the active currency, and search for that first, in which case the output would be "5.60"

"Rental material" => ""

"For sale ($450.00) or rent ($45.00)" => "450.00"

"For sale ($200.00 for 3/4 in.; $150.00 for 1/2 in." => "200.00"

"$4.95 (lib. bdg.)" => "4.95"
Comment 1 Kyle M Hall 2012-02-09 16:46:11 UTC
This should also perhaps take into account commas and decimal commas.

Examples:
"1,000,00" => "1000.00"

"$12,232,342.00" => "12232242.00"
Comment 2 Kyle M Hall 2012-02-09 19:15:49 UTC

*** This bug has been marked as a duplicate of bug 7112 ***