From ad50eaaa85691245117943716a1ffb4ceb82a462 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 4 Nov 2015 17:00:07 -0500 Subject: [PATCH] LP#1486294 ACQ sample data Sample ACQ data including: * funding sources * funds * funding source credits * fund allocations * providers * purchase orders * lineitems (some canceled) * lineitem details (copies, some canceled) * fund_debits Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- Open-ILS/tests/datasets/sql/acq.sql | 87 ++++++++++++++++++++++++++++++++ Open-ILS/tests/datasets/sql/load_all.sql | 3 ++ 2 files changed, 90 insertions(+) create mode 100644 Open-ILS/tests/datasets/sql/acq.sql diff --git a/Open-ILS/tests/datasets/sql/acq.sql b/Open-ILS/tests/datasets/sql/acq.sql new file mode 100644 index 0000000000..794eb710a2 --- /dev/null +++ b/Open-ILS/tests/datasets/sql/acq.sql @@ -0,0 +1,87 @@ + +-- note: using hard-coded ID's for most objects or this +-- would require 3 times as much SQL. + +INSERT INTO acq.funding_source (id, owner, name, currency_type, code) VALUES + (1, 1, 'LSTA', 'USD', 'LSTA'), + (2, 2, 'State', 'USD', 'ST'), + (3, 4, 'Foundation', 'USD', 'FNTN'); + +SELECT SETVAL('acq.funding_source_id_seq'::TEXT, 3); + +INSERT INTO acq.funding_source_credit (amount, funding_source) VALUES + ('10000',1), ('5000', 2), ('5000', 3); + +INSERT INTO acq.fund (id, org, year, currency_type, name, code) VALUES + (1, 1, EXTRACT(year FROM now()), 'USD', 'Adult', 'AD'), + (2, 2, EXTRACT(year FROM now()), 'USD', 'AV', 'AV'), + (3, 3, EXTRACT(year FROM now()), 'USD', 'AV', 'AV'), + (4, 4, EXTRACT(year FROM now()), 'USD', 'Juvenile', 'JUV'), + (5, 5, EXTRACT(year FROM now()), 'USD', 'Young Adult', 'YA'), + (6, 6, EXTRACT(year FROM now()), 'USD', 'Juvenile', 'JUV'), + (7, 7, EXTRACT(year FROM now()), 'USD', 'Young Adult', 'YA'), + (8, 2, EXTRACT(year FROM now()), 'USD', 'Reference', 'RF'), + (9, 2, EXTRACT(year FROM now()), 'USD', 'Fiction Print', 'FP'), + (10, 2, EXTRACT(year FROM now()), 'USD', 'Fiction Non-Print', 'FNP'), + (11, 3, EXTRACT(year FROM now()), 'USD', 'Fiction Print', 'FP'), + (12, 3, EXTRACT(year FROM now()), 'USD', 'Fiction Non-Print', 'FNP'); + +SELECT SETVAL('acq.fund_id_seq'::TEXT, 12); + +INSERT INTO acq.fund_allocation + (funding_source, fund, amount, allocator) VALUES + (1, 1, '3000', 1), + (1, 2, '3000', 1), + (1, 3, '3000', 1), + (2, 9, '500', 1), + (2, 10, '500', 1), + (3, 4, '2000', 1); + +INSERT INTO acq.provider + (id, name, owner, currency_type, code, holding_tag, san) VALUES + (1, 'Ingram', 1, 'USD', 'INGRAM', '970', '1697978'), + (2, 'Brodart', 2, 'USD', 'BRODART', '970', '1697684'), + (3, 'Baker & Taylor', 1, 'USD', 'BT', '970', '3349659'), + (4, 'Initech', 4, 'USD', 'IT', '970', '1001001'); + +SELECT SETVAL('acq.provider_id_seq'::TEXT, 4); + +INSERT INTO acq.purchase_order (id, owner, creator, + editor, ordering_agency, provider, state, order_date) VALUES + (1, 1, 1, 1, 4, 1, 'pending', NULL), + (2, 1, 1, 1, 4, 2, 'on-order', NOW()); + +SELECT SETVAL('acq.purchase_order_id_seq'::TEXT, 2); + +INSERT INTO acq.lineitem (id, creator, editor, selector, + provider, purchase_order, state, cancel_reason, + estimated_unit_price, eg_bib_id, marc) VALUES + (1, 1, 1, 1, 1, 1, 'new', NULL, '25.00', 1, + (SELECT marc FROM biblio.record_entry WHERE id = 1)), + (2, 1, 1, 1, 1, 1, 'new', NULL, '15.00', 2, + (SELECT marc FROM biblio.record_entry WHERE id = 2)), + (3, 1, 1, 1, 1, 2, 'on-order', NULL, '12.00', 3, + (SELECT marc FROM biblio.record_entry WHERE id = 3)), + (4, 1, 1, 1, 1, 2, 'cancelled', 1283, '18.50', 4, + (SELECT marc FROM biblio.record_entry WHERE id = 4)), + (5, 1, 1, 1, 1, 2, 'cancelled', 1, '22.00', 5, + (SELECT marc FROM biblio.record_entry WHERE id = 5)); + +SELECT SETVAL('acq.lineitem_id_seq'::TEXT, 5); + +INSERT INTO acq.fund_debit (id, fund, origin_amount, + origin_currency_type, amount, debit_type) VALUES + (1, 1, '12.00', 'USD', '12.00', 'purchase'), + (2, 1, '12.00', 'USD', '12.00', 'purchase'), + (3, 1, '18.50', 'USD', '12.00', 'purchase'); + +SELECT SETVAL('acq.fund_debit_id_seq'::TEXT, 4); + +INSERT INTO acq.lineitem_detail (lineitem, fund, fund_debit, eg_copy_id, + barcode, cn_label, owning_lib, location, cancel_reason) VALUES + (3, 1, 1, 3, 'ACQ0001', 'ACQ001', 4, 113, NULL), + (3, 1, 2, 103, 'ACQ0002', 'ACQ002', 5, 125, NULL), + (4, 1, 3, 4, 'ACQ0002', 'ACQ002', 4, 118, 1), + (5, 1, NULL, 5, 'ACQ0002', 'ACQ002', 4, 123, 1283); + + diff --git a/Open-ILS/tests/datasets/sql/load_all.sql b/Open-ILS/tests/datasets/sql/load_all.sql index 2694af98fe..1d4914ed52 100644 --- a/Open-ILS/tests/datasets/sql/load_all.sql +++ b/Open-ILS/tests/datasets/sql/load_all.sql @@ -62,6 +62,9 @@ INSERT INTO biblio.record_entry (marc, last_xact_id) \i transactions.sql \i neg_bal_custom_transactions.sql +-- funds, orders, etc. +\i acq.sql + -- clean up the env \i env_destroy.sql -- 2.11.0