|
Lines 4-10
Link Here
|
| 4 |
# Current state is very rudimentary. Please help to extend it! |
4 |
# Current state is very rudimentary. Please help to extend it! |
| 5 |
|
5 |
|
| 6 |
use Modern::Perl; |
6 |
use Modern::Perl; |
| 7 |
use Test::More tests => 4; |
7 |
use Test::More tests => 5; |
| 8 |
|
8 |
|
| 9 |
use Koha::Database; |
9 |
use Koha::Database; |
| 10 |
use t::lib::TestBuilder; |
10 |
use t::lib::TestBuilder; |
|
Lines 12-17
use t::lib::Mocks;
Link Here
|
| 12 |
use C4::SIP::ILS::Patron; |
12 |
use C4::SIP::ILS::Patron; |
| 13 |
use C4::SIP::ILS::Transaction::RenewAll; |
13 |
use C4::SIP::ILS::Transaction::RenewAll; |
| 14 |
use C4::SIP::ILS::Transaction::Checkout; |
14 |
use C4::SIP::ILS::Transaction::Checkout; |
|
|
15 |
use C4::SIP::ILS::Transaction::FeePayment; |
| 15 |
|
16 |
|
| 16 |
use C4::Reserves; |
17 |
use C4::Reserves; |
| 17 |
use Koha::IssuingRules; |
18 |
use Koha::IssuingRules; |
|
Lines 90-93
subtest fill_holds_at_checkout => sub {
Link Here
|
| 90 |
|
91 |
|
| 91 |
|
92 |
|
| 92 |
}; |
93 |
}; |
|
|
94 |
|
| 95 |
subtest "FeePayment->pay tests" => sub { |
| 96 |
|
| 97 |
plan tests => 5; |
| 98 |
|
| 99 |
# Create a borrower and add some outstanding debts to their account |
| 100 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 101 |
my $account = |
| 102 |
Koha::Account->new( { patron_id => $patron->{borrowernumber} } ); |
| 103 |
my $debt1 = $account->add_debit( |
| 104 |
{ type => 'account', amount => 100, interface => 'commandline' } ); |
| 105 |
my $debt2 = $account->add_debit( |
| 106 |
{ type => 'account', amount => 200, interface => 'commandline' } ); |
| 107 |
|
| 108 |
# Instantiate a new FeePayment transaction object |
| 109 |
my $trans = C4::SIP::ILS::Transaction::FeePayment->new(); |
| 110 |
is( |
| 111 |
ref $trans, |
| 112 |
"C4::SIP::ILS::Transaction::FeePayment", |
| 113 |
"New fee transaction created" |
| 114 |
); |
| 115 |
|
| 116 |
# Test the 'pay' method |
| 117 |
# FIXME: pay should not require a borrowernumber |
| 118 |
# (we should reach out to the transaction which should contain a patron object) |
| 119 |
my $pay_type = '00'; # 00 - Cash, 01 - VISA, 02 - Creditcard |
| 120 |
my $ok = |
| 121 |
$trans->pay( $patron->{borrowernumber}, 100, $pay_type, $debt1->id, 0, |
| 122 |
0 ); |
| 123 |
ok( $ok, "FeePayment transaction succeeded" ); |
| 124 |
$debt1->discard_changes; |
| 125 |
is( $debt1->amountoutstanding + 0, 0, |
| 126 |
"Debt1 was reduced to 0 as expected" ); |
| 127 |
my $offsets = Koha::Account::Offsets->search( |
| 128 |
{ debit_id => $debt1->id, credit_id => { '!=' => undef } } ); |
| 129 |
is( $offsets->count, 1, "FeePayment produced an offset line correctly" ); |
| 130 |
my $credit = $offsets->next->credit; |
| 131 |
is( $credit->payment_type, 'SIP00', "Payment type was set correctly" ); |
| 132 |
}; |
| 133 |
|
| 93 |
$schema->storage->txn_rollback; |
134 |
$schema->storage->txn_rollback; |
| 94 |
- |
|
|