Added ACQ validator module, starting with user request status validation. seed data...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 18 Feb 2010 14:21:04 +0000 (14:21 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 18 Feb 2010 14:21:04 +0000 (14:21 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15572 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq.pm [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq.pm
new file mode 100644 (file)
index 0000000..97de38a
--- /dev/null
@@ -0,0 +1,30 @@
+package OpenILS::Application::Trigger::Validator::Acq;
+use strict; use warnings;
+use OpenSRF::Utils::Logger qw/:logger/;
+
+sub UserRequestOrdered {
+    my $self = shift;
+    my $env = shift;
+    return get_lineitem_from_req($self, $env)->state eq 'on-order';
+}
+
+sub UserRequestReceived {
+    my $self = shift;
+    my $env = shift;
+    return get_lineitem_from_req($self, $env)->state eq 'received';
+}
+
+sub UserRequestCancelled {
+    my $self = shift;
+    my $env = shift;
+    return get_lineitem_from_req($self, $env)->state eq 'cancelled';
+}
+
+sub get_lineitem_from_req {
+    my($self, $env) = @_;
+    my $req = $env->{target};
+    return (ref $env->{target}->lineitem) ? 
+        $env->{target}->lineitem : 
+        $self->editor->retrieve_acq_lineitem($$env->{target}->lineitem);
+}
+