Lines 22-27
use Modern::Perl;
Link Here
|
22 |
use Test::More tests => 6; |
22 |
use Test::More tests => 6; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
|
|
25 |
use C4::Circulation qw/MarkIssueReturned/; |
26 |
|
25 |
use Koha::Account; |
27 |
use Koha::Account; |
26 |
use Koha::Account::Lines; |
28 |
use Koha::Account::Lines; |
27 |
use Koha::Account::Offsets; |
29 |
use Koha::Account::Offsets; |
Lines 273-281
subtest 'apply() tests' => sub {
Link Here
|
273 |
$schema->storage->txn_rollback; |
275 |
$schema->storage->txn_rollback; |
274 |
}; |
276 |
}; |
275 |
|
277 |
|
276 |
subtest 'Keep account info when related patron, staff or item is deleted' => sub { |
278 |
subtest 'Keep account info when related patron, staff, item or issue is deleted' => sub { |
277 |
|
279 |
|
278 |
plan tests => 3; |
280 |
plan tests => 4; |
279 |
|
281 |
|
280 |
$schema->storage->txn_begin; |
282 |
$schema->storage->txn_begin; |
281 |
|
283 |
|
Lines 288-298
subtest 'Keep account info when related patron, staff or item is deleted' => sub
Link Here
|
288 |
value => { itemnumber => $item->itemnumber } |
290 |
value => { itemnumber => $item->itemnumber } |
289 |
} |
291 |
} |
290 |
); |
292 |
); |
|
|
293 |
|
291 |
my $line = Koha::Account::Line->new( |
294 |
my $line = Koha::Account::Line->new( |
292 |
{ |
295 |
{ |
293 |
borrowernumber => $patron->borrowernumber, |
296 |
borrowernumber => $patron->borrowernumber, |
294 |
manager_id => $staff->borrowernumber, |
297 |
manager_id => $staff->borrowernumber, |
295 |
itemnumber => $item->itemnumber, |
298 |
itemnumber => $item->itemnumber, |
|
|
299 |
issue_id => $issue->issue_id, |
300 |
old_issue_id => undef, |
296 |
accounttype => "F", |
301 |
accounttype => "F", |
297 |
amount => 10, |
302 |
amount => 10, |
298 |
})->store; |
303 |
})->store; |
Lines 309-314
subtest 'Keep account info when related patron, staff or item is deleted' => sub
Link Here
|
309 |
$line = $line->get_from_storage; |
314 |
$line = $line->get_from_storage; |
310 |
is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); |
315 |
is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); |
311 |
|
316 |
|
|
|
317 |
my $issue_id = $issue->issue_id; |
318 |
MarkIssueReturned($patron->borrowernumber, $item->itemnumber, undef, 0 ); |
319 |
$line = $line->get_from_storage; |
320 |
is( $line->issue_id, undef, "The account line should not be deleted when the related issue is delete"); |
321 |
|
322 |
my $old_issue = Koha::Old::Checkouts->find($issue_id); |
323 |
$old_issue->delete; |
324 |
is( $line->old_issue_id, undef, "The account line should not be deleted when the related old_issue is deleted"); |
325 |
|
312 |
$schema->storage->txn_rollback; |
326 |
$schema->storage->txn_rollback; |
313 |
}; |
327 |
}; |
314 |
|
328 |
|
315 |
- |
|
|