|
Lines 783-789
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 783 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
783 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
| 784 |
my $dt = dt_from_string(); |
784 |
my $dt = dt_from_string(); |
| 785 |
Time::Fake->offset( $dt->epoch ); |
785 |
Time::Fake->offset( $dt->epoch ); |
| 786 |
my $datedue1 = AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); |
786 |
my $datedue1 = AddRenewal( |
|
|
787 |
{ |
| 788 |
borrowernumber => $renewing_borrower->{borrowernumber}, |
| 789 |
itemnumber => $item_7->itemnumber, |
| 790 |
branch => $branch |
| 791 |
} |
| 792 |
); |
| 787 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
793 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
| 788 |
is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog'); |
794 |
is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog'); |
| 789 |
isnt (DateTime->compare($datedue1, $dt), 0, "AddRenewal returned a good duedate"); |
795 |
isnt (DateTime->compare($datedue1, $dt), 0, "AddRenewal returned a good duedate"); |
|
Lines 792-798
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 792 |
t::lib::Mocks::mock_preference('RenewalLog', 1); |
798 |
t::lib::Mocks::mock_preference('RenewalLog', 1); |
| 793 |
$date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); |
799 |
$date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); |
| 794 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
800 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
| 795 |
AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); |
801 |
AddRenewal( |
|
|
802 |
{ |
| 803 |
borrowernumber => $renewing_borrower->{borrowernumber}, |
| 804 |
itemnumber => $item_7->itemnumber, |
| 805 |
branch => $branch |
| 806 |
} |
| 807 |
); |
| 796 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
808 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
| 797 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
809 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
| 798 |
|
810 |
|
|
Lines 4564-4570
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
| 4564 |
AddIssue( $patron->unblessed, $item->barcode ); |
4576 |
AddIssue( $patron->unblessed, $item->barcode ); |
| 4565 |
|
4577 |
|
| 4566 |
throws_ok { |
4578 |
throws_ok { |
| 4567 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
4579 |
AddRenewal( |
|
|
4580 |
{ |
| 4581 |
borrowernumber => $patron->borrowernumber, |
| 4582 |
itemnumber => $item->itemnumber, |
| 4583 |
branch => $library->id, |
| 4584 |
lastreneweddate => { break => "the_renewal" } |
| 4585 |
} |
| 4586 |
); |
| 4568 |
} 'Koha::Exceptions::Checkout::FailedRenewal', 'Exception is thrown when renewal update to issues fails'; |
4587 |
} 'Koha::Exceptions::Checkout::FailedRenewal', 'Exception is thrown when renewal update to issues fails'; |
| 4569 |
|
4588 |
|
| 4570 |
t::lib::Mocks::mock_preference( 'RenewalLog', 0 ); |
4589 |
t::lib::Mocks::mock_preference( 'RenewalLog', 0 ); |
|
Lines 4575-4581
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
| 4575 |
action => "RENEWAL", |
4594 |
action => "RENEWAL", |
| 4576 |
); |
4595 |
); |
| 4577 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal );; |
4596 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal );; |
| 4578 |
AddRenewal( $patron->id, $item->id, $library->id ); |
4597 |
AddRenewal( |
|
|
4598 |
{ |
| 4599 |
borrowernumber => $patron->id, |
| 4600 |
itemnumber => $item->id, |
| 4601 |
branch => $library->id |
| 4602 |
} |
| 4603 |
); |
| 4579 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
4604 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
| 4580 |
is( $new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog' ); |
4605 |
is( $new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog' ); |
| 4581 |
|
4606 |
|
|
Lines 4611-4617
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
| 4611 |
my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); |
4636 |
my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); |
| 4612 |
$sth->execute($item->id, $library->id); |
4637 |
$sth->execute($item->id, $library->id); |
| 4613 |
my ($old_stats_size) = $sth->fetchrow_array; |
4638 |
my ($old_stats_size) = $sth->fetchrow_array; |
| 4614 |
AddRenewal( $patron->id, $item->id, $library->id ); |
4639 |
AddRenewal( |
|
|
4640 |
{ |
| 4641 |
borrowernumber => $patron->id, |
| 4642 |
itemnumber => $item->id, |
| 4643 |
branch => $library->id |
| 4644 |
} |
| 4645 |
); |
| 4615 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
4646 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
| 4616 |
$sth->execute($item->id, $library->id); |
4647 |
$sth->execute($item->id, $library->id); |
| 4617 |
my ($new_stats_size) = $sth->fetchrow_array; |
4648 |
my ($new_stats_size) = $sth->fetchrow_array; |
|
Lines 4620-4626
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
| 4620 |
|
4651 |
|
| 4621 |
AddReturn( $item->id, $library->id, undef, $date ); |
4652 |
AddReturn( $item->id, $library->id, undef, $date ); |
| 4622 |
AddIssue( $patron->unblessed, $item->barcode, $now ); |
4653 |
AddIssue( $patron->unblessed, $item->barcode, $now ); |
| 4623 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
4654 |
AddRenewal( |
|
|
4655 |
{ |
| 4656 |
borrowernumber => $patron->id, |
| 4657 |
itemnumber => $item->id, |
| 4658 |
branch => $library->id, |
| 4659 |
skipfinecalc => 1 |
| 4660 |
} |
| 4661 |
); |
| 4624 |
my $lines_skipped = Koha::Account::Lines->search({ |
4662 |
my $lines_skipped = Koha::Account::Lines->search({ |
| 4625 |
borrowernumber => $patron->id, |
4663 |
borrowernumber => $patron->id, |
| 4626 |
itemnumber => $item->id |
4664 |
itemnumber => $item->id |
|
Lines 4647-4653
subtest 'AddRenewal() adds to renewals' => sub {
Link Here
|
| 4647 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4685 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
| 4648 |
|
4686 |
|
| 4649 |
# Renew item |
4687 |
# Renew item |
| 4650 |
my $duedate = AddRenewal( $patron->id, $item->id, $library->id, undef, undef, undef, undef, 1 ); |
4688 |
my $duedate = AddRenewal( |
|
|
4689 |
{ |
| 4690 |
borrowernumber => $patron->id, |
| 4691 |
itemnumber => $item->id, |
| 4692 |
branch => $library->id, |
| 4693 |
automatic => 1 |
| 4694 |
} |
| 4695 |
); |
| 4651 |
|
4696 |
|
| 4652 |
ok( $duedate, "Renewal added" ); |
4697 |
ok( $duedate, "Renewal added" ); |
| 4653 |
|
4698 |
|
|
Lines 4736-4742
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4736 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0" |
4781 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0" |
| 4737 |
); |
4782 |
); |
| 4738 |
$accountline->delete(); |
4783 |
$accountline->delete(); |
| 4739 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4784 |
AddRenewal( |
|
|
4785 |
{ |
| 4786 |
borrowernumber => $patron->id, |
| 4787 |
itemnumber => $item->id, |
| 4788 |
branch => $library->id, |
| 4789 |
datedue => $dt_to_renew, |
| 4790 |
lastreneweddate => $dt_to |
| 4791 |
} |
| 4792 |
); |
| 4740 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4793 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4741 |
is( |
4794 |
is( |
| 4742 |
$accountline->amount + 0, |
4795 |
$accountline->amount + 0, |
|
Lines 4757-4763
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4757 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1" |
4810 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1" |
| 4758 |
); |
4811 |
); |
| 4759 |
$accountline->delete(); |
4812 |
$accountline->delete(); |
| 4760 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4813 |
AddRenewal( |
|
|
4814 |
{ |
| 4815 |
borrowernumber => $patron->id, |
| 4816 |
itemnumber => $item->id, |
| 4817 |
branch => $library->id, |
| 4818 |
datedue => $dt_to_renew, |
| 4819 |
lastreneweddate => $dt_to |
| 4820 |
} |
| 4821 |
); |
| 4761 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4822 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4762 |
is( |
4823 |
is( |
| 4763 |
$accountline->amount + 0, |
4824 |
$accountline->amount + 0, |
|
Lines 4788-4794
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4788 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name" |
4849 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name" |
| 4789 |
); |
4850 |
); |
| 4790 |
$accountline->delete(); |
4851 |
$accountline->delete(); |
| 4791 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4852 |
AddRenewal( |
|
|
4853 |
{ |
| 4854 |
borrowernumber => $patron->id, |
| 4855 |
itemnumber => $item->id, |
| 4856 |
branch => $library->id, |
| 4857 |
datedue => $dt_to_renew, |
| 4858 |
lastreneweddate => $dt_to |
| 4859 |
} |
| 4860 |
); |
| 4792 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4861 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4793 |
is( |
4862 |
is( |
| 4794 |
$accountline->amount + 0, |
4863 |
$accountline->amount + 0, |
|
Lines 4806-4812
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4806 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4875 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
| 4807 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
4876 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
| 4808 |
$accountlines->delete(); |
4877 |
$accountlines->delete(); |
| 4809 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4878 |
AddRenewal( |
|
|
4879 |
{ |
| 4880 |
borrowernumber => $patron->id, |
| 4881 |
itemnumber => $item->id, |
| 4882 |
branch => $library->id, |
| 4883 |
datedue => $dt_to_renew, |
| 4884 |
lastreneweddate => $dt_to |
| 4885 |
} |
| 4886 |
); |
| 4810 |
$accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4887 |
$accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } ); |
| 4811 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly, for renewal" ); |
4888 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly, for renewal" ); |
| 4812 |
$accountlines->delete(); |
4889 |
$accountlines->delete(); |
|
Lines 4841-4847
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4841 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)" |
4918 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)" |
| 4842 |
); |
4919 |
); |
| 4843 |
$accountline->delete(); |
4920 |
$accountline->delete(); |
| 4844 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4921 |
AddRenewal( |
|
|
4922 |
{ |
| 4923 |
borrowernumber => $patron->id, |
| 4924 |
itemnumber => $item->id, |
| 4925 |
branch => $library->id, |
| 4926 |
datedue => $dt_to_renew, |
| 4927 |
lastreneweddate => $dt_to |
| 4928 |
} |
| 4929 |
); |
| 4845 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4930 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4846 |
is( |
4931 |
is( |
| 4847 |
$accountline->amount + 0, |
4932 |
$accountline->amount + 0, |
|
Lines 4861-4867
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4861 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)" |
4946 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)" |
| 4862 |
); |
4947 |
); |
| 4863 |
$accountline->delete(); |
4948 |
$accountline->delete(); |
| 4864 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4949 |
AddRenewal( |
|
|
4950 |
{ |
| 4951 |
borrowernumber => $patron->id, |
| 4952 |
itemnumber => $item->id, |
| 4953 |
branch => $library->id, |
| 4954 |
datedue => $dt_to_renew, |
| 4955 |
lastreneweddate => $dt_to |
| 4956 |
} |
| 4957 |
); |
| 4865 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4958 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4866 |
is( |
4959 |
is( |
| 4867 |
$accountline->amount + 0, |
4960 |
$accountline->amount + 0, |
|
Lines 4881-4887
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4881 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u" |
4974 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u" |
| 4882 |
); |
4975 |
); |
| 4883 |
$accountline->delete(); |
4976 |
$accountline->delete(); |
| 4884 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4977 |
AddRenewal( |
|
|
4978 |
{ |
| 4979 |
borrowernumber => $patron->id, |
| 4980 |
itemnumber => $item->id, |
| 4981 |
branch => $library->id, |
| 4982 |
datedue => $dt_to_renew, |
| 4983 |
lastreneweddate => $dt_to |
| 4984 |
} |
| 4985 |
); |
| 4885 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4986 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4886 |
is( |
4987 |
is( |
| 4887 |
$accountline->amount + 0, |
4988 |
$accountline->amount + 0, |