From cff4688e9cf276fdbcb4dc44b3bf3d4b3f2c0ba9 Mon Sep 17 00:00:00 2001
From: Mathieu Saby <mathieu.saby@univ-rennes2.fr>
Date: Wed, 13 Mar 2013 16:12:03 +0100
Subject: [PATCH] Bug 7593: Move orders on the destination record when merging 2 records
Revision : execute code before deleting the record
Note : this patch uses Acquisition::GetOrdersByBiblionumber created by bug 9780.
So you need to apply bug 9780 before testing this one.
At present, merging records breaks the link order/record.
This patch moves existing orders from deleted record to destination record.
To test :
1. create a basket with one order
2. put the record used by this order in a list
3. put an other record in the list
4. merge the 2 records
5. check if the order in the basket is updated
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
---
cataloguing/merge.pl | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/cataloguing/merge.pl b/cataloguing/merge.pl
index 6a46d2f..18de702 100755
--- a/cataloguing/merge.pl
+++ b/cataloguing/merge.pl
@@ -29,6 +29,7 @@ use C4::Biblio;
use C4::Serials;
use C4::Koha;
use C4::Reserves qw/MergeHolds/;
+use C4::Acquisition qw/ModOrder GetOrdersByBiblionumber/;
my $input = new CGI;
my @biblionumber = $input->param('biblionumber');
@@ -101,6 +102,15 @@ if ($merge) {
# TODO : Moving reserves
+ # Moving orders
+ my @allorders = GetOrdersByBiblionumber($frombiblio);
+ foreach my $myorder (@allorders) {
+ $myorder->{'biblionumber'} = $tobiblio;
+ $myorder->{'biblioitemnumber'} = $tobiblio; #maybe useless
+ ModOrder ($myorder);
+ # TODO : add error control (in ModOrder?)
+ }
+
# Deleting the other record
if (scalar(@errors) == 0) {
# Move holds
--
1.7.2.5