[open-ils-commits] [GIT] Evergreen ILS branch master updated. 3e78c58976f5e635cb52fa14b0a6f01f47e1b599

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, master has been updated
       via  3e78c58976f5e635cb52fa14b0a6f01f47e1b599 (commit)
       via  acc105d7fb2f28bb24faad0314329923c0695124 (commit)
       via  ee186a748837e175c23e834a0ce4ef6acc5ef895 (commit)
       via  22f871217f388ad0f6abd0c2d42e849c73dfd40b (commit)
      from  8278aab39dbac66daa28c6fc181bbef01b9e435d (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 3e78c58976f5e635cb52fa14b0a6f01f47e1b599
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 acc105d7fb2f28bb24faad0314329923c0695124
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 07aab00..3eae860 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
@@ -787,7 +787,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);
 }
 
 
@@ -1191,21 +1191,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;
@@ -3240,7 +3248,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 ee186a748837e175c23e834a0ce4ef6acc5ef895
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 58a6550..07aab00 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
@@ -1199,9 +1199,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"}}
         	]
     	}
@@ -3229,7 +3229,7 @@ sub cancel_lineitem {
             }
         }
     }
-
+ 
     update_lineitem($mgr, $li) or return 0;
     $result->{"li"} = {
         $li_id => {
@@ -3237,6 +3237,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 22f871217f388ad0f6abd0c2d42e849c73dfd40b
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 2a64bdf..58a6550 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
@@ -1191,10 +1191,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