Bill Erickson wrote:
Bill,
I'd like to look at incorporating this code into the repository. Are the
various attachments to the previous emails still accurate? Better yet,
would it be possible to get a unified diff of your changes (against 1.2 is
fine)? :)
Attached is the diff against the 1.4.0 branch.
What are the remaining UI pieces? We'll need to add the settings to the
org settings interface. We'll need some messages in the staff client to
alert the staff to what is happening when items are voided/unvoided. What
else?
I've never even looked into the org settings interface, but to aid in
that, of the 5 new settings noted in Const.pm, 4 are simple flags
considered true on a defined non-zero value, the fifth
(max_accept_return_of_lost) a date interval from the original due date
(e.g. "1 year", "180 days", etc.).
Because the item status Lost message is already coming up, I hadn't
considered additional messages, as I expected staff to be familiar with
their policies and what should be happening at that point. Maybe I'm
optimistic. The bill value does populate at checkin, but again, with no
details as to what was happening behind the scenes.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
Index: Open-ILS/src/perlmods/OpenILS/Const.pm
===================================================================
--- Open-ILS/src/perlmods/OpenILS/Const.pm (revision 12529)
+++ Open-ILS/src/perlmods/OpenILS/Const.pm (working copy)
@@ -82,9 +82,15 @@
econst OILS_SETTING_HOLD_SOFT_BOUNDARY => 'circ.hold_boundary.soft';
econst OILS_SETTING_HOLD_HARD_BOUNDARY => 'circ.hold_boundary.hard';
econst OILS_SETTING_HOLD_EXPIRE => 'circ.hold_expire_interval';
+econst OILS_SETTING_VOID_LOST_ON_CHECKIN =>
'circ.void_lost_on_checkin';
+econst OILS_SETTING_MAX_ACCEPT_RETURN_OF_LOST =>
'circ.max_accept_return_of_lost';
+econst OILS_SETTING_VOID_LOST_PROCESS_FEE_ON_CHECKIN =>
'circ.void_lost_proc_fee_on_checkin';
+econst OILS_SETTING_RESTORE_OVERDUE_ON_LOST_RETURN =>
'circ.restore_overdue_on_lost_return';
+econst OILS_SETTING_LOST_IMMEDIATELY_AVAILABLE =>
'circ.lost_immediately_available';
+
econst OILS_HOLD_TYPE_COPY => 'C';
econst OILS_HOLD_TYPE_VOLUME => 'V';
econst OILS_HOLD_TYPE_TITLE => 'T';
Index: Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm (revision 12529)
+++ Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm (working copy)
@@ -314,6 +314,7 @@
use OpenILS::Utils::CStoreEditor qw/:funcs/;
use OpenILS::Application::Circ::ScriptBuilder;
use OpenILS::Const qw/:const/;
+use Time::Local;
my $holdcode = "OpenILS::Application::Circ::Holds";
my $transcode = "OpenILS::Application::Circ::Transit";
@@ -2163,15 +2164,63 @@
$self->copy->circ_lib->id : $self->copy->circ_lib;
my $stat = $U->copy_status($self->copy->status)->id;
- # If the item is lost/missing and it needs to be sent home, don't
- # reshelve the copy, leave it lost/missing so the recipient will know
- if( ($stat == OILS_COPY_STATUS_LOST or $stat == OILS_COPY_STATUS_MISSING)
- and ($circ_lib != $self->editor->requestor->ws_ou) ) {
- $logger->info("circulator: not updating copy status on checkin because
copy is lost/missing");
+ # immediately available keeps items lost or missing items from going home
before being handled
+ my $lost_immediately_available = $U->ou_ancestor_setting_value(
+ $circ_lib, OILS_SETTING_LOST_IMMEDIATELY_AVAILABLE, $self->editor) ||
0;
- } else {
- $self->copy->status($U->copy_status(OILS_COPY_STATUS_RESHELVING));
- $self->update_copy;
+ if ( (!$lost_immediately_available) && ($circ_lib !=
$self->editor->requestor->ws_ou) ) {
+ if( ($stat == OILS_COPY_STATUS_LOST or $stat ==
OILS_COPY_STATUS_MISSING) ) {
+ $logger->info("circulator: not updating copy status on checkin
because copy is lost/missing");
+ }else{
+
$self->copy->status($U->copy_status(OILS_COPY_STATUS_RESHELVING));
+ $self->update_copy;
+ }
+ }elsif ($stat == OILS_COPY_STATUS_LOST) {
+
+ my $max_return = $U->ou_ancestor_setting_value(
+ $circ_lib, OILS_SETTING_MAX_ACCEPT_RETURN_OF_LOST,
$self->editor) || 0;
+
+ if ($max_return){
+ my $today = time();
+ my @tm = reverse($circ->due_date =~ /([\d\.]+)/og);
+ if ($tm[5] > 0) {
+ $tm[5] -= 1;
+ }
+ my $due = timelocal(int($tm[1]), int($tm[2]),
int($tm[3]), int($tm[4]), int($tm[5]), int($tm[6]));
+
+ my $last_chance =
OpenSRF::Utils->interval_to_seconds($max_return) + int($due);
+ $logger->info("MAX OD: ".$max_return." DUEDATE:
".$circ->due_date." TODAY: ".$today." DUE: ".$due." LAST: ".$last_chance);
+ if ($today < $last_chance ){
+ $max_return = 0;
+ }
+ }
+
+ if (!$max_return){ # there's either no max time to accept
returns defined or we're within that time
+
+ my $void_lost = $U->ou_ancestor_setting_value(
+ $circ_lib, OILS_SETTING_VOID_LOST_ON_CHECKIN,
$self->editor) || 0;
+ my $void_lost_fee = $U->ou_ancestor_setting_value(
+ $circ_lib,
OILS_SETTING_VOID_LOST_PROCESS_FEE_ON_CHECKIN, $self->editor) || 0;
+ my $restore_od = $U->ou_ancestor_setting_value(
+ $circ_lib,
OILS_SETTING_RESTORE_OVERDUE_ON_LOST_RETURN, $self->editor) || 0;
+
+ if ($void_lost){
+ $self->checkin_handle_lost_now_found('Lost
Materials');
+ }
+ if ($void_lost_fee){
+ $self->checkin_handle_lost_now_found('Lost
Materials Processing Fee');
+ }
+ if ($restore_od){
+
$self->checkin_handle_lost_now_found_restore_od();
+ }
+ }
+
+
$self->copy->status($U->copy_status(OILS_COPY_STATUS_RESHELVING));
+ $self->update_copy;
+
+ }else{
+
$self->copy->status($U->copy_status(OILS_COPY_STATUS_RESHELVING));
+ $self->update_copy;
}
return $self->bail_on_events($self->editor->event)
@@ -2404,6 +2453,63 @@
#$self->mk_script_runner;
}
+sub checkin_handle_lost_now_found {
+ my ($self, $bill_type) = @_;
+ # ------------------------------------------------------------------
+ # remove charge from patron's account if lost item is returned
+ # ------------------------------------------------------------------
+ my $bills = $self->editor->search_money_billing(
+ {
+ xact => $self->circ->id,
+ billing_type => $bill_type
+ }
+ );
+ $logger->debug("voiding lost item charge of ".scalar(@$bills));
+ for my $bill (@$bills) {
+ if( !$U->is_true($bill->voided) ) {
+ $logger->info("lost item returned - voiding bill ".$bill->id);
+ $bill->voided('t');
+ $bill->void_time('now');
+ $bill->voider($self->editor->requestor->id);
+ $bill->note("System: VOIDED FOR LOST ITEM RETURNED");
+
+ $self->bail_on_events($self->editor->event)
+ unless $self->editor->update_money_billing($bill);
+ }
+ }
+}
+
+sub checkin_handle_lost_now_found_restore_od {
+ my $self = shift;
+
+ # ------------------------------------------------------------------
+ # restore those overdue charges voided when item was set to lost
+ # ------------------------------------------------------------------
+
+ my $ods = $self->editor->search_money_billing(
+ {
+ xact => $self->circ->id,
+ billing_type => 'Overdue materials'
+ }
+ );
+
+ $logger->debug("returning overdue charges pre-lost ".scalar(@$ods));
+ for my $bill (@$ods) {
+ if( $U->is_true($bill->voided) ) {
+ $logger->info("lost item returned - restoring overdue
".$bill->id);
+ $bill->voided('f');
+ $bill->void_time('now');
+ $bill->voider($self->editor->requestor->id);
+ $bill->note("System: LOST RETURNED - OVERDUES REINSTATED");
+
+ $self->bail_on_events($self->editor->event)
+ unless $self->editor->update_money_billing($bill);
+ }
+ }
+}
+
+
+