Bug 33473: Rename UseEmailReceipts to AutomaticEmailReceipts

This bug will rename the UseEmailReceipts to AutomaticEmailReceipts, to
make it clearer the purpose of this syspref. This is because the receipts
dropdown is no longer conditional, and will always show, even if
AutomaticEmailReceipts is switched off.

To test (steps a-e before applying patch):
a)  search sysprefs for 'EmailReceipts'
    1)  note the name is currently 'UseEmailReceipts'
    2)  enable this syspref
b)  go to members/maninvoice.pl?borrowernumber=51
    1)  enter an amount (e.g. 100)
    2)  save & pay, confirm
c)  go to members/boraccount.pl?borrowernumber=51
    1)  note that the receipt dropdown is visible
d)  go to members/notices.pl?borrowernumber=51
    1)  note that a receipt was automatically sent
e)  apply the patch, upgrade the db schema
f)  search sysprefs for 'EmailReceipts'
    1)  note the name is now 'AutomaticEmailReceipts'
g)  go to members/maninvoice.pl?borrowernumber=51
    1)  enter an amount (e.g. 100)
    2)  save & pay, confirm
h)  go to members/boraccount.pl?borrowernumber=51
    1)  note that the receipt dropdown is no longer visible
i)  go to members/notices.pl?borrowernumber=51
    1)  note that a receipt was automatically sent again
j)  disable the 'AutomaticEmailReceipts' syspref
k)  go to members/memberentry.pl?op=edit_form&destination=circ&borrowernumber=19
    1)  add a valid email address
k)  go to members/maninvoice.pl?borrowernumber=51
    1)  enter an amount (e.g. 100)
    2)  save & pay, confirm
l)  go to members/boraccount.pl?borrowernumber=51
    1)  note that the receipt dropdown is now visible
m)  go to members/notices.pl?borrowernumber=51
    1)  note that a receipt was NOT automatically sent
n)  go to members/boraccount.pl?borrowernumber=51
    1)  on any account line where a payment is made, click receipts > email
o)  go to members/notices.pl?borrowernumber=51
    1)  confirm a manual notice has been generated
p)  make coffee & have a mini disco

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
PerplexedTheta 2024-08-14 11:58:22 +01:00 committed by Katrin Fischer
parent 28a5e6545d
commit 1fb771c2a1
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
7 changed files with 34 additions and 11 deletions

View File

@ -130,7 +130,7 @@ sub pay {
my $patron = Koha::Patrons->find( $self->{patron_id} );
my @account_offsets = $payment->credit_offsets( { type => 'APPLY' } )->as_list;
if ( C4::Context->preference('UseEmailReceipts') ) {
if ( C4::Context->preference('AutomaticEmailReceipts') ) {
if (
my $letter = C4::Letters::GetPreparedLetter(
module => 'circulation',

View File

@ -0,0 +1,17 @@
use Modern::Perl;
return {
bug_number => "33473",
description => "Allow to send email receipts for payments/writeoff manually instead of automatically",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
$dbh->do(
q{
UPDATE systempreferences SET variable = 'AutomaticEmailReceipts' WHERE variable = 'UseEmailReceipts';
}
);
say $out "Renamed system preference 'UseEmailReceipts' to 'AutomaticEmailReceipts'";
},
}

View File

@ -859,7 +859,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('useDaysMode','Calendar','Calendar|Days|Datedue|Dayweek','Choose the method for calculating due date: select Calendar, Datedue or Dayweek 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','0','','Allows librarians to discharge borrowers and borrowers to request a discharge','YesNo'),
('UseEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo'),
('AutomaticEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo'),
('UseICUStyleQuotes','0','1','Tell Koha whether to use ICU style quotes ({) or default (") when tracing subjects .','YesNo'),
('UseLocationAsAQInSIP', '0', '', 'Use permanent_location instead of homebranch for AQ in SIP response', 'YesNo'),
('UseOCLCEncodingLevels','0',NULL,'If enabled, include OCLC encoding levels in leader value builder dropdown for position 17.','YesNo'),

View File

@ -187,7 +187,7 @@ Patrons:
0: "Don't notify"
- patrons whenever their password is changed.
-
- pref: UseEmailReceipts
- pref: AutomaticEmailReceipts
choices:
1: Send
0: "Don't send"

View File

@ -157,7 +157,7 @@
<td class="[% td_class | html %]" style="text-align: right;">[% account.amountoutstanding | $Price %]</td>
<td class="actions">
[% IF ( account.is_credit ) %]
[% IF Koha.Preference('UseEmailReceipts') %]
[% IF patron.notice_email_address %]
<div class="btn-group dropup">
<button class="btn btn-xs btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-receipt"></i> Receipt</button>
<ul class="dropdown-menu dropdown-menu-end">
@ -170,8 +170,8 @@
<input type="hidden" name="op" value="cud-send_receipt" />
<input type="hidden" name="accountlines_id" value="[% account.accountlines_id | html %]" />
<input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]" />
<button type="submit" class="dropdown-item receipt-email-action"> <i class="fa fa-envelope"></i> Email </button>
</form>
<a href="#" class="receipt-email-action dropdown-item"><i class="fa fa-envelope"></i> Email</a>
</li>
</ul>
</div>

View File

@ -1257,14 +1257,20 @@ subtest "Payment notice tests" => sub {
);
$letter->store();
t::lib::Mocks::mock_preference( 'UseEmailReceipts', '0' );
t::lib::Mocks::mock_preference( 'AutomaticEmailReceipts', '0' );
my $id = $account->pay( { amount => 1 } )->{payment_id};
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' );
is(
Koha::Notice::Messages->search()->count(), 0,
'Notice for payment not sent if AutomaticEmailReceipts is disabled'
);
$id = $account->pay( { amount => 1, type => 'WRITEOFF' } )->{payment_id};
is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' );
is(
Koha::Notice::Messages->search()->count(), 0,
'Notice for writeoff not sent if AutomaticEmailReceipts is disabled'
);
t::lib::Mocks::mock_preference( 'UseEmailReceipts', '1' );
t::lib::Mocks::mock_preference( 'AutomaticEmailReceipts', '1' );
$id = $account->pay( { amount => 12, library_id => $branchcode } )->{payment_id};
my $notice = Koha::Notice::Messages->search()->next();

View File

@ -795,11 +795,11 @@ subtest 'pay() tests' => sub {
my $payment = Koha::Account::Lines->find( { accountlines_id => $result->{payment_id} } );
is( $payment->manager_id, undef, "manager_id left undefined when no userenv found" );
subtest 'UseEmailReceipts tests' => sub {
subtest 'AutomaticEmailReceipts tests' => sub {
plan tests => 5;
t::lib::Mocks::mock_preference( 'UseEmailReceipts', 1 );
t::lib::Mocks::mock_preference( 'AutomaticEmailReceipts', 1 );
my %params;