Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0de514ad

Von Bernd Bleßmann vor etwa 11 Jahren hinzugefügt

  • ID 0de514ad672b52435b74b12002a8000ebc883321
  • Vorgänger 342c0c28
  • Nachfolger a6372bfa

Währung auf Kundenwährung setzten, wenn nicht angegeben.

Unterschiede anzeigen:

SL/Controller/CsvImport/Order.pm
24 24

  
25 25
use Rose::Object::MakeMethods::Generic
26 26
(
27
 'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by departments_by projects_by ct_shiptos_by taxzones_by price_factors_by pricegroups_by) ],
27
 'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by departments_by projects_by ct_shiptos_by taxzones_by price_factors_by pricegroups_by currencies_by) ],
28 28
);
29 29

  
30 30

  
......
81 81
  $self->add_displayable_columns($self->settings->{'order_column'},
82 82
                                 { name => 'datatype',         description => $self->settings->{'order_column'}                 },
83 83
                                 { name => 'closed',           description => $::locale->text('Closed')                         },
84
                                 { name => 'curr',             description => $::locale->text('Currency')                       },
84
                                 { name => 'currency',         description => $::locale->text('Currency')                       },
85
                                 { name => 'currency_id',      description => $::locale->text('Currency (database ID)')         },
85 86
                                 { name => 'cusordnumber',     description => $::locale->text('Customer Order Number')          },
86 87
                                 { name => 'delivered',        description => $::locale->text('Delivered')                      },
87 88
                                 { name => 'employee_id',      description => $::locale->text('Employee (database ID)')         },
......
225 226
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_pricegroups } } ) } qw(id pricegroup) };
226 227
}
227 228

  
229
sub init_currencies_by {
230
  my ($self) = @_;
231

  
232
  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $self->all_currencies } } ) } qw(id name) };
233
}
234

  
228 235
sub check_objects {
229 236
  my ($self) = @_;
230 237

  
......
255 262
      $self->check_project($entry, global => 1);
256 263
      $self->check_ct_shipto($entry);
257 264
      $self->check_taxzone($entry);
265
      $self->check_currency($entry);
258 266

  
259 267
      if ($vc_obj) {
260 268
        # copy from customer if not given
261
        foreach (qw(payment_id language_id taxzone_id)) {
269
        foreach (qw(payment_id language_id taxzone_id currency_id)) {
262 270
          $entry->{object}->$_($vc_obj->$_) unless $entry->{object}->$_;
263 271
        }
264 272
      }
......
285 293
                          { header => $::locale->text('Customer/Vendor'), method => 'vc_name' });
286 294
  # Todo: access via ->[0] ok? Better: search first order column and use this
287 295
  $self->add_columns($self->settings->{'order_column'},
288
                     map { "${_}_id" } grep { exists $self->controller->data->[0]->{raw_data}->{$_} } qw(payment language department globalproject taxzone cp));
296
                     map { "${_}_id" } grep { exists $self->controller->data->[0]->{raw_data}->{$_} } qw(payment language department globalproject taxzone cp currency));
289 297
  $self->add_columns($self->settings->{'order_column'}, 'globalproject_id') if exists $self->controller->data->[0]->{raw_data}->{globalprojectnumber};
290 298
  $self->add_columns($self->settings->{'order_column'}, 'cp_id')            if exists $self->controller->data->[0]->{raw_data}->{contact};
291 299

  
......
615 623
  return 1;
616 624
}
617 625

  
618

  
619 626
sub check_price_factor {
620 627
  my ($self, $entry) = @_;
621 628

  
......
666 673
  return 1;
667 674
}
668 675

  
676
sub check_currency {
677
  my ($self, $entry) = @_;
678

  
679
  my $object = $entry->{object};
680

  
681
  # Check whether or not currency ID is valid.
682
  if ($object->currency_id && !$self->currencies_by->{id}->{ $object->currency_id }) {
683
    push @{ $entry->{errors} }, $::locale->text('Error: Invalid currency');
684
    return 0;
685
  }
686

  
687
  # Map name to ID if given.
688
  if (!$object->currency_id && $entry->{raw_data}->{currency}) {
689
    my $currency = $self->currencies_by->{name}->{  $entry->{raw_data}->{currency} };
690
    if (!$currency) {
691
      push @{ $entry->{errors} }, $::locale->text('Error: Invalid currency');
692
      return 0;
693
    }
694

  
695
    $object->currency_id($currency->id);
696
  }
697

  
698
  return 1;
699
}
700

  
669 701

  
670 702
sub save_objects {
671 703
  my ($self, %params) = @_;

Auch abrufbar als: Unified diff