Bugzilla – Attachment 29621 Details for
Bug 12557
Cannot revert the changes done by AcqItemSetSubfieldsWhenReceived on canceling a receipt
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12557: Add a way to revert the changes made on items on receving
Bug-12557-Add-a-way-to-revert-the-changes-made-on-.patch (text/plain), 4.53 KB, created by
Jonathan Druart
on 2014-07-11 10:14:32 UTC
(
hide
)
Description:
Bug 12557: Add a way to revert the changes made on items on receving
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-07-11 10:14:32 UTC
Size:
4.53 KB
patch
obsolete
>From 975b39ea239cce8ab7193e28230bfefb08978aba Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 11 Jul 2014 12:09:32 +0200 >Subject: [PATCH] Bug 12557: Add a way to revert the changes made on items on > receving > >Bug 8307 introduces the AcqItemSetSubfieldsWhenReceived pref. >You can now update an item field on receiving (if you create items on >ordering). >But if the receipt is cancel, there is no way to revert these changes. > >This patch adds a new pref AcqItemSetSubfieldsWhenReceiptIsCancelled to >allow to revert changes previously done on receiving > >Test plan: >0/ Set the AcqCreateItems to 'ordering' >1/ Fill AcqItemSetSubfieldsWhenReceived with o=1 (UNIMARC) or 7=1 >(MARC21). >2/ Fill AcqItemSetSubfieldsWhenReceiptIsCancelled with o=2 (UNIMARC) or >7=2 (MARC21) >3/ Create an order with some items >4/ Receive the order and verify the notforloan value is set to 1 >5/ Cancel the receipt and verify the notforloan value is set to 2 >--- > C4/Acquisition.pm | 20 ++++++++ > t/db_dependent/Acquisition/CancelReceipt.t | 74 ++++++++++++++++++++++++++++++ > 2 files changed, 94 insertions(+) > create mode 100644 t/db_dependent/Acquisition/CancelReceipt.t > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 2e013ac..bc99c44 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -1680,6 +1680,26 @@ sub CancelReceipt { > > } > >+ if(C4::Context->preference('AcqCreateItem') eq 'ordering') { >+ my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); >+ if ( @affects ) { >+ my @itemnumbers = GetItemnumbersFromOrder( $parent_ordernumber ); >+ for my $in ( @itemnumbers ) { >+ my $biblionumber = C4::Biblio::GetBiblionumberFromItemnumber( $in ); >+ my $frameworkcode = GetFrameworkCode($biblionumber); >+ my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $frameworkcode ); >+ my $item = C4::Items::GetMarcItem( $biblionumber, $in ); >+ for my $affect ( @affects ) { >+ my ( $sf, $v ) = split q{=}, $affect, 2; >+ foreach ( $item->field($itemfield) ) { >+ $_->update( $sf => $v ); >+ } >+ } >+ C4::Items::ModItemFromMarc( $item, $biblionumber, $in ); >+ } >+ } >+ } >+ > return $parent_ordernumber; > } > >diff --git a/t/db_dependent/Acquisition/CancelReceipt.t b/t/db_dependent/Acquisition/CancelReceipt.t >new file mode 100644 >index 0000000..c59836c >--- /dev/null >+++ b/t/db_dependent/Acquisition/CancelReceipt.t >@@ -0,0 +1,74 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Test::More tests => 2; >+use C4::Context; >+use C4::Acquisition; >+use C4::Biblio; >+use C4::Items; >+use C4::Bookseller; >+use C4::Budgets; >+use t::lib::Mocks; >+ >+use Koha::DateUtils; >+use MARC::Record; >+ >+my $dbh = C4::Context->dbh; >+$dbh->{RaiseError} = 1; >+$dbh->{AutoCommit} = 0; >+ >+my $booksellerid1 = C4::Bookseller::AddBookseller( >+ { >+ name => "my vendor 1", >+ address1 => "bookseller's address", >+ phone => "0123456", >+ active => 1 >+ } >+); >+ >+my $basketno1 = C4::Acquisition::NewBasket( >+ $booksellerid1 >+); >+ >+my $budgetid = C4::Budgets::AddBudget( >+ { >+ budget_code => "budget_code_test_transferorder", >+ budget_name => "budget_name_test_transferorder", >+ } >+); >+ >+my $budget = C4::Budgets::GetBudget( $budgetid ); >+ >+my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, ''); >+my $itemnumber = AddItem({}, $biblionumber); >+my ( $ordernumber, $order ); >+ >+t::lib::Mocks::mock_preference('AcqCreateItem', 'ordering'); >+t::lib::Mocks::mock_preference('AcqItemSetSubfieldsWhenReceiptIsCancelled', '7=9'); # notforloan is mapped with 952$7 >+( undef, $ordernumber ) = C4::Acquisition::NewOrder( >+ { >+ basketno => $basketno1, >+ quantity => 2, >+ biblionumber => $biblionumber, >+ budget_id => $budget->{budget_id}, >+ } >+); >+ >+ModReceiveOrder( >+ { >+ biblionumber => $biblionumber, >+ ordernumber => $ordernumber, >+ quantityreceived => 2, >+ datereceived => dt_from_string >+ } >+); >+ >+NewOrderItem($itemnumber, $ordernumber); >+ >+CancelReceipt($ordernumber); >+ >+$order = GetOrder( $ordernumber ); >+is(scalar GetItemnumbersFromOrder($order->{ordernumber}), 1, "Create items on ordering: items are not deleted after cancelling a receipt"); >+my $item = C4::Items::GetItem( $itemnumber ); >+is( $item->{notforloan}, 9, "The notforloan value has been updated with '9'" ); >-- >2.0.0.rc2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12557
:
29620
|
29621
|
30886
|
30887
|
31009
|
31039
|
31040
|
31041
|
31042
|
31043