Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 4; |
23 |
|
23 |
|
24 |
use Koha::Account; |
24 |
use Koha::Account; |
25 |
use Koha::Account::Lines; |
25 |
use Koha::Account::Lines; |
Lines 192-194
subtest 'add_credit() tests' => sub {
Link Here
|
192 |
|
192 |
|
193 |
$schema->storage->txn_rollback; |
193 |
$schema->storage->txn_rollback; |
194 |
}; |
194 |
}; |
195 |
- |
195 |
|
|
|
196 |
subtest 'transaction library' => sub { |
197 |
|
198 |
plan tests => 3; |
199 |
|
200 |
$schema->storage->txn_begin; |
201 |
|
202 |
my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
203 |
my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
204 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
205 |
|
206 |
my $account = $patron->account; |
207 |
my $credit1 = $account->add_credit({ |
208 |
amount => 13, |
209 |
description => 'Payment of 13', |
210 |
note => 'some note', |
211 |
}); |
212 |
my $offset1 = Koha::Account::Offsets->search({ credit_id => $credit1->id })->next; |
213 |
is($offset1->transaction_library, undef, "No transaction library without userenv and no library set"); |
214 |
|
215 |
C4::Context->_new_userenv('my_session1'); |
216 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library1->branchcode, $library1->branchname, '', '', ''); |
217 |
my $credit2 = $account->add_credit({ |
218 |
amount => 14, |
219 |
description => 'Payment of 14', |
220 |
note => 'some note', |
221 |
}); |
222 |
my $offset2 = Koha::Account::Offsets->search({ credit_id => $credit2->id })->next; |
223 |
is($offset2->transaction_library, $library1->branchcode, "Transaction library should be taken from userenv"); |
224 |
|
225 |
my $offset3 = Koha::Account::Offset->new({ |
226 |
amount => 15, |
227 |
type => 'Payment', |
228 |
credit_id => $credit2->id, |
229 |
transaction_library => $library2->branchcode, |
230 |
})->store; |
231 |
my $offset3_from_db = Koha::Account::Offsets->find( $offset3->id ); |
232 |
is($offset3_from_db->transaction_library, $library2->branchcode, "Transaction library should be set when param transaction_library is set"); |
233 |
|
234 |
$schema->storage->txn_rollback; |
235 |
}; |