Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 67ae175a

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID 67ae175a8aef3e189d6b44c2e0261a8e0448e5b1
  • Vorgänger 6b1f644c
  • Nachfolger 0b33ef7a

Unterscheidung Bankeinzug/Überweisung in zweiter Maske (Bestätigung der Informationen)

Unterschiede anzeigen:

bin/mozilla/sepa.pl
58 58
  my $form          = $main::form;
59 59
  my $locale        = $main::locale;
60 60
  my $myconfig      = \%main::myconfig;
61
  my $vc            = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
61 62

  
62
  $form->{title}    = $locale->text('Create bank transfer via SEPA XML');
63
  $form->{title}    = $vc eq 'customer' ? $::locale->text('Create bank collection via SEPA XML') : $locale->text('Create bank transfer via SEPA XML');
63 64

  
64 65
  my $bank_accounts = SL::BankAccount->list();
65 66

  
......
73 74
    $form->error($locale->text('The selected bank account does not exist anymore.'));
74 75
  }
75 76

  
76
  my $invoices       = SL::SEPA->retrieve_open_invoices();
77
  my $arap_id        = $vc eq 'customer' ? 'ar_id' : 'ap_id';
78
  my $invoices       = SL::SEPA->retrieve_open_invoices(vc => $vc);
79

  
77 80
  my %invoices_map   = map { $_->{id} => $_ } @{ $invoices };
78 81
  my @bank_transfers =
79
    map  +{ %{ $invoices_map{ $_->{ap_id} } }, %{ $_ } },
80
    grep  { $_->{selected} && (0 < $_->{amount}) && $invoices_map{ $_->{ap_id} } }
82
    map  +{ %{ $invoices_map{ $_->{$arap_id} } }, %{ $_ } },
83
    grep  { $_->{selected} && (0 < $_->{amount}) && $invoices_map{ $_->{$arap_id} } }
81 84
    map   { $_->{amount} = $form->parse_amount($myconfig, $_->{amount}); $_ }
82 85
          @{ $form->{bank_transfers} || [] };
83 86

  
......
85 88
    $form->error($locale->text('You have selected none of the invoices.'));
86 89
  }
87 90

  
88
  my ($vendor_bank_info);
91
  my ($vc_bank_info);
89 92
  my $error_message;
90 93

  
91 94
  if ($form->{confirmation}) {
92
    $vendor_bank_info = { map { $_->{id} => $_ } @{ $form->{vendor_bank_info} || [] } };
95
    $vc_bank_info = { map { $_->{id} => $_ } @{ $form->{vc_bank_info} || [] } };
93 96

  
94
    foreach my $info (values %{ $vendor_bank_info }) {
97
    foreach my $info (values %{ $vc_bank_info }) {
95 98
      if (any { !$info->{$_} } qw(iban bic)) {
96 99
        $error_message = $locale->text('The bank information must not be empty.');
97 100
        last;
......
100 103
  }
101 104

  
102 105
  if ($error_message || !$form->{confirmation}) {
103
    my @vendor_ids             = uniq map { $_->{vendor_id} } @bank_transfers;
104
    $vendor_bank_info        ||= CT->get_bank_info('vc' => 'vendor',
105
                                                   'id' => \@vendor_ids);
106
    my @vendor_bank_info       = sort { lc $a->{name} cmp lc $b->{name} } values %{ $vendor_bank_info };
106
    my @vc_ids                 = uniq map { $_->{"${vc}_id"} } @bank_transfers;
107
    $vc_bank_info            ||= CT->get_bank_info('vc' => $vc,
108
                                                   'id' => \@vc_ids);
109
    my @vc_bank_info           = sort { lc $a->{name} cmp lc $b->{name} } values %{ $vc_bank_info };
107 110

  
108 111
    my $bank_account_label_sub = sub { $locale->text('Account number #1, bank code #2, #3', $_[0]->{account_number}, $_[0]->{bank_code}, $_[0]->{bank}) };
109 112

  
......
113 116
    print $form->parse_html_template('sepa/bank_transfer_create',
114 117
                                     { 'BANK_TRANSFERS'     => \@bank_transfers,
115 118
                                       'BANK_ACCOUNTS'      => $bank_accounts,
116
                                       'VENDOR_BANK_INFO'   => \@vendor_bank_info,
119
                                       'VC_BANK_INFO'       => \@vc_bank_info,
117 120
                                       'bank_account'       => $bank_account,
118 121
                                       'bank_account_label' => $bank_account_label_sub,
119 122
                                       'error_message'      => $error_message,
123
                                       'vc'                 => $vc,
120 124
                                     });
121 125

  
122 126
  } else {
123 127
    foreach my $bank_transfer (@bank_transfers) {
124 128
      foreach (qw(iban bic)) {
125
        $bank_transfer->{"vendor_${_}"} = $vendor_bank_info->{ $bank_transfer->{vendor_id} }->{$_};
126
        $bank_transfer->{"our_${_}"}    = $bank_account->{$_};
129
        $bank_transfer->{"vc_${_}"}  = $vc_bank_info->{ $bank_transfer->{vc_id} }->{$_};
130
        $bank_transfer->{"our_${_}"} = $bank_account->{$_};
127 131
      }
128 132

  
129 133
      $bank_transfer->{chart_id} = $bank_account->{chart_id};
130 134
    }
131 135

  
132 136
    my $id = SL::SEPA->create_export('employee'       => $form->{login},
133
                                     'bank_transfers' => \@bank_transfers);
137
                                     'bank_transfers' => \@bank_transfers,
138
                                     'vc'             => $vc);
134 139

  
135 140
    $form->header();
136
    print $form->parse_html_template('sepa/bank_transfer_created', { 'id' => $id });
141
    print $form->parse_html_template('sepa/bank_transfer_created', { 'id' => $id, 'vc' => $vc });
137 142
  }
138 143

  
139 144
  $main::lxdebug->leave_sub();

Auch abrufbar als: Unified diff