|
Lines 29-34
use C4::Circulation;
Link Here
|
| 29 |
use C4::Items; |
29 |
use C4::Items; |
| 30 |
use C4::Members; |
30 |
use C4::Members; |
| 31 |
use Koha::Database; |
31 |
use Koha::Database; |
|
|
32 |
use Koha::Account::Lines; |
| 32 |
use Koha::DateUtils; |
33 |
use Koha::DateUtils; |
| 33 |
use Koha::Items; |
34 |
use Koha::Items; |
| 34 |
|
35 |
|
|
Lines 263-271
subtest "AddReturn logging on statistics table (item-level_itypes=0)" => sub {
Link Here
|
| 263 |
}; |
264 |
}; |
| 264 |
|
265 |
|
| 265 |
subtest 'Handle ids duplication' => sub { |
266 |
subtest 'Handle ids duplication' => sub { |
| 266 |
plan tests => 2; |
267 |
plan tests => 4; |
|
|
268 |
|
| 269 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); |
| 270 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnReturn', 1 ); |
| 271 |
t::lib::Mocks::mock_preference( 'finesMode', 'production' ); |
| 272 |
Koha::IssuingRules->search->update({ chargeperiod => 1, fine => 1, firstremind => 1, }); |
| 267 |
|
273 |
|
| 268 |
my $biblio = $builder->build( { source => 'Biblio' } ); |
274 |
my $biblio = $builder->build( { source => 'Biblio' } ); |
|
|
275 |
my $itemtype = $builder->build( { source => 'Itemtype', value => { rentalcharge => 5 } } ); |
| 269 |
my $item = $builder->build( |
276 |
my $item = $builder->build( |
| 270 |
{ |
277 |
{ |
| 271 |
source => 'Item', |
278 |
source => 'Item', |
|
Lines 274-292
subtest 'Handle ids duplication' => sub {
Link Here
|
| 274 |
notforloan => 0, |
281 |
notforloan => 0, |
| 275 |
itemlost => 0, |
282 |
itemlost => 0, |
| 276 |
withdrawn => 0, |
283 |
withdrawn => 0, |
| 277 |
|
284 |
itype => $itemtype->{itemtype}, |
| 278 |
} |
285 |
} |
| 279 |
} |
286 |
} |
| 280 |
); |
287 |
); |
| 281 |
my $patron = $builder->build({source => 'Borrower'}); |
288 |
my $patron = $builder->build({source => 'Borrower'}); |
|
|
289 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
| 290 |
|
| 291 |
my $original_checkout = AddIssue( $patron->unblessed, $item->{barcode}, dt_from_string->subtract( days => 50 ) ); |
| 292 |
$builder->build({ source => 'OldIssue', value => { issue_id => $original_checkout->issue_id } }); |
| 293 |
my $old_checkout = Koha::Old::Checkouts->find( $original_checkout->issue_id ); |
| 294 |
|
| 295 |
AddRenewal( $patron->borrowernumber, $item->{itemnumber} ); |
| 282 |
|
296 |
|
| 283 |
my $checkout = AddIssue( $patron, $item->{barcode} ); |
297 |
my ($doreturn, $messages, $new_checkout, $borrower) = AddReturn( $item->{barcode}, undef, undef, undef, dt_from_string ); |
| 284 |
$builder->build({ source => 'OldIssue', value => { issue_id => $checkout->issue_id } }); |
|
|
| 285 |
|
298 |
|
| 286 |
my ($doreturn, $messages, $issue, $borrower) = AddReturn( $item->{barcode} ); |
299 |
my $account_lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, issue_id => $new_checkout->{issue_id} }); |
| 287 |
my $old_checkout = Koha::Old::Checkouts->find( $checkout->issue_id ); |
300 |
is( $account_lines->count, 1, 'One account line should exist on new issue_id' ); |
| 288 |
|
301 |
|
| 289 |
isnt( $checkout->issue_id, $issue->{issue_id}, 'AddReturn should return the issue with the new issue_id' ); |
302 |
isnt( $original_checkout->issue_id, $new_checkout->{issue_id}, 'AddReturn should return the issue with the new issue_id' ); |
| 290 |
isnt( $old_checkout->itemnumber, $item->{itemnumber}, 'If an item is checked-in, it should be moved to old_issues even if the issue_id already existed in the table' ); |
303 |
isnt( $old_checkout->itemnumber, $item->{itemnumber}, 'If an item is checked-in, it should be moved to old_issues even if the issue_id already existed in the table' ); |
| 291 |
}; |
304 |
}; |
| 292 |
|
305 |
|
| 293 |
- |
|
|