- my $type = $self->settings->{part_type};
-
- if ($type eq 'mixed' && $entry->{raw_data}->{type}) {
- $type = $entry->{raw_data}->{part_type} =~ m/^p/i ? 'part'
- : $entry->{raw_data}->{part_type} =~ m/^s/i ? 'service'
- : $entry->{raw_data}->{part_type} =~ m/^a/i ? 'assembly'
- : $entry->{raw_data}->{part_type} =~ m/^assor/i ? 'assortment'
- : undef;
+ my $bg = $self->bg_by->{id}->{ $entry->{object}->buchungsgruppen_id };
+ $bg ||= SL::DB::Buchungsgruppe->new(inventory_accno_id => 1); # does this case ever occur?
+
+ my $part_type = $self->settings->{part_type};
+ if ($part_type eq 'mixed') {
+ $part_type = $entry->{raw_data}->{part_type} =~ m/^p/i ? 'part'
+ : $entry->{raw_data}->{part_type} =~ m/^s/i ? 'service'
+ : $entry->{raw_data}->{part_type} =~ m/^assem/i ? 'assembly'
+ : $entry->{raw_data}->{part_type} =~ m/^assor/i ? 'assortment'
+ : undef;