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

(-)a/t/db_dependent/Circulation.t (-3 / +72 lines)
Lines 497-503 subtest "GetIssuingCharges tests" => sub { Link Here
497
497
498
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
498
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
499
subtest "CanBookBeRenewed tests" => sub {
499
subtest "CanBookBeRenewed tests" => sub {
500
    plan tests => 114;
500
    plan tests => 115;
501
501
502
    C4::Context->set_preference( 'ItemsDeniedRenewal', '' );
502
    C4::Context->set_preference( 'ItemsDeniedRenewal', '' );
503
503
Lines 1715-1720 subtest "CanBookBeRenewed tests" => sub { Link Here
1715
    );
1715
    );
1716
    t::lib::Mocks::mock_preference( 'UnseenRenewals', 0 );
1716
    t::lib::Mocks::mock_preference( 'UnseenRenewals', 0 );
1717
1717
1718
    subtest 'Bug 35612: fee branch context' => sub {
1719
        plan tests => 8;
1720
1721
        my $lib_home   = $builder->build_object( { class => 'Koha::Libraries' } );
1722
        my $lib_hold   = $builder->build_object( { class => 'Koha::Libraries' } );
1723
        my $lib_issue  = $builder->build_object( { class => 'Koha::Libraries' } );
1724
        my $lib_patron = $builder->build_object( { class => 'Koha::Libraries' } );
1725
1726
        my $patron =
1727
            $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $lib_patron->branchcode } } );
1728
1729
        my $assert_fee_branchcode = sub {
1730
            my ( $fee_type, $circ_control, $lost_control, $hoh, $expected, $label ) = @_;
1731
1732
            t::lib::Mocks::mock_preference( 'CircControl',         $circ_control ) if defined $circ_control;
1733
            t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', $hoh // 'homebranch' );
1734
1735
            my $item = $builder->build_sample_item();
1736
            $item->homebranch( $lib_home->branchcode )->holdingbranch( $lib_hold->branchcode )->store;
1737
1738
            my $checkout = $builder->build_object(
1739
                {
1740
                    class => 'Koha::Checkouts',
1741
                    value => {
1742
                        itemnumber     => $item->itemnumber,
1743
                        borrowernumber => $patron->borrowernumber,
1744
                        branchcode     => $lib_issue->branchcode,
1745
                        date_due       => dt_from_string()->subtract( days => 1 ),
1746
                    }
1747
                }
1748
            );
1749
1750
            C4::Overdues::UpdateFine(
1751
                {
1752
                    issue_id       => $checkout->issue_id,
1753
                    itemnumber     => $item->itemnumber,
1754
                    borrowernumber => $patron->borrowernumber,
1755
                    amount         => 1,
1756
                    due            => $checkout->date_due,
1757
                }
1758
            );
1759
1760
            my $fine = Koha::Account::Lines->search(
1761
                { issue_id => $checkout->issue_id, debit_type_code => 'OVERDUE' },
1762
                { order_by => { -desc => 'accountlines_id' } }
1763
            )->next;
1764
1765
            ok( $fine, "$label: fine created" );
1766
            is( $fine->branchcode, $expected, "$label: branchcode recorded correctly" );
1767
        };
1768
1769
        $assert_fee_branchcode->(
1770
            'OVERDUE', 'PatronLibrary', undef, undef, $lib_patron->branchcode,
1771
            'OVERDUE CircControl=PatronLibrary'
1772
        );
1773
        $assert_fee_branchcode->(
1774
            'OVERDUE', 'PickupLibrary', undef, undef, $lib_issue->branchcode,
1775
            'OVERDUE CircControl=PickupLibrary'
1776
        );
1777
        $assert_fee_branchcode->(
1778
            'OVERDUE', 'ItemHomeLibrary', undef, 'homebranch', $lib_home->branchcode,
1779
            'OVERDUE ItemHomeLibrary + homebranch'
1780
        );
1781
        $assert_fee_branchcode->(
1782
            'OVERDUE', 'ItemHomeLibrary', undef, 'holdingbranch', $lib_hold->branchcode,
1783
            'OVERDUE ItemHomeLibrary + holdingbranch'
1784
        );
1785
1786
    };
1787
1718
    # Test WhenLostForgiveFine and WhenLostChargeReplacementFee
1788
    # Test WhenLostForgiveFine and WhenLostChargeReplacementFee
1719
    t::lib::Mocks::mock_preference( 'WhenLostForgiveFine',          '1' );
1789
    t::lib::Mocks::mock_preference( 'WhenLostForgiveFine',          '1' );
1720
    t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', '1' );
1790
    t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', '1' );
Lines 2339-2345 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
2339
    );
2409
    );
2340
2410
2341
    $item_2->notforloan(0)->store;
2411
    $item_2->notforloan(0)->store;
2342
    $item_3->delete();
2412
    $item_3->notforloan(1)->store;
2343
2413
2344
    # Two items total, one item available, one issued, two holds on record
2414
    # Two items total, one item available, one issued, two holds on record
2345
2415
2346
- 

Return to bug 35612