[Patches] [PATCH] bug_5473: Update items when receiving shipments

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Thu Dec 8 10:30:04 NZDT 2011


From: Srdjan Jankovic <srdjan at catalyst.net.nz>
Date: Thu, 8 Dec 2011 10:20:20 +1300
Subject: [PATCH] bug_5473: Update items when receiving shipments

---
 acqui/finishreceive.pl |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl
index 71b13d6..27a77c5 100755
--- a/acqui/finishreceive.pl
+++ b/acqui/finishreceive.pl
@@ -72,10 +72,14 @@ if ( any { $order->{$_} ne $tplorder{$_} } qw(quantity quantityreceived notes rr
     ModOrder($order);
 }
 
+my $items_created;
+
 #need old recievedate if we update the order, parcel.pl only shows the right parcel this way FIXME
 if ($quantityrec > $origquantityrec ) {
     # now, add items if applicable
     if (C4::Context->preference('AcqCreateItem') eq 'receiving') {
+        $items_created = 1;
+
         my @tags         = $input->param('tag');
         my @subfields    = $input->param('subfield');
         my @field_values = $input->param('field_value');
@@ -106,6 +110,7 @@ if ($quantityrec > $origquantityrec ) {
                                     $itemhash{$item}->{'indicator'},'ITEM');
             my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
             my ($biblionumber,$bibitemnum,$itemnumber) = AddItemFromMarc($record,$biblionumber);
+            update_item( $itemnumber, $record );
         }
     }
     
@@ -114,4 +119,23 @@ if ($quantityrec > $origquantityrec ) {
     	$datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoiceno,$freight,$replacement,undef,$datereceived);
 	}
 }
-    print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&datereceived=$datereceived$error_url_str");
+
+unless ( $items_created ) {
+    update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
+}
+
+print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&datereceived=$datereceived$error_url_str");
+
+################################ End of script ################################
+
+sub update_item {
+    my ( $itemnumber, $record ) = @_;
+
+    ModItem( {
+        booksellerid         => $supplierid,
+        dateaccessioned      => $datereceived,
+        price                => $unitprice,
+        replacementprice     => $replacement,
+        replacementpricedate => $datereceived,
+    }, $biblionumber, $itemnumber, $record );
+}
-- 
1.6.5




More information about the Patches mailing list