Revision 99d9cae4
Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt
- ID 99d9cae40679116072127a27c62db0f588deb5cb
- Vorgänger 9ec6503d
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 |
|
188 |
$self->{cv}->ustid( trim($self->{cv}->ustid)) if $self->{cv}->ustid; |
|
189 |
$self->{cv}->taxnumber(trim($self->{cv}->taxnumber)) if $self->{cv}->taxnumber; |
|
190 |
|
|
191 |
if ( $self->is_vendor() && $::instance_conf->get_vendor_ustid_taxnummer_unique) { |
|
192 |
$::form->error(t8('VAT ID and/or taxnumber must be given.')) if !($self->{cv}->ustid || $self->{cv}->taxnumber); |
|
193 |
|
|
194 |
my $count; |
|
195 |
$count += SL::DB::Manager::Vendor->get_all_count(query => ['!id' => $self->{cv}->id, ustid => $self->{cv}->ustid]) if $self->{cv}->ustid; |
|
196 |
$count += SL::DB::Manager::Vendor->get_all_count(query => ['!id' => $self->{cv}->id, taxnumber => $self->{cv}->taxnumber]) if $self->{cv}->taxnumber; |
|
197 |
|
|
198 |
$::form->error(t8('A vendor with the same VAT ID or taxnumber already exists.')) if $count; |
|
199 |
} |
|
200 |
if ($self->is_customer() && $::instance_conf->get_customer_ustid_taxnummer_unique) { |
|
201 |
$::form->error(t8('VAT ID and/or taxnumber must be given.')) if !($self->{cv}->ustid || $self->{cv}->taxnumber); |
|
202 |
|
|
203 |
my $count; |
|
204 |
$count += SL::DB::Manager::Customer->get_all_count(query => ['!id' => $self->{cv}->id, ustid => $self->{cv}->ustid]) if $self->{cv}->ustid; |
|
205 |
$count += SL::DB::Manager::Customer->get_all_count(query => ['!id' => $self->{cv}->id, taxnumber => $self->{cv}->taxnumber]) if $self->{cv}->taxnumber; |
|
206 |
|
|
207 |
$::form->error(t8('A customer with the same VAT ID or taxnumber already exists.')) if $count; |
|
208 |
} |
|
245 |
my $ustid_taxnumber_error = $self->_check_ustid_taxnumber_unique; |
|
246 |
$::form->error($ustid_taxnumber_error) if $ustid_taxnumber_error; |
|
209 | 247 |
|
210 | 248 |
$self->{cv}->save(cascade => 1); |
211 | 249 |
|
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 or taxnumber already exists.' => 'Ein Kunde mit der gleichen UStId oder Steuernummer existiert bereits.', |
|
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.', |
|
59 | 60 |
'A digit is required.' => 'Eine Ziffer ist vorgeschrieben.', |
60 | 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.', |
61 | 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.', |
... | ... | |
68 | 69 |
'A valid taxkey is missing!' => 'Ein gültiger Steuerschlüssel fehlt!', |
69 | 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.', |
70 | 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.', |
71 |
'A vendor with the same VAT ID or taxnumber already exists.' => 'Ein Lieferant mit der gleichen UStId oder Steuernummer existiert bereits.', |
|
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.', |
|
72 | 74 |
'ADDED' => 'Hinzugefügt', |
73 | 75 |
'AP' => 'Einkauf', |
74 | 76 |
'AP Aging' => 'Offene Verbindlichkeiten', |
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 or taxnumber already exists.' => '', |
|
58 |
'A customer with the same VAT ID already exists.' => '', |
|
59 |
'A customer with the same taxnumber already exists.' => '', |
|
59 | 60 |
'A digit is required.' => '', |
60 | 61 |
'A directory with the name for the new print templates exists already.' => '', |
61 | 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.' => '', |
... | ... | |
68 | 69 |
'A valid taxkey is missing!' => '', |
69 | 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.' => '', |
70 | 71 |
'A variable marked as \'editable\' can be changed in each quotation, order, invoice etc.' => '', |
71 |
'A vendor with the same VAT ID or taxnumber already exists.' => '', |
|
72 |
'A vendor with the same VAT ID already exists.' => '', |
|
73 |
'A vendor with the same taxnumber already exists.' => '', |
|
72 | 74 |
'ADDED' => '', |
73 | 75 |
'AP' => 'Purchases', |
74 | 76 |
'AP Aging' => 'Creditor Aging', |
Auch abrufbar als: Unified diff
Kunden/Lieferanten: UStId/Steuernr. eindeutig: refactored …
- Prüfung in eigene sub ausgelagert
- Code f. Kunde/Lieferant zusammengefasst
- auf "gesäuberte" Nummern prüfen
(SL::VATIDNr->clean für UStId und ähnlich f. Steuernummer)