Bugzilla – Attachment 75069 Details for
Bug 19191
Add ability to email receipts for account payments and write-offs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19191: Add correct unit tests
Bug-19191-Add-correct-unit-tests.patch (text/plain), 5.23 KB, created by
Kyle M Hall (khall)
on 2018-05-04 12:20:50 UTC
(
hide
)
Description:
Bug 19191: Add correct unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-05-04 12:20:50 UTC
Size:
5.23 KB
patch
obsolete
>From fa98ada01647dc7dd5405c35b392a1355cf000c4 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 12 Apr 2018 14:12:29 +0000 >Subject: [PATCH] Bug 19191: Add correct unit tests > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > installer/data/mysql/atomicupdate/bug_19191.sql | 4 ++ > t/db_dependent/Accounts.t | 62 ++++++++++++++++++++++++- > 2 files changed, 65 insertions(+), 1 deletion(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_19191.sql > >diff --git a/installer/data/mysql/atomicupdate/bug_19191.sql b/installer/data/mysql/atomicupdate/bug_19191.sql >new file mode 100644 >index 0000000000..e081ef43e9 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_19191.sql >@@ -0,0 +1,4 @@ >+INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) >+ VALUES >+ ('circulation', 'ACCOUNT_PAYMENT', '', 'Account Payment', 0, 'Account Payment', '[%- USE Price -%]\r\nA payment of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis payment affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default'), >+ ('circulation', 'ACCOUNT_WRITEOFF', '', 'Account Writeoff', 0, 'Account Writeoff', '[%- USE Price -%]\r\nAn account writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis writeoff affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default'); >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index ab1fc5fe01..feac857a4c 100644 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -18,7 +18,7 @@ > > use Modern::Perl; > >-use Test::More tests => 27; >+use Test::More tests => 28; > use Test::MockModule; > use Test::Warn; > >@@ -28,6 +28,8 @@ use t::lib::Mocks; > use Koha::Account; > use Koha::Account::Lines; > use Koha::Account::Offsets; >+use Koha::Notice::Messages; >+use Koha::Notice::Templates; > use Koha::DateUtils qw( dt_from_string ); > > BEGIN { >@@ -949,4 +951,62 @@ subtest "Koha::Account::Offset credit & debit tests" => sub { > is( $account_offset->credit, undef, "Koha::Account::Offset->credit returns undef if no associated credit" ); > }; > >+subtest "Payment notice tests" => sub { >+ >+ plan tests => 8; >+ >+ Koha::Account::Lines->delete(); >+ Koha::Patrons->delete(); >+ Koha::Notice::Messages->delete(); >+ # Create a borrower >+ my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; >+ my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; >+ >+ my $borrower = Koha::Patron->new( >+ { >+ cardnumber => 'chelseahall', >+ surname => 'Hall', >+ firstname => 'Chelsea', >+ email => 'chelsea@example.com', >+ categorycode => $categorycode, >+ branchcode => $branchcode, >+ } >+ )->store(); >+ >+ my $account = Koha::Account->new({ patron_id => $borrower->id }); >+ >+ my $line = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 27 })->store(); >+ >+ my $letter = Koha::Notice::Templates->find( { code => 'ACCOUNT_PAYMENT' } ); >+ $letter->content('[%- USE Price -%]A payment of [% credit.amount * -1 | $Price %] has been applied to your account.'); >+ $letter->store(); >+ >+ t::lib::Mocks::mock_preference('UseEmailReceipts', '0'); >+ >+ my $id = $account->pay( { amount => 1 } ); >+ is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' ); >+ >+ $id = $account->pay( { amount => 1, type => 'writeoff' } ); >+ is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' ); >+ >+ t::lib::Mocks::mock_preference('UseEmailReceipts', '1'); >+ >+ $id = $account->pay( { amount => 12 } ); >+ my $notice = Koha::Notice::Messages->search()->next(); >+ is( $notice->subject, 'Account payment', 'Notice subject is correct for payment' ); >+ is( $notice->letter_code, 'ACCOUNT_PAYMENT', 'Notice letter code is correct for payment' ); >+ is( $notice->content, 'A payment of 12.00 has been applied to your account.', 'Notice content is correct for payment' ); >+ $notice->delete(); >+ >+ $letter = Koha::Notice::Templates->find( { code => 'ACCOUNT_WRITEOFF' } ); >+ $letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.'); >+ $letter->store(); >+ >+ $id = $account->pay( { amount => 13, type => 'writeoff' } ); >+ $notice = Koha::Notice::Messages->search()->next(); >+ is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' ); >+ is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' ); >+ is( $notice->content, 'A writeoff of 13.00 has been applied to your account.', 'Notice content is correct for writeoff' ); >+}; >+ > 1; >-- >2.15.1 (Apple Git-101)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19191
:
66554
|
68605
|
68812
|
70465
|
70466
|
70471
|
72366
|
72367
|
72370
|
73924
|
74092
|
74093
|
74094
|
74095
|
74104
|
74105
|
74423
|
74424
|
74504
|
74505
|
74506
|
74507
|
74508
|
74625
|
74626
|
74627
|
74628
|
74629
|
74630
|
74631
|
74686
|
75066
|
75067
|
75068
| 75069 |
75070
|
75071
|
75072
|
75093
|
75134