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

(-)a/Koha/Item.pm (-10 / +14 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-1794 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 )->delta_days($today)
1791
                                    dt_from_string( $lost_fee_payment->created_on )
1792
                                    ->delta_days($today)
1792
                                    ->in_units('days');
1793
                                    ->in_units('days');
1793
                                if ( $payment_age_in_days > $no_refund_if_lost_fee_paid_age ) {
1794
                                if ( $payment_age_in_days > $no_refund_if_lost_fee_paid_age ) {
1794
                                    $self->add_message(
1795
                                    $self->add_message(
Lines 2174-2185 Returns the effective bookability of the current item, be that item or itemtype Link Here
2174
sub effective_bookable {
2175
sub effective_bookable {
2175
    my ($self) = @_;
2176
    my ($self) = @_;
2176
2177
2177
    my $bookable = $self->bookable // $self->itemtype->bookable;
2178
    return $self->bookable if defined $self->bookable;
2178
    if ( !$bookable && $self->itemtype && $self->itemtype->parent ) {
2179
2179
        $bookable = $self->itemtype->parent->bookable;
2180
    my $itype = $self->itemtype;
2180
    }
2181
    return 0 unless $itype;
2182
2183
    return $itype->bookable if $itype->bookable;
2181
2184
2182
    return $bookable;
2185
    my $parent = $itype->parent;
2186
    return $parent ? $parent->bookable : 0;
2183
}
2187
}
2184
2188
2185
=head3 orders
2189
=head3 orders
(-)a/t/db_dependent/Koha/Item.t (-3 / +9 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 => 9;
3872
    plan tests => 10;
3873
3873
3874
    $schema->storage->txn_begin;
3874
    $schema->storage->txn_begin;
3875
3875
Lines 3950-3955 subtest 'effective_bookable() tests' => sub { Link Here
3950
        '->effective_bookable uses item-level bookable over parent fallback'
3950
        '->effective_bookable uses item-level bookable over parent fallback'
3951
    );
3951
    );
3952
3952
3953
    $child_item->bookable(0)->store();
3954
    $child_item->discard_changes;
3955
    is(
3956
        $child_item->effective_bookable, 0,
3957
        '->effective_bookable item-level bookable=0 is not overridden by bookable parent'
3958
    );
3959
3953
    my $orphan_itype =
3960
    my $orphan_itype =
3954
        $builder->build_object( { class => 'Koha::ItemTypes', value => { bookable => 0, parent_type => undef } } );
3961
        $builder->build_object( { class => 'Koha::ItemTypes', value => { bookable => 0, parent_type => undef } } );
3955
    my $orphan_item = $builder->build_sample_item(
3962
    my $orphan_item = $builder->build_sample_item(
3956
- 

Return to bug 41917