Bugzilla – Attachment 50960 Details for
Bug 15531
Add support for standing orders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 15531: Add support for standing orders
PASSED-QA-Bug-15531-Add-support-for-standing-order.patch (text/plain), 27.57 KB, created by
Katrin Fischer
on 2016-04-28 22:11:20 UTC
(
hide
)
Description:
[PASSED QA] Bug 15531: Add support for standing orders
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2016-04-28 22:11:20 UTC
Size:
27.57 KB
patch
obsolete
>From c3cc97e5ead97d4731af57996db9ccb3fb63f865 Mon Sep 17 00:00:00 2001 >From: Jesse Weaver <jweaver@bywatersolutions.com> >Date: Mon, 11 Jan 2016 16:07:33 -0700 >Subject: [PATCH] [PASSED QA] Bug 15531: Add support for standing orders > >This allows creation of special baskets that include standing orders. >These orders do not have a known quantity (and may not have a known >price in advance). Upon receipt, the received items are split into a new >completed order. > >Test plan: > 1) Run updatedatabase.pl. > 2) Run prove t/db_dependent/Acquisition/StandingOrders.t . (and the > other Acquisition tests). > 3) Create a new basket, mark it as a standing order basket. > 4) Add an order to this basket, and notice that the quantity field is > missing (and thus not required). > 5) Receive items for this order, and notice that the original order is > unchanged. The new child order line should have the correct price > and quantity information. > >(Note: the QA tools output what seems to be a spurious spelling error >for Test::More's "isnt" in StandingOrders.t.) > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/Acquisition.pm | 40 +++--- > Koha/Acquisition/Order.pm | 8 +- > Koha/Schema/Result/Aqbasket.pm | 12 +- > acqui/addorder.pl | 6 +- > acqui/basket.pl | 16 ++- > acqui/basketheader.pl | 2 + > acqui/neworderempty.pl | 1 + > .../bug_15531-add_is_standing_to_aqbasket.sql | 1 + > installer/data/mysql/kohastructure.sql | 1 + > .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 5 +- > .../prog/en/modules/acqui/basketheader.tt | 5 + > .../prog/en/modules/acqui/neworderempty.tt | 44 ++++--- > t/db_dependent/Acquisition/NewOrder.t | 5 +- > t/db_dependent/Acquisition/StandingOrders.t | 136 +++++++++++++++++++++ > 14 files changed, 236 insertions(+), 46 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_15531-add_is_standing_to_aqbasket.sql > create mode 100644 t/db_dependent/Acquisition/StandingOrders.t > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index db6c45a..19ecb6b 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -186,8 +186,8 @@ sub GetBasket { > > =head3 NewBasket > >- $basket = &NewBasket( $booksellerid, $authorizedby, $basketname, >- $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace ); >+ $basket = &NewBasket( $booksellerid, $authorizedby, $basketname, >+ $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace, $is_standing ); > > Create a new basket in aqbasket table > >@@ -206,7 +206,7 @@ The other parameters are optional, see ModBasketHeader for more info on them. > sub NewBasket { > my ( $booksellerid, $authorisedby, $basketname, $basketnote, > $basketbooksellernote, $basketcontractnumber, $deliveryplace, >- $billingplace ) = @_; >+ $billingplace, $is_standing ) = @_; > my $dbh = C4::Context->dbh; > my $query = > 'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) ' >@@ -218,7 +218,7 @@ sub NewBasket { > $basketnote ||= q{}; > $basketbooksellernote ||= q{}; > ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote, >- $basketcontractnumber, $booksellerid, $deliveryplace, $billingplace ); >+ $basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing ); > return $basket; > } > >@@ -531,21 +531,23 @@ Modifies a basket's header. > > =item C<$billingplace> is the "billingplace" field in the aqbasket table. > >+=item C<$is_standing> is the "is_standing" field in the aqbasket table. >+ > =back > > =cut > > sub ModBasketHeader { >- my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace) = @_; >+ my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_; > my $query = qq{ > UPDATE aqbasket >- SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=? >+ SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=? > WHERE basketno=? > }; > > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); >- $sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $basketno); >+ $sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $basketno); > > if ( $contractnumber ) { > my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; >@@ -1385,7 +1387,7 @@ sub ModReceiveOrder { > } > > my $result_set = $dbh->selectall_arrayref( >-q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?}, >+q{SELECT *, aqbasket.is_standing FROM aqorders LEFT JOIN aqbasket USING (basketno) WHERE biblionumber=? AND aqorders.ordernumber=?}, > { Slice => {} }, $biblionumber, $ordernumber > ); > >@@ -1393,7 +1395,7 @@ q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?}, > my $order = $result_set->[0]; > > my $new_ordernumber = $ordernumber; >- if ( $order->{quantity} > $quantrec ) { >+ if ( $order->{is_standing} || $order->{quantity} > $quantrec ) { > # Split order line in two parts: the first is the original order line > # without received items (the quantity is decreased), > # the second part is a new order line with quantity=quantityrec >@@ -1408,7 +1410,7 @@ q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?}, > my $sth = $dbh->prepare($query); > > $sth->execute( >- $order->{quantity} - $quantrec, >+ ( $order->{quantity} < $quantrec ? 0 : ( $order->{quantity} - $quantrec ) ), > ( defined $order_internalnote ? $order_internalnote : () ), > ( defined $order_vendornote ? $order_vendornote : () ), > $ordernumber >@@ -1684,10 +1686,20 @@ sub SearchOrders { > }; > > if ( $pending or $ordered ) { >- $query .= q{ AND (quantity > quantityreceived OR quantityreceived is NULL)}; >- } >- if ( $ordered ) { >- $query .= q{ AND aqorders.orderstatus IN ( "ordered", "partial" )}; >+ $query .= q{ >+ AND ( >+ ( aqbasket.is_standing AND aqorders.orderstatus IN ( "new", "ordered", "partial" ) ) >+ OR ( >+ ( quantity > quantityreceived OR quantityreceived is NULL ) >+ }; >+ >+ if ( $ordered ) { >+ $query .= q{ AND aqorders.orderstatus IN ( "ordered", "partial" )}; >+ } >+ $query .= q{ >+ ) >+ ) >+ }; > } > > my $userenv = C4::Context->userenv; >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index 15b9867..de0c49d 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -27,16 +27,20 @@ sub insert { > my ($self) = @_; > > # if these parameters are missing, we can't continue >- for my $key (qw( basketno quantity biblionumber budget_id )) { >+ for my $key (qw( basketno biblionumber budget_id )) { > croak "Cannot insert order: Mandatory parameter $key is missing" > unless $self->{$key}; > } > >+ my $schema = Koha::Database->new->schema; >+ if ( !$self->{quantity} && !$schema->resultset('Aqbasket')->find( $self->{basketno} )->is_standing ) { >+ croak "Cannot insert order: Quantity is mandatory for non-standing orders"; >+ } >+ > $self->{quantityreceived} ||= 0; > $self->{entrydate} ||= > output_pref( { dt => dt_from_string, dateformat => 'iso' } ); > >- my $schema = Koha::Database->new->schema; > my @columns = $schema->source('Aqorder')->columns; > > $self->{ordernumber} ||= undef; >diff --git a/Koha/Schema/Result/Aqbasket.pm b/Koha/Schema/Result/Aqbasket.pm >index 52cc708..e2fb8d7 100644 >--- a/Koha/Schema/Result/Aqbasket.pm >+++ b/Koha/Schema/Result/Aqbasket.pm >@@ -106,6 +106,12 @@ __PACKAGE__->table("aqbasket"); > is_nullable: 1 > size: 10 > >+=head2 is_standing >+ >+ data_type: 'tinyint' >+ default_value: 0 >+ is_nullable: 0 >+ > =cut > > __PACKAGE__->add_columns( >@@ -142,6 +148,8 @@ __PACKAGE__->add_columns( > { data_type => "varchar", is_nullable => 1, size => 10 }, > "branch", > { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, >+ "is_standing", >+ { data_type => "tinyint", default_value => 0, is_nullable => 0 }, > ); > > =head1 PRIMARY KEY >@@ -289,8 +297,8 @@ Composing rels: L</aqbasketusers> -> borrowernumber > __PACKAGE__->many_to_many("borrowernumbers", "aqbasketusers", "borrowernumber"); > > >-# Created by DBIx::Class::Schema::Loader v0.07033 @ 2014-09-02 11:37:47 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tsMzwP7eofOR27sfZSTqFQ >+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-01-14 16:28:06 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CuP/8SFJOD4h4XZf7AdeiA > > > # You can replace this text with custom content, and it will be preserved on regeneration >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index 1e60f79..70cb36c 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -228,12 +228,15 @@ $orderinfo->{'list_price'} ||= 0; > $orderinfo->{'uncertainprice'} ||= 0; > $orderinfo->{subscriptionid} ||= undef; > >+my $basketno=$$orderinfo{basketno}; >+my $basket = GetBasket($basketno); >+ > my $user = $input->remote_user; > > # create, modify or delete biblio > # create if $quantity>0 and $existing='no' > # modify if $quantity>0 and $existing='yes' >-if ( $orderinfo->{quantity} ne '0' ) { >+if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { > #TODO:check to see if biblio exists > unless ( $$orderinfo{biblionumber} ) { > #if it doesn't create it >@@ -319,7 +322,6 @@ if ( $orderinfo->{quantity} ne '0' ) { > > } > >-my $basketno=$$orderinfo{basketno}; > my $booksellerid=$$orderinfo{booksellerid}; > if (my $import_batch_id=$$orderinfo{import_batch_id}) { > print $input->redirect("/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=$import_batch_id&basketno=$basketno&booksellerid=$booksellerid"); >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 0a0cbda..d1f37e6 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -366,6 +366,7 @@ elsif ( $op eq 'ediorder' ) { > > $template->param( > basketno => $basketno, >+ basket => $basket, > basketname => $basket->{'basketname'}, > basketbranchname => C4::Branch::GetBranchName($basket->{branch}), > basketnote => $basket->{note}, >@@ -380,6 +381,7 @@ elsif ( $op eq 'ediorder' ) { > users => \@basketusers, > closedate => $basket->{closedate}, > estimateddeliverydate=> $estimateddeliverydate, >+ is_standing => $basket->{is_standing}, > deliveryplace => C4::Branch::GetBranchName( $basket->{deliveryplace} ), > billingplace => C4::Branch::GetBranchName( $basket->{billingplace} ), > active => $bookseller->{'active'}, >@@ -397,7 +399,12 @@ elsif ( $op eq 'ediorder' ) { > basketgroups => $basketgroups, > basketgroup => $basketgroup, > grouped => $basket->{basketgroupid}, >- unclosable => @orders ? 0 : 1, >+ # The double negatives and booleans here mean: >+ # "A basket cannot be closed if there are no orders in it or it's a standing order basket." >+ # >+ # (The template has another implicit restriction that the order cannot be closed if there >+ # are any orders with uncertain prices.) >+ unclosable => @orders ? $basket->{is_standing} : 1, > has_budgets => $has_budgets, > duplinbatch => $duplinbatch, > ); >@@ -410,10 +417,12 @@ sub get_order_infos { > if ( !defined $order->{quantityreceived} ) { > $order->{quantityreceived} = 0; > } >- my $budget = GetBudget( $order->{'budget_id'} ); >+ my $budget = GetBudget($order->{budget_id}); >+ my $basket = GetBasket($order->{basketno}); > > my %line = %{ $order }; >- $line{order_received} = ( $qty == $order->{'quantityreceived'} ); >+ # Don't show unreceived standing orders as received >+ $line{order_received} = ( $qty == $order->{'quantityreceived'} && ( $basket->{is_standing} ? $qty : 1 ) ); > $line{basketno} = $basketno; > $line{budget_name} = $budget->{budget_name}; > >@@ -463,7 +472,6 @@ sub get_order_infos { > foreach my $key (qw(transferred_from transferred_to)) { > if ($line{$key}) { > my $order = GetOrder($line{$key}); >- my $basket = GetBasket($order->{basketno}); > my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} }); > $line{$key} = { > order => $order, >diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl >index a4ef0b9..051e148 100755 >--- a/acqui/basketheader.pl >+++ b/acqui/basketheader.pl >@@ -148,6 +148,7 @@ if ( $op eq 'add_form' ) { > $input->param('basketbooksellerid'), > $input->param('deliveryplace'), > $input->param('billingplace'), >+ $input->param('is_standing') ? 1 : undef, > ); > } else { #New basket > $basketno = NewBasket( >@@ -159,6 +160,7 @@ if ( $op eq 'add_form' ) { > $input->param('basketcontractnumber') || undef, > $input->param('deliveryplace'), > $input->param('billingplace'), >+ $input->param('is_standing') ? 1 : undef, > ); > } > print $input->redirect('basket.pl?basketno='.$basketno); >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index 4fdf33f..da5acd5 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -324,6 +324,7 @@ $template->param( > ordernumber => $ordernumber, > # basket informations > basketno => $basketno, >+ basket => $basket, > basketname => $basket->{'basketname'}, > basketnote => $basket->{'note'}, > booksellerid => $basket->{'booksellerid'}, >diff --git a/installer/data/mysql/atomicupdate/bug_15531-add_is_standing_to_aqbasket.sql b/installer/data/mysql/atomicupdate/bug_15531-add_is_standing_to_aqbasket.sql >new file mode 100644 >index 0000000..69d8fab >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_15531-add_is_standing_to_aqbasket.sql >@@ -0,0 +1 @@ >+ALTER TABLE aqbasket ADD COLUMN is_standing TINYINT(1) NOT NULL DEFAULT 0; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 028c85f..6a8d9e1 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2924,6 +2924,7 @@ CREATE TABLE `aqbasket` ( -- stores data about baskets in acquisitions > `deliveryplace` varchar(10) default NULL, -- basket delivery place > `billingplace` varchar(10) default NULL, -- basket billing place > branch varchar(10) default NULL, -- basket branch >+ is_standing TINYINT(1) NOT NULL DEFAULT 0, -- orders in this basket are standing > PRIMARY KEY (`basketno`), > KEY `booksellerid` (`booksellerid`), > KEY `basketgroupid` (`basketgroupid`), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index 6fe023d..774b634 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -316,6 +316,9 @@ > [% IF ( creationdate ) %]<li><span class="label">Opened on:</span> [% creationdate | $KohaDates %]</li>[% END %] > [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>[% END %] > [% IF ( estimateddeliverydate ) %]<li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates %]</li>[% END %] >+ [% IF ( estimateddeliverydate ) %]<li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates %]</li>[% END %] >+ <li><span class="label">Is standing order basket:</span> [% IF is_standing %]Yes[% ELSE %]No[% END %]</li> >+ > > </ol> > </div> >@@ -516,7 +519,7 @@ > <td class="number gste [% IF books_loo.ecostgste.search(zero_regex) %]error[% END %]">[% books_loo.ecostgste | $Price%]</td> > <td class="number gsti [% IF books_loo.rrpgsti.search(zero_regex) %]error[% END %]">[% books_loo.rrpgsti | $Price %]</td> > <td class="number gsti [% IF books_loo.ecostgsti.search(zero_regex) %]error[% END %]">[% books_loo.ecostgsti | $Price %]</td> >- <td class="number [% IF books_loo.quantity.search(zero_regex) %]error[% END %]">[% books_loo.quantity %]</td> >+ <td class="number [% IF books_loo.quantity.search(zero_regex) %]error[% END %]">[% IF is_standing and books_loo.quantity == 0 %]N/A[% ELSE %][% books_loo.quantity or 'N/A' %][% END %]</td> > <td class="number gste [% IF books_loo.totalgste.search(zero_regex) %]error[% END %]">[% books_loo.totalgste | $Price %]</td> > <td class="number gsti [% IF books_loo.totalgsti.search(zero_regex) %]error[% END %]">[% books_loo.totalgsti | $Price %]</td> > <td class="number">[% books_loo.gstrate * 100 | $Price %]</td> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >index 84b318c..1e7f4e6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >@@ -113,6 +113,11 @@ > </select> > </li> > [% END %] >+ <li> >+ <label for="is_standing">Orders are standing:</label> >+ <input type="checkbox" id="is_standing" name="is_standing"/> >+ <div class="hint">Standing orders do not close when received.</div> >+ </li> > </ol> > </fieldset> > <fieldset class="action"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >index 77a9abc..6779109 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -43,10 +43,12 @@ function Check(ff) { > _alertString += "\n- "+ _("You must select a fund"); > } > >+[% UNLESS basket.is_standing %] > if (!(isNum(ff.quantity,0)) || ff.quantity.value == 0){ > ok=1; > _alertString += "\n- " + _("Quantity must be greater than '0'"); > } >+[% END %] > > if (!(isNum(ff.listprice,0))){ > ok=1; >@@ -459,30 +461,32 @@ $(document).ready(function() > <fieldset class="rows"> > <legend>Accounting details</legend> > <ol> >- <li> >- [% IF ( close ) %] >- <span class="label required">Quantity: </span> >- <input type="hidden" name="quantity" value="[% quantity %]" />[% quantity %] >- [% ELSE %] >- <label class="required" for="quantity">Quantity: </label> >- [% IF (AcqCreateItemOrdering) %] >- [% IF subscriptionid %] >- <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" /> >- [% ELSE %] >- <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" /> >- [% END %] >+ [% UNLESS basket.is_standing %] >+ <li> >+ [% IF ( close ) %] >+ <span class="label required">Quantity: </span> >+ <input type="hidden" name="quantity" value="[% quantity %]" />[% quantity %] > [% ELSE %] >- [% IF subscriptionid %] >- <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" /> >+ <label class="required" for="quantity">Quantity: </label> >+ [% IF (AcqCreateItemOrdering) %] >+ [% IF subscriptionid %] >+ <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" /> >+ [% ELSE %] >+ <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" /> >+ [% END %] > [% ELSE %] >- <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="updateCosts();" /> >+ [% IF subscriptionid %] >+ <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" /> >+ [% ELSE %] >+ <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="updateCosts();" /> >+ [% END %] > [% END %] >+ <span class="required">Required</span> > [% END %] >- <span class="required">Required</span> >- [% END %] >- <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order --> >- <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" /> >- </li> >+ <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order --> >+ <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" /> >+ </li> >+ [% END %] > <li> > [% IF ( close ) %] > <span class="label required">Fund: </span> >diff --git a/t/db_dependent/Acquisition/NewOrder.t b/t/db_dependent/Acquisition/NewOrder.t >index b491075..53279ff 100644 >--- a/t/db_dependent/Acquisition/NewOrder.t >+++ b/t/db_dependent/Acquisition/NewOrder.t >@@ -67,6 +67,9 @@ foreach my $mandatoryparams_key (@mandatoryparams_keys) { > }; > $return_error = $@; > my $expected_error = "Cannot insert order: Mandatory parameter $mandatoryparams_key is missing"; >+ if ( $mandatoryparams_key eq 'quantity' ) { >+ $expected_error = "Cannot insert order: Quantity is mandatory for non-standing orders"; >+ } > ok( > ( !( defined $order ) ) > && ( index( $return_error, $expected_error ) >= 0 ), >@@ -87,4 +90,4 @@ $order = Koha::Acquisition::Order->fetch({ ordernumber => $ordernumber }); > is( $order->{quantityreceived}, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' ); > is( $order->{entrydate}, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->insert set entrydate to today' ); > >-$schema->storage->txn_rollback(); >\ No newline at end of file >+$schema->storage->txn_rollback(); >diff --git a/t/db_dependent/Acquisition/StandingOrders.t b/t/db_dependent/Acquisition/StandingOrders.t >new file mode 100644 >index 0000000..61c7d24 >--- /dev/null >+++ b/t/db_dependent/Acquisition/StandingOrders.t >@@ -0,0 +1,136 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Test::More tests => 14; >+use C4::Context; >+use C4::Acquisition; >+use C4::Biblio; >+use C4::Items; >+use C4::Bookseller; >+use C4::Budgets; >+use Koha::Acquisition::Order; >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin; >+my $builder = t::lib::TestBuilder->new; >+ >+# Set up configuration data >+ >+my $branch = $builder->build( { source => 'Branch' } ); >+my $bookseller = $builder->build( { source => 'Aqbookseller' } ); >+my $budget = $builder->build( { source => 'Aqbudget' } ); >+my $staffmember = $builder->build( { source => 'Borrower' } ); >+ >+# Create baskets and orders >+ >+my $basketno = NewBasket( >+ $bookseller->{id}, >+ $staffmember->{borrowernumber}, >+ 'Standing order basket', # basketname >+ '', # basketnote >+ '', # basketbooksellernote >+ undef, # basketcontractnumber >+ $branch->{branchcode}, # deliveryplace >+ $branch->{branchcode}, # billingplace >+ 1 # is_standing >+); >+ >+my $nonstandingbasketno = NewBasket( >+ $bookseller->{id}, >+ $staffmember->{borrowernumber}, >+ 'Non-standing order basket', # basketname >+ '', # basketnote >+ '', # basketbooksellernote >+ undef, # basketcontractnumber >+ $branch->{branchcode}, # deliveryplace >+ $branch->{branchcode}, # billingplace >+ 0 # is_standing >+); >+ >+my $basket = GetBasket($basketno); >+ >+is( $basket->{is_standing}, 1, 'basket correctly created as standing order basket' ); >+ >+my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' ); >+ >+my $ordernumber = Koha::Acquisition::Order->new( >+ { >+ basketno => $basketno, >+ biblionumber => $biblionumber, >+ budget_id => $budget->{budget_id}, >+ currency => 'USD', >+ quantity => 0, >+ } >+)->insert->{ordernumber}; >+ >+isnt( $ordernumber, undef, 'standing order successfully created' ); >+ >+eval { >+ Koha::Acquisition::Order->new( >+ { >+ basketno => $nonstandingbasketno, >+ biblionumber => $biblionumber, >+ budget_id => $budget->{budget_id}, >+ currency => 'USD', >+ quantity => 0, >+ } >+ )->insert; >+}; >+ >+like( $@, qr/quantity/im, 'normal orders cannot be created without quantity' ); >+ >+my $search_orders = SearchOrders( { >+ basketno => $basketno, >+ pending => 1, >+ ordered => 1, >+} ); >+ >+ok( >+ scalar @$search_orders == 1 && $search_orders->[0]->{ordernumber} == $ordernumber, >+ 'standing order counts as a pending/ordered order' >+); >+ >+my $invoiceid = AddInvoice( >+ invoicenumber => 'invoice', >+ booksellerid => $bookseller->{id}, >+ unknown => "unknown" >+); >+ >+my ( $datereceived, $new_ordernumber ) = ModReceiveOrder( >+ { >+ biblionumber => $biblionumber, >+ ordernumber => $ordernumber, >+ quantityreceived => 2, >+ cost => 12, >+ ecost => 22, >+ invoiceid => $invoiceid, >+ rrp => 42, >+ } >+); >+ >+isnt( $ordernumber, $new_ordernumber, "standing order split on receive" ); >+ >+my $order = Koha::Acquisition::Order->fetch( { ordernumber => $ordernumber } ); >+my $neworder = Koha::Acquisition::Order->fetch( { ordernumber => $new_ordernumber } ); >+ >+is( $order->{orderstatus}, 'partial', 'original order set to partially received' ); >+is( $order->{quantity}, 0, 'original order quantity unchanged' ); >+is( $order->{quantityreceived}, 0, 'original order has no received items' ); >+isnt( $order->{unitprice}, 12, 'original order does not get cost' ); >+is( $neworder->{orderstatus}, 'complete', 'new order set to complete' ); >+is( $neworder->{quantityreceived}, 2, 'new order has received items' ); >+cmp_ok( $neworder->{unitprice}, '==', 12, 'new order does get cost' ); >+ >+$search_orders = SearchOrders( { >+ basketno => $basketno, >+ pending => 1, >+ ordered => 1, >+} ); >+ >+is( scalar @$search_orders, 1, 'only one pending order after receive' ); >+is( $search_orders->[0]->{ordernumber}, $ordernumber, 'original order is only pending order' ); >+ >+$schema->storage->txn_rollback(); >-- >1.9.1
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 15531
:
47367
|
47569
|
50365
|
50366
|
50636
|
50637
|
50955
|
50956
|
50957
|
50958
| 50960 |
50961
|
50962