|
Lines 1902-1908
subtest 'store() tests' => sub {
Link Here
|
| 1902 |
|
1902 |
|
| 1903 |
subtest '_set_found_trigger() tests' => sub { |
1903 |
subtest '_set_found_trigger() tests' => sub { |
| 1904 |
|
1904 |
|
| 1905 |
plan tests => 9; |
1905 |
plan tests => 13; |
| 1906 |
|
1906 |
|
| 1907 |
$schema->storage->txn_begin; |
1907 |
$schema->storage->txn_begin; |
| 1908 |
|
1908 |
|
|
Lines 1979-1984
subtest 'store() tests' => sub {
Link Here
|
| 1979 |
$messages = $item->object_messages; |
1979 |
$messages = $item->object_messages; |
| 1980 |
is( scalar @{$messages}, 0, 'This item has no history, no associated lost fines, presumed not lost by patron, no messages returned'); |
1980 |
is( scalar @{$messages}, 0, 'This item has no history, no associated lost fines, presumed not lost by patron, no messages returned'); |
| 1981 |
|
1981 |
|
|
|
1982 |
# NoRefundOnLostFinesPaidAge |
| 1983 |
t::lib::Mocks::mock_preference( 'NoRefundOnLostFinesPaidAge', 10 ); |
| 1984 |
$mocked_circ_rules->mock( 'get_lostreturn_policy', sub { return { lostreturn => 'refund' }; } ); |
| 1985 |
|
| 1986 |
$item = $builder->build_sample_item( { itemlost => 1, itemlost_on => dt_from_string() } ); |
| 1987 |
my $fine = Koha::Account::Line->new( |
| 1988 |
{ |
| 1989 |
borrowernumber => $patron->id, |
| 1990 |
date => '1970-01-01 14:00:01', |
| 1991 |
amount => 5, |
| 1992 |
amountoutstanding => 0, |
| 1993 |
interface => 'commandline', |
| 1994 |
debit_type_code => 'LOST', |
| 1995 |
itemnumber => $item->itemnumber |
| 1996 |
} |
| 1997 |
)->store(); |
| 1998 |
my $payment = Koha::Account::Line->new( |
| 1999 |
{ |
| 2000 |
borrowernumber => $patron->id, |
| 2001 |
date => '1970-01-01 14:00:01', |
| 2002 |
amountoutstanding => 0, |
| 2003 |
amount => -5, |
| 2004 |
interface => 'commandline', |
| 2005 |
credit_type_code => 'PAYMENT' |
| 2006 |
} |
| 2007 |
)->store(); |
| 2008 |
my $offset = Koha::Account::Offset->new( |
| 2009 |
{ |
| 2010 |
credit_id => $payment->id, |
| 2011 |
debit_id => $fine->id, |
| 2012 |
type => 'APPLY', |
| 2013 |
amount => -5, |
| 2014 |
created_on => '1971-01-01 14:00:01' |
| 2015 |
} |
| 2016 |
)->store(); |
| 2017 |
|
| 2018 |
$item->set( { itemlost => 0 } )->store; |
| 2019 |
|
| 2020 |
$messages = $item->object_messages; |
| 2021 |
|
| 2022 |
is( |
| 2023 |
scalar @{$messages}, 1, |
| 2024 |
'This item has one message assigned' |
| 2025 |
); |
| 2026 |
|
| 2027 |
my $message = $messages->[0]; |
| 2028 |
is( $message->type, 'info', 'type is correct' ); |
| 2029 |
is( $message->message, 'payment_not_refunded', 'message is correct' ); |
| 2030 |
is( $message->payload, undef, 'no payload' ); |
| 2031 |
|
| 1982 |
$schema->storage->txn_rollback; |
2032 |
$schema->storage->txn_rollback; |
| 1983 |
}; |
2033 |
}; |
| 1984 |
|
2034 |
|
| 1985 |
- |
|
|