Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 301fdeba

Von Bernd Bleßmann vor etwa 2 Jahren hinzugefügt

  • ID 301fdebada6c024be99e200a593212c8c5ecbaf7
  • Vorgänger df3f88c5
  • Nachfolger 250a15ae

SEPA-Überweisungen sperren könnnen (Einkauf)

Unterschiede anzeigen:

SL/SEPA.pm
29 29

  
30 30
  my $mandate  = $params{vc} eq 'customer' ? " AND COALESCE(vc.mandator_id, '') <> '' AND vc.mandate_date_of_signature IS NOT NULL " : '';
31 31

  
32
  my $is_sepa_blocked = $params{vc} eq 'customer' ? 'FALSE' : "${arap}.is_sepa_blocked";
33

  
32 34
  # open_amount is not the current open amount according to bookkeeping, but
33 35
  # the open amount minus the SEPA transfer amounts that haven't been closed yet
34 36
  my $query =
......
38 40
         (${arap}.amount - (${arap}.amount * pt.percent_skonto)) as amount_less_skonto,
39 41
         (${arap}.amount * pt.percent_skonto) as skonto_amount,
40 42
         vc.name AS vcname, vc.language_id, ${arap}.duedate as duedate, ${arap}.direct_debit,
43
         ${is_sepa_blocked} AS is_sepa_blocked,
41 44
         vc.${vc_vc_id} as vc_vc_id,
42 45

  
43 46
         COALESCE(vc.iban, '') <> '' AND COALESCE(vc.bic, '') <> '' ${mandate} AS vc_bank_info_ok,
bin/mozilla/ap.pl
626 626
  $::form->redirect($::locale->text("Marked as paid"));
627 627
}
628 628

  
629
sub block_or_unblock_sepa_transfer {
630
  $::auth->assert('ap_transactions');
631

  
632
  my $invoice = SL::DB::PurchaseInvoice->new(id => $::form->{id})->load;
633
  $invoice->update_attributes(is_sepa_blocked => 0) if  $::form->{unblock_sepa} &&  $invoice->is_sepa_blocked;
634
  $invoice->update_attributes(is_sepa_blocked => 1) if !$::form->{unblock_sepa} && !$invoice->is_sepa_blocked;
635

  
636
  $::form->redirect($::form->{unblock_sepa} ? t8('Bank transfer via SEPA is unblocked') : t8('Bank transfer via SEPA is blocked'));
637
}
638

  
629 639
sub show_draft {
630 640
  $::form->{transdate} = DateTime->today_local->to_kivitendo if !$::form->{transdate};
631 641
  $::form->{gldate}    = $::form->{transdate} if !$::form->{gldate};
......
1374 1384
  my $may_edit_create         = $::auth->assert('ap_transactions', 1);
1375 1385

  
1376 1386
  my $has_sepa_exports;
1387
  my $is_sepa_blocked;
1377 1388
  if ($::form->{id}) {
1378 1389
    my $invoice = SL::DB::Manager::PurchaseInvoice->find_by(id => $::form->{id});
1379 1390
    $has_sepa_exports = 1 if ($invoice->find_sepa_export_items()->[0]);
1391
    $is_sepa_blocked  = !!$invoice->is_sepa_blocked;
1380 1392
  }
1381 1393

  
1382 1394
  my $is_linked_bank_transaction;
......
1440 1452
                    : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.')
1441 1453
                    :                               undef,
1442 1454
        ],
1455
        action => [ $is_sepa_blocked ? t8('Unblock Bank transfer via SEPA') : t8('Block Bank transfer via SEPA'),
1456
          submit   => [ '#form', { action => "block_or_unblock_sepa_transfer", unblock_sepa => !!$is_sepa_blocked } ],
1457
          disabled => !$may_edit_create ? t8('You must not change this AP transaction.')
1458
                    : !$::form->{id}    ? t8('This invoice has not been posted yet.')
1459
                    :                     undef,
1460
        ],
1443 1461
        action => [ t8('Mark as paid'),
1444 1462
          submit   => [ '#form', { action => "mark_as_paid" } ],
1445 1463
          confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
bin/mozilla/ir.pl
250 250
  my $may_edit_create         = $::auth->assert('vendor_invoice_edit', 1);
251 251

  
252 252
  my $has_sepa_exports;
253
  my $is_sepa_blocked;
253 254
  if ($form->{id}) {
254 255
    my $invoice = SL::DB::Manager::PurchaseInvoice->find_by(id => $form->{id});
255 256
    $has_sepa_exports = 1 if ($invoice->find_sepa_export_items()->[0]);
257
    $is_sepa_blocked  = !!$invoice->is_sepa_blocked;
256 258
  }
257 259

  
258 260
  my $is_linked_bank_transaction;
......
311 313
                    : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.')
312 314
                    :                               undef,
313 315
        ],
316
        action => [ $is_sepa_blocked ? t8('Unblock Bank transfer via SEPA') : t8('Block Bank transfer via SEPA'),
317
          submit   => [ '#form', { action => "block_or_unblock_sepa_transfer", unblock_sepa => !!$is_sepa_blocked } ],
318
          disabled => !$may_edit_create ? t8('You must not change this AP transaction.')
319
                    : !$::form->{id}    ? t8('This invoice has not been posted yet.')
320
                    :                     undef,
321
        ],
314 322
        action => [
315 323
          t8('Mark as paid'),
316 324
          submit   => [ '#form', { action => "mark_as_paid" } ],
......
607 615
  $::form->redirect($::locale->text("Marked as paid"));
608 616
}
609 617

  
618
sub block_or_unblock_sepa_transfer {
619
  $::auth->assert('ap_transactions');
620

  
621
  my $invoice = SL::DB::PurchaseInvoice->new(id => $::form->{id})->load;
622
  $invoice->update_attributes(is_sepa_blocked => 0) if  $::form->{unblock_sepa} &&  $invoice->is_sepa_blocked;
623
  $invoice->update_attributes(is_sepa_blocked => 1) if !$::form->{unblock_sepa} && !$invoice->is_sepa_blocked;
624

  
625
  $::form->redirect($::form->{unblock_sepa} ? t8('Bank transfer via SEPA is unblocked') : t8('Bank transfer via SEPA is blocked'));
626
}
627

  
610 628
sub show_draft {
611 629
  update();
612 630
}
bin/mozilla/sepa.pl
111 111
  my %invoices_map   = map { $_->{id} => $_ } @{ $invoices };
112 112
  my @bank_transfers =
113 113
    map  +{ %{ $invoices_map{ $_->{$arap_id} } }, %{ $_ } },
114
    grep  { ($_->{selected} || $selected_ids{$_->{$arap_id}}) && (0 < $_->{amount}) && $invoices_map{ $_->{$arap_id} } }
114
    grep  { ($_->{selected} || $selected_ids{$_->{$arap_id}}) && (0 < $_->{amount}) && $invoices_map{ $_->{$arap_id} } && !($invoices_map{ $_->{$arap_id} }->{is_sepa_blocked}) }
115 115
    map   { $_->{amount} = $form->parse_amount($myconfig, $_->{amount}); $_ }
116 116
          @{ $form->{bank_transfers} || [] };
117 117

  
templates/webpages/sepa/bank_transfer_add.html
54 54

  
55 55
     <tr class="listrow[% IF !invoice.vc_bank_info_ok && invoice.checked %]_error[% END %]">
56 56
      <td align="center">
57
       [%- IF invoice.vc_bank_info_ok %]
57
       [%- IF invoice.vc_bank_info_ok && !invoice.is_sepa_blocked %]
58 58
        [% L.checkbox_tag("ids[]", value=invoice.id, checked=invoice.checked) %]
59 59
       [%- END %]
60 60
      </td>
......
77 77

  
78 78
      <td>
79 79
       <a href="[% IF invoice.invoice %][% iris %][% ELSE %][% arap %][% END %].pl?action=edit&id=[% HTML.escape(invoice.id) %]">
80
        [% HTML.escape(invoice.invnumber) %]
80
         [%- GET HTML.escape(invoice.invnumber);
81
             IF invoice.is_sepa_blocked;
82
               GET ' <sup>(*)</sup>';
83
               SET show_is_sepa_blocked_footnote = '1';
84
             END;
85
         -%]
81 86
       </a>
82 87
      </td>
83 88

  
......
131 136
   </p>
132 137
  [%- END %]
133 138

  
134
  <input type="hidden" name="vc" value="[%- HTML.escape(vc) %]">
139
  [%- IF show_is_sepa_blocked_footnote %]
140
   <p>
141
    <sup>(*)</sup>
142
     [%- 'For this invoice the bank tranfer via SEPA was blocked manually.' | $T8 %]
143
   </p>
144
   [%- END %]
145

  
146
   <input type="hidden" name="vc" value="[%- HTML.escape(vc) %]">
135 147
 </form>
136 148

  
137 149
 <script type="text/javascript">

Auch abrufbar als: Unified diff