Bugzilla – Attachment 75072 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 syspref to control use of email receipts, defaulting to disabled
Bug-19191-Add-syspref-to-control-use-of-email-rece.patch (text/plain), 7.48 KB, created by
Kyle M Hall (khall)
on 2018-05-04 12:21:04 UTC
(
hide
)
Description:
Bug 19191: Add syspref to control use of email receipts, defaulting to disabled
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-05-04 12:21:04 UTC
Size:
7.48 KB
patch
obsolete
>From 4f83faa592e36cfafa5a1e31d1cc365f4aef38da Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 20 Apr 2018 12:42:15 +0000 >Subject: [PATCH] Bug 19191: Add syspref to control use of email receipts, > defaulting to disabled > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > Koha/Account.pm | 50 +++++++++++----------- > installer/data/mysql/atomicupdate/bug_19191.sql | 7 ++- > installer/data/mysql/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/patrons.pref | 6 +++ > t/db_dependent/Accounts.t | 2 +- > 5 files changed, 40 insertions(+), 26 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index d2ecc7a272..9b087df97d 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -263,31 +263,33 @@ sub pay { > ); > } > >- require C4::Letters; >- if ( >- my $letter = C4::Letters::GetPreparedLetter( >- module => 'circulation', >- letter_code => uc("ACCOUNT_$type"), >- message_transport_type => 'email', >- lang => Koha::Patrons->find( $self->{patron_id} )->lang, >- tables => { >- borrowers => $self->{patron_id}, >- branches => $self->{library_id}, >- }, >- substitute => { >- credit => $payment, >- offsets => scalar Koha::Account::Offsets->search( { id => { -in => [ map { $_->id } @account_offsets ] } } ), >- }, >- ) >- ) >- { >- C4::Letters::EnqueueLetter( >- { >- letter => $letter, >- borrowernumber => $self->{patron_id}, >+ if ( C4::Context->preference('UseEmailReceipts') ) { >+ require C4::Letters; >+ if ( >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'circulation', >+ letter_code => uc("ACCOUNT_$type"), > message_transport_type => 'email', >- } >- ) or warn "can't enqueue letter $letter"; >+ lang => Koha::Patrons->find( $self->{patron_id} )->lang, >+ tables => { >+ borrowers => $self->{patron_id}, >+ branches => $self->{library_id}, >+ }, >+ substitute => { >+ credit => $payment, >+ offsets => scalar Koha::Account::Offsets->search( { id => { -in => [ map { $_->id } @account_offsets ] } } ), >+ }, >+ ) >+ ) >+ { >+ C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $self->{patron_id}, >+ message_transport_type => 'email', >+ } >+ ) or warn "can't enqueue letter $letter"; >+ } > } > > return $payment->id; >diff --git a/installer/data/mysql/atomicupdate/bug_19191.sql b/installer/data/mysql/atomicupdate/bug_19191.sql >index e081ef43e9..99d9f97756 100644 >--- a/installer/data/mysql/atomicupdate/bug_19191.sql >+++ b/installer/data/mysql/atomicupdate/bug_19191.sql >@@ -1,4 +1,9 @@ > 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_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'); >+ >+$dbh->do(q{ >+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) >+ VALUES ('UseEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo') >+}); >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 4a594f0fbb..68e6588188 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -596,6 +596,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('useDaysMode','Calendar','Calendar|Days|Datedue','Choose the method for calculating due date: select Calendar to use the holidays module, and Days to ignore the holidays module','Choice'), > ('useDefaultReplacementCost', '0', NULL, 'default replacement cost defined in item type', 'YesNo'), > ('useDischarge','','','Allows librarians to discharge borrowers and borrowers to request a discharge','YesNo'), >+('UseEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo'), > ('UseICU','0','1','Tell Koha if ICU indexing is in use for Zebra or not.','YesNo'), > ('UseKohaPlugins','0','','Enable or disable the ability to use Koha Plugins.','YesNo'), > ('UseQueryParser','0',NULL,'If enabled, try to use QueryParser for queries.','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index 348e1dd9ed..4adcf1bb44 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -6,6 +6,12 @@ Patrons: > yes: Send > no: "Don't send" > - an email to newly created patrons with their account details. >+ - >+ - pref: UseEmailReceipts >+ choices: >+ yes: Send >+ no: "Don't send" >+ - email receipts to patrons for payments and writeoffs. > - > - "Use" > - pref: AutoEmailPrimaryAddress >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index feac857a4c..c2771b9230 100644 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -1004,7 +1004,7 @@ subtest "Payment notice tests" => sub { > > $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->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' ); > }; >-- >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