[open-ils-commits] [GIT] Evergreen ILS branch rel_2_11 updated. 2bb2d341a6156079fc10d734a66bbb291091afc0

Evergreen Git git at git.evergreen-ils.org
Mon May 1 16:43:30 EDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_11 has been updated
       via  2bb2d341a6156079fc10d734a66bbb291091afc0 (commit)
       via  697417bfdc5cf83a680de9afa4f6954d5559b8e6 (commit)
       via  cd0634888fa7769017a830e798ccab6d8e6c270d (commit)
       via  9d0db44c0f32170374d387eb9442f540a2be227b (commit)
      from  65902f0a6f2f8964dbea69fc9b66a58d4a7c66e9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2bb2d341a6156079fc10d734a66bbb291091afc0
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Mon May 1 16:45:29 2017 -0400

    LP#1257915: add live_t tests
    
    And here's a test plan for humans:
    
    [1] Create a purchase order with, say, 3 lineitems and 2
        copies on each of these.
    [2] Receive the first two lineitems outright.
    [3] Receive one of the copies on the last lineitem and cancel
        the other with a cancellation reason that's permanent (e.g.,
        bad ISBN) rather than temporary (e.g., backordered).
    [4] Note that the purchase order's state remains 'on-order'
    [5] Apply the patch.
    [6] Repeat steps #1-4. This time, the PO's state should be
        'received'.
    [7] Repeat steps #1-4, but this time, choose backordered as
        the cancellation reason. This time, the PO's state should
        remain 'on-order'.
    
    It should be noted that the patches for this bug do *not*
    retrospectively mark purchase orders as being received.
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/perlmods/live_t/22-acq-po-status.t b/Open-ILS/src/perlmods/live_t/22-acq-po-status.t
new file mode 100644
index 0000000..09ecda0
--- /dev/null
+++ b/Open-ILS/src/perlmods/live_t/22-acq-po-status.t
@@ -0,0 +1,64 @@
+#!perl
+use strict; use warnings;
+use Test::More tests => 11;
+use OpenILS::Utils::TestUtils;
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
+use OpenILS::Application::Acq::Order;
+
+diag("Tests ACQ purchase orders");
+
+my $script = OpenILS::Utils::TestUtils->new();
+$script->bootstrap;
+
+$script->authenticate({
+    username => 'admin',
+    password => 'demo123',
+    type => 'staff'
+});
+
+my $e = $script->editor(authtoken=>$script->authtoken);
+$e->xact_begin;
+
+ok($script->authtoken, 'Have an authtoken');
+
+my $conn; # dummy for now
+my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn);
+
+my $origpo = $e->retrieve_acq_purchase_order(2);
+is($origpo->state, 'on-order', 'order starts at expected state') or
+    BAIL_OUT('order 2 does not have expected state');
+
+my $origli3 = $e->retrieve_acq_lineitem(3);
+my $origli4 = $e->retrieve_acq_lineitem(4);
+my $origli5 = $e->retrieve_acq_lineitem(5);
+
+is($origli3->state, 'on-order', 'line item 3 starts at expected state') or
+    BAIL_OUT('line item 3 does not have expected state');
+is($origli4->state, 'cancelled', 'line item 4 starts at expected state') or
+    BAIL_OUT('line item 4 does not have expected state');
+is($origli5->state, 'cancelled', 'line item 5 starts at expected state') or
+    BAIL_OUT('line item 5 does not have expected state');
+is($origli4->cancel_reason, 1283, 'line item 4 starts at expected cancel_reason') or
+    BAIL_OUT('line item 4 does not have expected cancel_reason');
+is($origli5->cancel_reason, 1, 'line item 5 starts at expected cancel_reason') or
+    BAIL_OUT('line item 5 does not have expected cancel_reason');
+
+my $ret = OpenILS::Application::Acq::Order::check_purchase_order_received($mgr, 2);
+is($ret->state, 'on-order', 'order cannot be received (yet)');
+
+OpenILS::Application::Acq::Order::receive_lineitem($mgr, 3, 1);
+my $li = $e->retrieve_acq_lineitem(3);
+is($li->state, 'received', 'line item 3 received');
+
+$ret = OpenILS::Application::Acq::Order::check_purchase_order_received($mgr, 2);
+is($ret->state, 'on-order', 'order still cannot be received');
+
+$li = $e->retrieve_acq_lineitem(4);
+$li->cancel_reason(2); # this one has keep_debits = false, i.e., we don't expect
+                       # this one to ever show up
+$e->update_acq_lineitem($li);
+
+$ret = OpenILS::Application::Acq::Order::check_purchase_order_received($mgr, 2);
+is($ret->state, 'received', 'LP#1257915: order now received');
+
+$e->rollback;

commit 697417bfdc5cf83a680de9afa4f6954d5559b8e6
Author: Bill Erickson <berickxx at gmail.com>
Date:   Wed Apr 12 16:54:25 2017 -0400

    LP#1257915 Repair receive-when-cancel query
    
    Repaire the json_query used to determine if a PO is ready to be marked
    received.
    
    A PO is non-receiveable if it has any lineitems that are not in the
    received/cancelled [sic] state OR any that are canceled with a
    keep_debits=true cancel reason.
    
    Prior to this change, simply having a state of "cancelled" was enough to
    prevent receiving.
    
    * Replace tabs w/ spaces
    * Remove unnecessary "or return 0" clause which was causing Perl
      precedence warnings.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
index 80e59f2..c57c380 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
@@ -782,7 +782,7 @@ sub receive_lineitem_detail {
     my $li = check_lineitem_received($mgr, $lid->lineitem) or return 0;
     return 1 if $li == 1; # li not received
 
-    return check_purchase_order_received($mgr, $li->purchase_order) or return 0;
+    return check_purchase_order_received($mgr, $li->purchase_order);
 }
 
 
@@ -1186,21 +1186,29 @@ sub create_purchase_order {
 sub check_purchase_order_received {
     my($mgr, $po_id) = @_;
 
-	my $non_recv_li = $mgr->editor->json_query({
-		"select" =>{
-        	"jub" =>["id"]
-    	},
-    	"from" =>{
-        	"jub" => {"acqcr" => {"type" => "left"}}
-    	},
-    	"where" =>{
-        	"+jub" => {"purchase_order" => $po_id},
-        	"-or" => [
-            	{"+jub" => {"state" => {"!=" => "received"}}},
-            	{"+acqcr" => {"keep_debits" =>"t"}}
-        	]
-    	}
-	});
+    my $non_recv_li = $mgr->editor->json_query({
+        "select" =>{
+            "jub" =>["id"]
+        },
+        "from" =>{
+            "jub" => {"acqcr" => {"type" => "left"}}
+        },
+        "where" => {
+            "+jub" => {"purchase_order" => $po_id},
+            # Return lineitems that are not in the received/cancelled [sic] 
+            # state OR those that are canceled with keep_debits=true.
+            "-or" => [
+                {"+jub" => {
+                    "state" => {"not in" => ["received", "cancelled"]}}
+                }, {
+                    "-and" => [
+                        {"+jub" => {"state" => "cancelled"}},
+                        {"+acqcr" => {"keep_debits" =>"t"}}
+                    ]
+                }
+            ]
+        }
+    });
 
     my $po = $mgr->editor->retrieve_acq_purchase_order($po_id);
     return $po if @$non_recv_li;
@@ -3235,7 +3243,6 @@ sub cancel_lineitem {
 
     # check to see if this cancelation should result in
     # marking the purchase order "received"
-    my $po;
     return 0 unless check_purchase_order_received($mgr, $li->purchase_order->id);
 
     return $result;

commit cd0634888fa7769017a830e798ccab6d8e6c270d
Author: Chris Sharp <csharp at georgialibraries.org>
Date:   Fri Apr 7 08:45:06 2017 -0400

    LP#1257915 - Also check whether to mark the PO received when canceling.
    
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
index d0fd407..80e59f2 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
@@ -1194,9 +1194,9 @@ sub check_purchase_order_received {
         	"jub" => {"acqcr" => {"type" => "left"}}
     	},
     	"where" =>{
-        	"+jub" => {"id" => $po_id},
+        	"+jub" => {"purchase_order" => $po_id},
         	"-or" => [
-            	{"+jub" => {"state" => "received"}},
+            	{"+jub" => {"state" => {"!=" => "received"}}},
             	{"+acqcr" => {"keep_debits" =>"t"}}
         	]
     	}
@@ -3224,7 +3224,7 @@ sub cancel_lineitem {
             }
         }
     }
-
+ 
     update_lineitem($mgr, $li) or return 0;
     $result->{"li"} = {
         $li_id => {
@@ -3232,6 +3232,12 @@ sub cancel_lineitem {
             "cancel_reason" => $cancel_reason
         }
     };
+
+    # check to see if this cancelation should result in
+    # marking the purchase order "received"
+    my $po;
+    return 0 unless check_purchase_order_received($mgr, $li->purchase_order->id);
+
     return $result;
 }
 

commit 9d0db44c0f32170374d387eb9442f540a2be227b
Author: Chris Sharp <csharp at georgialibraries.org>
Date:   Wed Apr 5 09:52:50 2017 -0400

    LP#1257915 - Mark POs received when all lineitems are received or canceled.
    
    Previously, Evergreen only considered lineitems not in a "received" status
    when deciding whether to consider a purchase order to be "received".  Now
    items with cancel reasons that do not keep debits (e.g. not backordered)
    are considered "done".
    
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
index d3a106e..d0fd407 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
@@ -1186,10 +1186,21 @@ sub create_purchase_order {
 sub check_purchase_order_received {
     my($mgr, $po_id) = @_;
 
-    my $non_recv_li = $mgr->editor->search_acq_lineitem(
-        {   purchase_order => $po_id,
-            state => {'!=' => 'received'}
-        }, {idlist=>1});
+	my $non_recv_li = $mgr->editor->json_query({
+		"select" =>{
+        	"jub" =>["id"]
+    	},
+    	"from" =>{
+        	"jub" => {"acqcr" => {"type" => "left"}}
+    	},
+    	"where" =>{
+        	"+jub" => {"id" => $po_id},
+        	"-or" => [
+            	{"+jub" => {"state" => "received"}},
+            	{"+acqcr" => {"keep_debits" =>"t"}}
+        	]
+    	}
+	});
 
     my $po = $mgr->editor->retrieve_acq_purchase_order($po_id);
     return $po if @$non_recv_li;

-----------------------------------------------------------------------

Summary of changes:
 .../perlmods/lib/OpenILS/Application/Acq/Order.pm  |   36 +++++++++--
 Open-ILS/src/perlmods/live_t/22-acq-po-status.t    |   64 ++++++++++++++++++++
 2 files changed, 94 insertions(+), 6 deletions(-)
 create mode 100644 Open-ILS/src/perlmods/live_t/22-acq-po-status.t


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list