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

(-)a/t/db_dependent/Circulation.t (+9 lines)
Lines 686-691 subtest "CanBookBeRenewed tests" => sub { Link Here
686
            categorycode => undef,
686
            categorycode => undef,
687
            branchcode   => undef,
687
            branchcode   => undef,
688
            itemtype     => undef,
688
            itemtype     => undef,
689
            onsite_checkout => undef,
689
            rule_name    => 'norenewalbefore',
690
            rule_name    => 'norenewalbefore',
690
            rule_value   => '7',
691
            rule_value   => '7',
691
        }
692
        }
Lines 2227-2232 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2227
            categorycode => undef,
2228
            categorycode => undef,
2228
            branchcode   => undef,
2229
            branchcode   => undef,
2229
            itemtype     => undef,
2230
            itemtype     => undef,
2231
            onsite_checkout => undef,
2230
            rule_name    => 'suspension_chargeperiod',
2232
            rule_name    => 'suspension_chargeperiod',
2231
            rule_value   => '2',
2233
            rule_value   => '2',
2232
        }
2234
        }
Lines 2746-2751 subtest 'AddReturn | is_overdue' => sub { Link Here
2746
                    branchcode   => $branchcode_false,
2748
                    branchcode   => $branchcode_false,
2747
                    categorycode => undef,
2749
                    categorycode => undef,
2748
                    itemtype     => undef,
2750
                    itemtype     => undef,
2751
                    onsite_checkout => undef,
2749
                    rule_name    => 'lostreturn',
2752
                    rule_name    => 'lostreturn',
2750
                    rule_value   => 0
2753
                    rule_value   => 0
2751
                }
2754
                }
Lines 2760-2765 subtest 'AddReturn | is_overdue' => sub { Link Here
2760
                    branchcode   => $branchcode_refund,
2763
                    branchcode   => $branchcode_refund,
2761
                    categorycode => undef,
2764
                    categorycode => undef,
2762
                    itemtype     => undef,
2765
                    itemtype     => undef,
2766
                    onsite_checkout => undef,
2763
                    rule_name    => 'lostreturn',
2767
                    rule_name    => 'lostreturn',
2764
                    rule_value   => 'refund'
2768
                    rule_value   => 'refund'
2765
                }
2769
                }
Lines 2774-2779 subtest 'AddReturn | is_overdue' => sub { Link Here
2774
                    branchcode   => $branchcode_restore,
2778
                    branchcode   => $branchcode_restore,
2775
                    categorycode => undef,
2779
                    categorycode => undef,
2776
                    itemtype     => undef,
2780
                    itemtype     => undef,
2781
                    onsite_checkout => undef,
2777
                    rule_name    => 'lostreturn',
2782
                    rule_name    => 'lostreturn',
2778
                    rule_value   => 'restore'
2783
                    rule_value   => 'restore'
2779
                }
2784
                }
Lines 2788-2793 subtest 'AddReturn | is_overdue' => sub { Link Here
2788
                    branchcode   => $branchcode_charge,
2793
                    branchcode   => $branchcode_charge,
2789
                    categorycode => undef,
2794
                    categorycode => undef,
2790
                    itemtype     => undef,
2795
                    itemtype     => undef,
2796
                    onsite_checkout => undef,
2791
                    rule_name    => 'lostreturn',
2797
                    rule_name    => 'lostreturn',
2792
                    rule_value   => 'charge'
2798
                    rule_value   => 'charge'
2793
                }
2799
                }
Lines 3956-3961 subtest 'Incremented fee tests' => sub { Link Here
3956
            categorycode => $patron->categorycode,
3962
            categorycode => $patron->categorycode,
3957
            itemtype     => $itemtype->id,
3963
            itemtype     => $itemtype->id,
3958
            branchcode   => $library->id,
3964
            branchcode   => $library->id,
3965
            onsite_checkout => undef,
3959
            rule_name    => 'lengthunit',
3966
            rule_name    => 'lengthunit',
3960
            rule_value   => 'hours',
3967
            rule_value   => 'hours',
3961
        }
3968
        }
Lines 4206-4211 subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { Link Here
4206
                branchcode   => undef,
4213
                branchcode   => undef,
4207
                categorycode => undef,
4214
                categorycode => undef,
4208
                itemtype     => undef,
4215
                itemtype     => undef,
4216
                onsite_checkout => undef,
4209
                rule_name    => 'lostreturn',
4217
                rule_name    => 'lostreturn',
4210
                rule_value   => 'refund'
4218
                rule_value   => 'refund'
4211
            }
4219
            }
Lines 4399-4404 subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub { Link Here
4399
                branchcode   => undef,
4407
                branchcode   => undef,
4400
                categorycode => undef,
4408
                categorycode => undef,
4401
                itemtype     => undef,
4409
                itemtype     => undef,
4410
                onsite_checkout => undef,
4402
                rule_name    => 'lostreturn',
4411
                rule_name    => 'lostreturn',
4403
                rule_value   => 'refund'
4412
                rule_value   => 'refund'
4404
            }
4413
            }
(-)a/t/db_dependent/Circulation/CalcFine.t (-1 / +4 lines)
Lines 69-74 subtest 'Test basic functionality' => sub { Link Here
69
            branchcode   => undef,
69
            branchcode   => undef,
70
            categorycode => undef,
70
            categorycode => undef,
71
            itemtype     => undef,
71
            itemtype     => undef,
72
            onsite_checkout => undef,
72
            rules        => {
73
            rules        => {
73
                fine                          => '1.00',
74
                fine                          => '1.00',
74
                lengthunit                    => 'days',
75
                lengthunit                    => 'days',
Lines 109-114 subtest 'Test cap_fine_to_replacement_price' => sub { Link Here
109
            branchcode   => undef,
110
            branchcode   => undef,
110
            categorycode => undef,
111
            categorycode => undef,
111
            itemtype     => undef,
112
            itemtype     => undef,
113
            onsite_checkout => undef,
112
            rules        => {
114
            rules        => {
113
                fine                          => '1.00',
115
                fine                          => '1.00',
114
                lengthunit                    => 'days',
116
                lengthunit                    => 'days',
Lines 162-167 subtest 'Test cap_fine_to_replacement_pricew with overduefinescap' => sub { Link Here
162
            branchcode   => undef,
164
            branchcode   => undef,
163
            categorycode => undef,
165
            categorycode => undef,
164
            itemtype     => undef,
166
            itemtype     => undef,
167
            onsite_checkout => undef,
165
            rules        => {
168
            rules        => {
166
                fine                          => '1.00',
169
                fine                          => '1.00',
167
                lengthunit                    => 'days',
170
                lengthunit                    => 'days',
Lines 189-195 subtest 'Test cap_fine_to_replacement_pricew with overduefinescap' => sub { Link Here
189
    my ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
192
    my ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
190
    is( int($amount), 3, 'Got the lesser of overduefinescap and replacement price where overduefinescap < replacement price' );
193
    is( int($amount), 3, 'Got the lesser of overduefinescap and replacement price where overduefinescap < replacement price' );
191
194
192
    Koha::CirculationRules->set_rule({ rule_name => 'overduefinescap', rule_value => 6, branchcode => undef, categorycode => undef, itemtype => undef });
195
    Koha::CirculationRules->set_rule({ rule_name => 'overduefinescap', rule_value => 6, branchcode => undef, onsite_checkout => undef, categorycode => undef, itemtype => undef });
193
    ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
196
    ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
194
    is( int($amount), 5, 'Get the lesser of overduefinescap and replacement price where overduefinescap > replacement price' );
197
    is( int($amount), 5, 'Get the lesser of overduefinescap and replacement price where overduefinescap > replacement price' );
195
198
(-)a/t/db_dependent/Circulation/ReturnClaims.t (+1 lines)
Lines 51-56 Koha::CirculationRules->set_rule( Link Here
51
        branchcode   => undef,
51
        branchcode   => undef,
52
        categorycode => undef,
52
        categorycode => undef,
53
        itemtype     => undef,
53
        itemtype     => undef,
54
        onsite_checkout => undef,
54
        rule_name    => 'issuelength',
55
        rule_name    => 'issuelength',
55
        rule_value   => 1
56
        rule_value   => 1
56
    }
57
    }
(-)a/t/db_dependent/Circulation/Returns.t (+1 lines)
Lines 63-68 Koha::CirculationRules->set_rule( Link Here
63
        categorycode => undef,
63
        categorycode => undef,
64
        itemtype     => undef,
64
        itemtype     => undef,
65
        branchcode   => undef,
65
        branchcode   => undef,
66
        onsite_checkout => undef,
66
        rule_name    => 'issuelength',
67
        rule_name    => 'issuelength',
67
        rule_value   => 1,
68
        rule_value   => 1,
68
    }
69
    }
(-)a/t/db_dependent/Koha/IssuingRules.t (-3 / +30 lines)
Lines 154-162 subtest 'set_rule' => sub { Link Here
154
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
154
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
155
    my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
155
    my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
156
    my $itemtype     = $builder->build({ source => 'Itemtype' })->{'itemtype'};
156
    my $itemtype     = $builder->build({ source => 'Itemtype' })->{'itemtype'};
157
    my $onsite_checkout = 0;
157
158
158
    subtest 'Correct call' => sub {
159
    subtest 'Correct call' => sub {
159
        plan tests => 4;
160
        plan tests => 5;
160
161
161
        Koha::CirculationRules->delete;
162
        Koha::CirculationRules->delete;
162
163
Lines 172-177 subtest 'set_rule' => sub { Link Here
172
            Koha::CirculationRules->set_rule( {
173
            Koha::CirculationRules->set_rule( {
173
                branchcode => $branchcode,
174
                branchcode => $branchcode,
174
                categorycode => $categorycode,
175
                categorycode => $categorycode,
176
                onsite_checkout => $onsite_checkout,
175
                rule_name => 'patron_maxissueqty',
177
                rule_name => 'patron_maxissueqty',
176
                rule_value => '',
178
                rule_value => '',
177
            } );
179
            } );
Lines 191-200 subtest 'set_rule' => sub { Link Here
191
                branchcode => $branchcode,
193
                branchcode => $branchcode,
192
                categorycode => $categorycode,
194
                categorycode => $categorycode,
193
                itemtype => $itemtype,
195
                itemtype => $itemtype,
196
                onsite_checkout => $onsite_checkout,
194
                rule_name => 'fine',
197
                rule_name => 'fine',
195
                rule_value => '',
198
                rule_value => '',
196
            } );
199
            } );
197
        }, 'setting fine with branch/category/itemtype succeeds' );
200
        }, 'setting fine with branch/category/itemtype/onsite_checkout succeeds' );
201
202
        lives_ok( sub {
203
            Koha::CirculationRules->set_rule( {
204
                branchcode => $branchcode,
205
                categorycode => $categorycode,
206
                itemtype => $itemtype,
207
                onsite_checkout => $onsite_checkout,
208
                rule_name => 'maxissueqty',
209
                rule_value => 5,
210
            } );
211
        }, 'setting maxissueqty with branch/category/itemtype/onsite_checkout succeeds' );
198
    };
212
    };
199
213
200
    subtest 'Call with missing params' => sub {
214
    subtest 'Call with missing params' => sub {
Lines 212-217 subtest 'set_rule' => sub { Link Here
212
        throws_ok( sub {
226
        throws_ok( sub {
213
            Koha::CirculationRules->set_rule( {
227
            Koha::CirculationRules->set_rule( {
214
                branchcode => $branchcode,
228
                branchcode => $branchcode,
229
                onsite_checkout => $onsite_checkout,
215
                rule_name => 'patron_maxissueqty',
230
                rule_name => 'patron_maxissueqty',
216
                rule_value => '',
231
                rule_value => '',
217
            } );
232
            } );
Lines 229-234 subtest 'set_rule' => sub { Link Here
229
            Koha::CirculationRules->set_rule( {
244
            Koha::CirculationRules->set_rule( {
230
                branchcode => $branchcode,
245
                branchcode => $branchcode,
231
                categorycode => $categorycode,
246
                categorycode => $categorycode,
247
                onsite_checkout => undef,
232
                rule_name => 'fine',
248
                rule_name => 'fine',
233
                rule_value => '',
249
                rule_value => '',
234
            } );
250
            } );
Lines 236-242 subtest 'set_rule' => sub { Link Here
236
    };
252
    };
237
253
238
    subtest 'Call with extra params' => sub {
254
    subtest 'Call with extra params' => sub {
239
        plan tests => 3;
255
        plan tests => 4;
240
256
241
        Koha::CirculationRules->delete;
257
        Koha::CirculationRules->delete;
242
258
Lines 252-257 subtest 'set_rule' => sub { Link Here
252
        throws_ok( sub {
268
        throws_ok( sub {
253
            Koha::CirculationRules->set_rule( {
269
            Koha::CirculationRules->set_rule( {
254
                branchcode => $branchcode,
270
                branchcode => $branchcode,
271
                onsite_checkout => undef,
255
                categorycode => $categorycode,
272
                categorycode => $categorycode,
256
                itemtype => $itemtype,
273
                itemtype => $itemtype,
257
                rule_name => 'patron_maxissueqty',
274
                rule_name => 'patron_maxissueqty',
Lines 268-273 subtest 'set_rule' => sub { Link Here
268
                rule_value => '',
285
                rule_value => '',
269
            } );
286
            } );
270
        }, qr/categorycode/, 'setting holdallowed with categorycode fails' );
287
        }, qr/categorycode/, 'setting holdallowed with categorycode fails' );
288
289
        throws_ok( sub {
290
            Koha::CirculationRules->set_rule( {
291
                branchcode => $branchcode,
292
                onsite_checkout => undef,
293
                rule_name => 'holdallowed',
294
                itemtype => $itemtype,
295
                rule_value => '',
296
            } );
297
        }, qr/onsite_checkout/, 'setting holdallowed with onsite_checkout fails' );
271
    };
298
    };
272
};
299
};
273
300
(-)a/t/db_dependent/Koha/Items.t (-1 / +3 lines)
Lines 778-783 subtest 'store' => sub { Link Here
778
                        branchcode   => $manager->branchcode,
778
                        branchcode   => $manager->branchcode,
779
                        categorycode => undef,
779
                        categorycode => undef,
780
                        itemtype     => undef,
780
                        itemtype     => undef,
781
                        onsite_checkout => undef,
781
                        rule_name    => 'lostreturn',
782
                        rule_name    => 'lostreturn',
782
                        rule_value   => 'restore'
783
                        rule_value   => 'restore'
783
                    }
784
                    }
Lines 870-875 subtest 'store' => sub { Link Here
870
                        branchcode   => $manager->branchcode,
871
                        branchcode   => $manager->branchcode,
871
                        categorycode => undef,
872
                        categorycode => undef,
872
                        itemtype     => undef,
873
                        itemtype     => undef,
874
                        onsite_checkout => undef,
873
                        rule_name    => 'lostreturn',
875
                        rule_name    => 'lostreturn',
874
                        rule_value   => 'restore'
876
                        rule_value   => 'restore'
875
                    }
877
                    }
Lines 981-986 subtest 'store' => sub { Link Here
981
                        branchcode   => $manager->branchcode,
983
                        branchcode   => $manager->branchcode,
982
                        categorycode => undef,
984
                        categorycode => undef,
983
                        itemtype     => undef,
985
                        itemtype     => undef,
986
                        onsite_checkout => undef,
984
                        rule_name    => 'lostreturn',
987
                        rule_name    => 'lostreturn',
985
                        rule_value   => 'restore'
988
                        rule_value   => 'restore'
986
                    }
989
                    }
987
- 

Return to bug 26814