Lines 28-33
use t::lib::Mocks;
Link Here
|
28 |
use Koha::Account; |
28 |
use Koha::Account; |
29 |
use Koha::Account::Lines; |
29 |
use Koha::Account::Lines; |
30 |
use Koha::Account::Offsets; |
30 |
use Koha::Account::Offsets; |
|
|
31 |
use Koha::Notice::Messages; |
32 |
use Koha::Notice::Templates; |
31 |
use Koha::DateUtils qw( dt_from_string ); |
33 |
use Koha::DateUtils qw( dt_from_string ); |
32 |
|
34 |
|
33 |
BEGIN { |
35 |
BEGIN { |
Lines 844-883
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
844 |
is( Koha::Account::Lines->count({ borrowernumber => $patron->id }), 2 + 2, "The 2 + 2 account lines still exists, the last 2 have been deleted ok" ); |
846 |
is( Koha::Account::Lines->count({ borrowernumber => $patron->id }), 2 + 2, "The 2 + 2 account lines still exists, the last 2 have been deleted ok" ); |
845 |
}; |
847 |
}; |
846 |
|
848 |
|
847 |
subtest "Koha::Account::Offset tests" => sub { |
849 |
subtest "Payment notice tests" => sub { |
848 |
|
850 |
|
849 |
plan tests => 2; |
851 |
plan tests => 6; |
850 |
|
852 |
|
851 |
Koha::Account::Lines->delete(); |
853 |
Koha::Account::Lines->delete(); |
852 |
Koha::Patrons->delete(); |
854 |
Koha::Patrons->delete(); |
853 |
|
855 |
Koha::Notice::Messages->delete(); |
854 |
# Create a borrower |
856 |
# Create a borrower |
855 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
857 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
856 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
858 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
857 |
|
859 |
|
858 |
my $borrower = Koha::Patron->new( { |
860 |
my $borrower = Koha::Patron->new( |
859 |
cardnumber => 'chelseahall', |
861 |
{ |
860 |
surname => 'Hall', |
862 |
cardnumber => 'chelseahall', |
861 |
firstname => 'Chelsea', |
863 |
surname => 'Hall', |
862 |
} ); |
864 |
firstname => 'Chelsea', |
863 |
$borrower->categorycode( $categorycode ); |
865 |
email => 'chelsea@example.com', |
864 |
$borrower->branchcode( $branchcode ); |
866 |
categorycode => $categorycode, |
865 |
$borrower->store; |
867 |
branchcode => $branchcode, |
|
|
868 |
} |
869 |
)->store(); |
866 |
|
870 |
|
867 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
871 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
868 |
|
872 |
|
869 |
my $line = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 27 })->store(); |
873 |
my $line = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 27 })->store(); |
870 |
|
874 |
|
871 |
my $id = $account->pay( |
875 |
my $letter = Koha::Notice::Templates->find( { code => 'ACCOUNT_PAYMENT' } ); |
872 |
{ |
876 |
$letter->content('[%- USE Price -%]A payment of [% credit.amount * -1 | $Price %] has been applied to your account.'); |
873 |
amount => 13, |
877 |
$letter->store(); |
874 |
} |
878 |
|
875 |
); |
879 |
my $id = $account->pay( { amount => 13 } ); |
876 |
|
880 |
my $notice = Koha::Notice::Messages->search()->next(); |
877 |
my $offset = Koha::Account::Offsets->find( { credit_id => $id } ); |
881 |
is( $notice->subject, 'Account Payment', 'Notice subject is correct for payment' ); |
878 |
|
882 |
is( $notice->letter_code, 'ACCOUNT_PAYMENT', 'Notice letter code is correct for payment' ); |
879 |
is( $offset->credit->id, $id, 'Got correct credit for account offset' ); |
883 |
is( $notice->content, 'A payment of 13.00 has been applied to your account.', 'Notice content is correct for payment' ); |
880 |
is( $offset->debit->id, $line->id, 'Got correct debit for account offset' ); |
884 |
$notice->delete(); |
|
|
885 |
|
886 |
$letter = Koha::Notice::Templates->find( { code => 'ACCOUNT_WRITEOFF' } ); |
887 |
$letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.'); |
888 |
$letter->store(); |
889 |
|
890 |
$id = $account->pay( { amount => 14, type => 'writeoff' } ); |
891 |
$notice = Koha::Notice::Messages->search()->next(); |
892 |
is( $notice->subject, 'Account Writeoff', 'Notice subject is correct for payment' ); |
893 |
is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' ); |
894 |
is( $notice->content, 'A writeoff of 14.00 has been applied to your account.', 'Notice content is correct for writeoff' ); |
881 |
}; |
895 |
}; |
882 |
|
896 |
|
883 |
1; |
897 |
1; |
884 |
- |
|
|