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

(-)a/Koha/CirculationRules.pm (+2 lines)
Lines 499-504 This searches branchitemrules in the following order: Link Here
499
sub get_return_branch_policy {
499
sub get_return_branch_policy {
500
    my ( $self, $item ) = @_;
500
    my ( $self, $item ) = @_;
501
501
502
    return 'noreturn' if $item->floating;
503
502
    my $pref = C4::Context->preference('CircControlReturnsBranch');
504
    my $pref = C4::Context->preference('CircControlReturnsBranch');
503
505
504
    my $branchcode =
506
    my $branchcode =
(-)a/Koha/Item.pm (-1 / +2 lines)
Lines 143-153 sub store { Link Here
143
                 exists $updated_columns{itemlost}
143
                 exists $updated_columns{itemlost}
144
              or exists $updated_columns{withdrawn}
144
              or exists $updated_columns{withdrawn}
145
              or exists $updated_columns{damaged}
145
              or exists $updated_columns{damaged}
146
              or exists $updated_columns{floating}
146
        ) ? $self->get_from_storage : undef;
147
        ) ? $self->get_from_storage : undef;
147
148
148
        # Update *_on  fields if needed
149
        # Update *_on  fields if needed
149
        # FIXME: Why not for AddItem as well?
150
        # FIXME: Why not for AddItem as well?
150
        my @fields = qw( itemlost withdrawn damaged );
151
        my @fields = qw( itemlost withdrawn damaged floating );
151
        for my $field (@fields) {
152
        for my $field (@fields) {
152
153
153
            # If the field is defined but empty or 0, we are
154
            # If the field is defined but empty or 0, we are
(-)a/installer/data/mysql/atomicupdate/bug-XXXXX.pl (+22 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "XXXXX",
5
    description => "Add items.floating and items.floating_on",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        unless (column_exists('items', 'floating')) {
11
            $dbh->do(q{
12
                ALTER TABLE `items` ADD COLUMN `floating` TINYINT NOT NULL DEFAULT 0 COMMENT 'if set, the item does not return to its homebranch after being returned (overrides circulation rules)' AFTER withdrawn_on
13
            });
14
        }
15
16
        unless (column_exists('items', 'floating_on')) {
17
            $dbh->do(q{
18
                ALTER TABLE `items` ADD COLUMN `floating_on` DATETIME NULL DEFAULT NULL COMMENT 'the date and time an item was last marked as floating, NULL if not floating' AFTER floating
19
            });
20
        }
21
    },
22
};
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 3600-3605 CREATE TABLE `items` ( Link Here
3600
  `itemlost_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as lost, NULL if not lost',
3600
  `itemlost_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as lost, NULL if not lost',
3601
  `withdrawn` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as withdrawn (MARC21 952$0)',
3601
  `withdrawn` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as withdrawn (MARC21 952$0)',
3602
  `withdrawn_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as withdrawn, NULL if not withdrawn',
3602
  `withdrawn_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as withdrawn, NULL if not withdrawn',
3603
  `floating` TINYINT NOT NULL DEFAULT 0 COMMENT 'if set, the item does not return to its homebranch after being returned (overrides circulation rules)',
3604
  `floating_on` DATETIME NULL DEFAULT NULL COMMENT 'the date and time an item was last marked as floating, NULL if not floating',
3603
  `itemcallnumber` varchar(255) DEFAULT NULL COMMENT 'call number for this item (MARC21 952$o)',
3605
  `itemcallnumber` varchar(255) DEFAULT NULL COMMENT 'call number for this item (MARC21 952$o)',
3604
  `coded_location_qualifier` varchar(10) DEFAULT NULL COMMENT 'coded location qualifier(MARC21 952$f)',
3606
  `coded_location_qualifier` varchar(10) DEFAULT NULL COMMENT 'coded location qualifier(MARC21 952$f)',
3605
  `issues` smallint(6) DEFAULT 0 COMMENT 'number of times this item has been checked out/issued',
3607
  `issues` smallint(6) DEFAULT 0 COMMENT 'number of times this item has been checked out/issued',
(-)a/t/db_dependent/Circulation/AddReturn/floating.t (+47 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use Test::More;
5
6
use C4::Circulation;
7
use Koha::Database;
8
9
use t::lib::TestBuilder;
10
use t::lib::Mocks;
11
12
my $builder = t::lib::TestBuilder->new();
13
my $schema = Koha::Database->schema;
14
15
$schema->txn_begin();
16
17
my $biblio = $builder->build_sample_biblio();
18
my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, floating => 1 });
19
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
20
my $other_library = $builder->build_object({ class => 'Koha::Libraries' });
21
22
t::lib::Mocks::mock_userenv({ patron => $patron });
23
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary');
24
t::lib::Mocks::mock_preference('AllowReturnToBranch', 'anywhere');
25
26
Koha::CirculationRule->new(
27
    {
28
        branchcode   => $patron->branchcode,
29
        itemtype     => $biblio->itemtype,
30
        categorycode => $patron->categorycode,
31
        rule_name    => 'returnbranch',
32
        rule_value   => 'homebranch'
33
    }
34
);
35
36
C4::Circulation::AddIssue($patron->unblessed, $item->barcode);
37
my ($doreturn, $messages) = C4::Circulation::AddReturn($item->barcode, $other_library->branchcode);
38
$item->discard_changes;
39
40
ok($doreturn, 'item is returned');
41
ok(!exists $messages->{WasTransfered}, 'no transfer was done');
42
is($item->holdingbranch, $other_library->branchcode, 'item holding branch was changed');
43
44
$schema->txn_rollback();
45
46
done_testing;
47
(-)a/t/db_dependent/Circulation/Branch.t (-2 / +9 lines)
Lines 332-338 t::lib::Mocks::mock_preference( 'item-level_itypes', 0 ); Link Here
332
$schema->storage->txn_rollback;
332
$schema->storage->txn_rollback;
333
333
334
subtest "GetBranchItemRule() tests" => sub {
334
subtest "GetBranchItemRule() tests" => sub {
335
    plan tests => 3;
335
    plan tests => 5;
336
336
337
    $schema->storage->txn_begin;
337
    $schema->storage->txn_begin;
338
338
Lines 390-398 subtest "GetBranchItemRule() tests" => sub { Link Here
390
    t::lib::Mocks::mock_preference( 'CircControlReturnsBranch', 'ItemHomeLibrary' );
390
    t::lib::Mocks::mock_preference( 'CircControlReturnsBranch', 'ItemHomeLibrary' );
391
    is( Koha::CirculationRules->get_return_branch_policy($item), 'homebranch' );
391
    is( Koha::CirculationRules->get_return_branch_policy($item), 'homebranch' );
392
392
393
    $item->floating(1);
394
    is( Koha::CirculationRules->get_return_branch_policy($item), 'noreturn' );
395
    $item->floating(0);
396
393
    t::lib::Mocks::mock_preference( 'CircControlReturnsBranch', 'ItemHoldingLibrary' );
397
    t::lib::Mocks::mock_preference( 'CircControlReturnsBranch', 'ItemHoldingLibrary' );
394
    is( Koha::CirculationRules->get_return_branch_policy($item), 'holdingbranch' );
398
    is( Koha::CirculationRules->get_return_branch_policy($item), 'holdingbranch' );
395
399
400
    $item->floating(1);
401
    is( Koha::CirculationRules->get_return_branch_policy($item), 'noreturn' );
402
    $item->floating(0);
403
396
    t::lib::Mocks::mock_preference( 'CircControlReturnsBranch', 'CheckInLibrary' );
404
    t::lib::Mocks::mock_preference( 'CircControlReturnsBranch', 'CheckInLibrary' );
397
    is( Koha::CirculationRules->get_return_branch_policy($item), 'noreturn' );
405
    is( Koha::CirculationRules->get_return_branch_policy($item), 'noreturn' );
398
406
399
- 

Return to bug 33075