Add support for calculating the next value of an alternate enumeration.
authordjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 5 Nov 2008 02:53:58 +0000 (02:53 +0000)
committerdjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 5 Nov 2008 02:53:58 +0000 (02:53 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11062 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm

index 21c3ca5..422e731 100755 (executable)
@@ -102,10 +102,30 @@ sub next {
     my $caption = $self->{CAPTION};
     my $next = {};
 
-    foreach my $key ('a' .. 'f') {
-       last if !exists $self->{ENUMS}->{$key};
+    foreach my $key ('a' .. 'h') {
+       next if !exists $self->{ENUMS}->{$key};
        $next->{$key} = $self->{ENUMS}->{$key}->{HOLDINGS};
     }
+
+    # First handle any "alternative enumeration", since they're
+    # a lot simpler, and don't depend on the the calendar
+    foreach my $key ('h', 'g') {
+       next if !exists $next->{$key};
+       if (!exists $caption->{ENUMS}->{$key}) {
+           warn "Holding data exists for $key, but no caption specified";
+           $next->{$key} += 1;
+           last;
+       }
+
+       my $cap = $caption->{ENUMS}->{$key};
+       if ($cap->{RESTART} && $cap->{COUNT}
+           && ($next->{$key} == $cap->{COUNT})) {
+           $next->{$key} = 1;
+       } else {
+           $next->{$key} += 1;
+           last;
+       }
+    }
     foreach my $key (reverse('a'.. 'f')) {
        next if !exists $next->{$key};
        if (!exists $caption->{ENUMS}->{$key}) {