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

(-)a/C4/Circulation.pm (-19 / +49 lines)
Lines 1446-1464 sub AddIssue { Link Here
1446
                UpdateTotalIssues( $item_object->biblionumber, 1 );
1446
                UpdateTotalIssues( $item_object->biblionumber, 1 );
1447
            }
1447
            }
1448
1448
1449
            ## If item was lost, it has now been found, reverse any list item charges if necessary.
1449
            ## If item was lost, it has now been found, reverse any lost item charges if necessary.
1450
            if ( $item_object->itemlost ) {
1450
            if ( $item_object->itemlost ) {
1451
                if (
1451
                my $lostreturn_policy =
1452
                    Koha::CirculationRules->get_lostreturn_policy(
1452
                  Koha::CirculationRules->get_lostreturn_policy(
1453
                        {
1453
                    {
1454
                            return_branch => C4::Context->userenv->{branch},
1454
                        return_branch => C4::Context->userenv->{branch},
1455
                            item          => $item_object
1455
                        item          => $item_object
1456
                        }
1456
                    }
1457
                    )
1457
                  );
1458
                  )
1458
1459
                {
1459
                if ($lostreturn_policy) {
1460
                    _FixAccountForLostAndFound( $item_object->itemnumber, undef,
1460
                    _FixAccountForLostAndFound( $item_object->itemnumber, undef,
1461
                        $item_object->barcode );
1461
                        $item_object->barcode );
1462
1463
                    if ( $lostreturn_policy eq 'charge' ) {
1464
                        _CalculateAndUpdateFine(
1465
                            {
1466
                                issue    => $issue,
1467
                                item     => $item_unblessed,
1468
                                borrower => $borrower
1469
                            }
1470
                        );
1471
                        _FixOverduesOnReturn( $borrower->{borrowernumber},
1472
                            $item_object->itemnumber, undef, 'RENEWED' );
1473
                    }
1474
                    elsif ( $lostreturn_policy eq 'restore' ) {
1475
1476
                    }
1462
                }
1477
                }
1463
            }
1478
            }
1464
1479
Lines 2031-2048 sub AddReturn { Link Here
2031
    if ( $item->itemlost ) {
2046
    if ( $item->itemlost ) {
2032
        $messages->{'WasLost'} = 1;
2047
        $messages->{'WasLost'} = 1;
2033
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2048
        unless ( C4::Context->preference("BlockReturnOfLostItems") ) {
2034
            if (
2049
            my $lostreturn_policy =
2035
                Koha::CirculationRules->get_lostreturn_policy(
2050
              Koha::CirculationRules->get_lostreturn_policy(
2036
                    {
2051
                {
2037
                        return_branch => C4::Context->userenv->{branch},
2052
                    return_branch => C4::Context->userenv->{branch},
2038
                        item          => $item,
2053
                    item          => $item
2039
                    }
2054
                }
2040
                  )
2055
              );
2041
              )
2056
2042
            {
2057
            if ($lostreturn_policy) {
2043
                _FixAccountForLostAndFound( $item->itemnumber,
2058
                _FixAccountForLostAndFound( $item->itemnumber,
2044
                    $borrowernumber, $barcode );
2059
                    $borrowernumber, $barcode );
2045
                $messages->{'LostItemFeeRefunded'} = 1;
2060
                $messages->{'LostItemFeeRefunded'} = 1;
2061
2062
                if ( $lostreturn_policy eq 'charge' ) {
2063
                    _CalculateAndUpdateFine(
2064
                        {
2065
                            issue       => $issue,
2066
                            item        => $item,
2067
                            borrower    => $patron_unblessed,
2068
                            return_date => $return_date
2069
                        }
2070
                    );
2071
                    $messages->{'LostItemFeeCharged'} = 1;
2072
                }
2073
                elsif ( $lostreturn_policy eq 'restore' ) {
2074
                    $messages->{'LostItemFeeRestored'} = 1;
2075
                }
2046
            }
2076
            }
2047
        }
2077
        }
2048
    }
2078
    }
(-)a/Koha/CirculationRules.pm (-4 / +15 lines)
Lines 46-52 Any attempt to set a rule with a nonsensical scope (for instance, setting the C< Link Here
46
=cut
46
=cut
47
47
48
our $RULE_KINDS = {
48
our $RULE_KINDS = {
49
    refund => {
49
    lostreturn => {
50
        scope => [ 'branchcode' ],
50
        scope => [ 'branchcode' ],
51
    },
51
    },
52
52
Lines 425-431 sub get_onshelfholds_policy { Link Here
425
425
426
=head3 get_lostreturn_policy
426
=head3 get_lostreturn_policy
427
427
428
  my $refund = Koha::CirculationRules->get_lostreturn_policy( { return_branch => $return_branch, item => $item } );
428
  my $lostrefund_policy = Koha::CirculationRules->get_lostreturn_policy( { return_branch => $return_branch, item => $item } );
429
430
Return values are:
431
432
=over 2
433
434
=item 0 - Do not refund
435
=item refund - Refund the lost item charge
436
=item restore - Refund the lost item charge and restore the original overdue fine
437
=item charge - Refund the lost item charge and charge a new overdue fine
438
439
=back
429
440
430
=cut
441
=cut
431
442
Lines 446-456 sub get_lostreturn_policy { Link Here
446
    my $rule = Koha::CirculationRules->get_effective_rule(
457
    my $rule = Koha::CirculationRules->get_effective_rule(
447
        {
458
        {
448
            branchcode => $branch,
459
            branchcode => $branch,
449
            rule_name  => 'refund',
460
            rule_name  => 'lostreturn',
450
        }
461
        }
451
    );
462
    );
452
463
453
    return $rule ? $rule->rule_value : 1;
464
    return $rule ? $rule->rule_value : 'refund';
454
}
465
}
455
466
456
=head3 article_requestable_rules
467
=head3 article_requestable_rules
(-)a/admin/smart-rules.pl (-8 / +8 lines)
Lines 522-537 elsif ($op eq "add-branch-item") { Link Here
522
}
522
}
523
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
523
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
524
524
525
    my $refund = $input->param('refund');
525
    my $lostreturn = $input->param('lostreturn');
526
526
527
    if ( $refund eq '*' ) {
527
    if ( $lostreturn eq '*' ) {
528
        if ( $branch ne '*' ) {
528
        if ( $branch ne '*' ) {
529
            # only do something for $refund eq '*' if branch-specific
529
            # only do something for $lostreturn eq '*' if branch-specific
530
            Koha::CirculationRules->set_rules(
530
            Koha::CirculationRules->set_rules(
531
                {
531
                {
532
                    branchcode   => $branch,
532
                    branchcode   => $branch,
533
                    rules        => {
533
                    rules        => {
534
                        refund => undef
534
                        lostreturn => undef
535
                    }
535
                    }
536
                }
536
                }
537
            );
537
            );
Lines 541-558 elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) { Link Here
541
            {
541
            {
542
                branchcode   => $branch,
542
                branchcode   => $branch,
543
                rules        => {
543
                rules        => {
544
                    refund => $refund
544
                    lostreturn => $lostreturn
545
                }
545
                }
546
            }
546
            }
547
        );
547
        );
548
    }
548
    }
549
}
549
}
550
550
551
my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'refund' });
551
my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'lostreturn' });
552
my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'refund' });
552
my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'lostreturn' });
553
$template->param(
553
$template->param(
554
    refundLostItemFeeRule => $refundLostItemFeeRule,
554
    refundLostItemFeeRule => $refundLostItemFeeRule,
555
    defaultRefundRule     => $defaultLostItemFeeRule ? $defaultLostItemFeeRule->rule_value : 1
555
    defaultRefundRule     => $defaultLostItemFeeRule ? $defaultLostItemFeeRule->rule_value : 'refund'
556
);
556
);
557
557
558
my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] });
558
my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-32 / +56 lines)
Lines 718-740 Link Here
718
                </tr>
718
                </tr>
719
                <tr>
719
                <tr>
720
                    <td>
720
                    <td>
721
                        <select name="refund">
721
                        <select name="lostreturn">
722
                          [%# Default branch %]
722
                          [%# Default branch %]
723
                          [% IF ( current_branch == '*' ) %]
723
                          [% IF ( current_branch == '*' ) %]
724
                            [% IF ( defaultRefundRule ) %]
724
                            [% IF ( defaultRefundRule == 'refund' ) %]
725
                            <option value="1" selected="selected">
725
                            <option value="refund" selected="selected">Refund lost item charge</option>
726
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
727
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
728
                            <option value="0">Leave lost item charge</option>
729
                            [% ELSIF ( defaultRefundRule == 'charge' ) %]
730
                            <option value="refund">Refund lost item charge</option>
731
                            <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
732
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
733
                            <option value="0">Leave lost item charge</option>
734
                            [% ELSIF ( defaultRefundRule == 'restore' ) %]
735
                            <option value="refund">Refund lost item charge</option>
736
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
737
                            <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option>
738
                            <option value="0">Leave lost item charge</option>
739
                            [% ELSIF ( defaultRefundRule == 0 ) %]
740
                            <option value="refund">Refund lost item charge</option>
741
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
742
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
743
                            <option value="0" selected="selected">Leave lost item charge</option>
726
                            [% ELSE %]
744
                            [% ELSE %]
727
                            <option value="1">
745
                            <option value="refund">Refund lost item charge</option>
746
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
747
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
748
                            <option value="0">Leave lost item charge</option>
728
                            [% END %]
749
                            [% END %]
729
                                Yes
730
                            </option>
731
                            [% IF ( not defaultRefundRule ) %]
732
                            <option value="0" selected="selected">
733
                            [% ELSE %]
734
                            <option value="0">
735
                            [% END %]
736
                                No
737
                            </option>
738
                          [% ELSE %]
750
                          [% ELSE %]
739
                          [%# Branch-specific %]
751
                          [%# Branch-specific %]
740
                            [% IF ( not refundLostItemFeeRule ) %]
752
                            [% IF ( not refundLostItemFeeRule ) %]
Lines 742-771 Link Here
742
                            [% ELSE %]
754
                            [% ELSE %]
743
                                <option value="*">
755
                                <option value="*">
744
                            [% END %]
756
                            [% END %]
745
                              [% IF defaultRefundRule %]
757
                              [% IF defaultRefundRule == 'refund' %]
746
                                Use default (Yes)
758
                                Use default (Refund lost item charge)
759
                              [% ELSIF defaultRefundRule == 'charge' %]
760
                                Use default (Refund lost item charge and restore overdue fine)
761
                              [% ELSIF defaultRefundRule == 'restore' %]
762
                                Use default (Refund lost item charge and charge new overdue fine)
747
                              [% ELSE %]
763
                              [% ELSE %]
748
                                Use default (No)
764
                                Use default (Leave lost item charge)
749
                              [% END %]
765
                              [% END %]
750
                                </option>
766
                                </option>
751
                            [% IF ( not refundLostItemFeeRule ) %]
767
                            [% IF ( not refundLostItemFeeRule ) %]
752
                                <option value="1">Yes</option>
768
                                <option value="refund">Refund lost item charge</option>
753
                                <option value="0">No</option>
769
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
770
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
771
                                <option value="0">Leave lost item charge</option>
754
                            [% ELSE %]
772
                            [% ELSE %]
755
                                [% IF ( refundLostItemFeeRule.rule_value ) %]
773
                                [% IF ( refundLostItemFeeRule.rule_value == 'refund' ) %]
756
                                <option value="1" selected="selected">
774
                                <option value="refund" selected="selected">Refund lost item charge</option>
757
                                [% ELSE %]
775
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
758
                                <option value="1">
776
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
777
                                <option value="0">Leave lost item charge</option>
778
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 'charge' ) %]
779
                                <option value="refund">Refund lost item charge</option>
780
                                <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
781
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
782
                                <option value="0">Leave lost item charge</option>
783
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 'restore' ) %]
784
                                <option value="refund">Refund lost item charge</option>
785
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
786
                                <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option>
787
                                <option value="0">Leave lost item charge</option>
788
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 0 ) %]
789
                                <option value="refund">Refund lost item charge</option>
790
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
791
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
792
                                <option value="0" selected="selected">Leave lost item charge</option>
759
                                [% END %]
793
                                [% END %]
760
                                    Yes
761
                                </option>
762
                                [% IF ( not refundLostItemFeeRule.rule_value ) %]
763
                                <option value="0" selected="selected">
764
                                [% ELSE %]
765
                                <option value="0">
766
                                [% END %]
767
                                    No
768
                                </option>
769
                            [% END %]
794
                            [% END %]
770
                          [% END %]
795
                          [% END %]
771
                        </select>
796
                        </select>
772
- 

Return to bug 23091