Revision f747a789
Von Bernd Bleßmann vor mehr als 6 Jahren hinzugefügt
SL/DB/Order.pm | ||
---|---|---|
6 | 6 |
use Carp; |
7 | 7 |
use DateTime; |
8 | 8 |
use List::Util qw(max); |
9 |
use List::MoreUtils qw(any); |
|
9 | 10 |
|
10 | 11 |
use SL::DB::MetaSetup::Order; |
11 | 12 |
use SL::DB::Manager::Order; |
... | ... | |
205 | 206 |
croak("A destination type must be given as parameter") unless $params{destination_type}; |
206 | 207 |
|
207 | 208 |
my $destination_type = delete $params{destination_type}; |
208 |
my $src_dst_allowed = ('sales_quotation' eq $source->type && 'sales_order' eq $destination_type) |
|
209 |
|| ('request_quotation' eq $source->type && 'purchase_order' eq $destination_type) |
|
210 |
|| ('sales_quotation' eq $source->type && 'sales_quotation' eq $destination_type) |
|
211 |
|| ('sales_order' eq $source->type && 'sales_order' eq $destination_type) |
|
212 |
|| ('request_quotation' eq $source->type && 'request_quotation' eq $destination_type) |
|
213 |
|| ('purchase_order' eq $source->type && 'purchase_order' eq $destination_type); |
|
214 |
croak("Cannot convert from '" . $source->type . "' to '" . $destination_type . "'") unless $src_dst_allowed; |
|
209 |
|
|
210 |
my @from_tos = ( |
|
211 |
{ from => 'sales_quotation', to => 'sales_order', abbr => 'sqso' }, |
|
212 |
{ from => 'request_quotation', to => 'purchase_order', abbr => 'rqpo' }, |
|
213 |
{ from => 'sales_quotation', to => 'sales_quotation', abbr => 'sqsq' }, |
|
214 |
{ from => 'sales_order', to => 'sales_order', abbr => 'soso' }, |
|
215 |
{ from => 'request_quotation', to => 'request_quotation', abbr => 'rqrq' }, |
|
216 |
{ from => 'purchase_order', to => 'purchase_order', abbr => 'popo' }, |
|
217 |
); |
|
218 |
my $from_to = (grep { $_->{from} eq $source->type && $_->{to} eq $destination_type} @from_tos)[0]; |
|
219 |
croak("Cannot convert from '" . $source->type . "' to '" . $destination_type . "'") if !$from_to; |
|
215 | 220 |
|
216 | 221 |
my ($item_parent_id_column, $item_parent_column); |
217 | 222 |
|
Auch abrufbar als: Unified diff
SL::DB::Order->new_from: Prüfung auf Quell- und Ziel-Typ refactored