Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f7c01833

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

  • ID f7c018334a07ee00579f923422ab03bd0a277750
  • Vorgänger bf0b9c5e
  • Nachfolger 0f214df5

CsvImport: Aufträge: Einheiten behandeln

Unterschiede anzeigen:

SL/Controller/CsvImport/Order.pm
use strict;
use List::MoreUtils qw(any);
use List::MoreUtils qw(any none);
use SL::Helper::Csv;
use SL::Controller::CsvImport::Helper::Consistency;
......
use SL::DB::Project;
use SL::DB::Shipto;
use SL::DB::TaxZone;
use SL::DB::Unit;
use SL::TransNumber;
use parent qw(SL::Controller::CsvImport::BaseMulti);
......
use Rose::Object::MakeMethods::Generic
(
'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by ct_shiptos_by price_factors_by pricegroups_by) ],
'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by ct_shiptos_by price_factors_by pricegroups_by units_by) ],
);
......
return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_pricegroups } } ) } qw(id pricegroup) };
}
sub init_units_by {
my ($self) = @_;
my $all_units = SL::DB::Manager::Unit->get_all;
return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_units } } ) } qw(name) };
}
sub check_objects {
my ($self) = @_;
......
my $part_obj = SL::DB::Part->new(id => $object->parts_id)->load;
$self->handle_unit($entry);
$self->handle_sellprice($entry);
# copy from part if not given
$object->description($part_obj->description) unless $object->description;
$object->longdescription($part_obj->notes) unless $object->longdescription;
$object->unit($part_obj->unit) unless $object->unit;
$object->sellprice($part_obj->sellprice) unless defined $object->sellprice;
$object->lastcost($part_obj->lastcost) unless defined $object->lastcost;
# set to 0 if not given
......
$self->check_pricegroup($entry);
}
sub handle_unit {
my ($self, $entry) = @_;
my $object = $entry->{object};
# Set unit from part if not given.
if (!$object->unit) {
$object->unit($object->part->unit);
return 1;
}
# Check whether or not unit is valid.
if ($object->unit && !$self->units_by->{name}->{ $object->unit }) {
push @{ $entry->{errors} }, $::locale->text('Error: Invalid unit');
return 0;
}
# Check whether unit is convertible to parts unit
if (none { $object->unit eq $_ } map { $_->name } @{ $object->part->unit_obj->convertible_units }) {
push @{ $entry->{errors} }, $::locale->text('Error: Invalid unit');
return 0;
}
return 1;
}
sub handle_sellprice {
my ($self, $entry) = @_;
my $object = $entry->{object};
# Set sellprice from part if not given. Convert with respect to unit.
if (!defined $object->sellprice) {
my $sellprice = $object->part->sellprice;
if ($object->unit ne $object->part->unit) {
$sellprice = $object->unit_obj->convert_to($sellprice, $object->part->unit_obj);
}
$object->sellprice($sellprice);
}
}
sub check_part {
my ($self, $entry) = @_;
locale/de/all
'Error: Invalid salesman' => 'Fehler: Ungültiger Verkäufer',
'Error: Invalid shipto' => 'Fehler: Lieferadresse ungültig',
'Error: Invalid tax zone' => 'Fehler: Steuerzone ungültig',
'Error: Invalid unit' => 'Fehler: Einheit ungültig',
'Error: Invalid vendor in column make_#1' => 'Fehler: Lieferant ungültig in Spalte make_#1',
'Error: Invalid warehouse' => 'Fehler: Ungültiges Lager',
'Error: Name missing' => 'Fehler: Name fehlt',
locale/en/all
'Error: Invalid salesman' => '',
'Error: Invalid shipto' => '',
'Error: Invalid tax zone' => '',
'Error: Invalid unit' => '',
'Error: Invalid vendor in column make_#1' => '',
'Error: Invalid warehouse' => '',
'Error: Name missing' => '',

Auch abrufbar als: Unified diff