View | Details | Raw Unified | Return to bug 33473
Collapse All | Expand All

(-)a/Koha/Account.pm (-1 / +1 lines)
Lines 126-132 sub pay { Link Here
126
126
127
    my $patron = Koha::Patrons->find( $self->{patron_id} );
127
    my $patron = Koha::Patrons->find( $self->{patron_id} );
128
    my @account_offsets = $payment->credit_offsets({ type => 'APPLY' })->as_list;
128
    my @account_offsets = $payment->credit_offsets({ type => 'APPLY' })->as_list;
129
    if ( C4::Context->preference('UseEmailReceipts') ) {
129
    if ( C4::Context->preference('AutomaticEmailReceipts') ) {
130
        if (
130
        if (
131
            my $letter = C4::Letters::GetPreparedLetter(
131
            my $letter = C4::Letters::GetPreparedLetter(
132
                module                 => 'circulation',
132
                module                 => 'circulation',
(-)a/installer/data/mysql/atomicupdate/bug_33473-Add-option-to-resend-email-receipt-when-UseEmailReceipts-is-enabled.pl (+15 lines)
Line 0 Link Here
1
    use Modern::Perl;
2
    
3
    return {
4
        bug_number  => "33473",
5
        description => "Allow to send email receipts for payments/writeoff manually instead of automatically",
6
        up          => sub {
7
            my ($args) = @_;
8
            my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
            $dbh->do(q{
11
                UPDATE systempreferences SET variable = 'AutomaticEmailReceipts' WHERE variable = 'UseEmailReceipts';
12
            });
13
            say $out "Renamed system preference 'UseEmailReceipts' to 'AutomaticEmailReceipts'";
14
        },
15
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 838-844 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
838
('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'),
838
('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'),
839
('useDefaultReplacementCost', '0', NULL, 'default replacement cost defined in item type', 'YesNo'),
839
('useDefaultReplacementCost', '0', NULL, 'default replacement cost defined in item type', 'YesNo'),
840
('useDischarge','0','','Allows librarians to discharge borrowers and borrowers to request a discharge','YesNo'),
840
('useDischarge','0','','Allows librarians to discharge borrowers and borrowers to request a discharge','YesNo'),
841
('UseEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo'),
841
('AutomaticEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo'),
842
('UseICUStyleQuotes','0','1','Tell Koha whether to use ICU style quotes ({) or default (") when tracing subjects .','YesNo'),
842
('UseICUStyleQuotes','0','1','Tell Koha whether to use ICU style quotes ({) or default (") when tracing subjects .','YesNo'),
843
('UseLocationAsAQInSIP', '0', '', 'Use permanent_location instead of homebranch for AQ in SIP response', 'YesNo'),
843
('UseLocationAsAQInSIP', '0', '', 'Use permanent_location instead of homebranch for AQ in SIP response', 'YesNo'),
844
('UseOCLCEncodingLevels','0',NULL,'If enabled, include OCLC encoding levels in leader value builder dropdown for position 17.','YesNo'),
844
('UseOCLCEncodingLevels','0',NULL,'If enabled, include OCLC encoding levels in leader value builder dropdown for position 17.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +1 lines)
Lines 185-191 Patrons: Link Here
185
               0: "Don't notify"
185
               0: "Don't notify"
186
         - patrons whenever their password is changed.
186
         - patrons whenever their password is changed.
187
     -
187
     -
188
         - pref: UseEmailReceipts
188
         - pref: AutomaticEmailReceipts
189
           choices:
189
           choices:
190
               1: Send
190
               1: Send
191
               0: "Don't send"
191
               0: "Don't send"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-2 / +2 lines)
Lines 137-143 Link Here
137
      [% IF account.amountoutstanding <= 0 %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding | $Price %]</td>
137
      [% IF account.amountoutstanding <= 0 %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding | $Price %]</td>
138
      <td class="actions">
138
      <td class="actions">
139
        [% IF ( account.is_credit ) %]
139
        [% IF ( account.is_credit ) %]
140
          [% IF Koha.Preference('UseEmailReceipts') %]
140
          [% IF patron.notice_email_address %]
141
          <div class="btn-group">
141
          <div class="btn-group">
142
          <button class="btn btn-xs btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-receipt"></i> Receipt</button>
142
          <button class="btn btn-xs btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-receipt"></i> Receipt</button>
143
          <ul class="dropdown-menu dropdown-menu-end">
143
          <ul class="dropdown-menu dropdown-menu-end">
Lines 149-155 Link Here
149
                      <input type="hidden" name="accountlines_id" value="[% account.accountlines_id | html %]" />
149
                      <input type="hidden" name="accountlines_id" value="[% account.accountlines_id | html %]" />
150
                      <input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]" />
150
                      <input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]" />
151
                  </form>
151
                  </form>
152
                  <a href="#" class="receipt-email-action"><i class="fa fa-envelope"></i> Email</a>
152
                  <a href="#" class="receipt-email-action dropdown-item"><i class="fa fa-envelope"></i> Email</a>
153
              </li>
153
              </li>
154
          </ul>
154
          </ul>
155
          </div>
155
          </div>
(-)a/t/db_dependent/Accounts.t (-4 / +4 lines)
Lines 1059-1072 subtest "Payment notice tests" => sub { Link Here
1059
    $letter->content('[%- USE Price -%]A payment of [% credit.amount * -1 | $Price %] has been applied to your account. Your [% branch.branchcode %]');
1059
    $letter->content('[%- USE Price -%]A payment of [% credit.amount * -1 | $Price %] has been applied to your account. Your [% branch.branchcode %]');
1060
    $letter->store();
1060
    $letter->store();
1061
1061
1062
    t::lib::Mocks::mock_preference('UseEmailReceipts', '0');
1062
    t::lib::Mocks::mock_preference('AutomaticEmailReceipts', '0');
1063
    my $id = $account->pay( { amount => 1 } )->{payment_id};
1063
    my $id = $account->pay( { amount => 1 } )->{payment_id};
1064
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' );
1064
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if AutomaticEmailReceipts is disabled' );
1065
1065
1066
    $id = $account->pay( { amount => 1, type => 'WRITEOFF' } )->{payment_id};
1066
    $id = $account->pay( { amount => 1, type => 'WRITEOFF' } )->{payment_id};
1067
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' );
1067
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if AutomaticEmailReceipts is disabled' );
1068
1068
1069
    t::lib::Mocks::mock_preference('UseEmailReceipts', '1');
1069
    t::lib::Mocks::mock_preference('AutomaticEmailReceipts', '1');
1070
1070
1071
    $id = $account->pay( { amount => 12, library_id => $branchcode } )->{payment_id};
1071
    $id = $account->pay( { amount => 12, library_id => $branchcode } )->{payment_id};
1072
    my $notice = Koha::Notice::Messages->search()->next();
1072
    my $notice = Koha::Notice::Messages->search()->next();
(-)a/t/db_dependent/Koha/Account.t (-3 / +2 lines)
Lines 780-790 subtest 'pay() tests' => sub { Link Here
780
    my $payment = Koha::Account::Lines->find({accountlines_id => $result->{payment_id}});
780
    my $payment = Koha::Account::Lines->find({accountlines_id => $result->{payment_id}});
781
    is($payment->manager_id, undef, "manager_id left undefined when no userenv found");
781
    is($payment->manager_id, undef, "manager_id left undefined when no userenv found");
782
782
783
    subtest 'UseEmailReceipts tests' => sub {
783
    subtest 'AutomaticEmailReceipts tests' => sub {
784
784
785
        plan tests => 5;
785
        plan tests => 5;
786
786
787
        t::lib::Mocks::mock_preference( 'UseEmailReceipts', 1 );
787
        t::lib::Mocks::mock_preference( 'AutomaticEmailReceipts', 1 );
788
788
789
        my %params;
789
        my %params;
790
790
791
- 

Return to bug 33473