Hopefully fix a holds list sorting issue that only manifested when printing.
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 23 Sep 2010 00:14:03 +0000 (00:14 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 23 Sep 2010 00:14:03 +0000 (00:14 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17899 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm

index 22b2188..7dde2ef 100644 (file)
@@ -1269,10 +1269,18 @@ sub print_hold_pull_list {
     return undef unless @$hold_ids;
     $client->status(new OpenSRF::DomainObject::oilsContinueStatus);
 
+    # Holds will /NOT/ be in order after this ...
     my $holds = $e->search_action_hold_request({id => $hold_ids}, {substream => 1});
     $client->status(new OpenSRF::DomainObject::oilsContinueStatus);
 
-    return $U->fire_object_event(undef, 'ahr.format.pull_list', $holds, $org_id);
+    # ... so we must resort.
+    my $hold_map = +{map { $_->id => $_ } @$holds};
+    my $sorted_holds = [];
+    push @$sorted_holds, $hold_map->{$_} foreach @$hold_ids;
+
+    return $U->fire_object_event(
+        undef, "ahr.format.pull_list", $sorted_holds, $org_id
+    );
 }