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

(-)a/Koha/Item.pm (-7 / +11 lines)
Lines 179-185 sub store { Link Here
179
179
180
            # If the field has changed otherwise, we much update
180
            # If the field has changed otherwise, we much update
181
            # the 'on' field
181
            # the 'on' field
182
            elsif ( exists $updated_columns{$field}
182
            elsif (exists $updated_columns{$field}
183
                && $updated_columns{$field}
183
                && $updated_columns{$field}
184
                && !$pre_mod_item->$field )
184
                && !$pre_mod_item->$field )
185
            {
185
            {
Lines 381-387 sub safe_to_delete { Link Here
381
        {
381
        {
382
            itemnumber => undef,
382
            itemnumber => undef,
383
        }
383
        }
384
        )->count;
384
    )->count;
385
385
386
    if ($error) {
386
    if ($error) {
387
        return Koha::Result::Boolean->new(0)->add_message( { message => $error } );
387
        return Koha::Result::Boolean->new(0)->add_message( { message => $error } );
Lines 1563-1570 sub columns_to_str { Link Here
1563
              $subfield
1563
              $subfield
1564
            ? $subfield->{authorised_value}
1564
            ? $subfield->{authorised_value}
1565
                ? C4::Biblio::GetAuthorisedValueDesc(
1565
                ? C4::Biblio::GetAuthorisedValueDesc(
1566
                $itemtagfield,
1566
                    $itemtagfield,
1567
                $subfield->{tagsubfield}, $value, '', $tagslib
1567
                    $subfield->{tagsubfield}, $value, '', $tagslib
1568
                )
1568
                )
1569
                : $value
1569
                : $value
1570
            : $value;
1570
            : $value;
Lines 1788-1795 sub _set_found_trigger { Link Here
1788
                            if ($lost_fee_payment) {
1788
                            if ($lost_fee_payment) {
1789
                                my $today = dt_from_string();
1789
                                my $today = dt_from_string();
1790
                                my $payment_age_in_days =
1790
                                my $payment_age_in_days =
1791
                                    dt_from_string( $lost_fee_payment->created_on )
1791
                                    dt_from_string( $lost_fee_payment->created_on )->delta_days($today)
1792
                                    ->delta_days($today)
1793
                                    ->in_units('days');
1792
                                    ->in_units('days');
1794
                                if ( $payment_age_in_days > $no_refund_if_lost_fee_paid_age ) {
1793
                                if ( $payment_age_in_days > $no_refund_if_lost_fee_paid_age ) {
1795
                                    $self->add_message(
1794
                                    $self->add_message(
Lines 2175-2181 Returns the effective bookability of the current item, be that item or itemtype Link Here
2175
sub effective_bookable {
2174
sub effective_bookable {
2176
    my ($self) = @_;
2175
    my ($self) = @_;
2177
2176
2178
    return $self->bookable // $self->itemtype->bookable;
2177
    my $bookable = $self->bookable // $self->itemtype->bookable;
2178
    if ( !$bookable && $self->itemtype && $self->itemtype->parent ) {
2179
        $bookable = $self->itemtype->parent->bookable;
2180
    }
2181
2182
    return $bookable;
2179
}
2183
}
2180
2184
2181
=head3 orders
2185
=head3 orders
(-)a/t/db_dependent/Koha/Item.t (-3 / +41 lines)
Lines 2886-2892 subtest 'store() tests' => sub { Link Here
2886
            {
2886
            {
2887
                borrowernumber    => $patron->id,
2887
                borrowernumber    => $patron->id,
2888
                date              => '1970-01-01 14:00:01',
2888
                date              => '1970-01-01 14:00:01',
2889
                amountoutstanding =>  0,
2889
                amountoutstanding => 0,
2890
                amount            => -5,
2890
                amount            => -5,
2891
                interface         => 'commandline',
2891
                interface         => 'commandline',
2892
                credit_type_code  => 'PAYMENT'
2892
                credit_type_code  => 'PAYMENT'
Lines 3869-3875 subtest 'effective_not_for_loan_status() tests' => sub { Link Here
3869
3869
3870
subtest 'effective_bookable() tests' => sub {
3870
subtest 'effective_bookable() tests' => sub {
3871
3871
3872
    plan tests => 5;
3872
    plan tests => 9;
3873
3873
3874
    $schema->storage->txn_begin;
3874
    $schema->storage->txn_begin;
3875
3875
Lines 3920-3925 subtest 'effective_bookable() tests' => sub { Link Here
3920
        '->effective_bookable returns item specific bookable value when item bookable is defined'
3920
        '->effective_bookable returns item specific bookable value when item bookable is defined'
3921
    );
3921
    );
3922
3922
3923
    note("Parent itemtype fallback tests");
3924
3925
    my $parent_itype = $builder->build_object( { class => 'Koha::ItemTypes', value => { bookable => 1 } } );
3926
    my $child_itype  = $builder->build_object(
3927
        { class => 'Koha::ItemTypes', value => { bookable => 0, parent_type => $parent_itype->itemtype } } );
3928
3929
    my $child_item = $builder->build_sample_item(
3930
        { biblionumber => $biblio->biblionumber, itype => $child_itype->itemtype, bookable => undef } );
3931
3932
    is(
3933
        $child_item->effective_bookable, $parent_itype->bookable,
3934
        '->effective_bookable falls back to parent itemtype when child is not bookable'
3935
    );
3936
3937
    $child_itype->bookable(1)->store();
3938
    $child_itype->discard_changes;
3939
    is(
3940
        $child_item->effective_bookable, 1,
3941
        '->effective_bookable uses child itemtype bookable when set'
3942
    );
3943
3944
    $child_itype->bookable(0)->store();
3945
    $child_itype->discard_changes;
3946
    $child_item->bookable(1)->store();
3947
    $child_item->discard_changes;
3948
    is(
3949
        $child_item->effective_bookable, 1,
3950
        '->effective_bookable uses item-level bookable over parent fallback'
3951
    );
3952
3953
    my $orphan_itype =
3954
        $builder->build_object( { class => 'Koha::ItemTypes', value => { bookable => 0, parent_type => undef } } );
3955
    my $orphan_item = $builder->build_sample_item(
3956
        { biblionumber => $biblio->biblionumber, itype => $orphan_itype->itemtype, bookable => undef } );
3957
    is(
3958
        $orphan_item->effective_bookable, 0,
3959
        '->effective_bookable returns 0 for orphan itemtype with no parent'
3960
    );
3961
3923
    $schema->storage->txn_rollback;
3962
    $schema->storage->txn_rollback;
3924
};
3963
};
3925
3964
3926
- 

Return to bug 41917