don't allow creation of PO's against inactive providers
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 9 Feb 2010 03:22:26 +0000 (03:22 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 9 Feb 2010 03:22:26 +0000 (03:22 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15478 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm

index c8d0986..1b7cbeb 100644 (file)
@@ -978,6 +978,14 @@ sub upload_records {
     }
 
     if($create_po) {
+
+        # verify the provider is still active
+        unless($U->is_true($provider->active)) {
+            $logger->error("provider is not active.  cannot create PO");
+            $e->rollback;
+            return OpenILS::Event->new('ACQ_PROVIDER_INACTIVE');
+        }
+
         $po = create_purchase_order($mgr, 
             ordering_agency => $ordering_agency,
             provider => $provider->id,
@@ -1290,6 +1298,14 @@ sub create_purchase_order_api {
     return $e->die_event unless $e->allowed('CREATE_PURCHASE_ORDER', $po->ordering_agency);
     my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn);
 
+    # verify the provider is still active
+    my $provider = $e->retrieve_acq_provider($po->provider) or return $e->die_event;
+    unless($U->is_true($provider->active)) {
+        $logger->error("provider is not active.  cannot create PO");
+        $e->rollback;
+        return OpenILS::Event->new('ACQ_PROVIDER_INACTIVE');
+    }
+
     # create the PO
     my %pargs = (ordering_agency => $e->requestor->ws_ou); # default
     $pargs{provider} = $po->provider if $po->provider;