Bugzilla – Attachment 31492 Details for
Bug 12891
NewOrder does not return ordernumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12891: NewOrder does not return ordernumber if ordernumber is defined
Bug-12891-NewOrder-does-not-return-ordernumber-if-.patch (text/plain), 2.30 KB, created by
Dobrica Pavlinusic
on 2014-09-09 14:46:55 UTC
(
hide
)
Description:
Bug 12891: NewOrder does not return ordernumber if ordernumber is defined
Filename:
MIME Type:
Creator:
Dobrica Pavlinusic
Created:
2014-09-09 14:46:55 UTC
Size:
2.30 KB
patch
obsolete
>From fed52c1ef01e018608ec586efb7ca3a462e52cdc Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 8 Sep 2014 20:25:27 +0200 >Subject: [PATCH] Bug 12891: NewOrder does not return ordernumber if ordernumber is defined > >The behavior is quite weird, but > $schema->resultset('Table')->create($data)->id >does not return the id inserted if $data contains the key. > >To be more clear, in this case > $schema->resultset('Aqorder')->create($new_order)->id >returns an empty string because $new_order->{ordernumber} is an empty >string! > >This was not caught by the unit tests, I added one. > >Test plan: >- AcqCreateItem set to ordering >- Create an order with items and verify items are correctly linked to the > order. > >Signed-off-by: Dobrica Pavlinusic <dpavlin@rot13.org> >--- > C4/Acquisition.pm | 3 +++ > t/db_dependent/Acquisition.t | 3 ++- > 2 files changed, 5 insertions(+), 1 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 5fc45c7..98acb48 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -1266,6 +1266,8 @@ sub NewOrder { > my $dbh = C4::Context->dbh; > my @params; > >+ croak "The ordernumber parameter should not be provided on calling NewOrder" >+ if $orderinfo->{ordernumber}; > > # if these parameters are missing, we can't continue > for my $key (qw/basketno quantity biblionumber budget_id/) { >@@ -1281,6 +1283,7 @@ sub NewOrder { > my $schema = Koha::Database->new()->schema; > my $columns = ' '.join(' ', $schema->source('Aqorder')->columns).' '; > my $new_order = { map { $columns =~ / $_ / ? ($_ => $orderinfo->{$_}) : () } keys(%$orderinfo) }; >+ $new_order->{ordernumber} ||= undef; > > my $rs = $schema->resultset('Aqorder'); > my $ordernumber = $rs->create($new_order)->id; >diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t >index 837024a..0ae9ab7 100755 >--- a/t/db_dependent/Acquisition.t >+++ b/t/db_dependent/Acquisition.t >@@ -195,7 +195,8 @@ my @order_content = ( > budget_id => $budget->{budget_id}, > uncertainprice => 0, > order_internalnote => "internal note", >- order_vendornote => "vendor note" >+ order_vendornote => "vendor note", >+ ordernumber => '', > }, > num => { > quantity => 24, >-- >1.7.2.5
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 12891
:
31470
|
31492
|
31515