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, $create_parts) = @_;
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 if ($incoming_part->isnew) {
202 next unless $create_parts;
203 my $new_part = Fieldmapper::biblio::monograph_part->new();
204 $new_part->record( $incoming_part->record );
205 $new_part->label( $incoming_part->label );
206 $incoming_part = $editor->create_biblio_monograph_part($new_part)
207 or return $editor->event;
210 my $new_map = Fieldmapper::asset::copy_part_map->new();
212 $new_map->part( $incoming_part->id );
213 $new_map->target_copy( $copy->id );
215 $editor->create_asset_copy_part_map($new_map)
216 or return $editor->event;
218 $logger->info("copy update created new monographic part copy map ".$editor->data);
227 my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib) = @_;
229 $override = { all => 1 } if($override && !ref $override);
230 $override = { all => 0 } if(!ref $override);
232 # Duplicated check from create_copy in case a copy template with a deleted location is applied later
233 my $copy_loc = $editor->search_asset_copy_location(
234 { id => $copy->location, deleted => 'f' } );
236 return OpenILS::Event->new('COPY_LOCATION_NOT_FOUND') unless @$copy_loc;
239 my $org = (ref $copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
240 return $evt if ( $evt = $class->org_cannot_have_vols($editor, $org) );
242 $logger->info("vol-update: updating copy ".$copy->id);
243 my $orig_copy = $editor->retrieve_asset_copy($copy->id);
245 # Call-number may have changed, find the original
246 my $orig_vol_id = $editor->json_query({select => {acp => ['call_number']}, from => 'acp', where => {id => $copy->id}});
247 my $orig_vol = $editor->retrieve_asset_call_number($orig_vol_id->[0]->{call_number});
249 $copy->editor($editor->requestor->id);
250 $copy->edit_date('now');
252 $copy->age_protect( $copy->age_protect->id )
253 if ref $copy->age_protect;
255 $class->fix_copy_price($copy);
256 $class->check_hold_retarget($editor, $copy, $orig_copy, $retarget_holds);
258 return $editor->event unless $editor->update_asset_copy($copy);
259 return $class->remove_empty_objects($editor, $override, $orig_vol, $force_delete_empty_bib);
262 sub check_hold_retarget {
263 my($class, $editor, $copy, $orig_copy, $retarget_holds) = @_;
264 return unless $retarget_holds;
266 if( !($copy->isdeleted or $U->is_true($copy->deleted)) ) {
267 # see if a status change warrants a retarget
269 $orig_copy = $editor->retrieve_asset_copy($copy->id) unless $orig_copy;
271 if($orig_copy->status == $copy->status) {
272 # no status change, no retarget
276 my $stat = $editor->retrieve_config_copy_status($copy->status);
278 # new status is holdable, no retarget. Later add logic to find potential
279 # holds and retarget those to pick up the newly available copy
280 return if $U->is_true($stat->holdable);
283 my $hold_ids = $editor->search_action_hold_request(
284 { current_copy => $copy->id,
285 cancel_time => undef,
286 fulfillment_time => undef
290 push(@$retarget_holds, @$hold_ids);
294 # this does the actual work
295 sub update_fleshed_copies {
296 my($class, $editor, $override, $vol, $copies, $delete_stats, $retarget_holds, $force_delete_empty_bib, $create_parts) = @_;
298 $override = { all => 1 } if($override && !ref $override);
299 $override = { all => 0 } if(!ref $override);
302 my $fetchvol = ($vol) ? 0 : 1;
305 $cache{$vol->id} = $vol if $vol;
307 for my $copy (@$copies) {
309 my $copyid = $copy->id;
310 $logger->info("vol-update: inspecting copy $copyid");
312 if( !($vol = $cache{$copy->call_number}) ) {
313 $vol = $cache{$copy->call_number} =
314 $editor->retrieve_asset_call_number($copy->call_number);
315 return $editor->event unless $vol;
318 return $editor->event unless
319 $editor->allowed('UPDATE_COPY', $class->copy_perm_org($vol, $copy));
321 $copy->editor($editor->requestor->id);
322 $copy->edit_date('now');
324 $copy->status( $copy->status->id ) if ref($copy->status);
325 $copy->location( $copy->location->id ) if ref($copy->location);
326 $copy->circ_lib( $copy->circ_lib->id ) if ref($copy->circ_lib);
328 my $sc_entries = $copy->stat_cat_entries;
329 $copy->clear_stat_cat_entries;
331 my $parts = $copy->parts;
334 if( $copy->isdeleted ) {
335 $evt = $class->delete_copy($editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib);
338 } elsif( $copy->isnew ) {
339 $evt = $class->create_copy( $editor, $vol, $copy );
342 } elsif( $copy->ischanged ) {
344 $evt = $class->update_copy( $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib);
348 $copy->stat_cat_entries( $sc_entries );
349 $evt = $class->update_copy_stat_entries($editor, $copy, $delete_stats);
350 $copy->parts( $parts );
351 # probably okay to use $delete_stats here for simplicity
352 $evt = $class->update_copy_parts($editor, $copy, $delete_stats, $create_parts);
356 $logger->debug("vol-update: done updating copy batch");
363 my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib, $skip_empty_cleanup) = @_;
365 return $editor->event unless
366 $editor->allowed('DELETE_COPY', $class->copy_perm_org($vol, $copy));
368 $override = { all => 1 } if($override && !ref $override);
369 $override = { all => 0 } if(!ref $override);
371 my $stat = $U->copy_status($copy->status);
372 if ($U->is_true($stat->restrict_copy_delete)) {
373 if ($override->{all} || grep { $_ eq 'COPY_DELETE_WARNING' } @{$override->{events}}) {
374 return $editor->event unless $editor->allowed('COPY_DELETE_WARNING.override', $class->copy_perm_org($vol, $copy))
376 return OpenILS::Event->new('COPY_DELETE_WARNING', payload => $copy->id )
380 $logger->info("vol-update: deleting copy ".$copy->id);
383 $copy->editor($editor->requestor->id);
384 $copy->edit_date('now');
385 $editor->update_asset_copy($copy) or return $editor->event;
387 # Delete any open transits for this copy
388 my $transits = $editor->search_action_transit_copy(
389 { target_copy=>$copy->id, dest_recv_time => undef } );
391 for my $t (@$transits) {
392 $editor->delete_action_transit_copy($t)
393 or return $editor->event;
396 my $evt = $class->cancel_copy_holds($editor, $copy);
399 $class->check_hold_retarget($editor, $copy, undef, $retarget_holds);
401 return undef if $skip_empty_cleanup;
403 return $class->remove_empty_objects($editor, $override, $vol, $force_delete_empty_bib);
407 # deletes all holds that specifically target the deleted copy
408 sub cancel_copy_holds {
409 my($class, $editor, $copy) = @_;
411 my $holds = $editor->search_action_hold_request({
413 hold_type => [qw/C R F/],
414 cancel_time => undef,
415 fulfillment_time => undef
418 return $class->cancel_hold_list($editor, $holds);
421 # deletes all holds that specifically target the deleted volume
422 sub cancel_volume_holds {
423 my($class, $editor, $volume) = @_;
425 my $holds = $editor->search_action_hold_request({
426 target => $volume->id,
428 cancel_time => undef,
429 fulfillment_time => undef
432 return $class->cancel_hold_list($editor, $holds);
435 sub cancel_hold_list {
436 my($class, $editor, $holds) = @_;
438 for my $hold (@$holds) {
440 $hold->cancel_time('now');
441 $hold->cancel_cause(1); # un-targeted expiration. Do we need an alternate "target deleted" cause?
442 $editor->update_action_hold_request($hold) or return $editor->die_event;
444 # tell A/T the hold was cancelled. Don't wait for a response..
445 my $at_ses = OpenSRF::AppSession->create('open-ils.trigger');
447 'open-ils.trigger.event.autocreate',
448 'hold_request.cancel.expire_no_target',
449 $hold, $hold->pickup_lib);
458 my($class, $override, $editor, $vol) = @_;
461 return $evt if ( $evt = $class->org_cannot_have_vols($editor, $vol->owning_lib) );
463 $override = { all => 1 } if($override && !ref $override);
464 $override = { all => 0 } if(!ref $override);
466 # see if the record this volume references is marked as deleted
467 my $rec = $editor->retrieve_biblio_record_entry($vol->record)
468 or return $editor->die_event;
469 return OpenILS::Event->new('BIB_RECORD_DELETED', rec => $rec->id)
470 if $U->is_true($rec->deleted);
472 # first lets see if there are any collisions
473 my $vols = $editor->search_asset_call_number( {
474 owning_lib => $vol->owning_lib,
475 record => $vol->record,
476 label => $vol->label,
477 prefix => $vol->prefix,
478 suffix => $vol->suffix,
485 # we've found an exising volume
486 if($override->{all} || grep { $_ eq 'VOLUME_LABEL_EXISTS' } @{$override->{events}}) {
487 $label = $vol->label;
489 return OpenILS::Event->new(
490 'VOLUME_LABEL_EXISTS', payload => $vol->id);
494 # create a temp label so we can create the new volume,
495 # then de-dup it with the existing volume
496 $vol->label( "__SYSTEM_TMP_$$".time) if $label;
498 $vol->creator($editor->requestor->id);
499 $vol->create_date('now');
500 $vol->editor($editor->requestor->id);
501 $vol->edit_date('now');
504 $editor->create_asset_call_number($vol) or return $editor->die_event;
507 # now restore the label and merge into the existing record
510 OpenILS::Application::Cat::Merge::merge_volumes($editor, [$vol], $$vols[0]);
517 # returns the volume if it exists
519 my($class, $e, $rec_id, $label, $owning_lib, $prefix, $suffix) = @_;
520 return $e->search_asset_call_number(
521 {label => $label, record => $rec_id, owning_lib => $owning_lib, deleted => 'f', prefix => $prefix, suffix => $suffix})->[0];
524 sub find_or_create_volume {
525 my($class, $e, $label, $record_id, $org_id, $prefix, $suffix, $label_class) = @_;
532 if($record_id == OILS_PRECAT_RECORD) {
533 $vol = $e->retrieve_asset_call_number(OILS_PRECAT_CALL_NUMBER)
534 or return (undef, $e->die_event);
537 $vol = $class->volume_exists($e, $record_id, $label, $org_id, $prefix, $suffix);
540 # If the volume exists, return the ID
541 return ($vol, undef, 1) if $vol;
543 # -----------------------------------------------------------------
544 # Otherwise, create a new volume with the given attributes
545 # -----------------------------------------------------------------
546 return (undef, $e->die_event) unless $e->allowed('UPDATE_VOLUME', $org_id);
548 $vol = Fieldmapper::asset::call_number->new;
549 $vol->owning_lib($org_id);
550 $vol->label_class($label_class) if ($label_class);
552 $vol->prefix($prefix);
553 $vol->suffix($suffix);
554 $vol->record($record_id);
556 my $evt = $class->create_volume(0, $e, $vol);
557 return (undef, $evt) if $evt;
563 sub create_copy_note {
564 my($class, $e, $copy, $title, $value, $pub) = @_;
565 my $note = Fieldmapper::asset::copy_note->new;
566 $note->owning_copy($copy->id);
567 $note->creator($e->requestor->id);
568 $note->pub($pub ? 't' : 'f');
569 $note->value($value);
570 $note->title($title);
571 $e->create_asset_copy_note($note) or return $e->die_event;
576 sub remove_empty_objects {
577 my($class, $editor, $override, $vol, $force_delete_empty_bib) = @_;
579 $override = { all => 1 } if($override && !ref $override);
580 $override = { all => 0 } if(!ref $override);
582 my $koe = $U->ou_ancestor_setting_value(
583 $editor->requestor->ws_ou, 'cat.bib.keep_on_empty', $editor);
584 my $aoe = $U->ou_ancestor_setting_value(
585 $editor->requestor->ws_ou, 'cat.bib.alert_on_empty', $editor);
587 if( OpenILS::Application::Cat::BibCommon->title_is_empty($editor, $vol->record, $vol->id) ) {
589 # delete this volume if it's not already marked as deleted
590 unless( $U->is_true($vol->deleted) || $vol->isdeleted ) {
591 my $evt = $class->delete_volume($editor, $vol, $override, 0, 1);
595 return OpenILS::Event->new('TITLE_LAST_COPY', payload => $vol->record )
596 if $aoe and not ($override->{all} || grep { $_ eq 'TITLE_LAST_COPY' } @{$override->{events}}) and not $force_delete_empty_bib;
598 unless($koe and not $force_delete_empty_bib) {
599 # delete the bib record if the keep-on-empty setting is not set (and we're not otherwise forcing things, say through acq settings)
600 my $evt = OpenILS::Application::Cat::BibCommon->delete_rec($editor, $vol->record);
606 # this may be the last copy attached to the volume.
608 if($U->ou_ancestor_setting_value(
609 $editor->requestor->ws_ou, 'cat.volume.delete_on_empty', $editor)) {
611 # if this volume is "empty" and not mid-delete, delete it.
612 unless($U->is_true($vol->deleted) || $vol->isdeleted) {
614 my $copies = $editor->search_asset_copy(
615 [{call_number => $vol->id, deleted => 'f'}, {limit => 1}], {idlist => 1});
618 my $evt = $class->delete_volume($editor, $vol, $override, 0, 1);
628 # Deletes a volume. Returns undef on success, event on error
629 # force : deletes all attached copies
630 # skip_copy_check : assumes caller has verified no copies need deleting first
632 my($class, $editor, $vol, $override, $delete_copies, $skip_copy_checks) = @_;
635 unless($skip_copy_checks) {
636 my $cs = $editor->search_asset_copy(
637 [{call_number => $vol->id, deleted => 'f'}, {limit => 1}], {idlist => 1});
639 return OpenILS::Event->new('VOLUME_NOT_EMPTY', payload => $vol->id)
640 if @$cs and !$delete_copies;
642 my $copies = $editor->search_asset_copy({call_number => $vol->id, deleted => 'f'});
644 for my $copy (@$copies) {
645 $evt = $class->delete_copy($editor, $override, $vol, $copy, 0, 0, 1);
651 $vol->edit_date('now');
652 $vol->editor($editor->requestor->id);
653 $editor->update_asset_call_number($vol) or return $editor->die_event;
655 $evt = $class->cancel_volume_holds($editor, $vol);
658 # handle the case where this is the last volume on the record
659 return $class->remove_empty_objects($editor, $override, $vol);
664 my($class, $vol, $copy) = @_;
665 my $org = $vol->owning_lib;
666 if( $vol->id == OILS_PRECAT_CALL_NUMBER ) {
667 $org = ref($copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
669 $logger->debug("using copy perm org $org");
675 my ($class, $e, $copy_id) = @_;
677 return $class->set_item_lost_or_lod(
679 perm => 'SET_CIRC_LOST',
680 status => OILS_COPY_STATUS_LOST,
681 ous_proc_fee => OILS_SETTING_LOST_PROCESSING_FEE,
682 ous_void_od => OILS_SETTING_VOID_OVERDUE_ON_LOST,
685 bill_note => 'Lost Materials',
686 bill_fee_note => 'Lost Materials Processing Fee',
687 event => 'COPY_MARKED_LOST',
688 stop_fines => OILS_STOP_FINES_LOST,
693 sub set_item_long_overdue {
694 my ($class, $e, $copy_id) = @_;
696 return $class->set_item_lost_or_lod(
698 perm => 'SET_CIRC_LONG_OVERDUE',
699 status => 16, # Long Overdue
700 ous_proc_fee => 'circ.longoverdue_materials_processing_fee',
701 ous_void_od => 'circ.void_overdue_on_longoverdue',
704 bill_note => 'Long Overdue Materials',
705 bill_fee_note => 'Long Overdue Materials Processing Fee',
706 event => 'COPY_MARKED_LONG_OVERDUE',
707 stop_fines => 'LONGOVERDUE',
708 at_hook => 'longoverdue'
712 # LOST or LONGOVERDUE
713 # basic process is the same. details change.
714 sub set_item_lost_or_lod {
715 my ($class, $e, $copy_id, %args) = @_;
717 my $copy = $e->retrieve_asset_copy([
719 {flesh => 1, flesh_fields => {'acp' => ['call_number']}}])
720 or return $e->die_event;
723 ($copy->call_number->id == OILS_PRECAT_CALL_NUMBER) ?
724 $copy->circ_lib : $copy->call_number->owning_lib;
726 my $circ = $e->search_action_circulation(
727 {checkin_time => undef, target_copy => $copy->id} )->[0]
728 or return $e->die_event;
730 $e->allowed($args{perm}, $circ->circ_lib) or return $e->die_event;
732 return $e->die_event(OpenILS::Event->new($args{event}))
733 if $copy->status == $args{status};
735 # ---------------------------------------------------------------------
736 # fetch the related org settings
737 my $proc_fee = $U->ou_ancestor_setting_value(
738 $owning_lib, $args{ous_proc_fee}, $e) || 0;
739 my $void_overdue = $U->ou_ancestor_setting_value(
740 $owning_lib, $args{ous_void_od}, $e) || 0;
742 # ---------------------------------------------------------------------
743 # move the copy into LOST status
744 $copy->status($args{status});
745 $copy->editor($e->requestor->id);
746 $copy->edit_date('now');
747 $e->update_asset_copy($copy) or return $e->die_event;
749 my $price = $U->get_copy_price($e, $copy, $copy->call_number);
752 my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e,
753 $price, $args{bill_type}, $args{bill_note}, $circ->id);
757 # ---------------------------------------------------------------------
758 # if there is a processing fee, charge that too
759 if( $proc_fee > 0 ) {
760 my $evt = OpenILS::Application::Circ::CircCommon->create_bill($e,
761 $proc_fee, $args{bill_fee_type}, $args{bill_fee_note}, $circ->id);
765 # ---------------------------------------------------------------------
766 # mark the circ as lost and stop the fines
767 $circ->stop_fines($args{stop_fines});
768 $circ->stop_fines_time('now') unless $circ->stop_fines_time;
769 $e->update_action_circulation($circ) or return $e->die_event;
771 # ---------------------------------------------------------------------
772 # zero out overdue fines on this circ if configured
773 if( $void_overdue ) {
774 my $evt = OpenILS::Application::Circ::CircCommon->void_or_zero_overdues($e, $circ, {force_zero => 1});
778 my $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($e, $circ->id);
781 my $ses = OpenSRF::AppSession->create('open-ils.trigger');
783 'open-ils.trigger.event.autocreate',
784 $args{at_hook}, $circ, $circ->circ_lib
787 my $evt2 = OpenILS::Utils::Penalty->calculate_penalties(
788 $e, $circ->usr, $U->xact_org($circ->id, $e));
789 return $evt2 if $evt2;