Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2f94dfa1

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID 2f94dfa1c82787fdc94c2b3c67ba79ec5b126e8f
  • Vorgänger 5b0d61b4
  • Nachfolger 1ffedc13

Import von Lieferanten/Lieferanten-Artikelnummern (makemodel) zu Artikeln

Unterschiede anzeigen:

SL/Controller/CsvImport/Part.pm
19 19

  
20 20
use Rose::Object::MakeMethods::Generic
21 21
(
22
 scalar                  => [ qw(table) ],
22
 scalar                  => [ qw(table makemodel_columns) ],
23 23
 'scalar --get_set_init' => [ qw(bg_by settings parts_by price_factors_by units_by packing_types_by partsgroups_by
24 24
                                 translation_columns all_pricegroups) ],
25 25
);
......
110 110

  
111 111
  return unless @{ $self->controller->data };
112 112

  
113
  $self->makemodel_columns({});
114

  
113 115
  foreach my $entry (@{ $self->controller->data }) {
114 116
    $self->check_buchungsgruppe($entry);
115 117
    $self->check_type($entry);
......
124 126
    $self->handle_shoparticle($entry);
125 127
    $self->handle_translations($entry);
126 128
    $self->handle_cvars($entry);
129
    $self->handle_makemodel($entry);
127 130
    $self->set_various_fields($entry);
128 131
  }
129 132

  
......
134 137
  $self->add_cvar_raw_data_columns;
135 138
  map { $self->add_raw_data_columns("pricegroup_${_}") } (1..scalar(@{ $self->all_pricegroups }));
136 139
  map { $self->add_raw_data_columns($_) if exists $self->controller->data->[0]->{raw_data}->{$_} } @{ $self->translation_columns };
140
  map { $self->add_raw_data_columns("make_${_}", "model_${_}") } sort { $a <=> $b } keys %{ $self->makemodel_columns };
137 141
}
138 142

  
139 143
sub check_duplicates {
......
205 209
      map { $entry->{part}->$_( $object->$_ ) } qw(sellprice listprice lastcost min_sellprice prices);
206 210
      push @{ $entry->{information} }, $::locale->text('Updating prices of existing entry in database');
207 211
      $entry->{object_to_save} = $entry->{part};
208

  
209
      $::lxdebug->dump(0, "P1", $entry->{object}->prices);
210
      $::lxdebug->dump(0, "P1", $entry->{object_to_save}->prices);
211 212
    }
212 213

  
213 214
  } else {
......
387 388
  $entry->{object}->prices(\@prices);
388 389
}
389 390

  
391
sub handle_makemodel {
392
  my ($self, $entry) = @_;
393

  
394
  my @makemodels;
395
  foreach my $idx (map { substr $_, 5 } grep { m/^make_\d+$/ && $entry->{raw_data}->{$_} } keys %{ $entry->{raw_data} }) {
396
    my $vendor = $entry->{raw_data}->{"make_${idx}"};
397
    $vendor    = $self->vc_by->{id}->               { $vendor }
398
              || $self->vc_by->{number}->{vendors}->{ $vendor }
399
              || $self->vc_by->{name}->  {vendors}->{ $vendor };
400

  
401
    if (ref($vendor) ne 'SL::DB::Vendor') {
402
      push @{ $entry->{errors} }, $::locale->text('Error: Invalid vendor in column make_#1', $idx);
403

  
404
    } else {
405
      push @makemodels, SL::DB::MakeModel->new(make  => $vendor->id,
406
                                               model => $entry->{raw_data}->{"model_${idx}"});
407
      $self->makemodel_columns->{$idx}    = 1;
408
      $entry->{raw_data}->{"make_${idx}"} = $vendor->name;
409
    }
410
  }
411

  
412
  $entry->{object}->makemodels(\@makemodels);
413
  $entry->{object}->makemodel(scalar(@makemodels) ? 1 : 0);
414
}
415

  
390 416
sub set_various_fields {
391 417
  my ($self, $entry) = @_;
392 418

  
......
420 446
  $self->SUPER::setup_displayable_columns;
421 447
  $self->add_cvar_columns_to_displayable_columns;
422 448

  
423
  $self->add_displayable_columns({ name => 'bin',                description => $::locale->text('Bin')                          },
424
                                 { name => 'binding_max_qty',    description => $::locale->text('Binding Max Qty')              },
425
                                 { name => 'buchungsgruppen_id', description => $::locale->text('Buchungsgruppe (database ID)') },
426
                                 { name => 'buchungsgruppe',     description => $::locale->text('Buchungsgruppe (name)')        },
427
                                 { name => 'description',        description => $::locale->text('Description')                  },
428
                                 { name => 'drawing',            description => $::locale->text('Drawing')                      },
429
                                 { name => 'ean',                description => $::locale->text('EAN')                          },
430
                                 { name => 'formel',             description => $::locale->text('Formula')                      },
431
                                 { name => 'gv',                 description => $::locale->text('Business Volume')              },
432
                                 { name => 'has_sernumber',      description => $::locale->text('Has serial number')            },
433
                                 { name => 'image',              description => $::locale->text('Image')                        },
434
                                 { name => 'lastcost',           description => $::locale->text('Last Cost')                    },
435
                                 { name => 'listprice',          description => $::locale->text('List Price')                   },
436
                                 { name => 'microfiche',         description => $::locale->text('Microfiche')                   },
437
                                 { name => 'min_sellprice',      description => $::locale->text('Minimum Sell Price')           },
438
                                 { name => 'not_discountable',   description => $::locale->text('Not Discountable')             },
439
                                 { name => 'notes',              description => $::locale->text('Notes')                        },
440
                                 { name => 'obsolete',           description => $::locale->text('Obsolete')                     },
441
                                 { name => 'onhand',             description => $::locale->text('On Hand')                      },
442
                                 { name => 'packing_type_id',    description => $::locale->text('Packing type (database ID)')   },
443
                                 { name => 'packing_type',       description => $::locale->text('Packing type (name)')          },
444
                                 { name => 'partnumber',         description => $::locale->text('Part Number')                  },
445
                                 { name => 'partsgroup_id',      description => $::locale->text('Partsgroup (database ID)')     },
446
                                 { name => 'partsgroup',         description => $::locale->text('Partsgroup (name)')            },
447
                                 { name => 'payment_id',         description => $::locale->text('Payment terms (database ID)')  },
448
                                 { name => 'payment',            description => $::locale->text('Payment terms (name)')         },
449
                                 { name => 'price_factor_id',    description => $::locale->text('Price factor (database ID)')   },
450
                                 { name => 'price_factor',       description => $::locale->text('Price factor (name)')          },
451
                                 { name => 'rop',                description => $::locale->text('ROP')                          },
452
                                 { name => 'sellprice',          description => $::locale->text('Sellprice')                    },
453
                                 { name => 'shop',               description => $::locale->text('Shopartikel')                  },
454
                                 { name => 'unit',               description => $::locale->text('Unit')                         },
455
                                 { name => 've',                 description => $::locale->text('Verrechnungseinheit')          },
456
                                 { name => 'weight',             description => $::locale->text('Weight')                       },
449
  $self->add_displayable_columns({ name => 'bin',                description => $::locale->text('Bin')                           },
450
                                 { name => 'binding_max_qty',    description => $::locale->text('Binding Max Qty')               },
451
                                 { name => 'buchungsgruppen_id', description => $::locale->text('Buchungsgruppe (database ID)')  },
452
                                 { name => 'buchungsgruppe',     description => $::locale->text('Buchungsgruppe (name)')         },
453
                                 { name => 'description',        description => $::locale->text('Description')                   },
454
                                 { name => 'drawing',            description => $::locale->text('Drawing')                       },
455
                                 { name => 'ean',                description => $::locale->text('EAN')                           },
456
                                 { name => 'formel',             description => $::locale->text('Formula')                       },
457
                                 { name => 'gv',                 description => $::locale->text('Business Volume')               },
458
                                 { name => 'has_sernumber',      description => $::locale->text('Has serial number')             },
459
                                 { name => 'image',              description => $::locale->text('Image')                         },
460
                                 { name => 'lastcost',           description => $::locale->text('Last Cost')                     },
461
                                 { name => 'listprice',          description => $::locale->text('List Price')                    },
462
                                 { name => 'make_X',             description => $::locale->text('Make (with X being a number)')  },
463
                                 { name => 'microfiche',         description => $::locale->text('Microfiche')                    },
464
                                 { name => 'min_sellprice',      description => $::locale->text('Minimum Sell Price')            },
465
                                 { name => 'model_X',            description => $::locale->text('Model (with X being a number)') },
466
                                 { name => 'not_discountable',   description => $::locale->text('Not Discountable')              },
467
                                 { name => 'notes',              description => $::locale->text('Notes')                         },
468
                                 { name => 'obsolete',           description => $::locale->text('Obsolete')                      },
469
                                 { name => 'onhand',             description => $::locale->text('On Hand')                       },
470
                                 { name => 'packing_type_id',    description => $::locale->text('Packing type (database ID)')    },
471
                                 { name => 'packing_type',       description => $::locale->text('Packing type (name)')           },
472
                                 { name => 'partnumber',         description => $::locale->text('Part Number')                   },
473
                                 { name => 'partsgroup_id',      description => $::locale->text('Partsgroup (database ID)')      },
474
                                 { name => 'partsgroup',         description => $::locale->text('Partsgroup (name)')             },
475
                                 { name => 'payment_id',         description => $::locale->text('Payment terms (database ID)')   },
476
                                 { name => 'payment',            description => $::locale->text('Payment terms (name)')          },
477
                                 { name => 'price_factor_id',    description => $::locale->text('Price factor (database ID)')    },
478
                                 { name => 'price_factor',       description => $::locale->text('Price factor (name)')           },
479
                                 { name => 'rop',                description => $::locale->text('ROP')                           },
480
                                 { name => 'sellprice',          description => $::locale->text('Sellprice')                     },
481
                                 { name => 'shop',               description => $::locale->text('Shopartikel')                   },
482
                                 { name => 'unit',               description => $::locale->text('Unit')                          },
483
                                 { name => 've',                 description => $::locale->text('Verrechnungseinheit')           },
484
                                 { name => 'weight',             description => $::locale->text('Weight')                        },
457 485
                                );
458 486

  
459 487
  foreach my $language (@{ $self->all_languages }) {
locale/de/all
752 752
  'Error: Invalid parts group'  => 'Fehler: Warengruppe ungültig',
753 753
  'Error: Invalid payment terms' => 'Fehler: Zahlungsbedingungen ungültig',
754 754
  'Error: Invalid price factor' => 'Fehler: Preisfaktor ungültig',
755
  'Error: Invalid vendor in column make_#1' => 'Fehler: Lieferant ungültig in Spalte make_#1',
755 756
  'Error: Name missing'         => 'Fehler: Name fehlt',
756 757
  'Error: Unit missing or invalid' => 'Fehler: Einheit fehlt oder ungültig',
757 758
  'Errors'                      => 'Fehler',
......
1072 1073
  'Main Preferences'            => 'Grundeinstellungen',
1073 1074
  'Main sorting'                => 'Hauptsortierung',
1074 1075
  'Make'                        => 'Lieferant',
1076
  'Make (with X being a number)' => 'Lieferant (X ist eine fortlaufende Zahl)',
1075 1077
  'Make default profile'        => 'Zu Standardprofil machen',
1076 1078
  'Manage Custom Variables'     => 'Benutzerdefinierte Variablen',
1077 1079
  'Manage license keys'         => 'Lizenzschl&uuml;ssel verwalten',
......
1116 1118
  'Mobile1'                     => 'Mobile 1',
1117 1119
  'Mobile2'                     => 'Mobile 2',
1118 1120
  'Model'                       => 'Lieferanten-Art-Nr.',
1121
  'Model (with X being a number)' => 'Lieferanten-Art-Nr. (X ist eine fortlaufende Zahl)',
1119 1122
  'Module'                      => 'Modul',
1120 1123
  'Module home page'            => 'Modul-Webseite',
1121 1124
  'Module name'                 => 'Modulname',

Auch abrufbar als: Unified diff