X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/cd3150ed14f13bc1af071dd0f91015dd32360eae..ba802064109d19f3488e5555ec04491681e37b51:/SL/Controller/CsvImport/Part.pm?ds=inline diff --git a/SL/Controller/CsvImport/Part.pm b/SL/Controller/CsvImport/Part.pm index 34bdd7365..a78ab8c1e 100644 --- a/SL/Controller/CsvImport/Part.pm +++ b/SL/Controller/CsvImport/Part.pm @@ -258,7 +258,7 @@ sub check_type { my ($self, $entry) = @_; my $bg = $self->bg_by->{id}->{ $entry->{object}->buchungsgruppen_id }; - $bg ||= SL::DB::Buchungsgruppe->new(inventory_accno_id => 1, income_accno_id_0 => 1, expense_accno_id_0 => 1); + $bg ||= SL::DB::Buchungsgruppe->new(inventory_accno_id => 1); # does this case ever occur? my $type = $self->settings->{parts_type}; if ($type eq 'mixed') { @@ -270,17 +270,21 @@ sub check_type { $entry->{object}->assembly($type eq 'assembly'); - $entry->{object}->income_accno_id( $bg->income_accno_id_0 ); + # when saving income_accno_id or expense_accno_id use ids from the selected + # $bg according to the default tax_zone (the one with the highest sort + # order). Alternatively one could use the ids from defaults, but they might + # not all be set. + + $entry->{object}->income_accno_id( $bg->income_accno_id( SL::DB::Manager::TaxZone->get_default->id ) ); if ($type eq 'part' || $type eq 'service') { - $entry->{object}->expense_accno_id( $bg->expense_accno_id_0 ); + $entry->{object}->expense_accno_id( $bg->expense_accno_id( SL::DB::Manager::TaxZone->get_default->id ) ); } if ($type eq 'part') { $entry->{object}->inventory_accno_id( $bg->inventory_accno_id ); } - if (none { $_ eq $type } qw(part service assembly)) { push @{ $entry->{errors} }, $::locale->text('Error: Invalid part type'); return 0; @@ -438,7 +442,9 @@ sub handle_makemodel { } } - $entry->{part}->makemodel($object->makemodel); + # reindex makemodels + my $i = 0; + $_->sortorder(++$i) for @{ $entry->{part}->makemodels }; $self->save_with_cascade(1) if $found_any; }