--- /dev/null
+--Insert in four more activity types (Payment, Checkin, Checkout, Hold Request).
+--Default Activity Types use up the first 24 of the 1000 reserved IDs.
+INSERT INTO config.usr_activity_type (ewhat, egroup, label)
+VALUES
+('payment' ,'circ', 'Payment'),
+('checkin' ,'circ', 'Check in'),
+('checkout' ,'circ', 'Check out'),
+('hold' ,'hold' , 'Hold Request')
+;
+
+
+-- Change constraint to 'cascade' on delete, rather than 'no action'
+-- For easier rollback of activities
+
+ALTER TABLE actor.usr_activity
+ DROP CONSTRAINT usr_activity_etype_fkey;
+
+ALTER TABLE actor.usr_activity
+ ADD CONSTRAINT usr_activity_etype_fkey FOREIGN KEY (etype)
+ REFERENCES config.usr_activity_type (id) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE CASCADE;
+
--- /dev/null
+
+------- Delete added user activities -------------------------
+DELETE FROM config.usr_activity_type
+WHERE ewho IS NULL AND ehow IS NULL AND ewhat = 'payment';
+DELETE FROM config.usr_activity_type
+WHERE ewho IS NULL AND ehow IS NULL AND ewhat = 'checkin';
+DELETE FROM config.usr_activity_type
+WHERE ewho IS NULL AND ehow IS NULL AND ewhat = 'checkout';
+DELETE FROM config.usr_activity_type
+WHERE ewho IS NULL AND ehow IS NULL AND ewhat = 'hold';
+
+-------Revert constraint change------
+ALTER TABLE actor.usr_activity
+ DROP CONSTRAINT usr_activity_etype_fkey;
+
+ALTER TABLE actor.usr_activity
+ ADD CONSTRAINT usr_activity_etype_fkey FOREIGN KEY (etype)
+ REFERENCES config.usr_activity_type (id) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION;
+
return circ_events($circulator) if $circulator->bail_out;
+ my $ops = 0;
if( $api =~ /checkout\.permit/ ) {
$circulator->do_permit();
unless( $circulator->bail_out ) {
$circulator->events([]);
$circulator->do_checkout();
+ $ops = 1;
}
} elsif( $circulator->is_res_checkout ) {
} elsif( $api =~ /checkout/ ) {
$circulator->do_checkout();
+ $ops = 1;
} elsif( $circulator->is_res_checkin ) {
$circulator->do_reservation_return();
$circulator->do_checkin() if ($circulator->copy());
} elsif( $api =~ /checkin/ ) {
$circulator->do_checkin();
+ $ops = 2;
} elsif( $api =~ /renew/ ) {
$circulator->do_renew($api);
}
$circulator->editor->commit;
+
+ if($ops == 1) {
+ $U->log_user_activity($$args{patron_id}, '', 'checkout');
+ } elsif ($ops == 2) {
+ if ($circulator->circ) {
+ $U->log_user_activity($circulator->circ->usr, '', 'checkin');
+ }
+ }
}
$conn->respond_complete(circ_events($circulator));
}
}
-# ------------------------------------------------------------------
-# Lost-then-found item checked in. This sub generates new overdue
-# fines, beyond the point of any existing and possibly voided
-# overdue fines, up to the point of final checkin time (or max fine
-# amount).
-# ------------------------------------------------------------------
-sub generate_lost_overdue_fines {
- my $self = shift;
- my $circ = $self->circ;
- my $e = $self->editor;
- my $isBackDated = 0;
-
- # Re-open the transaction so the fine generator can see it
- if ($circ->checkin_time == $circ->checkin_scan_time) {
- #Check in is not backdated
- if($circ->xact_finish or $circ->stop_fines) {
- $e->xact_begin;
- $circ->clear_xact_finish;
- $circ->clear_stop_fines;
- $circ->clear_stop_fines_time;
- $e->update_action_circulation($circ) or return $e->die_event;
- $e->xact_commit;
- }
- }
- else {
- #Check in is backdated
- $isBackDated = 1;
- if($circ->xact_finish or $circ->stop_fines) {
- $e->xact_begin;
- $circ->clear_xact_finish;
- $e->update_action_circulation($circ) or return $e->die_event;
- $e->xact_commit;
- }
- }
-
- $e->xact_begin; # generate_fines expects an in-xact editor
- $self->generate_fines;
- $circ = $self->circ; # generate fines re-fetches the circ
-
- my $update = 0;
-
- # Re-close the transaction if no money is owed
- my ($obt) = $U->fetch_mbts($circ->id, $e);
- if ($obt and $obt->balance_owed == 0) {
- $circ->xact_finish('now');
- $update = 1;
- }
-
- if ($isBackDated == 1) {
- #Check in is backdated
- if($circ->xact_finish or $circ->stop_fines) {
- $circ->clear_stop_fines;
- $circ->clear_stop_fines_time;
- }
- }
-
- # Set stop fines if the fine generator didn't have to
- unless($circ->stop_fines) {
- $circ->stop_fines(OILS_STOP_FINES_CHECKIN);
- $circ->stop_fines_time('now');
- $update = 1;
- }
-
- # update the event data sent to the caller within the transaction
- $self->checkin_flesh_events;
-
- if ($update) {
- $e->update_action_circulation($circ) or return $e->die_event;
- $e->commit;
- } else {
- $e->rollback;
- }
-
- return undef;
-}
-
1;