Lines 1805-1814
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
1805 |
); |
1805 |
); |
1806 |
$rule->store(); |
1806 |
$rule->store(); |
1807 |
|
1807 |
|
1808 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
1808 |
my $now = dt_from_string; |
|
|
1809 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
1809 |
# We want to charge 2 days every day, without grace |
1810 |
# We want to charge 2 days every day, without grace |
1810 |
# With 5 days of overdue: 5 * Z |
1811 |
# With 5 days of overdue: 5 * Z |
1811 |
my $expected_expiration = dt_from_string->add( days => ( 5 * 2 ) / 1 ); |
1812 |
my $expected_expiration = $now->clone->add( days => ( 5 * 2 ) / 1 ); |
1812 |
test_debarment_on_checkout( |
1813 |
test_debarment_on_checkout( |
1813 |
{ |
1814 |
{ |
1814 |
item => $item_1, |
1815 |
item => $item_1, |
Lines 1822-1828
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
1822 |
# We want to charge 2 days every 2 days, without grace |
1823 |
# We want to charge 2 days every 2 days, without grace |
1823 |
# With 5 days of overdue: (5 * 2) / 2 |
1824 |
# With 5 days of overdue: (5 * 2) / 2 |
1824 |
$rule->suspension_chargeperiod(2)->store; |
1825 |
$rule->suspension_chargeperiod(2)->store; |
1825 |
$expected_expiration = dt_from_string->add( days => floor( 5 * 2 ) / 2 ); |
1826 |
$expected_expiration = $now->clone->add( days => floor( 5 * 2 ) / 2 ); |
1826 |
test_debarment_on_checkout( |
1827 |
test_debarment_on_checkout( |
1827 |
{ |
1828 |
{ |
1828 |
item => $item_1, |
1829 |
item => $item_1, |
Lines 1837-1843
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
1837 |
# With 5 days of overdue: ((5-1) / 3 ) * 2 |
1838 |
# With 5 days of overdue: ((5-1) / 3 ) * 2 |
1838 |
$rule->suspension_chargeperiod(3)->store; |
1839 |
$rule->suspension_chargeperiod(3)->store; |
1839 |
$rule->firstremind(1)->store; |
1840 |
$rule->firstremind(1)->store; |
1840 |
$expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) ); |
1841 |
$expected_expiration = $now->clone->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) ); |
1841 |
test_debarment_on_checkout( |
1842 |
test_debarment_on_checkout( |
1842 |
{ |
1843 |
{ |
1843 |
item => $item_1, |
1844 |
item => $item_1, |
Lines 1858-1864
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
1858 |
|
1859 |
|
1859 |
# Adding a holiday 2 days ago |
1860 |
# Adding a holiday 2 days ago |
1860 |
my $calendar = C4::Calendar->new(branchcode => $library->{branchcode}); |
1861 |
my $calendar = C4::Calendar->new(branchcode => $library->{branchcode}); |
1861 |
my $two_days_ago = dt_from_string->subtract( days => 2 ); |
1862 |
my $two_days_ago = $now->clone->subtract( days => 2 ); |
1862 |
$calendar->insert_single_holiday( |
1863 |
$calendar->insert_single_holiday( |
1863 |
day => $two_days_ago->day, |
1864 |
day => $two_days_ago->day, |
1864 |
month => $two_days_ago->month, |
1865 |
month => $two_days_ago->month, |
Lines 1867-1873
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
1867 |
description => 'holidayDesc 2 days ago' |
1868 |
description => 'holidayDesc 2 days ago' |
1868 |
); |
1869 |
); |
1869 |
# With 5 days of overdue, only 4 (x finedays=2) days must charged (one was an holiday) |
1870 |
# With 5 days of overdue, only 4 (x finedays=2) days must charged (one was an holiday) |
1870 |
$expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) ); |
1871 |
$expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) ); |
1871 |
test_debarment_on_checkout( |
1872 |
test_debarment_on_checkout( |
1872 |
{ |
1873 |
{ |
1873 |
item => $item_1, |
1874 |
item => $item_1, |
Lines 1879-1885
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
1879 |
); |
1880 |
); |
1880 |
|
1881 |
|
1881 |
# Adding a holiday 2 days ahead, with finesCalendar=noFinesWhenClosed it should be skipped |
1882 |
# Adding a holiday 2 days ahead, with finesCalendar=noFinesWhenClosed it should be skipped |
1882 |
my $two_days_ahead = dt_from_string->add( days => 2 ); |
1883 |
my $two_days_ahead = $now->clone->add( days => 2 ); |
1883 |
$calendar->insert_single_holiday( |
1884 |
$calendar->insert_single_holiday( |
1884 |
day => $two_days_ahead->day, |
1885 |
day => $two_days_ahead->day, |
1885 |
month => $two_days_ahead->month, |
1886 |
month => $two_days_ahead->month, |
Lines 1889-1895
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
1889 |
); |
1890 |
); |
1890 |
|
1891 |
|
1891 |
# Same as above, but we should skip D+2 |
1892 |
# Same as above, but we should skip D+2 |
1892 |
$expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) + 1 ); |
1893 |
$expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) + 1 ); |
1893 |
test_debarment_on_checkout( |
1894 |
test_debarment_on_checkout( |
1894 |
{ |
1895 |
{ |
1895 |
item => $item_1, |
1896 |
item => $item_1, |
Lines 1925-1932
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
1925 |
item => $item_1, |
1926 |
item => $item_1, |
1926 |
library => $library, |
1927 |
library => $library, |
1927 |
patron => $patron, |
1928 |
patron => $patron, |
1928 |
return_date => dt_from_string->add(days => 5), |
1929 |
return_date => $now->clone->add(days => 5), |
1929 |
expiration_date => dt_from_string->add(days => 5 + (5 * 2 - 1) ), |
1930 |
expiration_date => $now->clone->add(days => 5 + (5 * 2 - 1) ), |
1930 |
} |
1931 |
} |
1931 |
); |
1932 |
); |
1932 |
}; |
1933 |
}; |
Lines 2014-2022
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2014 |
$rule->store(); |
2015 |
$rule->store(); |
2015 |
|
2016 |
|
2016 |
my $now = dt_from_string; |
2017 |
my $now = dt_from_string; |
2017 |
my $one_day_ago = dt_from_string->subtract( days => 1 ); |
2018 |
my $one_day_ago = $now->clone->subtract( days => 1 ); |
2018 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
2019 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2019 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
2020 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2020 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
2021 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
2021 |
|
2022 |
|
2022 |
# No return date specified, today will be used => 10 days overdue charged |
2023 |
# No return date specified, today will be used => 10 days overdue charged |
Lines 2674-2681
subtest 'CanBookBeIssued | is_overdue' => sub {
Link Here
|
2674 |
.10, 1 |
2675 |
.10, 1 |
2675 |
); |
2676 |
); |
2676 |
|
2677 |
|
2677 |
my $five_days_go = output_pref({ dt => dt_from_string->add( days => 5 ), dateonly => 1}); |
2678 |
my $now = dt_from_string; |
2678 |
my $ten_days_go = output_pref({ dt => dt_from_string->add( days => 10), dateonly => 1 }); |
2679 |
my $five_days_go = output_pref({ dt => $now->clone->add( days => 5 ), dateonly => 1}); |
|
|
2680 |
my $ten_days_go = output_pref({ dt => $now->clone->add( days => 10), dateonly => 1 }); |
2679 |
my $library = $builder->build( { source => 'Branch' } ); |
2681 |
my $library = $builder->build( { source => 'Branch' } ); |
2680 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
2682 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
2681 |
|
2683 |
|
2682 |
- |
|
|