Browse Source
This patch adds a new DB field serial.claims_count This field already exists for late orders. It makes sense to introduce it for serial. Test plan: 0/ a) Does not apply the patch. b) Remove all your claimissues notices and be sure you have some serial issues in late. c) remove email address for the vendor you will use. d) remove email address for the logged in user. e) Export claims using the csv export => The selected issues will be marked as claimed. f) logout/login (to update the email address). 1/ Apply the patch and execute the updatedb entry. 2/ Go on the Serials > Claims page 3/ Verify that you get a warning message 'No claimissue notice defined' 4/ Verify the vendor list is correct (with the number of serial in late. You should not get any changes here. 5/ Select one vendor and verify that the issue which was claimed before has a claim count set to 1. 6/ Verify that you are not able to send notification to the vendor. 7/ Create a claimissue notice. Something like: <<LibrarianFirstname>> <<LibrarianSurname>> The following issues are in late: <order><<biblio.title>>, <<biblio.author>> (<<biblio.serial>>)</order> 8/ Go on the Serials > Claims page, the warning message does not appear anymore. 9/ Select issues. Select a notice. And "Send notification". You should get an error (no email defined for this vendor). 10/ Add an email for the vendor. 11/ Select issues. Select a notice. And "Send notification". You should get an error (no email defined for your user). 12/ Add an email address to your user logout/login 13/ Select issues. Select a notice. And "Send notification". You should get a happy message: the email has been sent! 14/ The email will contain the order tags if bug 12851 is not pushed/applied. Signed-off-by: Paola Rossi <paola.rossi@cineca.it> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Works as described, some small issues fixed in a follow-up. Note: If you change the email address of your staff user, you will have to log out and back in to make the change take effect. Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>MM-OPAC/theme_dep
9 changed files with 273 additions and 91 deletions
@ -0,0 +1,145 @@ |
|||
use Modern::Perl; |
|||
use Test::More tests => 13; |
|||
|
|||
use C4::Acquisition; |
|||
use C4::Budgets; |
|||
use_ok('C4::Serials'); |
|||
|
|||
use Koha::DateUtils qw( dt_from_string output_pref ); |
|||
|
|||
my $dbh = C4::Context->dbh; |
|||
$dbh->{AutoCommit} = 0; |
|||
$dbh->{RaiseError} = 1; |
|||
|
|||
my $branchcode = 'CPL'; |
|||
my $bpid = AddBudgetPeriod({ |
|||
budget_period_startdate => '2015-01-01', |
|||
budget_period_enddate => '2015-12-31', |
|||
budget_period_description => "budget desc" |
|||
}); |
|||
|
|||
my $budget_id = AddBudget({ |
|||
budget_code => "ABCD", |
|||
budget_amount => "123.132", |
|||
budget_name => "Périodiques", |
|||
budget_notes => "This is a note", |
|||
budget_period_id => $bpid |
|||
}); |
|||
|
|||
my $record = MARC::Record->new(); |
|||
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, ''); |
|||
|
|||
my $sample_supplier1 = { |
|||
name => 'Name1', |
|||
address1 => 'address1_1', |
|||
address2 => 'address1-2', |
|||
address3 => 'address1_2', |
|||
address4 => 'address1_2', |
|||
postal => 'postal1', |
|||
phone => 'phone1', |
|||
accountnumber => 'accountnumber1', |
|||
fax => 'fax1', |
|||
url => 'url1', |
|||
active => 1, |
|||
gstreg => 1, |
|||
listincgst => 1, |
|||
invoiceincgst => 1, |
|||
gstrate => '1.0000', |
|||
discount => '1.0000', |
|||
notes => 'notes1', |
|||
deliverytime => undef |
|||
}; |
|||
my $sample_supplier2 = { |
|||
name => 'Name2', |
|||
address1 => 'address1_2', |
|||
address2 => 'address2-2', |
|||
address3 => 'address3_2', |
|||
address4 => 'address4_2', |
|||
postal => 'postal2', |
|||
phone => 'phone2', |
|||
accountnumber => 'accountnumber2', |
|||
fax => 'fax2', |
|||
url => 'url2', |
|||
active => 1, |
|||
gstreg => 1, |
|||
listincgst => 1, |
|||
invoiceincgst => 1, |
|||
gstrate => '2.0000', |
|||
discount => '2.0000', |
|||
notes => 'notes2', |
|||
deliverytime => 2 |
|||
}; |
|||
|
|||
my $supplier_id1 = C4::Bookseller::AddBookseller($sample_supplier1); |
|||
my $supplier_id2 = C4::Bookseller::AddBookseller($sample_supplier2); |
|||
|
|||
my $supplierlist = eval { GetSuppliersWithLateIssues() }; |
|||
is( length($@), 0, "No SQL problem in GetSuppliersWithLateIssues" ); |
|||
is ( scalar(@$supplierlist), 0, 'There is no late issues yet'); |
|||
|
|||
my $subscriptionid_not_late = NewSubscription( |
|||
undef, $branchcode, $supplier_id1, undef, $budget_id, $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 |
|||
); |
|||
$supplierlist = GetSuppliersWithLateIssues(); |
|||
is ( scalar(@$supplierlist), 0, 'There is still no late issues yet'); |
|||
|
|||
my $subscriptionid_inlate1 = NewSubscription( |
|||
undef, $branchcode, $supplier_id1, undef, $budget_id, $biblionumber, |
|||
'2013-01-01', undef, undef, undef, undef, |
|||
undef, undef, undef, undef, undef, undef, |
|||
1, "notes",undef, '2013-01-01', undef, undef, |
|||
undef, undef, 0, "intnotes", 0, |
|||
undef, undef, 0, undef, '2013-12-31', 0 |
|||
); |
|||
|
|||
my $subscriptionid_inlate2 = NewSubscription( |
|||
undef, $branchcode, $supplier_id2, undef, $budget_id, $biblionumber, |
|||
'2013-01-01', undef, undef, undef, undef, |
|||
undef, undef, undef, undef, undef, undef, |
|||
1, "notes",undef, '2013-01-01', undef, undef, |
|||
undef, undef, 0, "intnotes", 0, |
|||
undef, undef, 0, undef, '2013-12-31', 0 |
|||
); |
|||
|
|||
my $subscriptionid_inlate3 = NewSubscription( |
|||
undef, $branchcode, $supplier_id2, undef, $budget_id, $biblionumber, |
|||
'2013-01-02', undef, undef, undef, undef, |
|||
undef, undef, undef, undef, undef, undef, |
|||
1, "notes",undef, '2013-01-02', undef, undef, |
|||
undef, undef, 0, "intnotes", 0, |
|||
undef, undef, 0, undef, '2013-12-31', 0 |
|||
); |
|||
|
|||
|
|||
$supplierlist = GetSuppliersWithLateIssues(); |
|||
is ( scalar(@$supplierlist), 2, '2 suppliers should have issues in late'); |
|||
|
|||
is( GetLateOrMissingIssues(), undef, 'GetLateOrMissingIssues should return undef without parameter' ); |
|||
|
|||
my @late_or_missing_issues = GetLateOrMissingIssues( $supplier_id1 ); |
|||
is( scalar(@late_or_missing_issues), 1, 'supplier 1 should have 1 issue in late' ); |
|||
|
|||
@late_or_missing_issues = GetLateOrMissingIssues( $supplier_id2); |
|||
is( scalar(@late_or_missing_issues), 2, 'supplier 2 should have 2 issues in late' ); |
|||
|
|||
is( exists $late_or_missing_issues[0]->{claimdate}, 1, 'GetLateOrMissingIssues returns claimdate' ); |
|||
is( exists $late_or_missing_issues[0]->{claims_count}, 1, 'GetLateOrMissingIssues returns claims_count' ); |
|||
is( $late_or_missing_issues[0]->{claims_count}, 0, 'The issues should not habe been claimed yet' ); |
|||
|
|||
my $serialid_to_claim = $late_or_missing_issues[0]->{serialid}; |
|||
updateClaim( $serialid_to_claim ); |
|||
|
|||
@late_or_missing_issues = GetLateOrMissingIssues( $supplier_id2); |
|||
is( scalar(@late_or_missing_issues), 2, 'supplier 2 should have 2 issues in late (already claimed issues are returns)' ); |
|||
|
|||
my ( $serial_claimed ) = grep { ($_->{serialid} == $serialid_to_claim) ? $_ : () } @late_or_missing_issues; |
|||
is( $serial_claimed->{claims_count}, 1, 'The serial should have been claimed' ); |
|||
|
|||
my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); |
|||
# FIXME: This test should pass. The GetLateOrMissingIssues should not deal with date format! |
|||
#is( $serial_claimed->{claimdate}, $today, 'The serial should have been claimed today' ); |
Loading…
Reference in new issue