Koha/t/db_dependent/Serials/updateClaim.t
jeremy breuillard bd72f24d04
Bug 23775: Claiming a serial issue doesn't create the next one
Whenever we need to generate manually a new serial we go to page
'serials-edit.pl'. With this patch it is possible to generate a new
serial on page 'serials.pl'.

Test Plan:
-- Previously we need a serial which is in EXPECTED status & the Date
received should not be later than today --
1) On the intra. Make sure to have at least 1 subscription for a
   bibliographic record & 1 vendor linked
2) Then Home > Serials > Claims > Claims for <your_vendor_name>
3) Tick the checkbox of the row where the status is EXPECTED then
4) Click 'Send notification'
5) Notice the status of the row : it is now CLAIMED
6) To verify: Home > Serials > Serial collection information for
   <your_record_name>
7) Here the status is CLAIMED too but nothing happened around
8) Apply patch
9) Repeat from 2) to 6)
10) The status is still CLAIMED & the new serial with status EXPECTED is
    freshly generated

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-07-03 10:35:09 -03:00

42 lines
1.5 KiB
Perl
Executable file

use Modern::Perl;
use Test::More tests => 3;
use C4::Serials;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
$dbh->do(q|DELETE FROM issues|);
$dbh->do(q|DELETE FROM subscription|);
my $branchcode = 'CPL';
my $record = MARC::Record->new();
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, '');
# Create a new subscription
my $subscriptionid_claims = C4::Serials::NewSubscription(
undef, $branchcode, undef, undef, undef, $biblionumber,
'2013-01-01', undef, undef, undef, undef,
undef, undef, undef, undef, undef, undef,
1, "notes",undef, '9999-01-01', undef, undef,
undef, undef, 0, "intnotes", 0,
undef, undef, 0, undef, '2013-12-31', 0
);
# Verify and get the serial ID of the subscription
my ( $totalissues, @serials ) = C4::Serials::GetSerials($subscriptionid_claims, 1);
C4::Serials::updateClaim( $serials[0]->{serialid} ); # Updating the claim
# sort the result to separate the CLAIMED and EXPECTED status
@serials = sort { $a->{serialid} <=> $b->{serialid} } @serials;
# Verify if serial IDs are correctly generated
( $totalissues, @serials ) = C4::Serials::GetSerials($subscriptionid_claims);
is ( scalar(@serials), 2, "le test est terminé" ); # Gives the length of the @serials
is ( ($serials[0]->{status}), C4::Serials::CLAIMED, "test CLAIMED" );
is ( ($serials[1]->{status}), C4::Serials::EXPECTED, "test EXPECTED" );