1 package OpenILS::Application::Cat::AssetCommon;
2 use strict; use warnings;
3 use OpenILS::Application::Cat::BibCommon;
4 use OpenILS::Utils::CStoreEditor q/:funcs/;
5 use OpenSRF::Utils::Logger qw($logger);
6 use OpenILS::Application::Cat::Merge;
7 use OpenILS::Application::AppUtils;
8 use OpenILS::Utils::Fieldmapper;
9 use OpenILS::Const qw/:const/;
10 use OpenSRF::AppSession;
12 use OpenILS::Utils::Penalty;
13 use OpenILS::Application::Circ::CircCommon;
14 my $U = 'OpenILS::Application::AppUtils';
17 # ---------------------------------------------------------------------------
18 # Shared copy mangling code. Do not publish methods from here.
19 # ---------------------------------------------------------------------------
21 sub org_cannot_have_vols {
22 my($class, $e, $org_id) = @_;
23 my $org = $e->retrieve_actor_org_unit([
26 flesh_fields => {aou => ['ou_type']}
27 }]) or return $e->event;
29 return OpenILS::Event->new('ORG_CANNOT_HAVE_VOLS')
30 unless $U->is_true($org->ou_type->can_have_vols);
39 if(defined $copy->price) {
40 my $p = $copy->price || 0;
45 my $d = $copy->deposit_amount || 0;
47 $copy->deposit_amount($d);
51 my($class, $editor, $vol, $copy) = @_;
53 my $existing = $editor->search_asset_copy(
54 { barcode => $copy->barcode, deleted => 'f' } );
56 return OpenILS::Event->new('ITEM_BARCODE_EXISTS') if @$existing;
58 my $copy_loc = $editor->search_asset_copy_location(
59 { id => $copy->location, deleted => 'f' } );
61 return OpenILS::Event->new('COPY_LOCATION_NOT_FOUND') unless @$copy_loc;
63 # see if the volume this copy references is marked as deleted
64 return OpenILS::Event->new('VOLUME_DELETED', vol => $vol->id)
65 if $U->is_true($vol->deleted);
68 my $org = (ref $copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
69 return $evt if ($evt = $class->org_cannot_have_vols($editor, $org));
72 $copy->editor($editor->requestor->id);
73 $copy->creator($editor->requestor->id);
74 $copy->create_date('now');
75 $copy->call_number($vol->id);
76 $class->fix_copy_price($copy);
78 $editor->create_asset_copy($copy) or return $editor->die_event;
83 # 'delete_stats' is somewhat of a misnomer. With no flags set, this method
84 # still deletes any existing maps not represented in $copy->stat_cat_entries,
85 # but aborts when $copy->stat_cat_entries is empty or undefined. If
86 # 'delete_stats' is true, this method will delete all the maps when
87 # $copy->stat_cat_entries is empty or undefined.
89 # The 'add_or_update_only' flag is more straightforward. It adds missing
90 # maps, updates present maps with any new values, and leaves the rest
92 sub update_copy_stat_entries {
93 my($class, $editor, $copy, $delete_stats, $add_or_update_only) = @_;
95 return undef if $copy->isdeleted;
96 return undef unless $copy->ischanged or $copy->isnew;
99 my $entries = $copy->stat_cat_entries;
101 if( $delete_stats ) {
102 $entries = ($entries and @$entries) ? $entries : [];
104 return undef unless ($entries and @$entries);
107 my $maps = $editor->search_asset_stat_cat_entry_copy_map({owning_copy=>$copy->id});
110 # if there is no stat cat entry on the copy who's id matches the
111 # current map's id, remove the map from the database
112 for my $map (@$maps) {
113 if (!$add_or_update_only) {
114 if(! grep { $_->id == $map->stat_cat_entry } @$entries ) {
116 $logger->info("copy update found stale ".
117 "stat cat entry map ".$map->id. " on copy ".$copy->id);
119 $editor->delete_asset_stat_cat_entry_copy_map($map)
120 or return $editor->event;
123 if( grep { $_->stat_cat == $map->stat_cat and $_->id != $map->stat_cat_entry } @$entries ) {
125 $logger->info("copy update found ".
126 "stat cat entry map ".$map->id. " needing update on copy ".$copy->id);
128 $editor->delete_asset_stat_cat_entry_copy_map($map)
129 or return $editor->event;
135 # go through the stat cat update/create process
136 for my $entry (@$entries) {
139 # if this link already exists in the DB, don't attempt to re-create it
140 next if( grep{$_->stat_cat_entry == $entry->id} @$maps );
142 my $new_map = Fieldmapper::asset::stat_cat_entry_copy_map->new();
144 my $sc = ref($entry->stat_cat) ? $entry->stat_cat->id : $entry->stat_cat;
146 $new_map->stat_cat( $sc );
147 $new_map->stat_cat_entry( $entry->id );
148 $new_map->owning_copy( $copy->id );
150 $editor->create_asset_stat_cat_entry_copy_map($new_map)
151 or return $editor->event;
153 $logger->info("copy update created new stat cat entry map ".$editor->data);
159 # if 'delete_maps' is true, the copy->parts data is treated as the
160 # authoritative list for the copy. existing part maps not targeting
161 # these parts will be deleted from the DB
162 sub update_copy_parts {
163 my($class, $editor, $copy, $delete_maps) = @_;
165 return undef if $copy->isdeleted;
166 return undef unless $copy->ischanged or $copy->isnew;
169 my $incoming_parts = $copy->parts;
172 $incoming_parts = ($incoming_parts and @$incoming_parts) ? $incoming_parts : [];
174 return undef unless ($incoming_parts and @$incoming_parts);
177 my $maps = $editor->search_asset_copy_part_map({target_copy=>$copy->id});
180 # if there is no part map on the copy who's id matches the
181 # current map's id, remove the map from the database
182 for my $map (@$maps) {
183 if(! grep { $_->id == $map->part } @$incoming_parts ) {
185 $logger->info("copy update found stale ".
186 "monographic part map ".$map->id. " on copy ".$copy->id);
188 $editor->delete_asset_copy_part_map($map)
189 or return $editor->event;
194 # go through the part map update/create process
195 for my $incoming_part (@$incoming_parts) {
196 next unless $incoming_part;
198 # if this link already exists in the DB, don't attempt to re-create it
199 next if( grep{$_->part == $incoming_part->id} @$maps );
201 my $new_map = Fieldmapper::asset::copy_part_map->new();
203 $new_map->part( $incoming_part->id );
204 $new_map->target_copy( $copy->id );
206 $editor->create_asset_copy_part_map($new_map)
207 or return $editor->event;
209 $logger->info("copy update created new monographic part copy map ".$editor->data);
218 my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib) = @_;
220 $override = { all => 1 } if($override && !ref $override);
221 $override = { all => 0 } if(!ref $override);
223 # Duplicated check from create_copy in case a copy template with a deleted location is applied later
224 my $copy_loc = $editor->search_asset_copy_location(
225 { id => $copy->location, deleted => 'f' } );
227 return OpenILS::Event->new('COPY_LOCATION_NOT_FOUND') unless @$copy_loc;
230 my $org = (ref $copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
231 return $evt if ( $evt = $class->org_cannot_have_vols($editor, $org) );
233 $logger->info("vol-update: updating copy ".$copy->id);
234 my $orig_copy = $editor->retrieve_asset_copy($copy->id);
236 # Call-number may have changed, find the original
237 my $orig_vol_id = $editor->json_query({select => {acp => ['call_number']}, from => 'acp', where => {id => $copy->id}});
238 my $orig_vol = $editor->retrieve_asset_call_number($orig_vol_id->[0]->{call_number});
240 $copy->editor($editor->requestor->id);
241 $copy->edit_date('now');
243 $copy->age_protect( $copy->age_protect->id )
244 if ref $copy->age_protect;
246 $class->fix_copy_price($copy);
247 $class->check_hold_retarget($editor, $copy, $orig_copy, $retarget_holds);
249 return $editor->event unless $editor->update_asset_copy($copy);
250 return $class->remove_empty_objects($editor, $override, $orig_vol, $force_delete_empty_bib);
253 sub check_hold_retarget {
254 my($class, $editor, $copy, $orig_copy, $retarget_holds) = @_;
255 return unless $retarget_holds;
257 if( !($copy->isdeleted or $U->is_true($copy->deleted)) ) {
258 # see if a status change warrants a retarget
260 $orig_copy = $editor->retrieve_asset_copy($copy->id) unless $orig_copy;
262 if($orig_copy->status == $copy->status) {
263 # no status change, no retarget
267 my $stat = $editor->retrieve_config_copy_status($copy->status);
269 # new status is holdable, no retarget. Later add logic to find potential
270 # holds and retarget those to pick up the newly available copy
271 return if $U->is_true($stat->holdable);
274 my $hold_ids = $editor->search_action_hold_request(
275 { current_copy => $copy->id,
276 cancel_time => undef,
277 fulfillment_time => undef
281 push(@$retarget_holds, @$hold_ids);
285 # this does the actual work
286 sub update_fleshed_copies {
287 my($class, $editor, $override, $vol, $copies, $delete_stats, $retarget_holds, $force_delete_empty_bib) = @_;
289 $override = { all => 1 } if($override && !ref $override);
290 $override = { all => 0 } if(!ref $override);
293 my $fetchvol = ($vol) ? 0 : 1;
296 $cache{$vol->id} = $vol if $vol;
298 for my $copy (@$copies) {
300 my $copyid = $copy->id;
301 $logger->info("vol-update: inspecting copy $copyid");
303 if( !($vol = $cache{$copy->call_number}) ) {
304 $vol = $cache{$copy->call_number} =
305 $editor->retrieve_asset_call_number($copy->call_number);
306 return $editor->event unless $vol;
309 return $editor->event unless
310 $editor->allowed('UPDATE_COPY', $class->copy_perm_org($vol, $copy));
312 $copy->editor($editor->requestor->id);
313 $copy->edit_date('now');
315 $copy->status( $copy->status->id ) if ref($copy->status);
316 $copy->location( $copy->location->id ) if ref($copy->location);
317 $copy->circ_lib( $copy->circ_lib->id ) if ref($copy->circ_lib);
319 my $sc_entries = $copy->stat_cat_entries;
320 $copy->clear_stat_cat_entries;
322 my $parts = $copy->parts;
325 if( $copy->isdeleted ) {
326 $evt = $class->delete_copy($editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib);
329 } elsif( $copy->isnew ) {
330 $evt = $class->create_copy( $editor, $vol, $copy );
333 } elsif( $copy->ischanged ) {
335 $evt = $class->update_copy( $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib);
339 $copy->stat_cat_entries( $sc_entries );
340 $evt = $class->update_copy_stat_entries($editor, $copy, $delete_stats);
341 $copy->parts( $parts );
342 # probably okay to use $delete_stats here for simplicity
343 $evt = $class->update_copy_parts($editor, $copy, $delete_stats);
347 $logger->debug("vol-update: done updating copy batch");
354 my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib, $skip_empty_cleanup) = @_;
356 return $editor->event unless
357 $editor->allowed('DELETE_COPY', $class->copy_perm_org($vol, $copy));
359 $override = { all => 1 } if($override && !ref $override);
360 $override = { all => 0 } if(!ref $override);
362 my $stat = $U->copy_status($copy->status);
363 if ($U->is_true($stat->restrict_copy_delete)) {
364 if ($override->{all} || grep { $_ eq 'COPY_DELETE_WARNING' } @{$override->{events}}) {
365 return $editor->event unless $editor->allowed('COPY_DELETE_WARNING.override', $class->copy_perm_org($vol, $copy))
367 return OpenILS::Event->new('COPY_DELETE_WARNING', payload => $copy->id )
371 $logger->info("vol-update: deleting copy ".$copy->id);
374 $copy->editor($editor->requestor->id);
375 $copy->edit_date('now');
376 $editor->update_asset_copy($copy) or return $editor->event;
378 # Delete any open transits for this copy
379 my $transits = $editor->search_action_transit_copy(
380 { target_copy=>$copy->id, dest_recv_time => undef } );
382 for my $t (@$transits) {
383 $editor->delete_action_transit_copy($t)
384 or return $editor->event;
387 my $evt = $class->cancel_copy_holds($editor, $copy);
390 $class->check_hold_retarget($editor, $copy, undef, $retarget_holds);
392 return undef if $skip_empty_cleanup;
394 return $class->remove_empty_objects($editor, $override, $vol, $force_delete_empty_bib);
398 # deletes all holds that specifically target the deleted copy
399 sub cancel_copy_holds {
400 my($class, $editor, $copy) = @_;
402 my $holds = $editor->search_action_hold_request({
404 hold_type => [qw/C R F/],
405 cancel_time => undef,
406 fulfillment_time => undef
409 return $class->cancel_hold_list($editor, $holds);
412 # deletes all holds that specifically target the deleted volume
413 sub cancel_volume_holds {
414 my($class, $editor, $volume) = @_;
416 my $holds = $editor->search_action_hold_request({
417 target => $volume->id,
419 cancel_time => undef,
420 fulfillment_time => undef
423 return $class->cancel_hold_list($editor, $holds);
426 sub cancel_hold_list {
427 my($class, $editor, $holds) = @_;
429 for my $hold (@$holds) {
431 $hold->cancel_time('now');
432 $hold->cancel_cause(1); # un-targeted expiration. Do we need an alternate "target deleted" cause?
433 $editor->update_action_hold_request($hold) or return $editor->die_event;
435 # tell A/T the hold was cancelled. Don't wait for a response..
436 my $at_ses = OpenSRF::AppSession->create('open-ils.trigger');
438 'open-ils.trigger.event.autocreate',
439 'hold_request.cancel.expire_no_target',
440 $hold, $hold->pickup_lib);
449 my($class, $override, $editor, $vol) = @_;
452 return $evt if ( $evt = $class->org_cannot_have_vols($editor, $vol->owning_lib) );
454 $override = { all => 1 } if($override && !ref $override);
455 $override = { all => 0 } if(!ref $override);
457 # see if the record this volume references is marked as deleted
458 my $rec = $editor->retrieve_biblio_record_entry($vol->record)
459 or return $editor->die_event;
460 return OpenILS::Event->new('BIB_RECORD_DELETED', rec => $rec->id)
461 if $U->is_true($rec->deleted);
463 # first lets see if there are any collisions
464 my $vols = $editor->search_asset_call_number( {
465 owning_lib => $vol->owning_lib,
466 record => $vol->record,
467 label => $vol->label,
468 prefix => $vol->prefix,
469 suffix => $vol->suffix,
476 # we've found an exising volume
477 if($override->{all} || grep { $_ eq 'VOLUME_LABEL_EXISTS' } @{$override->{events}}) {
478 $label = $vol->label;
480 return OpenILS::Event->new(
481 'VOLUME_LABEL_EXISTS', payload => $vol->id);
485 # create a temp label so we can create the new volume,
486 # then de-dup it with the existing volume
487 $vol->label( "__SYSTEM_TMP_$$".time) if $label;
489 $vol->creator($editor->requestor->id);
490 $vol->create_date('now');
491 $vol->editor($editor->requestor->id);
492 $vol->edit_date('now');
495 $editor->create_asset_call_number($vol) or return $editor->die_event;
498 # now restore the label and merge into the existing record
501 OpenILS::Application::Cat::Merge::merge_volumes($editor, [$vol], $$vols[0]);
508 # returns the volume if it exists
510 my($class, $e, $rec_id, $label, $owning_lib, $prefix, $suffix) = @_;
511 return $e->search_asset_call_number(
512 {label => $label, record => $rec_id, owning_lib => $owning_lib, deleted => 'f', prefix => $prefix, suffix => $suffix})->[0];
515 sub find_or_create_volume {
516 my($class, $e, $label, $record_id, $org_id, $prefix, $suffix, $label_class) = @_;
523 if($record_id == OILS_PRECAT_RECORD) {
524 $vol = $e->retrieve_asset_call_number(OILS_PRECAT_CALL_NUMBER)
525 or return (undef, $e->die_event);
528 $vol = $class->volume_exists($e, $record_id, $label, $org_id, $prefix, $suffix);
531 # If the volume exists, return the ID
532 return ($vol, undef, 1) if $vol;
534 # -----------------------------------------------------------------
535 # Otherwise, create a new volume with the given attributes
536 # -----------------------------------------------------------------
537 return (undef, $e->die_event) unless $e->allowed('UPDATE_VOLUME', $org_id);
539 $vol = Fieldmapper::asset::call_number->new;
540 $vol->owning_lib($org_id);
541 $vol->label_class($label_class) if ($label_class);
543 $vol->prefix($prefix);
544 $vol->suffix($suffix);
545 $vol->record($record_id);
547 my $evt = $class->create_volume(0, $e, $vol);
548 return (undef, $evt) if $evt;
554 sub create_copy_note {
555 my($class, $e, $copy, $title, $value, $pub) = @_;
556 my $note = Fieldmapper::asset::copy_note->new;
557 $note->owning_copy($copy->id);
558 $note->creator($e->requestor->id);
559 $note->pub($pub ? 't' : 'f');
560 $note->value($value);
561 $note->title($title);
562 $e->create_asset_copy_note($note) or return $e->die_event;
567 sub remove_empty_objects {
568 my($class, $editor, $override, $vol, $force_delete_empty_bib) = @_;
570 $override = { all => 1 } if($override && !ref $override);
571 $override = { all => 0 } if(!ref $override);
573 my $koe = $U->ou_ancestor_setting_value(
574 $editor->requestor->ws_ou, 'cat.bib.keep_on_empty', $editor);
575 my $aoe = $U->ou_ancestor_setting_value(
576 $editor->requestor->ws_ou, 'cat.bib.alert_on_empty', $editor);
578 if( OpenILS::Application::Cat::BibCommon->title_is_empty($editor, $vol->record, $vol->id) ) {
580 # delete this volume if it's not already marked as deleted
581 unless( $U->is_true($vol->deleted) || $vol->isdeleted ) {
582 my $evt = $class->delete_volume($editor, $vol, $override, 0, 1);
586 return OpenILS::Event->new('TITLE_LAST_COPY', payload => $vol->record )
587 if $aoe and not ($override->{all} || grep { $_ eq 'TITLE_LAST_COPY' } @{$override->{events}}) and not $force_delete_empty_bib;
589 unless($koe and not $force_delete_empty_bib) {
590 # delete the bib record if the keep-on-empty setting is not set (and we're not otherwise forcing things, say through acq settings)
591 my $evt = OpenILS::Application::Cat::BibCommon->delete_rec($editor, $vol->record);
597 # this may be the last copy attached to the volume.
599 if($U->ou_ancestor_setting_value(
600 $editor->requestor->ws_ou, 'cat.volume.delete_on_empty', $editor)) {
602 # if this volume is "empty" and not mid-delete, delete it.
603 unless($U->is_true($vol->deleted) || $vol->isdeleted) {
605 my $copies = $editor->search_asset_copy(
606 [{call_number => $vol->id, deleted => 'f'}, {limit => 1}], {idlist => 1});
609 my $evt = $class->delete_volume($editor, $vol, $override, 0, 1);
619 # Deletes a volume. Returns undef on success, event on error
620 # force : deletes all attached copies
621 # skip_copy_check : assumes caller has verified no copies need deleting first
623 my($class, $editor, $vol, $override, $delete_copies, $skip_copy_checks) = @_;
626 unless($skip_copy_checks) {
627 my $cs = $editor->search_asset_copy(
628 [{call_number => $vol->id, deleted => 'f'}, {limit => 1}], {idlist => 1});
630 return OpenILS::Event->new('VOLUME_NOT_EMPTY', payload => $vol->id)
631 if @$cs and !$delete_copies;
633 my $copies = $editor->search_asset_copy({call_number => $vol->id, deleted => 'f'});
635 for my $copy (@$copies) {
636 $evt = $class->delete_copy($editor, $override, $vol, $copy, 0, 0, 1);
642 $vol->edit_date('now');
643 $vol->editor($editor->requestor->id);
644 $editor->update_asset_call_number($vol) or return $editor->die_event;
646 $evt = $class->cancel_volume_holds($editor, $vol);
649 # handle the case where this is the last volume on the record
650 return $class->remove_empty_objects($editor, $override, $vol);
655 my($class, $vol, $copy) = @_;
656 my $org = $vol->owning_lib;
657 if( $vol->id == OILS_PRECAT_CALL_NUMBER ) {
658 $org = ref($copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
660 $logger->debug("using copy perm org $org");
666 my ($class, $e, $copy_id) = @_;
668 return $class->set_item_lost_or_lod(
670 perm => 'SET_CIRC_LOST',
671 status => OILS_COPY_STATUS_LOST,
672 ous_proc_fee => OILS_SETTING_LOST_PROCESSING_FEE,
673 ous_void_od => OILS_SETTING_VOID_OVERDUE_ON_LOST,
676 bill_note => 'Lost Materials',
677 bill_fee_note => 'Lost Materials Processing Fee',
678 event => 'COPY_MARKED_LOST',
679 stop_fines => OILS_STOP_FINES_LOST,
684 sub set_item_long_overdue {
685 my ($class, $e, $copy_id) = @_;
687 return $class->set_item_lost_or_lod(
689 perm => 'SET_CIRC_LONG_OVERDUE',
690 status => 16, # Long Overdue
691 ous_proc_fee => 'circ.longoverdue_materials_processing_fee',
692 ous_void_od => 'circ.void_overdue_on_longoverdue',
695 bill_note => 'Long Overdue Materials',
696 bill_fee_note => 'Long Overdue Materials Processing Fee',
697 event => 'COPY_MARKED_LONG_OVERDUE',
698 stop_fines => 'LONGOVERDUE',
699 at_hook => 'longoverdue'
703 # LOST or LONGOVERDUE
704 # basic process is the same. details change.
705 sub set_item_lost_or_lod {
706 my ($class, $e, $copy_id, %args) = @_;
708 my $copy = $e->retrieve_asset_copy([
710 {flesh => 1, flesh_fields => {'acp' => ['call_number']}}])
711 or return $e->die_event;
714 ($copy->call_number->id == OILS_PRECAT_CALL_NUMBER) ?
715 $copy->circ_lib : $copy->call_number->owning_lib;
717 my $circ = $e->search_action_circulation(
718 {checkin_time => undef, target_copy => $copy->id} )->[0]
719 or return $e->die_event;
721 $e->allowed($args{perm}, $circ->circ_lib) or return $e->die_event;
723 return $e->die_event(OpenILS::Event->new($args{event}))
724 if $copy->status == $args{status};
726 # ---------------------------------------------------------------------
727 # fetch the related org settings
728 my $proc_fee = $U->ou_ancestor_setting_value(
729 $owning_lib, $args{ous_proc_fee}, $e) || 0;
730 my $void_overdue = $U->ou_ancestor_setting_value(
731 $owning_lib, $args{ous_void_od}, $e) || 0;
733 # ---------------------------------------------------------------------
734 # move the copy into LOST status
735 $copy->status($args{status});
736 $copy->editor($e->requestor->id);
737 $copy->edit_date('now');
738 $e->update_asset_copy($copy) or return $e->die_event;
740 my $price = $U->get_copy_price($e, $copy, $copy->call_number);
743 my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e,
744 $price, $args{bill_type}, $args{bill_note}, $circ->id);
748 # ---------------------------------------------------------------------
749 # if there is a processing fee, charge that too
750 if( $proc_fee > 0 ) {
751 my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e,
752 $proc_fee, $args{bill_fee_type}, $args{bill_fee_note}, $circ->id);
756 # ---------------------------------------------------------------------
757 # mark the circ as lost and stop the fines
758 $circ->stop_fines($args{stop_fines});
759 $circ->stop_fines_time('now') unless $circ->stop_fines_time;
760 $e->update_action_circulation($circ) or return $e->die_event;
762 # ---------------------------------------------------------------------
763 # zero out overdue fines on this circ if configured
764 if( $void_overdue ) {
765 my $evt = OpenILS::Application::Circ::CircCommon->void_or_zero_overdues($e, $circ, {force_zero => 1});
769 my $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($e, $circ->id);
772 my $ses = OpenSRF::AppSession->create('open-ils.trigger');
774 'open-ils.trigger.event.autocreate',
775 $args{at_hook}, $circ, $circ->circ_lib
778 my $evt2 = OpenILS::Utils::Penalty->calculate_penalties(
779 $e, $circ->usr, $U->xact_org($circ->id, $e));
780 return $evt2 if $evt2;