From: Bill Erickson Date: Fri, 10 Jan 2014 20:51:52 +0000 (-0500) Subject: ACQ : apply default owning_lib value to batched copies X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Facq-batch-update-default-owning-lib;p=working%2FEvergreen.git ACQ : apply default owning_lib value to batched copies Copies created/edited via batch update (PO interface) are now given a default owning lib of the PO ordering agency. If the lineitem has no PO (which is not currently a possible series of events), the picklist org unit is used instead. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem/BatchUpdate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem/BatchUpdate.pm index a12052ca3d..0633b64ecc 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem/BatchUpdate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem/BatchUpdate.pm @@ -291,6 +291,7 @@ sub lineitem_batch_update_impl { my $starting_use_count = $dist_formula ? $dist_formula->use_count : undef; + my $li_owner; # cache to avoid repeat lookups on the same lineitem for (my $i = 0; $i < scalar @{$jub->lineitem_details}; $i++) { my $lid = $jub->lineitem_details->[$i]; @@ -331,6 +332,17 @@ sub lineitem_batch_update_impl { my $method = ($lid->isnew ? "create" : "update") . "_acq_lineitem_detail"; + # Apply a default owning_lib to affected LIDs as needed. + if (!$lid->owning_lib) { + if (!$li_owner) { + $li_owner = ($jub->purchase_order) ? + $e->retrieve_acq_purchase_order( + $jub->purchase_order)->ordering_agency : + $e->retrieve_acq_picklist($jub->picklist)->org_unit; + } + $lid->owning_lib($li_owner); + } + if ($fund_changed) { # handle_changed_lid updates any existing fund debits # linked to the LID to use the new fund. If the fund