Lines 44-49
use Koha::Patrons;
Link Here
|
44 |
use Koha::Subscriptions; |
44 |
use Koha::Subscriptions; |
45 |
use Koha::Account::Lines; |
45 |
use Koha::Account::Lines; |
46 |
use Koha::Account::Offsets; |
46 |
use Koha::Account::Offsets; |
|
|
47 |
use Koha::ActionLogs; |
47 |
|
48 |
|
48 |
my $schema = Koha::Database->schema; |
49 |
my $schema = Koha::Database->schema; |
49 |
$schema->storage->txn_begin; |
50 |
$schema->storage->txn_begin; |
Lines 467-483
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
467 |
); |
468 |
); |
468 |
|
469 |
|
469 |
t::lib::Mocks::mock_preference('RenewalLog', 0); |
470 |
t::lib::Mocks::mock_preference('RenewalLog', 0); |
470 |
my $date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } ); |
471 |
my $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); |
471 |
my $old_log_size = scalar(@{GetLogs( $date, $date, undef,["CIRCULATION"], ["RENEWAL"]) } ); |
472 |
my %params_renewal = ( |
|
|
473 |
timestamp => { -like => $date . "%" }, |
474 |
module => "CIRCULATION", |
475 |
action => "RENEWAL", |
476 |
); |
477 |
my %params_issue = ( |
478 |
timestamp => { -like => $date . "%" }, |
479 |
module => "CIRCULATION", |
480 |
action => "ISSUE" |
481 |
); |
482 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
472 |
AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); |
483 |
AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); |
473 |
my $new_log_size = scalar(@{GetLogs( $date, $date, undef,["CIRCULATION"], ["RENEWAL"]) } ); |
484 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
474 |
is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog'); |
485 |
is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog'); |
475 |
|
486 |
|
476 |
t::lib::Mocks::mock_preference('RenewalLog', 1); |
487 |
t::lib::Mocks::mock_preference('RenewalLog', 1); |
477 |
$date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } ); |
488 |
$date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); |
478 |
$old_log_size = scalar(@{GetLogs( $date, $date, undef,["CIRCULATION"], ["RENEWAL"]) } ); |
489 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
479 |
AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); |
490 |
AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); |
480 |
$new_log_size = scalar(@{GetLogs( $date, $date, undef,["CIRCULATION"], ["RENEWAL"]) } ); |
491 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
481 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
492 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
482 |
|
493 |
|
483 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
494 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
Lines 487-498
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
487 |
$fines->delete(); |
498 |
$fines->delete(); |
488 |
|
499 |
|
489 |
|
500 |
|
490 |
my $old_issue_log_size = scalar(@{GetLogs( $date, $date, undef,["CIRCULATION"], ["ISSUE"]) } ); |
501 |
my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue ); |
491 |
my $old_renew_log_size = scalar(@{GetLogs( $date, $date, undef,["CIRCULATION"], ["RENEWAL"]) } ); |
502 |
my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal ); |
492 |
AddIssue( $renewing_borrower,$item_7->barcode,Koha::DateUtils::output_pref({str=>$datedue6->date_due, dateformat =>'iso'}),0,$date, 0, undef ); |
503 |
AddIssue( $renewing_borrower,$item_7->barcode,Koha::DateUtils::output_pref({str=>$datedue6->date_due, dateformat =>'iso'}),0,$date, 0, undef ); |
493 |
$new_log_size = scalar(@{GetLogs( $date, $date, undef,["CIRCULATION"], ["RENEWAL"]) } ); |
504 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
494 |
is ($new_log_size, $old_renew_log_size + 1, 'renew log successfully added when renewed via issuing'); |
505 |
is ($new_log_size, $old_renew_log_size + 1, 'renew log successfully added when renewed via issuing'); |
495 |
$new_log_size = scalar(@{GetLogs( $date, $date, undef,["CIRCULATION"], ["ISSUE"]) } ); |
506 |
$new_log_size = Koha::ActionLogs->count( \%params_issue ); |
496 |
is ($new_log_size, $old_issue_log_size, 'renew not logged as issue when renewed via issuing'); |
507 |
is ($new_log_size, $old_issue_log_size, 'renew not logged as issue when renewed via issuing'); |
497 |
|
508 |
|
498 |
$fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
509 |
$fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
Lines 2867-2878
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
2867 |
|
2878 |
|
2868 |
# Check the item out |
2879 |
# Check the item out |
2869 |
AddIssue( $patron->unblessed, $item->barcode ); |
2880 |
AddIssue( $patron->unblessed, $item->barcode ); |
2870 |
|
|
|
2871 |
t::lib::Mocks::mock_preference( 'RenewalLog', 0 ); |
2881 |
t::lib::Mocks::mock_preference( 'RenewalLog', 0 ); |
2872 |
my $date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } ); |
2882 |
my $date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } ); |
2873 |
my $old_log_size = scalar( @{ GetLogs( $date, $date, undef, ["CIRCULATION"], ["RENEWAL"] ) } ); |
2883 |
my %params_renewal = ( |
|
|
2884 |
timestamp => { -like => $date . "%" }, |
2885 |
module => "CIRCULATION", |
2886 |
action => "RENEWAL", |
2887 |
); |
2888 |
my $old_log_size = Koha::ActionLogs->count( \%params_renewal );; |
2874 |
AddRenewal( $patron->id, $item->id, $library->id ); |
2889 |
AddRenewal( $patron->id, $item->id, $library->id ); |
2875 |
my $new_log_size = scalar( @{ GetLogs( $date, $date, undef, ["CIRCULATION"], ["RENEWAL"] ) } ); |
2890 |
my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
2876 |
is( $new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog' ); |
2891 |
is( $new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog' ); |
2877 |
|
2892 |
|
2878 |
my $checkouts = $patron->checkouts; |
2893 |
my $checkouts = $patron->checkouts; |
Lines 2881-2889
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
2881 |
|
2896 |
|
2882 |
t::lib::Mocks::mock_preference( 'RenewalLog', 1 ); |
2897 |
t::lib::Mocks::mock_preference( 'RenewalLog', 1 ); |
2883 |
$date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } ); |
2898 |
$date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } ); |
2884 |
$old_log_size = scalar( @{ GetLogs( $date, $date, undef, ["CIRCULATION"], ["RENEWAL"] ) } ); |
2899 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
2885 |
AddRenewal( $patron->id, $item->id, $library->id ); |
2900 |
AddRenewal( $patron->id, $item->id, $library->id ); |
2886 |
$new_log_size = scalar( @{ GetLogs( $date, $date, undef, ["CIRCULATION"], ["RENEWAL"] ) } ); |
2901 |
$new_log_size = Koha::ActionLogs->count( \%params_renewal ); |
2887 |
is( $new_log_size, $old_log_size + 1, 'renew log successfully added' ); |
2902 |
is( $new_log_size, $old_log_size + 1, 'renew log successfully added' ); |
2888 |
|
2903 |
|
2889 |
my $lines = Koha::Account::Lines->search({ |
2904 |
my $lines = Koha::Account::Lines->search({ |
2890 |
- |
|
|