X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/098e73fe719291263d4dce4a8e276869ca039eae..228dfbdc7b671f8c8ac8254ae7cda2e3675351ae:/SL/Controller/CsvImport/Order.pm diff --git a/SL/Controller/CsvImport/Order.pm b/SL/Controller/CsvImport/Order.pm index c8cb5b30c..7577ef047 100644 --- a/SL/Controller/CsvImport/Order.pm +++ b/SL/Controller/CsvImport/Order.pm @@ -6,6 +6,7 @@ use strict; use List::MoreUtils qw(any); use SL::Helper::Csv; +use SL::Controller::CsvImport::Helper::Consistency; use SL::DB::Order; use SL::DB::OrderItem; use SL::DB::Part; @@ -24,7 +25,7 @@ use parent qw(SL::Controller::CsvImport::BaseMulti); use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by departments_by projects_by ct_shiptos_by taxzones_by price_factors_by pricegroups_by currencies_by) ], + 'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by departments_by projects_by ct_shiptos_by taxzones_by price_factors_by pricegroups_by) ], ); @@ -244,12 +245,6 @@ sub init_pricegroups_by { return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_pricegroups } } ) } qw(id pricegroup) }; } -sub init_currencies_by { - my ($self) = @_; - - return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $self->all_currencies } } ) } qw(id name) }; -} - sub check_objects { my ($self) = @_; @@ -330,7 +325,7 @@ sub handle_order { $self->check_project($entry, global => 1); $self->check_ct_shipto($entry); $self->check_taxzone($entry); - $self->check_currency($entry); + $self->check_currency($entry, take_default => 0); if ($vc_obj) { # copy from customer if not given @@ -649,31 +644,6 @@ sub check_pricegroup { return 1; } -sub check_currency { - my ($self, $entry) = @_; - - my $object = $entry->{object}; - - # Check whether or not currency ID is valid. - if ($object->currency_id && !$self->currencies_by->{id}->{ $object->currency_id }) { - push @{ $entry->{errors} }, $::locale->text('Error: Invalid currency'); - return 0; - } - - # Map name to ID if given. - if (!$object->currency_id && $entry->{raw_data}->{currency}) { - my $currency = $self->currencies_by->{name}->{ $entry->{raw_data}->{currency} }; - if (!$currency) { - push @{ $entry->{errors} }, $::locale->text('Error: Invalid currency'); - return 0; - } - - $object->currency_id($currency->id); - } - - return 1; -} - sub add_items_to_order { my ($self) = @_;