Add the Lost and Paid status to config.copy_status.
Add org_unit_settig to control if the copy status is used.
Add checks to O::A::Circ::Money::make_payments to check for LOST
status and org_unit setting and change the copy status to
Lost and Paid as appropriate.
Also add checks for Lost and Paid copy status wherever LOST copy
status is used.
Add the COPY_STATUS_LOST_AND_PAID event.
Add the event to ils_events.xml with id 7026.
Check for the event in circ/util.js in the staff client.
Add pgTAP tests for the existence of the Lost and Paid copy status
and the new org_unit setting to control if it isused.
Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Rogan Hamby <rogan.hamby@gmail.com>
<event code='7025' textcode='COPY_STATUS_LONG_OVERDUE'>
<desc xml:lang="en-US">Copy is marked as long-overdue</desc>
</event>
+ <event code='7026' textcode='COPY_STATUS_LOST_AND_PAID'>
+ <desc xml:lang="en-US">Copy is marked as lost and paid</desc>
+ </event>
<!-- ================================================================ -->
my( @lost, @cr, @lo );
for my $c (@$open) {
- push( @lost, $c->id ) if $c->stop_fines eq 'LOST';
+ push( @lost, $c->id ) if ($c->stop_fines eq 'LOST');
push( @cr, $c->id ) if $c->stop_fines eq 'CLAIMSRETURNED';
push( @lo, $c->id ) if $c->stop_fines eq 'LONGOVERDUE';
}
$self->copy->circ_lib->id : $self->copy->circ_lib;
my $stat = $U->copy_status($self->copy->status)->id;
- if ($stat == OILS_COPY_STATUS_LOST) {
+ if ($stat == OILS_COPY_STATUS_LOST || $stat == OILS_COPY_STATUS_LOST_AND_PAID) {
# we will now handle lost fines, but the copy will retain its 'lost'
# status if it needs to transit home unless lost_immediately_available
# is true
return OpenILS::Event->new('COPY_STATUS_LOST', payload => $copy )
if( $status == OILS_COPY_STATUS_LOST );
+ return OpenILS::Event->new('COPY_STATUS_LOST_AND_PAID', payload => $copy)
+ if ($status == OILS_COPY_STATUS_LOST_AND_PAID);
+
return OpenILS::Event->new('COPY_STATUS_LONG_OVERDUE', payload => $copy )
if( $status == OILS_COPY_STATUS_LONG_OVERDUE );
use OpenILS::Utils::Penalty;
use Business::Stripe;
$Data::Dumper::Indent = 0;
+use OpenILS::Const qw/:const/;
sub get_processor_settings {
my $e = shift;
# credit
$cred = -$cred;
$credit += $cred;
- my $circ = $e->retrieve_action_circulation($transid);
+ my $circ = $e->retrieve_action_circulation(
+ [
+ $transid,
+ {
+ flesh => 1,
+ flesh_fields => {circ => ['target_copy','billings']}
+ }
+ ]
+ ); # Flesh the copy, so we can monkey with the status if
+ # necessary.
# Whether or not we close the transaction. We definitely
- # close is no circulation transaction is present,
+ # close if no circulation transaction is present,
# otherwise we check if the circulation is in a state that
# allows itself to be closed.
if (!$circ || OpenILS::Application::Circ::CircCommon->can_close_circ($e, $circ)) {
$payment, $cc_payload
)
}
+
+ # If we have a circ, we need to check if the copy
+ # status is lost or long overdue. If it is then we
+ # check org_unit_settings for the copy owning library
+ # and adjust and possibly adjust copy status to lost
+ # and paid.
+ if ($circ) {
+ # We need the copy to check settings and to possibly
+ # change its status.
+ my $copy = $circ->target_copy();
+ # Library where we'll check settings.
+ my $check_lib = $copy->circ_lib();
+
+ # check the copy status
+ if (($copy->status() == OILS_COPY_STATUS_LOST || $copy->status() == OILS_COPY_STATUS_LONG_OVERDUE)
+ && $U->is_true($U->ou_ancestor_setting_value($check_lib, 'circ.use_lost_paid_copy_status', $e))) {
+ $copy->status(OILS_COPY_STATUS_LOST_AND_PAID);
+ if (!$e->update_asset_copy($copy)) {
+ return _recording_failure(
+ $e, "update_asset_copy_failed()",
+ $payment, $cc_payload
+ )
+ }
+ }
+ }
}
}
my $evt;
my $hold;
- if( ($transit->copy_status == OILS_COPY_STATUS_LOST and !$e->allowed('ABORT_TRANSIT_ON_LOST')) or
+ if( (($transit->copy_status == OILS_COPY_STATUS_LOST || $transit->copy_status == OILS_COPY_STATUS_LOST_AND_PAID)
+ and !$e->allowed('ABORT_TRANSIT_ON_LOST')) or
($transit->copy_status == OILS_COPY_STATUS_MISSING and !$e->allowed('ABORT_TRANSIT_ON_MISSING')) ) {
$e->rollback;
return OpenILS::Event->new('TRANSIT_ABORT_NOT_ALLOWED', copy_status => $transit->copy_status);
econst OILS_COPY_STATUS_DAMAGED => 14;
econst OILS_COPY_STATUS_ON_RESV_SHELF => 15;
econst OILS_COPY_STATUS_LONG_OVERDUE => 16;
+econst OILS_COPY_STATUS_LOST_AND_PAID => 17;
# ---------------------------------------------------------------------
return '08' if $stat == OILS_COPY_STATUS_ON_HOLDS_SHELF;
return '09' if $stat == OILS_COPY_STATUS_RESHELVING;
return '10' if $stat == OILS_COPY_STATUS_IN_TRANSIT;
- return '12' if $stat == OILS_COPY_STATUS_LOST;
+ return '12' if ($stat == OILS_COPY_STATUS_LOST || $stat == OILS_COPY_STATUS_LOST_AND_PAID);
return '13' if $stat == OILS_COPY_STATUS_MISSING;
return '01';
INSERT INTO config.copy_status
(id, name, holdable, opac_visible, copy_active, restrict_copy_delete)
VALUES (16, oils_i18n_gettext(16, 'Long Overdue', 'ccs', 'name'), 'f', 'f', 'f', 't');
+INSERT INTO config.copy_status
+(id, name, holdable, opac_visible, copy_active, restrict_copy_delete)
+VALUES (17, 'Lost and Paid', FALSE, FALSE, FALSE, TRUE);
SELECT SETVAL('config.copy_status_id_seq'::TEXT, 100);
'coust',
'description'),
'integer', null)
+,('circ.use_lost_paid_copy_status',
+ 'circ',
+ oils_i18n_gettext('circ.use_lost_paid_copy_status',
+ 'Use Lost and Paid copy status',
+ 'coust', 'label'),
+ oils_i18n_gettext('circ.use_lost_paid_copy_status',
+ 'Use Lost and Paid copy status when lost or long overdue billing is paid',
+ 'coust', 'description'),
+ 'bool')
;
UPDATE config.org_unit_setting_type
--- /dev/null
+\set ECHO
+\set QUIET 1
+-- Turn off echo and keep things quiet.
+
+-- Format the output for nice TAP.
+\pset format unaligned
+\pset tuples_only true
+\pset pager
+
+-- Revert all changes on failure.
+\set ON_ERROR_ROLLBACK 1
+\set ON_ERROR_STOP true
+\set QUIET 1
+
+-- Load the TAP functions.
+BEGIN;
+
+-- Plan the tests.
+SELECT plan(2);
+
+-- Run the tests.
+-- Check for Lost and Paid copy status.
+SELECT isnt_empty(
+ 'SELECT * FROM config.copy_status WHERE id = 17',
+ 'Lost and Paid copy status exists'
+);
+
+--Check for the org_unit setting.
+SELECT isnt_empty(
+ 'SELECT * FROM config.org_unit_setting_type WHERE name = $$circ.use_lost_paid_copy_status$$',
+ 'circ.use_lost_paid_copy_status exists'
+);
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;
--- /dev/null
+INSERT INTO config.copy_status
+(id, name, holdable, opac_visible, copy_active, restrict_copy_delete)
+VALUES (17, 'Lost and Paid', FALSE, FALSE, FALSE, TRUE);
+
+INSERT INTO config.org_unit_setting_type
+(name, grp, label, description, datatype)
+VALUES
+('circ.use_lost_paid_copy_status',
+ 'circ',
+ oils_i18n_gettext('circ.use_lost_paid_copy_status',
+ 'Use Lost and Paid copy status',
+ 'coust', 'label'),
+ oils_i18n_gettext('circ.use_lost_paid_copy_status',
+ 'Use Lost and Paid copy status when lost or long overdue billing is paid',
+ 'coust', 'description'),
+ 'bool');
+
7010 /* COPY_ALERT_MESSAGE */,
7011 /* COPY_STATUS_LOST */,
7025 /* COPY_STATUS_LONG_OVERDUE */,
+ 7026 /* COPY_STATUS_LOST_AND_PAID */,
7012 /* COPY_STATUS_MISSING */,
7013 /* PATRON_EXCEEDS_FINES */
] : [],
7010 /* COPY_ALERT_MESSAGE */,
7011 /* COPY_STATUS_LOST */,
7025 /* COPY_STATUS_LONG_OVERDUE */,
+ 7026 /* COPY_STATUS_LOST_AND_PAID */,
7012 /* COPY_STATUS_MISSING */,
7013 /* PATRON_EXCEEDS_FINES */,
11103 /* TRANSIT_CHECKIN_INTERVAL_BLOCK */