Revision 7fc41a37
Von Moritz Bunkus vor fast 2 Jahren hinzugefügt
SL/Helper/Inventory.pm | ||
---|---|---|
8 | 8 |
use List::UtilsBy qw(sort_by); |
9 | 9 |
use List::MoreUtils qw(any); |
10 | 10 |
use POSIX qw(ceil); |
11 |
use Scalar::Util qw(blessed); |
|
11 | 12 |
|
12 | 13 |
use SL::Locale::String qw(t8); |
13 | 14 |
use SL::MoreCommon qw(listify); |
... | ... | |
196 | 197 |
last if $rest_qty == 0; |
197 | 198 |
} |
198 | 199 |
if ($rest_qty > 0) { |
199 |
die SL::X::Inventory::Allocation->new( |
|
200 |
code => 'not enough to allocate', |
|
201 |
message => t8("can not allocate #1 units of #2, missing #3 units", _format_number($qty), $part->displayable_name, _format_number($rest_qty)), |
|
200 |
die SL::X::Inventory::Allocation::MissingQty->new( |
|
201 |
code => 'not enough to allocate', |
|
202 |
message => t8("can not allocate #1 units of #2, missing #3 units", _format_number($qty), $part->displayable_name, _format_number($rest_qty)), |
|
203 |
part_description => $part->displayable_name, |
|
204 |
to_allocate_qty => $qty, |
|
205 |
missing_qty => $rest_qty, |
|
202 | 206 |
); |
203 | 207 |
} else { |
204 | 208 |
if ($params{constraints}) { |
... | ... | |
228 | 232 |
$parts_to_allocate{ $assembly->part->id } += $assembly->qty * $qty; |
229 | 233 |
} |
230 | 234 |
|
231 |
my @allocations;
|
|
235 |
my (@allocations, @errors);
|
|
232 | 236 |
|
233 | 237 |
for my $part_id (keys %parts_to_allocate) { |
234 | 238 |
my $part = SL::DB::Part->load_cached($part_id); |
235 |
push @allocations, allocate(%params, part => $part, qty => $parts_to_allocate{$part_id}); |
|
236 |
if ($wh_strict) { |
|
237 |
die SL::X::Inventory::Allocation->new( |
|
238 |
code => "wrong warehouse for part", |
|
239 |
message => t8('Part #1 exists in warehouse #2, but not in warehouse #3 ', |
|
240 |
$part->partnumber . ' ' . $part->description, |
|
241 |
SL::DB::Manager::Warehouse->find_by(id => $allocations[-1]->{warehouse_id})->description, |
|
242 |
$wh->description), |
|
243 |
) unless $allocations[-1]->{warehouse_id} == $wh->id; |
|
244 |
} |
|
239 |
|
|
240 |
eval { |
|
241 |
push @allocations, allocate(%params, part => $part, qty => $parts_to_allocate{$part_id}); |
|
242 |
if ($wh_strict) { |
|
243 |
die SL::X::Inventory::Allocation->new( |
|
244 |
code => "wrong warehouse for part", |
|
245 |
message => t8('Part #1 exists in warehouse #2, but not in warehouse #3 ', |
|
246 |
$part->partnumber . ' ' . $part->description, |
|
247 |
SL::DB::Manager::Warehouse->find_by(id => $allocations[-1]->{warehouse_id})->description, |
|
248 |
$wh->description), |
|
249 |
) unless $allocations[-1]->{warehouse_id} == $wh->id; |
|
250 |
} |
|
251 |
1; |
|
252 |
} or do { |
|
253 |
my $ex = $@; |
|
254 |
die $ex unless blessed($ex) && $ex->can('rethrow'); |
|
255 |
|
|
256 |
if ($ex->isa('SL::X::Inventory::Allocation')) { |
|
257 |
push @errors, $@; |
|
258 |
} else { |
|
259 |
$ex->rethrow; |
|
260 |
} |
|
261 |
}; |
|
262 |
} |
|
263 |
|
|
264 |
if (@errors) { |
|
265 |
die SL::X::Inventory::Allocation::Multi->new( |
|
266 |
code => "multiple errors during allocation", |
|
267 |
message => "multiple errors during allocation", |
|
268 |
errors => \@errors, |
|
269 |
); |
|
245 | 270 |
} |
246 | 271 |
|
247 | 272 |
@allocations; |
SL/X.pm | ||
---|---|---|
43 | 43 |
isa => 'SL::X::Base', |
44 | 44 |
fields => [ qw(code) ], |
45 | 45 |
}, |
46 |
'SL::X::Inventory::Allocation::MissingQty' => { |
|
47 |
isa => 'SL::X::Inventory::Allocation', |
|
48 |
fields => [ qw(code part_description to_allocate_qty missing_qty) ], |
|
49 |
}, |
|
50 |
'SL::X::Inventory::Allocation::Multi' => { |
|
51 |
isa => 'SL::X::Inventory::Allocation', |
|
52 |
fields => [ qw(errors) ], |
|
53 |
}, |
|
46 | 54 |
); |
47 | 55 |
|
48 | 56 |
1; |
bin/mozilla/wh.pl | ||
---|---|---|
32 | 32 |
# |
33 | 33 |
####################################################################### |
34 | 34 |
|
35 |
use Carp; |
|
35 | 36 |
use List::Util qw(min max first); |
36 | 37 |
use POSIX qw(strftime); |
38 |
use Scalar::Util qw(blessed); |
|
37 | 39 |
|
38 | 40 |
use SL::Form; |
39 | 41 |
use SL::User; |
... | ... | |
396 | 398 |
$form->{bestbefore} = ''; |
397 | 399 |
} |
398 | 400 |
|
399 |
produce_assembly( |
|
401 |
eval { |
|
402 |
produce_assembly( |
|
400 | 403 |
part => $assembly, # target assembly |
401 | 404 |
qty => $form->{qty}, # qty |
402 | 405 |
auto_allocate => 1, |
... | ... | |
404 | 407 |
chargenumber => $form->{chargenumber}, # optional |
405 | 408 |
bestbefore => $form->{bestbefore}, |
406 | 409 |
comment => $form->{comment}, # optional |
407 |
); |
|
410 |
); |
|
411 |
1; |
|
412 |
|
|
413 |
} or do { |
|
414 |
my $ex = $@; |
|
415 |
die $ex unless blessed($ex) && $ex->isa('SL::X::Inventory::Allocation::Multi'); |
|
416 |
|
|
417 |
$form->{title} = $locale->text('Produce Assembly'); |
|
418 |
$form->header; |
|
419 |
print $form->parse_html_template( |
|
420 |
'wh/produce_assembly_error', |
|
421 |
{ |
|
422 |
missing_qty_exceptions => [ grep { $_->isa('SL::X::Inventory::Allocation::MissingQty') } @{ $ex->errors } ], |
|
423 |
other_exceptions => [ grep { !$_->isa('SL::X::Inventory::Allocation::MissingQty') } @{ $ex->errors } ], |
|
424 |
}); |
|
425 |
|
|
426 |
return $::lxdebug->leave_sub(); |
|
427 |
}; |
|
408 | 428 |
|
409 | 429 |
delete @{$form}{qw(parts_id partnumber description qty unit chargenumber bestbefore comment)}; |
410 | 430 |
|
locale/de/all | ||
---|---|---|
270 | 270 |
'Additional Billing Addresses' => 'Zusätzliche Rechnungsadressen', |
271 | 271 |
'Additional articles' => 'Zusätzliche Artikel', |
272 | 272 |
'Additional articles actions' => 'Aktionen zu zusätzlichen Artikeln', |
273 |
'Additional errors:' => 'Weitere Fehler:', |
|
273 | 274 |
'Additionally the invoice is marked for direct debit and would have been checked automatically had the bank information been entered.' => 'Weiterhin ist die Rechnung für Lastschrifteinzug vorgesehen und wäre standardmäßig ausgewählt, wenn die Bankinformationen eingetragen wären.', |
274 | 275 |
'Additionally the invoice is not marked for direct debit and would have been checked automatically had the bank information been entered.' => 'Weiterhin ist die Rechnung nicht für Lastschrifteinzug vorgesehen und wäre standardmäßig ausgewählt, wenn die Bankinformationen eingetragen wären.', |
275 | 276 |
'Address' => 'Adresse', |
... | ... | |
2254 | 2255 |
'Missing parameter #1 in call to sub #2.' => 'Fehlender Parameter \'#1\' in Funktionsaufruf \'#2\'.', |
2255 | 2256 |
'Missing parameter (at least one of #1) in call to sub #2.' => 'Fehlernder Parameter (mindestens einer aus \'#1\') in Funktionsaufruf \'#2\'.', |
2256 | 2257 |
'Missing parameter for WebDAV file copy' => 'Fehlender Parameter für WebDAV Datei kopieren', |
2258 |
'Missing qty' => 'Fehlende Menge', |
|
2257 | 2259 |
'Missing taxkeys in invoices with taxes.' => 'Fehlende Steuerschlüssel in Rechnungen mit Steuern', |
2258 | 2260 |
'Mitarbeiter' => 'Mitarbeiter', |
2259 | 2261 |
'Mixed (requires column "type" or "pclass")' => 'Gemischt (Spalte "type" oder "pclass" notwendig', |
... | ... | |
3085 | 3087 |
'Require stock out to consider a delivery order position delivered?' => 'Muss eine Lieferscheinposition ausgelagert sein um als geliefert zu gelten?', |
3086 | 3088 |
'Required access right' => 'Benötigtes Zugriffsrecht', |
3087 | 3089 |
'Required by' => 'Lieferdatum', |
3090 |
'Required qty' => 'Erforderliche Menge', |
|
3088 | 3091 |
'Requirement Spec Status' => 'Pflichtenheftstatus', |
3089 | 3092 |
'Requirement Spec Statuses' => 'Pflichtenheftstatus', |
3090 | 3093 |
'Requirement Spec Templates' => 'Pflichtenheftvorlagen', |
... | ... | |
3728 | 3731 |
'The application "#1" was not found on the system.' => 'Die Anwendung "#1" wurde auf dem System nicht gefunden.', |
3729 | 3732 |
'The assembly \'#1\' cannot be a part from itself.' => 'Das Erzeugnis \'#1\' kann kein Teil von sich selbst sein.', |
3730 | 3733 |
'The assembly \'#1\' would make a loop in assembly tree.' => 'Das Erzeugnis \'#1\' würde eine Schleife im Erzeugnisbaum machen.', |
3734 |
'The assembly could not be produced.' => 'Das Erzeugnis konnte nicht produziert werden.', |
|
3731 | 3735 |
'The assembly doesn\'t have any items.' => 'Das Erzeugnis enthält keine Artikel.', |
3732 | 3736 |
'The assembly has been created.' => 'Das Erzeugnis wurde hergestellt.', |
3733 | 3737 |
'The assistant could not find anything wrong with #1. Maybe the problem has been solved in the meantime.' => 'Der Korrekturassistent konnte kein Problem bei #1 feststellen. Eventuell wurde das Problem in der Zwischenzeit bereits behoben.', |
... | ... | |
3848 | 3852 |
'The following is only a preview.' => 'Das Folgende ist nur eine Vorschau.', |
3849 | 3853 |
'The following list has been generated automatically from existing users collapsing users with identical settings into a single entry.' => 'Die folgende Liste wurde automatisch aus den im System vorhandenen Benutzern zusammengestellt, wobei identische Einstellungen zu einem Eintrag zusammengefasst wurden.', |
3850 | 3854 |
'The following old files whose settings have to be merged manually into the new configuration file "config/kivitendo.conf" still exist:' => 'Es existieren noch die folgenden alten Dateien, deren Einstellungen manuell in die neue Konfiguratsdatei "config/kivitendo.conf" migriert werden müssen:', |
3855 |
'The following parts could not be allocated:' => 'Die folgenden Artikel konnten nicht für die Produktion belegt werden:', |
|
3851 | 3856 |
'The following transaction contains wrong taxes:' => 'Die folgende Buchung enthält falsche Steuern:', |
3852 | 3857 |
'The following transaction contains wrong taxkeys:' => 'Die folgende Buchung enthält falsche Steuerschlüssel:', |
3853 | 3858 |
'The following transactions are concerned:' => 'Die folgenden Buchungen sind betroffen:', |
templates/design40_webpages/wh/produce_assembly_error.html | ||
---|---|---|
1 |
[%- USE T8 %][%- USE HTML %][%- USE LxERP -%][%- USE L -%] |
|
2 |
|
|
3 |
<div class="message message_error"> |
|
4 |
<h4>[% LxERP.t8("Error!") %]</h4> |
|
5 |
</div> |
|
6 |
|
|
7 |
[% IF missing_qty_exceptions.size %] |
|
8 |
<div class="wrapper">[% LxERP.t8("The following parts could not be allocated:") %]</div> |
|
9 |
|
|
10 |
<div class="wrapper"> |
|
11 |
<table class="tbl-list"> |
|
12 |
<thead> |
|
13 |
<tr> |
|
14 |
<th>[% LxERP.t8("Part") %]</th> |
|
15 |
<th class="right">[% LxERP.t8("Required qty") %]</th> |
|
16 |
<th class="right">[% LxERP.t8("Missing qty") %]</th> |
|
17 |
</tr> |
|
18 |
</thead> |
|
19 |
|
|
20 |
<tbody> |
|
21 |
[% FOREACH ex = missing_qty_exceptions %] |
|
22 |
<tr class="listrow"> |
|
23 |
<td>[% HTML.escape(ex.part_description) %]</td> |
|
24 |
<td class="numeric">[% HTML.escape(LxERP.format_amount(ex.to_allocate_qty)) %]</td> |
|
25 |
<td class="numeric">[% HTML.escape(LxERP.format_amount(ex.missing_qty)) %]</td> |
|
26 |
</tr> |
|
27 |
[% END %] |
|
28 |
</tbody> |
|
29 |
</table> |
|
30 |
</div> |
|
31 |
[% END %] |
|
32 |
|
|
33 |
[% IF other_exceptions.size %] |
|
34 |
<div class="wrapper">[% LxERP.t8("Additional errors:") %]</div> |
|
35 |
|
|
36 |
<div class="wrapper"> |
|
37 |
<ul> |
|
38 |
[% FOREACH ex = other_exceptions %] |
|
39 |
<li>[% HTML.escape(ex.message) %]</li> |
|
40 |
[% END %] |
|
41 |
</ul> |
|
42 |
</div> |
|
43 |
[% END %] |
templates/webpages/wh/produce_assembly_error.html | ||
---|---|---|
1 |
[%- USE T8 %][%- USE HTML %][%- USE LxERP -%][%- USE L -%] |
|
2 |
|
|
3 |
<div class="message_error"> |
|
4 |
<p>[% LxERP.t8("Error!") %]</p> |
|
5 |
|
|
6 |
<p class="message_error_label">[% LxERP.t8("The assembly could not be produced.") %]</p> |
|
7 |
</div> |
|
8 |
|
|
9 |
[% IF missing_qty_exceptions.size %] |
|
10 |
<p>[% LxERP.t8("The following parts could not be allocated:") %]</p> |
|
11 |
|
|
12 |
<div> |
|
13 |
<table> |
|
14 |
<thead> |
|
15 |
<tr class="listheading"> |
|
16 |
<th>[% LxERP.t8("Part") %]</th> |
|
17 |
<th align="right">[% LxERP.t8("Required qty") %]</th> |
|
18 |
<th align="right">[% LxERP.t8("Missing qty") %]</th> |
|
19 |
</tr> |
|
20 |
</thead> |
|
21 |
|
|
22 |
<tbody> |
|
23 |
[% FOREACH ex = missing_qty_exceptions %] |
|
24 |
<tr class="listrow"> |
|
25 |
<td>[% HTML.escape(ex.part_description) %]</td> |
|
26 |
<td align="right">[% HTML.escape(LxERP.format_amount(ex.to_allocate_qty)) %]</td> |
|
27 |
<td align="right">[% HTML.escape(LxERP.format_amount(ex.missing_qty)) %]</td> |
|
28 |
</tr> |
|
29 |
[% END %] |
|
30 |
</tbody> |
|
31 |
</table> |
|
32 |
</div> |
|
33 |
[% END %] |
|
34 |
|
|
35 |
[% IF other_exceptions.size %] |
|
36 |
<p>[% LxERP.t8("Additional errors:") %]</p> |
|
37 |
|
|
38 |
<div> |
|
39 |
<ul> |
|
40 |
[% FOREACH ex = other_exceptions %] |
|
41 |
<li>[% HTML.escape(ex.message) %]</li> |
|
42 |
[% END %] |
|
43 |
</ul> |
|
44 |
</div> |
|
45 |
[% END %] |
Auch abrufbar als: Unified diff
Erzeugnis fertigen: alle möglichen Allokationsfehler auf einmal anzeigen