View | Details | Raw Unified | Return to bug 15685
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug15685.perl (+11 lines)
Line 0 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    $dbh->do(q{
5
        ALTER TABLE aqbasket
6
            ADD COLUMN create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL
7
    });
8
9
    SetVersion( $DBversion );
10
    print "Upgrade to $DBversion done (Bug 15685: Allow creation of items (AcqCreateItem) to be customizable per-basket)\n";
11
}
(-)a/installer/data/mysql/atomicupdate/bug_15685-add_create_items_to_aqbasket.sql (-1 lines)
Line 1 Link Here
1
ALTER TABLE aqbasket ADD COLUMN create_items ENUM('ordering', 'receiving', 'cataloguing') DEFAULT NULL;
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 2990-2996 CREATE TABLE `aqbasket` ( -- stores data about baskets in acquisitions Link Here
2990
  `basketgroupid` int(11), -- links this basket to its group (aqbasketgroups.id)
2990
  `basketgroupid` int(11), -- links this basket to its group (aqbasketgroups.id)
2991
  `deliveryplace` varchar(10) default NULL, -- basket delivery place
2991
  `deliveryplace` varchar(10) default NULL, -- basket delivery place
2992
  `billingplace` varchar(10) default NULL, -- basket billing place
2992
  `billingplace` varchar(10) default NULL, -- basket billing place
2993
  create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL; -- when items should be created for orders in this basket
2993
  create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL, -- when items should be created for orders in this basket
2994
  branch varchar(10) default NULL, -- basket branch
2994
  branch varchar(10) default NULL, -- basket branch
2995
  is_standing TINYINT(1) NOT NULL DEFAULT 0, -- orders in this basket are standing
2995
  is_standing TINYINT(1) NOT NULL DEFAULT 0, -- orders in this basket are standing
2996
  PRIMARY KEY  (`basketno`),
2996
  PRIMARY KEY  (`basketno`),
(-)a/t/db_dependent/Koha/Acquisition/Basket.t (-1 / +51 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2017 Koha Development team
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use Test::More tests => 8;
22
use Koha::Database;
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
25
use C4::Acquisition;
26
27
use_ok('Koha::Acquisition::Basket');
28
use_ok('Koha::Acquisition::Baskets');
29
30
my $schema = Koha::Database->schema;
31
$schema->storage->txn_begin;
32
my $dbh = C4::Context->dbh;
33
34
# Start transaction
35
$dbh->{RaiseError} = 1;
36
37
my $builder = t::lib::TestBuilder->new;
38
my $basket = $builder->build_object({ class => 'Koha::Acquisition::Baskets', value => { create_items => undef } });
39
my $created_basketno = C4::Acquisition::NewBasket($basket->booksellerid, $basket->authorisedby, $basket->basketname,$basket->note, $basket->booksellernote, $basket->contractnumber, $basket->deliveryplace, $basket->billingplace, $basket->is_standing, $basket->create_items);
40
my $created_basket = Koha::Acquisition::Baskets->find({ basketno => $created_basketno });
41
is($created_basket->basketno, $created_basketno, "Basket created by NewBasket matches db basket");
42
is( $basket->create_items, undef, "Create items value can be null");
43
t::lib::Mocks::mock_preference('AcqCreateItem', 'cataloguing');
44
is( $basket->effective_create_items, "cataloguing","We use AcqCreateItem if basket create items is not set");
45
C4::Acquisition::ModBasketHeader($basket->basketno, $basket->basketname, $basket->note, $basket->booksellernote, $basket->contractnumber, $basket->booksellerid, $basket->deliveryplace, $basket->billingplace, $basket->is_standing, "ordering");
46
my $retrieved_basket = Koha::Acquisition::Baskets->find({ basketno => $basket->basketno });
47
$basket->create_items("ordering");
48
is( $retrieved_basket->create_items, "ordering", "Should be able to set with ModBasketHeader");
49
is( $basket->create_items, "ordering", "Should be able to set with object methods");
50
is_deeply($retrieved_basket->unblessed, $basket->unblessed, "Correct basket found and updated");
51
is( $retrieved_basket->effective_create_items, "ordering","We use basket create items if it is set");

Return to bug 15685