From: Galen Charlton Date: Thu, 14 Jul 2022 16:14:36 +0000 (+0000) Subject: LP#1981714: add settings to control owning library of auto-added LIDs X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d16cbe08511032bc824e1be81618d9083a10ed53;p=working%2FEvergreen.git LP#1981714: add settings to control owning library of auto-added LIDs Previously, when line item copies/details/items where automatically created because the provider's default copy count is non-zero, the owning library of those line item copies was set to the workstation library. This patch adds two new settings to tweak this behavior: * How to set default owning library for auto-created line item items Stategy to use to set default owning library to set when line item items are auto-created because the provider's default copy count has been set. Valid values are "workstation" to use the workstation library, "blank" to leave it blank, and "use_setting" to use the "Default owning library for auto-created line item items" setting. If not set, the workstation library will be used. * Default owning library for auto-created line item items The default owning library to set when line item items are auto-created because the provider's default copy count has been set. This applies if the "How to set default owning library for auto-created line item items" setting is set to "use_setting". Signed-off-by: Galen Charlton Signed-off-by: Ruth Frasur Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Common.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Common.pm index 7b94177801..f77deb573c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Common.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Common.pm @@ -76,5 +76,26 @@ sub li_existing_copies { return $counts->[0]->{id}; } +# returns the owning library to use when auto-creating +# line item details in the case where the provider's default +# copy count is greater than zero +sub get_default_lid_owning_library { + my ($class, $e) = @_; + my $strategy = $U->ou_ancestor_setting_value($e->requestor->ws_ou, 'acq.default_owning_lib_for_auto_lids_strategy'); + if (defined $strategy) { + if ($strategy eq 'workstation') { + return $e->requestor->ws_ou; + } elsif ($strategy eq 'blank') { + return undef; + } elsif ($strategy eq 'use_setting') { + return $U->ou_ancestor_setting_value($e->requestor->ws_ou, 'acq.default_owning_lib_for_auto_lids'); + } else { + return $e->requestor->ws_ou; + } + } else { + return $e->requestor->ws_ou; + } +} +1; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm index 45d62f86c2..011d7e0936 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm @@ -75,10 +75,12 @@ sub create_lineitem { if ($po) { # apply the default number of copies for this provider + my $owning_lib = $AC->get_default_lid_owning_library($e); + $logger->warn("GMC: owning_lib => $owning_lib"); for (1 .. $po->provider->default_copy_count) { my $lid = Fieldmapper::acq::lineitem_detail->new; $lid->lineitem($li->id); - $lid->owning_lib($e->requestor->ws_ou); + $lid->owning_lib($owning_lib); $e->create_acq_lineitem_detail($lid) or return $e->die_event; } } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index e8cdf53fa0..807a2756a9 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -1964,7 +1964,8 @@ sub apply_default_copies { }, {idlist => 1} ); - + + my $owning_lib = $AC->get_default_lid_owning_library($e); for my $li_id (@$li_ids) { my $lid_ids = $e->search_acq_lineitem_detail( @@ -1976,7 +1977,7 @@ sub apply_default_copies { for (1 .. $copy_count) { create_lineitem_detail($mgr, lineitem => $li_id, - owning_lib => $e->requestor->ws_ou + owning_lib => $owning_lib ) or return 0; } } diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 51b8d70b7f..2277038377 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -3146,7 +3146,23 @@ SELECT SETVAL('acq.user_request_type_id_seq'::TEXT, 7); INSERT into config.org_unit_setting_type ( name, grp, label, description, datatype, fm_class ) VALUES -( 'acq.copy_creator_uses_receiver', 'acq', +( 'acq.default_owning_lib_for_auto_lids_strategy', 'acq', + oils_i18n_gettext('acq.default_owning_lib_for_auto_lids_strategy', + 'How to set default owning library for auto-created line item items', + 'coust', 'label'), + oils_i18n_gettext('acq.default_owning_lib_for_auto_lids_strategy', + 'Stategy to use to set default owning library to set when line item items are auto-created because the provider''s default copy count has been set. Valid values are "workstation" to use the workstation library, "blank" to leave it blank, and "use_setting" to use the "Default owning library for auto-created line item items" setting. If not set, the workstation library will be used.', + 'coust', 'description'), + 'string', null) +,( 'acq.default_owning_lib_for_auto_lids', 'acq', + oils_i18n_gettext('acq.default_owning_lib_for_auto_lids', + 'Default owning library for auto-created line item items', + 'coust', 'label'), + oils_i18n_gettext('acq.default_owning_lib_for_auto_lids', + 'The default owning library to set when line item items are auto-created because the provider''s default copy count has been set. This applies if the "How to set default owning library for auto-created line item items" setting is set to "use_setting".', + 'coust', 'description'), + 'link', 'aou') +,( 'acq.copy_creator_uses_receiver', 'acq', oils_i18n_gettext('acq.copy_creator_uses_receiver', 'Set copy creator as receiver', 'coust', 'label'), diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.lp1981714_default_lid_owning_library_setting.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.lp1981714_default_lid_owning_library_setting.sql new file mode 100644 index 0000000000..df1e3de118 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.lp1981714_default_lid_owning_library_setting.sql @@ -0,0 +1,26 @@ +BEGIN; + +--SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version); + +INSERT into config.org_unit_setting_type +( name, grp, label, description, datatype, fm_class ) VALUES + +( 'acq.default_owning_lib_for_auto_lids_strategy', 'acq', + oils_i18n_gettext('acq.default_owning_lib_for_auto_lids_strategy', + 'How to set default owning library for auto-created line item items', + 'coust', 'label'), + oils_i18n_gettext('acq.default_owning_lib_for_auto_lids_strategy', + 'Stategy to use to set default owning library to set when line item items are auto-created because the provider''s default copy count has been set. Valid values are "workstation" to use the workstation library, "blank" to leave it blank, and "use_setting" to use the "Default owning library for auto-created line item items" setting. If not set, the workstation library will be used.', + 'coust', 'description'), + 'string', null) +,( 'acq.default_owning_lib_for_auto_lids', 'acq', + oils_i18n_gettext('acq.default_owning_lib_for_auto_lids', + 'Default owning library for auto-created line item items', + 'coust', 'label'), + oils_i18n_gettext('acq.default_owning_lib_for_auto_lids', + 'The default owning library to set when line item items are auto-created because the provider''s default copy count has been set. This applies if the "How to set default owning library for auto-created line item items" setting is set to "use_setting".', + 'coust', 'description'), + 'link', 'aou') +; + +COMMIT;