Revision 6dfdb5a7
Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt
SL/Controller/CsvImport/Part.pm | ||
---|---|---|
407 | 407 |
sub check_type { |
408 | 408 |
my ($self, $entry) = @_; |
409 | 409 |
|
410 |
my $type = $self->settings->{part_type}; |
|
411 |
|
|
412 |
if ($type eq 'mixed' && $entry->{raw_data}->{type}) { |
|
413 |
$type = $entry->{raw_data}->{part_type} =~ m/^p/i ? 'part' |
|
414 |
: $entry->{raw_data}->{part_type} =~ m/^s/i ? 'service' |
|
415 |
: $entry->{raw_data}->{part_type} =~ m/^a/i ? 'assembly' |
|
416 |
: $entry->{raw_data}->{part_type} =~ m/^assor/i ? 'assortment' |
|
417 |
: undef; |
|
410 |
my $bg = $self->bg_by->{id}->{ $entry->{object}->buchungsgruppen_id }; |
|
411 |
$bg ||= SL::DB::Buchungsgruppe->new(inventory_accno_id => 1); # does this case ever occur? |
|
412 |
|
|
413 |
my $part_type = $self->settings->{part_type}; |
|
414 |
if ($part_type eq 'mixed') { |
|
415 |
$part_type = $entry->{raw_data}->{part_type} =~ m/^p/i ? 'part' |
|
416 |
: $entry->{raw_data}->{part_type} =~ m/^s/i ? 'service' |
|
417 |
: $entry->{raw_data}->{part_type} =~ m/^assem/i ? 'assembly' |
|
418 |
: $entry->{raw_data}->{part_type} =~ m/^assor/i ? 'assortment' |
|
419 |
: undef; |
|
418 | 420 |
} |
419 | 421 |
|
420 | 422 |
# when saving income_accno_id or expense_accno_id use ids from the selected |
... | ... | |
423 | 425 |
# not all be set. |
424 | 426 |
# Only use existing bg |
425 | 427 |
|
426 |
my $bg = $self->bg_by->{id}->{ $entry->{object}->buchungsgruppen_id };
|
|
428 |
# $entry->{object}->income_accno_id( $bg->income_accno_id( SL::DB::Manager::TaxZone->get_default->id ) );
|
|
427 | 429 |
|
428 |
# if not set there is an error occurred in check_buchungsgruppe() |
|
429 |
# but if the part exists the new values for accno are ignored |
|
430 |
# if ($part_type eq 'part' || $part_type eq 'service') { |
|
431 |
# $entry->{object}->expense_accno_id( $bg->expense_accno_id( SL::DB::Manager::TaxZone->get_default->id ) ); |
|
432 |
# } |
|
430 | 433 |
|
431 |
if ( $bg ) {
|
|
432 |
$entry->{object}->income_accno_id( $bg->income_accno_id( SL::DB::Manager::TaxZone->get_default->id ) );
|
|
433 |
$self->clone_methods->{income_accno_id} = 1;
|
|
434 |
# if ($part_type eq 'part') {
|
|
435 |
# $entry->{object}->inventory_accno_id( $bg->inventory_accno_id );
|
|
436 |
# }
|
|
434 | 437 |
|
435 |
if ($type eq 'part' || $type eq 'service') { |
|
436 |
$entry->{object}->expense_accno_id( $bg->expense_accno_id( SL::DB::Manager::TaxZone->get_default->id ) ); |
|
437 |
$self->clone_methods->{expense_accno_id} = 1; |
|
438 |
} |
|
438 |
if (none { $_ eq $part_type } qw(part service assembly assortment)) { |
|
439 |
push @{ $entry->{errors} }, $::locale->text('Error: Invalid part type'); |
|
440 |
return 0; |
|
439 | 441 |
} |
440 | 442 |
|
441 |
if ($type eq 'part') { |
|
442 |
if ( $bg ) { |
|
443 |
$entry->{object}->inventory_accno_id( $bg->inventory_accno_id ); |
|
444 |
} |
|
445 |
else { |
|
446 |
#use an existent bg |
|
447 |
$entry->{object}->inventory_accno_id( SL::DB::Manager::Buchungsgruppe->get_first->id ); |
|
448 |
} |
|
449 |
} elsif ($type eq 'assembly') { |
|
450 |
$entry->{object}->assembly(1); |
|
451 |
} |
|
443 |
$entry->{object}->part_type($part_type); |
|
444 |
|
|
452 | 445 |
return 1; |
453 | 446 |
} |
454 | 447 |
|
... | ... | |
677 | 670 |
my ($self) = @_; |
678 | 671 |
|
679 | 672 |
my $profile = $self->SUPER::init_profile; |
680 |
delete @{$profile}{qw(bom expense_accno_id income_accno_id inventory_accno_id makemodel priceupdate stockable type)};
|
|
673 |
delete @{$profile}{qw(bom expense_accno_id income_accno_id makemodel priceupdate stockable type)}; |
|
681 | 674 |
|
682 | 675 |
$profile->{"pricegroup_$_"} = '' for 1 .. scalar @{ $_[0]->all_pricegroups }; |
683 | 676 |
|
... | ... | |
702 | 695 |
$self->SUPER::setup_displayable_columns; |
703 | 696 |
$self->add_cvar_columns_to_displayable_columns; |
704 | 697 |
|
705 |
$self->add_displayable_columns({ name => 'assembly', description => $::locale->text('assembly') }, |
|
706 |
{ name => 'bin_id', description => $::locale->text('Bin (database ID)') }, |
|
698 |
$self->add_displayable_columns({ name => 'bin_id', description => $::locale->text('Bin (database ID)') }, |
|
707 | 699 |
{ name => 'bin', description => $::locale->text('Bin (name)') }, |
708 | 700 |
{ name => 'buchungsgruppen_id', description => $::locale->text('Booking group (database ID)') }, |
709 | 701 |
{ name => 'buchungsgruppe', description => $::locale->text('Booking group (name)') }, |
... | ... | |
714 | 706 |
{ name => 'gv', description => $::locale->text('Business Volume') }, |
715 | 707 |
{ name => 'has_sernumber', description => $::locale->text('Has serial number') }, |
716 | 708 |
{ name => 'image', description => $::locale->text('Image') }, |
717 |
{ name => 'inventory_accno_id', description => $::locale->text('part') }, |
|
718 | 709 |
{ name => 'lastcost', description => $::locale->text('Last Cost') }, |
719 | 710 |
{ name => 'listprice', description => $::locale->text('List Price') }, |
720 | 711 |
{ name => 'make_X', description => $::locale->text('Make (vendor\'s database ID, number or name; with X being a number)') . ' [1]' }, |
Auch abrufbar als: Unified diff
Part CSV Import - Umstellung von part_type