|
Lines 41-47
use C4::Biblio;
Link Here
|
| 41 |
use C4::Items qw( ModItemTransfer ); |
41 |
use C4::Items qw( ModItemTransfer ); |
| 42 |
use C4::Log; |
42 |
use C4::Log; |
| 43 |
use C4::Reserves qw( AddReserve ModReserve ModReserveCancelAll ModReserveAffect CheckReserves ); |
43 |
use C4::Reserves qw( AddReserve ModReserve ModReserveCancelAll ModReserveAffect CheckReserves ); |
| 44 |
use C4::Overdues qw( CalcFine UpdateFine get_chargeable_units ); |
44 |
use C4::Overdues qw( CalcFine UpdateFine get_chargeable_units branch_for_fee_context ); |
| 45 |
use C4::Members::Messaging qw( SetMessagingPreference ); |
45 |
use C4::Members::Messaging qw( SetMessagingPreference ); |
| 46 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
46 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
| 47 |
use Koha::Database; |
47 |
use Koha::Database; |
|
Lines 77-82
sub str {
Link Here
|
| 77 |
return $s; |
77 |
return $s; |
| 78 |
} |
78 |
} |
| 79 |
|
79 |
|
|
|
80 |
sub _latest_lost_line_for_item { |
| 81 |
my ($itemnumber) = @_; |
| 82 |
return Koha::Account::Lines->search( |
| 83 |
{ itemnumber => $itemnumber, debit_type_code => 'LOST' }, |
| 84 |
{ order_by => { -desc => 'accountlines_id' } } |
| 85 |
)->next; |
| 86 |
} |
| 87 |
|
| 80 |
sub test_debarment_on_checkout { |
88 |
sub test_debarment_on_checkout { |
| 81 |
my ($params) = @_; |
89 |
my ($params) = @_; |
| 82 |
my $item = $params->{item}; |
90 |
my $item = $params->{item}; |
|
Lines 495-501
subtest "GetIssuingCharges tests" => sub {
Link Here
|
| 495 |
|
503 |
|
| 496 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
504 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
| 497 |
subtest "CanBookBeRenewed tests" => sub { |
505 |
subtest "CanBookBeRenewed tests" => sub { |
| 498 |
plan tests => 114; |
506 |
plan tests => 116; |
| 499 |
|
507 |
|
| 500 |
C4::Context->set_preference( 'ItemsDeniedRenewal', '' ); |
508 |
C4::Context->set_preference( 'ItemsDeniedRenewal', '' ); |
| 501 |
|
509 |
|
|
Lines 1818-1823
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1818 |
"Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber" |
1826 |
"Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber" |
| 1819 |
); |
1827 |
); |
| 1820 |
|
1828 |
|
|
|
1829 |
subtest 'LostItem records accountlines.branchcode per LostChargesControl' => sub { |
| 1830 |
plan tests => 8; |
| 1831 |
my $FPL = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 1832 |
my $CPL = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 1833 |
my $PVL = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 1834 |
|
| 1835 |
my $p = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $PVL } } ); |
| 1836 |
my $it = $builder->build_object( |
| 1837 |
{ |
| 1838 |
class => 'Koha::Items', |
| 1839 |
value => { |
| 1840 |
homebranch => $FPL, |
| 1841 |
holdingbranch => $CPL, |
| 1842 |
replacementprice => 12.34, |
| 1843 |
} |
| 1844 |
} |
| 1845 |
); |
| 1846 |
|
| 1847 |
t::lib::Mocks::mock_userenv( |
| 1848 |
{ |
| 1849 |
patron => $builder->build_object( { class => 'Koha::Patrons' } ), |
| 1850 |
branchcode => $CPL, |
| 1851 |
} |
| 1852 |
); |
| 1853 |
|
| 1854 |
t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 ); |
| 1855 |
|
| 1856 |
my $chk = C4::Circulation::AddIssue( $p, $it->barcode ); |
| 1857 |
for my $path ( [ cron => 'cronjob' ], [ intranet => 'intranet' ] ) { |
| 1858 |
my ( $label, $mark_from ) = @$path; |
| 1859 |
|
| 1860 |
Koha::Account::Lines->search( { itemnumber => $it->itemnumber, debit_type_code => 'LOST' } )->delete; |
| 1861 |
|
| 1862 |
$it->itemlost(0)->store; |
| 1863 |
$it->discard_changes; |
| 1864 |
unless ( Koha::Checkouts->find( { itemnumber => $it->itemnumber } ) ) { |
| 1865 |
C4::Circulation::AddIssue( $p, $it->barcode ); |
| 1866 |
} |
| 1867 |
|
| 1868 |
t::lib::Mocks::mock_preference( 'LostChargesControl', 'ItemHomeLibrary' ); |
| 1869 |
t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' ); |
| 1870 |
C4::Circulation::LostItem( $it->itemnumber, $mark_from, 0 ); |
| 1871 |
my $l = _latest_lost_line_for_item( $it->itemnumber ); |
| 1872 |
ok( $l, "[$label] LOST line created" ); |
| 1873 |
is( $l->branchcode, $FPL, "[$label] branchcode = item home (FPL) for ItemHomeLibrary/homebranch" ); |
| 1874 |
|
| 1875 |
Koha::Account::Lines->search( { itemnumber => $it->itemnumber, debit_type_code => 'LOST' } )->delete; |
| 1876 |
|
| 1877 |
$it->itemlost(0)->store; |
| 1878 |
$it->discard_changes; |
| 1879 |
|
| 1880 |
unless ( Koha::Checkouts->find( { itemnumber => $it->itemnumber } ) ) { |
| 1881 |
C4::Circulation::AddIssue( $p, $it->barcode ); |
| 1882 |
} |
| 1883 |
t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'holdingbranch' ); |
| 1884 |
C4::Circulation::LostItem( $it->itemnumber, $mark_from, 0 ); |
| 1885 |
$l = _latest_lost_line_for_item( $it->itemnumber ); |
| 1886 |
ok( $l, "[$label] LOST line created (holding)" ); |
| 1887 |
is( $l->branchcode, $CPL, "[$label] branchcode = item holding (CPL) for ItemHomeLibrary/holdingbranch" ); |
| 1888 |
} |
| 1889 |
}; |
| 1890 |
|
| 1891 |
subtest 'UpdateFine records accountlines.branchcode per CircControl' => sub { |
| 1892 |
plan tests => 6; |
| 1893 |
|
| 1894 |
my $FPL = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 1895 |
my $CPL = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 1896 |
my $PVL = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 1897 |
|
| 1898 |
my $pat = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $PVL } } ); |
| 1899 |
my $itm = $builder->build_object( |
| 1900 |
{ class => 'Koha::Items', value => { homebranch => $FPL, holdingbranch => $CPL } } ); |
| 1901 |
|
| 1902 |
set_userenv( { branchcode => $CPL } ); |
| 1903 |
|
| 1904 |
my $due = dt_from_string->clone->subtract( days => 5 ); |
| 1905 |
my $issue = C4::Circulation::AddIssue( $pat, $itm->barcode, $due ); |
| 1906 |
|
| 1907 |
Koha::Account::Lines->search( |
| 1908 |
{ |
| 1909 |
borrowernumber => $pat->borrowernumber, |
| 1910 |
itemnumber => $itm->itemnumber, |
| 1911 |
debit_type_code => 'OVERDUE', |
| 1912 |
} |
| 1913 |
)->delete; |
| 1914 |
|
| 1915 |
# 1) PatronLibrary -> PVL |
| 1916 |
t::lib::Mocks::mock_preference( 'CircControl', 'PatronLibrary' ); |
| 1917 |
t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' ); |
| 1918 |
C4::Overdues::UpdateFine( |
| 1919 |
{ |
| 1920 |
issue_id => $issue->id, |
| 1921 |
itemnumber => $itm->itemnumber, |
| 1922 |
borrowernumber => $pat->borrowernumber, |
| 1923 |
amount => 1.50, |
| 1924 |
due => Koha::DateUtils::output_pref($due), |
| 1925 |
} |
| 1926 |
); |
| 1927 |
|
| 1928 |
my $od = Koha::Account::Lines->search( |
| 1929 |
{ borrowernumber => $pat->borrowernumber, itemnumber => $itm->itemnumber, debit_type_code => 'OVERDUE' }, |
| 1930 |
{ order_by => { -desc => 'accountlines_id' } } |
| 1931 |
)->next; |
| 1932 |
ok( $od, 'OVERDUE line created (PatronLibrary)' ); |
| 1933 |
is( $od->branchcode, $PVL, 'branchcode = patron home (PVL)' ); |
| 1934 |
$od->delete; |
| 1935 |
|
| 1936 |
# 2) PickupLibrary -> CPL |
| 1937 |
t::lib::Mocks::mock_preference( 'CircControl', 'PickupLibrary' ); |
| 1938 |
C4::Overdues::UpdateFine( |
| 1939 |
{ |
| 1940 |
issue_id => $issue->id, |
| 1941 |
itemnumber => $itm->itemnumber, |
| 1942 |
borrowernumber => $pat->borrowernumber, |
| 1943 |
amount => 1.50, |
| 1944 |
due => Koha::DateUtils::output_pref($due), |
| 1945 |
} |
| 1946 |
); |
| 1947 |
$od = Koha::Account::Lines->search( |
| 1948 |
{ borrowernumber => $pat->borrowernumber, itemnumber => $itm->itemnumber, debit_type_code => 'OVERDUE' }, |
| 1949 |
{ order_by => { -desc => 'accountlines_id' } } |
| 1950 |
)->next; |
| 1951 |
ok( $od, 'OVERDUE line created (PickupLibrary)' ); |
| 1952 |
is( $od->branchcode, $CPL, 'branchcode = issuing branch (CPL)' ); |
| 1953 |
$od->delete; |
| 1954 |
|
| 1955 |
# 3) ItemHomeLibrary + homebranch -> FPL |
| 1956 |
t::lib::Mocks::mock_preference( 'CircControl', 'ItemHomeLibrary' ); |
| 1957 |
t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' ); |
| 1958 |
C4::Overdues::UpdateFine( |
| 1959 |
{ |
| 1960 |
issue_id => $issue->id, |
| 1961 |
itemnumber => $itm->itemnumber, |
| 1962 |
borrowernumber => $pat->borrowernumber, |
| 1963 |
amount => 1.50, |
| 1964 |
due => Koha::DateUtils::output_pref($due), |
| 1965 |
} |
| 1966 |
); |
| 1967 |
$od = Koha::Account::Lines->search( |
| 1968 |
{ borrowernumber => $pat->borrowernumber, itemnumber => $itm->itemnumber, debit_type_code => 'OVERDUE' }, |
| 1969 |
{ order_by => { -desc => 'accountlines_id' } } |
| 1970 |
)->next; |
| 1971 |
ok( $od, 'OVERDUE line created (ItemHomeLibrary/homebranch)' ); |
| 1972 |
is( $od->branchcode, $FPL, 'branchcode = item home (FPL)' ); |
| 1973 |
}; |
| 1974 |
|
| 1821 |
# Recalls |
1975 |
# Recalls |
| 1822 |
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); |
1976 |
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); |
| 1823 |
Koha::CirculationRules->set_rules( |
1977 |
Koha::CirculationRules->set_rules( |
|
Lines 4881-4886
subtest 'Set waiting flag' => sub {
Link Here
|
| 4881 |
); |
5035 |
); |
| 4882 |
|
5036 |
|
| 4883 |
set_userenv($library_2); |
5037 |
set_userenv($library_2); |
|
|
5038 |
|
| 4884 |
my $reserve_id = AddReserve( |
5039 |
my $reserve_id = AddReserve( |
| 4885 |
{ |
5040 |
{ |
| 4886 |
branchcode => $library_2->{branchcode}, |
5041 |
branchcode => $library_2->{branchcode}, |
| 4887 |
- |
|
|