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];
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