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