Lines 214-220
subtest "Koha::Account::pay tests" => sub {
Link Here
|
214 |
my $borrowernumber = $borrower->borrowernumber; |
214 |
my $borrowernumber = $borrower->borrowernumber; |
215 |
my $data = '20.00'; |
215 |
my $data = '20.00'; |
216 |
my $payment_note = '$20.00 payment note'; |
216 |
my $payment_note = '$20.00 payment note'; |
217 |
my $id = $account->pay( { amount => $data, note => $payment_note, payment_type => "TEST_TYPE" } ); |
217 |
my $id = $account->pay( { amount => $data, note => $payment_note, payment_type => "TEST_TYPE" } )->{payment_id}; |
218 |
|
218 |
|
219 |
my $accountline = Koha::Account::Lines->find( $id ); |
219 |
my $accountline = Koha::Account::Lines->find( $id ); |
220 |
is( $accountline->payment_type, "TEST_TYPE", "Payment type passed into pay is set in account line correctly" ); |
220 |
is( $accountline->payment_type, "TEST_TYPE", "Payment type passed into pay is set in account line correctly" ); |
Lines 294-300
subtest "Koha::Account::pay tests" => sub {
Link Here
|
294 |
is($note,'$200.00 payment note', '$200.00 payment note is registered'); |
294 |
is($note,'$200.00 payment note', '$200.00 payment note is registered'); |
295 |
|
295 |
|
296 |
my $line3 = $account->add_debit({ type => 'ACCOUNT', amount => 42, interface => 'commandline' }); |
296 |
my $line3 = $account->add_debit({ type => 'ACCOUNT', amount => 42, interface => 'commandline' }); |
297 |
my $payment_id = $account->pay( { lines => [$line3], amount => 42 } ); |
297 |
my $payment_id = $account->pay( { lines => [$line3], amount => 42 } )->{payment_id}; |
298 |
my $payment = Koha::Account::Lines->find( $payment_id ); |
298 |
my $payment = Koha::Account::Lines->find( $payment_id ); |
299 |
is( $payment->amount()+0, -42, "Payment paid the specified fine" ); |
299 |
is( $payment->amount()+0, -42, "Payment paid the specified fine" ); |
300 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
300 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
Lines 376-382
subtest "Koha::Account::pay writeoff tests" => sub {
Link Here
|
376 |
amount => 42, |
376 |
amount => 42, |
377 |
type => 'WRITEOFF', |
377 |
type => 'WRITEOFF', |
378 |
} |
378 |
} |
379 |
); |
379 |
)->{payment_id}; |
380 |
|
380 |
|
381 |
$line->_result->discard_changes(); |
381 |
$line->_result->discard_changes(); |
382 |
|
382 |
|
Lines 1111-1117
subtest "Koha::Account::Offset credit & debit tests" => sub {
Link Here
|
1111 |
lines => [$line1, $line2], |
1111 |
lines => [$line1, $line2], |
1112 |
amount => 30, |
1112 |
amount => 30, |
1113 |
} |
1113 |
} |
1114 |
); |
1114 |
)->{payment_id}; |
1115 |
|
1115 |
|
1116 |
# Test debit and credit methods for Koha::Account::Offset |
1116 |
# Test debit and credit methods for Koha::Account::Offset |
1117 |
my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } ); |
1117 |
my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } ); |
Lines 1177-1191
subtest "Payment notice tests" => sub {
Link Here
|
1177 |
$letter->store(); |
1177 |
$letter->store(); |
1178 |
|
1178 |
|
1179 |
t::lib::Mocks::mock_preference('UseEmailReceipts', '0'); |
1179 |
t::lib::Mocks::mock_preference('UseEmailReceipts', '0'); |
1180 |
my $id = $account->pay( { amount => 1 } ); |
1180 |
my $id = $account->pay( { amount => 1 } )->{payment_id}; |
1181 |
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' ); |
1181 |
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' ); |
1182 |
|
1182 |
|
1183 |
$id = $account->pay( { amount => 1, type => 'WRITEOFF' } ); |
1183 |
$id = $account->pay( { amount => 1, type => 'WRITEOFF' } )->{payment_id}; |
1184 |
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' ); |
1184 |
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' ); |
1185 |
|
1185 |
|
1186 |
t::lib::Mocks::mock_preference('UseEmailReceipts', '1'); |
1186 |
t::lib::Mocks::mock_preference('UseEmailReceipts', '1'); |
1187 |
|
1187 |
|
1188 |
$id = $account->pay( { amount => 12, library_id => $branchcode } ); |
1188 |
$id = $account->pay( { amount => 12, library_id => $branchcode } )->{payment_id}; |
1189 |
my $notice = Koha::Notice::Messages->search()->next(); |
1189 |
my $notice = Koha::Notice::Messages->search()->next(); |
1190 |
is( $notice->subject, 'Account payment', 'Notice subject is correct for payment' ); |
1190 |
is( $notice->subject, 'Account payment', 'Notice subject is correct for payment' ); |
1191 |
is( $notice->letter_code, 'ACCOUNT_PAYMENT', 'Notice letter code is correct for payment' ); |
1191 |
is( $notice->letter_code, 'ACCOUNT_PAYMENT', 'Notice letter code is correct for payment' ); |
Lines 1196-1202
subtest "Payment notice tests" => sub {
Link Here
|
1196 |
$letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account. Your [% branch.branchcode %]'); |
1196 |
$letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account. Your [% branch.branchcode %]'); |
1197 |
$letter->store(); |
1197 |
$letter->store(); |
1198 |
|
1198 |
|
1199 |
$id = $account->pay( { amount => 13, type => 'WRITEOFF', library_id => $branchcode } ); |
1199 |
$id = $account->pay( { amount => 13, type => 'WRITEOFF', library_id => $branchcode } )->{payment_id}; |
1200 |
$notice = Koha::Notice::Messages->search()->next(); |
1200 |
$notice = Koha::Notice::Messages->search()->next(); |
1201 |
is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' ); |
1201 |
is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' ); |
1202 |
is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' ); |
1202 |
is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' ); |