|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
use utf8; |
19 |
use utf8; |
| 20 |
|
20 |
|
| 21 |
use Test::NoWarnings; |
21 |
use Test::NoWarnings; |
| 22 |
use Test::More tests => 84; |
22 |
use Test::More tests => 85; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
use Test::Deep qw( cmp_deeply ); |
25 |
use Test::Deep qw( cmp_deeply ); |
|
Lines 6185-6191
subtest 'Lost status does not change when preferences are set to 0' => sub {
Link Here
|
| 6185 |
)->store(); |
6185 |
)->store(); |
| 6186 |
|
6186 |
|
| 6187 |
# Test for UpdateItemLostStatusWhenPaid |
6187 |
# Test for UpdateItemLostStatusWhenPaid |
| 6188 |
t::lib::Mocks::mock_preference( 'UpdateItemLostStatusWhenPaid', 0 ); |
6188 |
t::lib::Mocks::mock_preference( 'UpdateItemLostStatusWhenPaid', 0 ); |
|
|
6189 |
t::lib::Mocks::mock_preference( 'UpdateItemWithdrawnStatusWhenPaid', 0 ); |
| 6189 |
|
6190 |
|
| 6190 |
my $paymentLine = Koha::Account::Line->new( |
6191 |
my $paymentLine = Koha::Account::Line->new( |
| 6191 |
{ |
6192 |
{ |
|
Lines 6313-6318
subtest 'Update lost item to authorized value on payment of balance' => sub {
Link Here
|
| 6313 |
} |
6314 |
} |
| 6314 |
}; |
6315 |
}; |
| 6315 |
|
6316 |
|
|
|
6317 |
# Test for UpdateItemWithdrawnStatusWhenPaid |
| 6318 |
subtest 'Update lost item to authorized value on payment of balance' => sub { |
| 6319 |
plan tests => 8; |
| 6320 |
|
| 6321 |
my $library = $builder->build_object( { class => "Koha::Libraries" } ); |
| 6322 |
my $manager = $builder->build_object( { class => "Koha::Patrons" } ); |
| 6323 |
t::lib::Mocks::mock_userenv( { patron => $manager, branchcode => $manager->branchcode } ); |
| 6324 |
|
| 6325 |
my $biblio = $builder->build_sample_biblio; |
| 6326 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 6327 |
|
| 6328 |
my @prefs = ( |
| 6329 |
{ withdrawn => 0, paid => 0, writeoff => 0 }, |
| 6330 |
{ withdrawn => 0, paid => 1, writeoff => 0 }, |
| 6331 |
{ withdrawn => 0, paid => 1, writeoff => 1 }, |
| 6332 |
{ withdrawn => 0, paid => 0, writeoff => 1 }, |
| 6333 |
{ withdrawn => 1, paid => 0, writeoff => 0 }, |
| 6334 |
{ withdrawn => 1, paid => 1, writeoff => 0 }, |
| 6335 |
{ withdrawn => 1, paid => 1, writeoff => 1 }, |
| 6336 |
{ withdrawn => 1, paid => 0, writeoff => 1 } |
| 6337 |
); |
| 6338 |
foreach my $pref (@prefs) { |
| 6339 |
t::lib::Mocks::mock_preference( 'UpdateItemWithdrawnStatusWhenPaid', $pref->{withdrawn} ); |
| 6340 |
t::lib::Mocks::mock_preference( 'UpdateItemLostStatusWhenPaid', $pref->{paid} ); |
| 6341 |
t::lib::Mocks::mock_preference( 'UpdateItemLostStatusWhenWriteoff', $pref->{writeoff} ); |
| 6342 |
|
| 6343 |
my $item = $builder->build_sample_item( |
| 6344 |
{ |
| 6345 |
biblionumber => $biblio->biblionumber, |
| 6346 |
library => $library->branchcode, |
| 6347 |
replacementprice => 99, |
| 6348 |
itype => $itemtype, |
| 6349 |
itemlost => 1, |
| 6350 |
} |
| 6351 |
); |
| 6352 |
|
| 6353 |
my $debitCharge = Koha::Account::Line->new( |
| 6354 |
{ |
| 6355 |
borrowernumber => $patron->borrowernumber, |
| 6356 |
debit_type_code => 'LOST', |
| 6357 |
status => undef, |
| 6358 |
itemnumber => $item->itemnumber, |
| 6359 |
amount => 12, |
| 6360 |
amountoutstanding => 12, |
| 6361 |
interface => 'something', |
| 6362 |
} |
| 6363 |
)->store(); |
| 6364 |
|
| 6365 |
my $paymentLine = Koha::Account::Line->new( |
| 6366 |
{ |
| 6367 |
borrowernumber => $patron->borrowernumber, |
| 6368 |
credit_type_code => 'CREDIT', |
| 6369 |
status => undef, |
| 6370 |
itemnumber => $item->itemnumber, |
| 6371 |
amountoutstanding => 0 - 12, |
| 6372 |
amount => 0 - 12, |
| 6373 |
interface => 'something', |
| 6374 |
} |
| 6375 |
)->store(); |
| 6376 |
|
| 6377 |
my $offset = Koha::Account::Offset->new( |
| 6378 |
{ |
| 6379 |
credit_id => $paymentLine->id, |
| 6380 |
debit_id => $debitCharge->id, |
| 6381 |
type => 'APPLY', |
| 6382 |
amount => 0 |
| 6383 |
} |
| 6384 |
)->store(); |
| 6385 |
|
| 6386 |
$paymentLine->apply( { debits => [$debitCharge] } ); |
| 6387 |
|
| 6388 |
is( |
| 6389 |
Koha::Items->find( $item->itemnumber )->withdrawn, $pref->{withdrawn}, |
| 6390 |
"Payment should set withdrawn to status $pref->{withdrawn}" |
| 6391 |
); |
| 6392 |
} |
| 6393 |
}; |
| 6394 |
|
| 6316 |
# Test for UpdateItemLostStatusWhenWriteOff |
6395 |
# Test for UpdateItemLostStatusWhenWriteOff |
| 6317 |
subtest 'Update lost item to authorized value on write-off of balance' => sub { |
6396 |
subtest 'Update lost item to authorized value on write-off of balance' => sub { |
| 6318 |
plan tests => 5; |
6397 |
plan tests => 5; |
| 6319 |
- |
|
|