Lines 203-209
subtest "Koha::Account::pay tests" => sub {
Link Here
|
203 |
my $borrowernumber = $borrower->borrowernumber; |
203 |
my $borrowernumber = $borrower->borrowernumber; |
204 |
my $data = '20.00'; |
204 |
my $data = '20.00'; |
205 |
my $payment_note = '$20.00 payment note'; |
205 |
my $payment_note = '$20.00 payment note'; |
206 |
my $id = $account->pay( { amount => $data, note => $payment_note, payment_type => "TEST_TYPE" } ); |
206 |
my $id = $account->pay( { amount => $data, note => $payment_note, payment_type => "TEST_TYPE" } )->{payment_id}; |
207 |
|
207 |
|
208 |
my $accountline = Koha::Account::Lines->find( $id ); |
208 |
my $accountline = Koha::Account::Lines->find( $id ); |
209 |
is( $accountline->payment_type, "TEST_TYPE", "Payment type passed into pay is set in account line correctly" ); |
209 |
is( $accountline->payment_type, "TEST_TYPE", "Payment type passed into pay is set in account line correctly" ); |
Lines 283-289
subtest "Koha::Account::pay tests" => sub {
Link Here
|
283 |
is($note,'$200.00 payment note', '$200.00 payment note is registered'); |
283 |
is($note,'$200.00 payment note', '$200.00 payment note is registered'); |
284 |
|
284 |
|
285 |
my $line3 = $account->add_debit({ type => 'account', amount => 42, interface => 'commandline' }); |
285 |
my $line3 = $account->add_debit({ type => 'account', amount => 42, interface => 'commandline' }); |
286 |
my $payment_id = $account->pay( { lines => [$line3], amount => 42 } ); |
286 |
my $payment_id = $account->pay( { lines => [$line3], amount => 42 } )->{payment_id}; |
287 |
my $payment = Koha::Account::Lines->find( $payment_id ); |
287 |
my $payment = Koha::Account::Lines->find( $payment_id ); |
288 |
is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); |
288 |
is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); |
289 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
289 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
Lines 365-371
subtest "Koha::Account::pay writeoff tests" => sub {
Link Here
|
365 |
amount => 42, |
365 |
amount => 42, |
366 |
type => 'writeoff', |
366 |
type => 'writeoff', |
367 |
} |
367 |
} |
368 |
); |
368 |
)->{payment_id}; |
369 |
|
369 |
|
370 |
$line->_result->discard_changes(); |
370 |
$line->_result->discard_changes(); |
371 |
|
371 |
|
Lines 1001-1007
subtest "Koha::Account::Offset credit & debit tests" => sub {
Link Here
|
1001 |
lines => [$line1, $line2], |
1001 |
lines => [$line1, $line2], |
1002 |
amount => 30, |
1002 |
amount => 30, |
1003 |
} |
1003 |
} |
1004 |
); |
1004 |
)->{payment_id}; |
1005 |
|
1005 |
|
1006 |
# Test debit and credit methods for Koha::Account::Offset |
1006 |
# Test debit and credit methods for Koha::Account::Offset |
1007 |
my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } ); |
1007 |
my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } ); |
Lines 1060-1074
subtest "Payment notice tests" => sub {
Link Here
|
1060 |
$letter->store(); |
1060 |
$letter->store(); |
1061 |
|
1061 |
|
1062 |
t::lib::Mocks::mock_preference('UseEmailReceipts', '0'); |
1062 |
t::lib::Mocks::mock_preference('UseEmailReceipts', '0'); |
1063 |
my $id = $account->pay( { amount => 1 } ); |
1063 |
my $id = $account->pay( { amount => 1 } )->{payment_id}; |
1064 |
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' ); |
1064 |
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' ); |
1065 |
|
1065 |
|
1066 |
$id = $account->pay( { amount => 1, type => 'writeoff' } ); |
1066 |
$id = $account->pay( { amount => 1, type => 'writeoff' } )->{payment_id}; |
1067 |
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' ); |
1067 |
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' ); |
1068 |
|
1068 |
|
1069 |
t::lib::Mocks::mock_preference('UseEmailReceipts', '1'); |
1069 |
t::lib::Mocks::mock_preference('UseEmailReceipts', '1'); |
1070 |
|
1070 |
|
1071 |
$id = $account->pay( { amount => 12 } ); |
1071 |
$id = $account->pay( { amount => 12 } )->{payment_id}; |
1072 |
my $notice = Koha::Notice::Messages->search()->next(); |
1072 |
my $notice = Koha::Notice::Messages->search()->next(); |
1073 |
is( $notice->subject, 'Account payment', 'Notice subject is correct for payment' ); |
1073 |
is( $notice->subject, 'Account payment', 'Notice subject is correct for payment' ); |
1074 |
is( $notice->letter_code, 'ACCOUNT_PAYMENT', 'Notice letter code is correct for payment' ); |
1074 |
is( $notice->letter_code, 'ACCOUNT_PAYMENT', 'Notice letter code is correct for payment' ); |
Lines 1079-1085
subtest "Payment notice tests" => sub {
Link Here
|
1079 |
$letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.'); |
1079 |
$letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.'); |
1080 |
$letter->store(); |
1080 |
$letter->store(); |
1081 |
|
1081 |
|
1082 |
$id = $account->pay( { amount => 13, type => 'writeoff' } ); |
1082 |
$id = $account->pay( { amount => 13, type => 'writeoff' } )->{payment_id}; |
1083 |
$notice = Koha::Notice::Messages->search()->next(); |
1083 |
$notice = Koha::Notice::Messages->search()->next(); |
1084 |
is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' ); |
1084 |
is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' ); |
1085 |
is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' ); |
1085 |
is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' ); |