Lines 779-785
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
779 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
779 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
780 |
my $dt = dt_from_string(); |
780 |
my $dt = dt_from_string(); |
781 |
Time::Fake->offset( $dt->epoch ); |
781 |
Time::Fake->offset( $dt->epoch ); |
782 |
my $datedue1 = AddRenewal( $renewing_borrower_obj->borrowernumber, $item_7->itemnumber, $branch ); |
782 |
my $datedue1 = AddRenewal( |
|
|
783 |
{ |
784 |
borrowernumber => $renewing_borrower_obj->borrowernumber, |
785 |
itemnumber => $item_7->itemnumber, |
786 |
branch => $branch |
787 |
} |
788 |
); |
783 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
789 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
784 |
is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog'); |
790 |
is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog'); |
785 |
isnt (DateTime->compare($datedue1, $dt), 0, "AddRenewal returned a good duedate"); |
791 |
isnt (DateTime->compare($datedue1, $dt), 0, "AddRenewal returned a good duedate"); |
Lines 788-794
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
788 |
t::lib::Mocks::mock_preference('RenewalLog', 1); |
794 |
t::lib::Mocks::mock_preference('RenewalLog', 1); |
789 |
$date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); |
795 |
$date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); |
790 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
796 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
791 |
AddRenewal( $renewing_borrower_obj->borrowernumber, $item_7->itemnumber, $branch ); |
797 |
AddRenewal( |
|
|
798 |
{ |
799 |
borrowernumber => $renewing_borrower_obj->borrowernumber, |
800 |
itemnumber => $item_7->itemnumber, |
801 |
branch => $branch |
802 |
} |
803 |
); |
792 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
804 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
793 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
805 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
794 |
|
806 |
|
Lines 4557-4563
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4557 |
AddIssue( $patron->unblessed, $item->barcode ); |
4569 |
AddIssue( $patron->unblessed, $item->barcode ); |
4558 |
|
4570 |
|
4559 |
throws_ok { |
4571 |
throws_ok { |
4560 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
4572 |
AddRenewal( |
|
|
4573 |
{ |
4574 |
borrowernumber => $patron->borrowernumber, |
4575 |
itemnumber => $item->itemnumber, |
4576 |
branch => $library->id, |
4577 |
lastreneweddate => { break => "the_renewal" } |
4578 |
} |
4579 |
); |
4561 |
} 'Koha::Exceptions::Checkout::FailedRenewal', 'Exception is thrown when renewal update to issues fails'; |
4580 |
} 'Koha::Exceptions::Checkout::FailedRenewal', 'Exception is thrown when renewal update to issues fails'; |
4562 |
|
4581 |
|
4563 |
t::lib::Mocks::mock_preference( 'RenewalLog', 0 ); |
4582 |
t::lib::Mocks::mock_preference( 'RenewalLog', 0 ); |
Lines 4568-4574
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4568 |
action => "RENEWAL", |
4587 |
action => "RENEWAL", |
4569 |
); |
4588 |
); |
4570 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal );; |
4589 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal );; |
4571 |
AddRenewal( $patron->id, $item->id, $library->id ); |
4590 |
AddRenewal( |
|
|
4591 |
{ |
4592 |
borrowernumber => $patron->id, |
4593 |
itemnumber => $item->id, |
4594 |
branch => $library->id |
4595 |
} |
4596 |
); |
4572 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
4597 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
4573 |
is( $new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog' ); |
4598 |
is( $new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog' ); |
4574 |
|
4599 |
|
Lines 4604-4610
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4604 |
my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); |
4629 |
my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); |
4605 |
$sth->execute($item->id, $library->id); |
4630 |
$sth->execute($item->id, $library->id); |
4606 |
my ($old_stats_size) = $sth->fetchrow_array; |
4631 |
my ($old_stats_size) = $sth->fetchrow_array; |
4607 |
AddRenewal( $patron->id, $item->id, $library->id ); |
4632 |
AddRenewal( |
|
|
4633 |
{ |
4634 |
borrowernumber => $patron->id, |
4635 |
itemnumber => $item->id, |
4636 |
branch => $library->id |
4637 |
} |
4638 |
); |
4608 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
4639 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
4609 |
$sth->execute($item->id, $library->id); |
4640 |
$sth->execute($item->id, $library->id); |
4610 |
my ($new_stats_size) = $sth->fetchrow_array; |
4641 |
my ($new_stats_size) = $sth->fetchrow_array; |
Lines 4613-4619
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4613 |
|
4644 |
|
4614 |
AddReturn( $item->id, $library->id, undef, $date ); |
4645 |
AddReturn( $item->id, $library->id, undef, $date ); |
4615 |
AddIssue( $patron->unblessed, $item->barcode, $now ); |
4646 |
AddIssue( $patron->unblessed, $item->barcode, $now ); |
4616 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
4647 |
AddRenewal( |
|
|
4648 |
{ |
4649 |
borrowernumber => $patron->id, |
4650 |
itemnumber => $item->id, |
4651 |
branch => $library->id, |
4652 |
skipfinecalc => 1 |
4653 |
} |
4654 |
); |
4617 |
my $lines_skipped = Koha::Account::Lines->search({ |
4655 |
my $lines_skipped = Koha::Account::Lines->search({ |
4618 |
borrowernumber => $patron->id, |
4656 |
borrowernumber => $patron->id, |
4619 |
itemnumber => $item->id |
4657 |
itemnumber => $item->id |
Lines 4640-4646
subtest 'AddRenewal() adds to renewals' => sub {
Link Here
|
4640 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4678 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4641 |
|
4679 |
|
4642 |
# Renew item |
4680 |
# Renew item |
4643 |
my $duedate = AddRenewal( $patron->id, $item->id, $library->id, undef, undef, undef, undef, 1 ); |
4681 |
my $duedate = AddRenewal( |
|
|
4682 |
{ |
4683 |
borrowernumber => $patron->id, |
4684 |
itemnumber => $item->id, |
4685 |
branch => $library->id, |
4686 |
automatic => 1 |
4687 |
} |
4688 |
); |
4644 |
|
4689 |
|
4645 |
ok( $duedate, "Renewal added" ); |
4690 |
ok( $duedate, "Renewal added" ); |
4646 |
|
4691 |
|
Lines 4729-4735
subtest 'Incremented fee tests' => sub {
Link Here
|
4729 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0" |
4774 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0" |
4730 |
); |
4775 |
); |
4731 |
$accountline->delete(); |
4776 |
$accountline->delete(); |
4732 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4777 |
AddRenewal( |
|
|
4778 |
{ |
4779 |
borrowernumber => $patron->id, |
4780 |
itemnumber => $item->id, |
4781 |
branch => $library->id, |
4782 |
datedue => $dt_to_renew, |
4783 |
lastreneweddate => $dt_to |
4784 |
} |
4785 |
); |
4733 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4786 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4734 |
is( |
4787 |
is( |
4735 |
$accountline->amount + 0, |
4788 |
$accountline->amount + 0, |
Lines 4750-4756
subtest 'Incremented fee tests' => sub {
Link Here
|
4750 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1" |
4803 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1" |
4751 |
); |
4804 |
); |
4752 |
$accountline->delete(); |
4805 |
$accountline->delete(); |
4753 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4806 |
AddRenewal( |
|
|
4807 |
{ |
4808 |
borrowernumber => $patron->id, |
4809 |
itemnumber => $item->id, |
4810 |
branch => $library->id, |
4811 |
datedue => $dt_to_renew, |
4812 |
lastreneweddate => $dt_to |
4813 |
} |
4814 |
); |
4754 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4815 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4755 |
is( |
4816 |
is( |
4756 |
$accountline->amount + 0, |
4817 |
$accountline->amount + 0, |
Lines 4781-4787
subtest 'Incremented fee tests' => sub {
Link Here
|
4781 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name" |
4842 |
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name" |
4782 |
); |
4843 |
); |
4783 |
$accountline->delete(); |
4844 |
$accountline->delete(); |
4784 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4845 |
AddRenewal( |
|
|
4846 |
{ |
4847 |
borrowernumber => $patron->id, |
4848 |
itemnumber => $item->id, |
4849 |
branch => $library->id, |
4850 |
datedue => $dt_to_renew, |
4851 |
lastreneweddate => $dt_to |
4852 |
} |
4853 |
); |
4785 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4854 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4786 |
is( |
4855 |
is( |
4787 |
$accountline->amount + 0, |
4856 |
$accountline->amount + 0, |
Lines 4799-4805
subtest 'Incremented fee tests' => sub {
Link Here
|
4799 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4868 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4800 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
4869 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
4801 |
$accountlines->delete(); |
4870 |
$accountlines->delete(); |
4802 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4871 |
AddRenewal( |
|
|
4872 |
{ |
4873 |
borrowernumber => $patron->id, |
4874 |
itemnumber => $item->id, |
4875 |
branch => $library->id, |
4876 |
datedue => $dt_to_renew, |
4877 |
lastreneweddate => $dt_to |
4878 |
} |
4879 |
); |
4803 |
$accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4880 |
$accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4804 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly, for renewal" ); |
4881 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly, for renewal" ); |
4805 |
$accountlines->delete(); |
4882 |
$accountlines->delete(); |
Lines 4834-4840
subtest 'Incremented fee tests' => sub {
Link Here
|
4834 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)" |
4911 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)" |
4835 |
); |
4912 |
); |
4836 |
$accountline->delete(); |
4913 |
$accountline->delete(); |
4837 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4914 |
AddRenewal( |
|
|
4915 |
{ |
4916 |
borrowernumber => $patron->id, |
4917 |
itemnumber => $item->id, |
4918 |
branch => $library->id, |
4919 |
datedue => $dt_to_renew, |
4920 |
lastreneweddate => $dt_to |
4921 |
} |
4922 |
); |
4838 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4923 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4839 |
is( |
4924 |
is( |
4840 |
$accountline->amount + 0, |
4925 |
$accountline->amount + 0, |
Lines 4854-4860
subtest 'Incremented fee tests' => sub {
Link Here
|
4854 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)" |
4939 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)" |
4855 |
); |
4940 |
); |
4856 |
$accountline->delete(); |
4941 |
$accountline->delete(); |
4857 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4942 |
AddRenewal( |
|
|
4943 |
{ |
4944 |
borrowernumber => $patron->id, |
4945 |
itemnumber => $item->id, |
4946 |
branch => $library->id, |
4947 |
datedue => $dt_to_renew, |
4948 |
lastreneweddate => $dt_to |
4949 |
} |
4950 |
); |
4858 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4951 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4859 |
is( |
4952 |
is( |
4860 |
$accountline->amount + 0, |
4953 |
$accountline->amount + 0, |
Lines 4874-4880
subtest 'Incremented fee tests' => sub {
Link Here
|
4874 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u" |
4967 |
"Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u" |
4875 |
); |
4968 |
); |
4876 |
$accountline->delete(); |
4969 |
$accountline->delete(); |
4877 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
4970 |
AddRenewal( |
|
|
4971 |
{ |
4972 |
borrowernumber => $patron->id, |
4973 |
itemnumber => $item->id, |
4974 |
branch => $library->id, |
4975 |
datedue => $dt_to_renew, |
4976 |
lastreneweddate => $dt_to |
4977 |
} |
4978 |
); |
4878 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4979 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4879 |
is( |
4980 |
is( |
4880 |
$accountline->amount + 0, |
4981 |
$accountline->amount + 0, |