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 95-98
subtest fill_holds_at_checkout => sub {
Link Here
|
95 |
$transaction = C4::SIP::ILS::Transaction::Checkout->new(); |
96 |
$transaction = C4::SIP::ILS::Transaction::Checkout->new(); |
96 |
is( $sip_item->{barcode}, $item1->{barcode}, "Item assigned to transaction" ); |
97 |
is( $sip_item->{barcode}, $item1->{barcode}, "Item assigned to transaction" ); |
97 |
}; |
98 |
}; |
|
|
99 |
|
100 |
subtest "FeePayment->pay tests" => sub { |
101 |
|
102 |
plan tests => 5; |
103 |
|
104 |
# Create a borrower and add some outstanding debts to their account |
105 |
my $patron = $builder->build( { source => 'Borrower' } ); |
106 |
my $account = |
107 |
Koha::Account->new( { patron_id => $patron->{borrowernumber} } ); |
108 |
my $debt1 = $account->add_debit( |
109 |
{ type => 'account', amount => 100, interface => 'commandline' } ); |
110 |
my $debt2 = $account->add_debit( |
111 |
{ type => 'account', amount => 200, interface => 'commandline' } ); |
112 |
|
113 |
# Instantiate a new FeePayment transaction object |
114 |
my $trans = C4::SIP::ILS::Transaction::FeePayment->new(); |
115 |
is( |
116 |
ref $trans, |
117 |
"C4::SIP::ILS::Transaction::FeePayment", |
118 |
"New fee transaction created" |
119 |
); |
120 |
|
121 |
# Test the 'pay' method |
122 |
# FIXME: pay should not require a borrowernumber |
123 |
# (we should reach out to the transaction which should contain a patron object) |
124 |
my $pay_type = '00'; # 00 - Cash, 01 - VISA, 02 - Creditcard |
125 |
my $ok = |
126 |
$trans->pay( $patron->{borrowernumber}, 100, $pay_type, $debt1->id, 0, |
127 |
0 ); |
128 |
ok( $ok, "FeePayment transaction succeeded" ); |
129 |
$debt1->discard_changes; |
130 |
is( $debt1->amountoutstanding + 0, 0, |
131 |
"Debt1 was reduced to 0 as expected" ); |
132 |
my $offsets = Koha::Account::Offsets->search( |
133 |
{ debit_id => $debt1->id, credit_id => { '!=' => undef } } ); |
134 |
is( $offsets->count, 1, "FeePayment produced an offset line correctly" ); |
135 |
my $credit = $offsets->next->credit; |
136 |
is( $credit->payment_type, 'SIP00', "Payment type was set correctly" ); |
137 |
}; |
138 |
|
98 |
$schema->storage->txn_rollback; |
139 |
$schema->storage->txn_rollback; |
99 |
- |
|
|