SELECT evergreen.populate_call_number($1, $2, $3, NULL);
$$ LANGUAGE SQL;
+/*
+ * Each copy needs a price to be able to test lost/longoverdue and other
+ * real-life situations. Randomly generate a price between 1.99 and 25.99.
+ */
+CREATE OR REPLACE FUNCTION evergreen.generate_price() RETURNS FLOAT AS $$
+BEGIN
+ RETURN trunc(random() * 25 + 1) + .99;
+END;
+$$ LANGUAGE 'plpgsql';
/*
* create a copy for every callnumber in the database whose label and owning_lib
CREATE FUNCTION evergreen.populate_copy
(circlib INTEGER, ownlib INTEGER, barcode TEXT, label TEXT)
RETURNS void AS $$
- INSERT INTO asset.copy (call_number, circ_lib, creator, editor, loan_duration, fine_level, barcode)
- SELECT id, $1, 1, 1, 1, 1, $3 || id::text
+ INSERT INTO asset.copy (call_number, circ_lib, creator, editor, loan_duration, fine_level, price, barcode)
+ SELECT id, $1, 1, 1, 1, 1, (SELECT evergreen.generate_price()), $3 || id::text
FROM asset.call_number
WHERE record > 0 AND label LIKE $4 || '%' AND owning_lib = $2;
$$ LANGUAGE SQL;
DROP FUNCTION evergreen.create_aou_address(INTEGER, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT);
DROP FUNCTION evergreen.populate_call_number(INTEGER, TEXT, TEXT);
DROP FUNCTION evergreen.populate_call_number(INTEGER, TEXT, TEXT, INTEGER);
+DROP FUNCTION evergreen.generate_price();
DROP FUNCTION evergreen.populate_copy(INTEGER, INTEGER, TEXT, TEXT);
DROP FUNCTION evergreen.next_copy (BIGINT);
DROP FUNCTION evergreen.next_bib (BIGINT);