Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 48da0312

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

  • ID 48da03126f83ad6f3406b8c70a077ab52e18823d
  • Vorgänger df141b69
  • Nachfolger 1870f11e

Zeilenkennung und maximaler Differenzbetrag lassen sich an der Oberfläche eingeben.

Unterschiede anzeigen:

SL/Controller/CsvImport.pm
387 387
  }
388 388

  
389 389
  if ($self->type eq 'orders') {
390
    $::form->{settings}->{order_column} = 'Order';
391
    $::form->{settings}->{item_column}  = 'OrderItem';
390
    $::form->{settings}->{max_amount_diff} = $::form->parse_amount(\%::myconfig, $::form->{settings}->{max_amount_diff});
392 391
  }
393 392

  
394 393
  delete $::form->{profile}->{id};
SL/Controller/CsvImport/Order.pm
37 37
sub init_settings {
38 38
  my ($self) = @_;
39 39

  
40
  return { map { ( $_ => $self->controller->profile->get($_) ) } qw(order_column item_column) };
40
  return { map { ( $_ => $self->controller->profile->get($_) ) } qw(order_column item_column max_amount_diff) };
41 41
}
42 42

  
43 43

  
......
46 46

  
47 47
  my $profile = $self->SUPER::init_profile;
48 48

  
49
  # SUPER::init_profile sets row_ident to the class name
50
  # overwrite it with the user specified settings
49 51
  foreach my $p (@{ $profile }) {
50
    my $prof = $p->{profile};
51 52
    if ($p->{row_ident} eq 'Order') {
53
      $p->{row_ident} = $self->settings->{'order_column'};
54
    }
55
    if ($p->{row_ident} eq 'OrderItem') {
56
      $p->{row_ident} = $self->settings->{'item_column'};
57
    }
58
  }
59

  
60
  foreach my $p (@{ $profile }) {
61
    my $prof = $p->{profile};
62
    if ($p->{row_ident} eq $self->settings->{'order_column'}) {
52 63
      # no need to handle
53 64
      delete @{$prof}{qw(delivery_customer_id delivery_vendor_id proforma quotation amount netamount)};
54
      # handable, but not handled by now
55 65
    }
56
    if ($p->{row_ident} eq 'OrderItem') {
66
    if ($p->{row_ident} eq $self->settings->{'item_column'}) {
67
      # no need to handle
57 68
      delete @{$prof}{qw(trans_id)};
58 69
    }
59 70
  }
......
67 78

  
68 79
  $self->SUPER::setup_displayable_columns;
69 80

  
70
  $self->add_displayable_columns('Order',
81
  $self->add_displayable_columns($self->settings->{'order_column'},
71 82
                                 { name => 'datatype',         description => $::locale->text('Zeilenkennung')                  },
72 83
                                 { name => 'closed',           description => $::locale->text('Closed')                         },
73 84
                                 { name => 'curr',             description => $::locale->text('Currency')                       },
......
111 122
                                 { name => 'shipto_id',        description => $::locale->text('Ship to (database ID)')          },
112 123
                                );
113 124

  
114
  $self->add_displayable_columns('OrderItem',
125
  $self->add_displayable_columns($self->settings->{'item_column'},
115 126
                                 { name => 'datatype',        description => $::locale->text('Zeilenkennung')              },
116 127
                                 { name => 'cusordnumber',    description => $::locale->text('Customer Order Number')      },
117 128
                                 { name => 'description',     description => $::locale->text('Description')                },
......
353 364

  
354 365
  # If amounts are given, show calculated amounts as info and given amounts (verify_xxx).
355 366
  # And throw an error if the differences are too big.
356
  my $max_diff = 0.02;
357 367
  my @to_verify = ( { column      => 'amount',
358 368
                      raw_column  => 'verify_amount',
359 369
                      info_header => 'Calc. Amount',
......
381 391
      if ($entry->{raw_data}->{datatype} eq $self->settings->{'order_column'}) {
382 392
        next if !$entry->{raw_data}->{ $tv->{raw_column} };
383 393
        my $parsed_value = $::form->parse_amount(\%::myconfig, $entry->{raw_data}->{ $tv->{raw_column} });
384
        if (abs($entry->{object}->${ \$tv->{column} } - $parsed_value) > $max_diff) {
394
        if (abs($entry->{object}->${ \$tv->{column} } - $parsed_value) > $self->settings->{'max_amount_diff'}) {
385 395
          push @{ $entry->{errors} }, $::locale->text($tv->{err_msg});
386 396
        }
387 397
      }
SL/DB/CsvImportProfile.pm
54 54
                         default_buchungsgruppe    => ($bugru ? $bugru->id : undef),
55 55
                         apply_buchungsgruppe      => 'all',
56 56
                        );
57
  } elsif ($self->type eq 'orders') {
58
    $self->_set_defaults(order_column    => 'Order',
59
                         item_column     => 'OrderItem',
60
                         max_amount_diff => 0.02,
61
                        );
57 62
  } else {
58 63
    $self->_set_defaults(table => 'customer');
59 64
  }
templates/webpages/csv_import/_form_orders.html
3 3
<tr>
4 4
 <th align="right">[%- LxERP.t8('Order/Item columns') %]:</th>
5 5
 <td colspan="10">
6
  [% L.input_tag('settings.order_column', SELF.profile.get('order_column'), size => "5") %]
7
  [% L.input_tag('settings.item_column',  SELF.profile.get('item_column'),  size => "5") %]
6
  [% L.input_tag('settings.order_column', SELF.profile.get('order_column'), size => "10") %]
7
  [% L.input_tag('settings.item_column',  SELF.profile.get('item_column'),  size => "10") %]
8
 </td>
9
</tr>
10

  
11
<tr>
12
 <th align="right">[%- LxERP.t8('Maximal amount difference') %]:</th>
13
 <td colspan="10">
14
  [% L.input_tag('settings.max_amount_diff', LxERP.format_amount(SELF.profile.get('max_amount_diff')), size => "5") %]
8 15
 </td>
9 16
</tr>

Auch abrufbar als: Unified diff