Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f70c8fa4

Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt

  • ID f70c8fa479417e7c20108a23c18c0c6e5e683c6a
  • Vorgänger a23eb775
  • Nachfolger 484f14f3

Kunden/Lieferanten: UStId/Steuernr. eindeutig: Prüfung im Controller

Unterschiede anzeigen:

SL/Controller/CustomerVendor.pm
10 10
use SL::Helper::Flash;
11 11
use SL::Locale::String;
12 12
use SL::Util qw(trim);
13
use SL::VATIDNr;
13 14
use SL::Webdav;
14 15
use SL::ZUGFeRD;
15 16
use SL::Controller::Helper::GetModels;
......
132 133
  }
133 134
}
134 135

  
136
sub _check_ustid_taxnumber_unique {
137
  my ($self) = @_;
138

  
139
  my %cfg;
140
  if ($self->is_vendor()) {
141
    %cfg = (should_check  => $::instance_conf->get_vendor_ustid_taxnummer_unique,
142
            manager_class => 'SL::DB::Manager::Vendor',
143
            err_ustid     => t8('A vendor with the same VAT ID already exists.'),
144
            err_taxnumber => t8('A vendor with the same taxnumber already exists.'),
145
    );
146

  
147
  } elsif ($self->is_customer()) {
148
    %cfg = (should_check  => $::instance_conf->get_customer_ustid_taxnummer_unique,
149
            manager_class => 'SL::DB::Manager::Customer',
150
            err_ustid     => t8('A customer with the same VAT ID already exists.'),
151
            err_taxnumber => t8('A customer with the same taxnumber already exists.'),
152
    );
153

  
154
  } else {
155
    return;
156
  }
157

  
158
  my @errors;
159

  
160
  if ($cfg{should_check}) {
161
    my $do_clean_taxnumber = sub { my $n = $_[0]; $n //= ''; $n =~ s{[[:space:].-]+}{}g; return $n};
162

  
163
    my $clean_ustid     = SL::VATIDNr->clean($self->{cv}->ustid);
164
    my $clean_taxnumber = $do_clean_taxnumber->($self->{cv}->taxnumber);
165

  
166
    if (!($clean_ustid || $clean_taxnumber)) {
167
      return t8('VAT ID and/or taxnumber must be given.');
168

  
169
    } else {
170
      my $clean_number = $clean_ustid;
171
      if ($clean_number) {
172
        my $entries = $cfg{manager_class}->get_all(query => ['!id' => $self->{cv}->id, '!ustid' => undef, '!ustid' => ''], select => ['ustid'], distinct => 1);
173
        if (any { $clean_number eq SL::VATIDNr->clean($_->ustid) } @$entries) {
174
          push @errors, $cfg{err_ustid};
175
        }
176
      }
177

  
178
      $clean_number = $clean_taxnumber;
179
      if ($clean_number) {
180
        my $entries = $cfg{manager_class}->get_all(query => ['!id' => $self->{cv}->id, '!taxnumber' => undef, '!taxnumber' => ''], select => ['taxnumber'], distinct => 1);
181
        if (any { $clean_number eq $do_clean_taxnumber->($_->taxnumber) } @$entries) {
182
          push @errors, $cfg{err_taxnumber};
183
        }
184
      }
185
    }
186
  }
187

  
188
  return join "\n", @errors if @errors;
189
  return;
190
}
191

  
135 192
sub _save {
136 193
  my ($self) = @_;
137 194

  
......
185 242
      }
186 243
    }
187 244

  
245
    my $ustid_taxnumber_error = $self->_check_ustid_taxnumber_unique;
246
    $::form->error($ustid_taxnumber_error) if $ustid_taxnumber_error;
247

  
188 248
    $self->{cv}->save(cascade => 1);
189 249

  
190 250
    SL::DB::Greeting->new(description => $self->{cv}->greeting)->save if $save_greeting;
locale/de/all
55 55
  'A canceled general ledger transaction cannot be deleted.' => 'Eine stornierte Dialogbuchung kann nicht gelöscht werden.',
56 56
  'A canceled general ledger transaction cannot be posted.' => 'Eine stornierte Dialogbuchung kann nicht mehr gebucht werden.',
57 57
  'A canceled invoice cannot be posted.' => 'Eine stornierte Rechnung kann nicht mehr gebucht werden.',
58
  'A customer with the same VAT ID already exists.' => 'Ein Kunde mit der gleichen USt-IdNr. existiert bereits.',
59
  'A customer with the same taxnumber already exists.' => 'Ein Kunde mit der gleichen Steuernummer existiert bereits.',
58 60
  'A digit is required.'        => 'Eine Ziffer ist vorgeschrieben.',
59 61
  'A directory with the name for the new print templates exists already.' => 'Ein Verzeichnis mit dem selben Namen wie die neuen Druckvorlagen existiert bereits.',
60 62
  'A lot of the usability of kivitendo has been enhanced with javascript. Although it is currently possible to use every aspect of kivitendo without javascript, we strongly recommend it. In a future version this may change and javascript may be necessary to access advanced features.' => 'Die Bedienung von kivitendo wurde an vielen Stellen mit Javascript verbessert. Obwohl es derzeit möglich ist, jeden Aspekt von kivitendo auch ohne Javascript zu benutzen, empfehlen wir es. In einer zukünftigen Version wird Javascript eventuell notwendig sein um weitergehende Features zu benutzen.',
......
67 69
  'A valid taxkey is missing!'  => 'Ein gültiger Steuerschlüssel fehlt!',
68 70
  'A variable marked as \'Deactivate by default\' isn\'t automatically added to all articles, and has to be explicitly added for each desired article in its master data tab. Only then can the variable be used for that article in the records.' => 'Eine als \'Deaktiviert als Voreinstellung\' markierte Variable wird nicht automatisch bei allen Artikeln hinzugefügt, sondern muß explizit für jeden gewünschten Artikel in den Stammdaten aktiviert werden. Erst danach ist die Variable für den Artikel in Belegen bearbeitbar.',
69 71
  'A variable marked as \'editable\' can be changed in each quotation, order, invoice etc.' => 'Eine als \'editierbar\' markierte Variable kann in jedem Angebot, Auftrag, jeder Rechnung etc für jede Position geändert werden.',
72
  'A vendor with the same VAT ID already exists.' => 'Ein Lieferant mit der gleichen USt-IdNr. existiert bereits.',
73
  'A vendor with the same taxnumber already exists.' => 'Ein Lieferant mit der gleichen Steuernummer existiert bereits.',
70 74
  'ADDED'                       => 'Hinzugefügt',
71 75
  'AP'                          => 'Einkauf',
72 76
  'AP Aging'                    => 'Offene Verbindlichkeiten',
......
3924 3928
  'Usually the delivery date of an order is the next working day. If a value is set here this value will be added to the delivery date of the sales order. The resulting date will be adjusted to the next working day if it ends up on a weekend.' => 'Standardmäßig ist das vorausgewählte Lieferdatum der nächste Arbeitstag. Falls hier ein Wert gesetzt ist, wird dieser zum eigentlichen Lieferdatum hinzuaddiert. Fällt das daraus resultierende Datum auf ein Wochenende, so wird der nächste Werktag genommen.',
3925 3929
  'Usually the sales quotation is valid until the next working day. If a value is set here then the quotation will be valid for at least that many days. The resulting date will be adjusted to the next working day if it ends up on a weekend.' => 'Standardmäßig ist ein Verkaufsangebot bis zum nächsten Werktag gültig. Ist hier ein Wert angegeben, so ist ein Angebot mindestens so viele Tage gültig. Sollte das dabei herauskommende Datum auf ein Wochenende fallen, so wird statt dessen der nachfolgende Arbeitstag genommen.',
3926 3930
  'VAT ID'                      => 'USt-IdNr.',
3931
  'VAT ID and/or taxnumber must be given.' => 'UStId und/oder Steuernummer muss angegeben werden.',
3927 3932
  'VN'                          => 'Kred.-Nr.',
3928 3933
  'Valid'                       => 'Gültig',
3929 3934
  'Valid from'                  => 'Gültig ab',
locale/en/all
55 55
  'A canceled general ledger transaction cannot be deleted.' => '',
56 56
  'A canceled general ledger transaction cannot be posted.' => '',
57 57
  'A canceled invoice cannot be posted.' => '',
58
  'A customer with the same VAT ID already exists.' => '',
59
  'A customer with the same taxnumber already exists.' => '',
58 60
  'A digit is required.'        => '',
59 61
  'A directory with the name for the new print templates exists already.' => '',
60 62
  'A lot of the usability of kivitendo has been enhanced with javascript. Although it is currently possible to use every aspect of kivitendo without javascript, we strongly recommend it. In a future version this may change and javascript may be necessary to access advanced features.' => '',
......
67 69
  'A valid taxkey is missing!'  => '',
68 70
  'A variable marked as \'Deactivate by default\' isn\'t automatically added to all articles, and has to be explicitly added for each desired article in its master data tab. Only then can the variable be used for that article in the records.' => '',
69 71
  'A variable marked as \'editable\' can be changed in each quotation, order, invoice etc.' => '',
72
  'A vendor with the same VAT ID already exists.' => '',
73
  'A vendor with the same taxnumber already exists.' => '',
70 74
  'ADDED'                       => '',
71 75
  'AP'                          => 'Purchases',
72 76
  'AP Aging'                    => 'Creditor Aging',
......
3923 3927
  'Usually the delivery date of an order is the next working day. If a value is set here this value will be added to the delivery date of the sales order. The resulting date will be adjusted to the next working day if it ends up on a weekend.' => '',
3924 3928
  'Usually the sales quotation is valid until the next working day. If a value is set here then the quotation will be valid for at least that many days. The resulting date will be adjusted to the next working day if it ends up on a weekend.' => '',
3925 3929
  'VAT ID'                      => '',
3930
  'VAT ID and/or taxnumber must be given.' => '',
3926 3931
  'VN'                          => '',
3927 3932
  'Valid'                       => '',
3928 3933
  'Valid from'                  => '',

Auch abrufbar als: Unified diff