Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 89b26688

Von Sven Schöling vor mehr als 9 Jahren hinzugefügt

  • ID 89b2668811eac6023ad58322e2f9970ddb6a27c9
  • Vorgänger c653b98f
  • Nachfolger 766ed2a6

PriceSource: Rabattbehandlung

Unterschiede anzeigen:

bin/mozilla/io.pl
226 226
  for my $i (1 .. $numrows) {
227 227
    my %column_data = ();
228 228

  
229
    my $record_item = $record->id && $record->items ? $record->items->[$i-1] : _make_record_item($i);
230

  
229 231
    # undo formatting
230 232
    map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
231 233
      qw(qty discount sellprice lastcost price_new price_old)
......
235 237
      $form->{"sellprice_$i"} = $form->{"price_new_$i"};
236 238
    }
237 239

  
238
    my $record_item = $record->id && $record->items ? $record->items->[$i-1] : _make_record_item($i);
239

  
240 240
# unit begin
241 241
    $form->{"unit_old_$i"}      ||= $form->{"unit_$i"};
242 242
    $form->{"selected_unit_$i"} ||= $form->{"unit_$i"};
......
310 310
    }
311 311

  
312 312
    my $sellprice_value = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
313
    my $discount_value  = $form->format_amount(\%myconfig, $form->{"discount_$i"});
313 314
    my $edit_prices     = $main::auth->assert('edit_prices', 1) && !$::form->{"active_price_source_$i"};
315
    my $edit_discounts  = $main::auth->assert('edit_prices', 1) && !$::form->{"active_discount_source_$i"};
314 316
    $column_data{sellprice}   = (!$edit_prices)
315 317
                                ? $cgi->hidden(   -name => "sellprice_$i", -id => "sellprice_$i", -value => $sellprice_value) . $sellprice_value
316 318
                                : $cgi->textfield(-name => "sellprice_$i", -id => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $sellprice_value);
317
    $column_data{discount}    = (!$edit_prices)
318
                                  ? $cgi->textfield(-readonly => "readonly",
319
                                                    -name => "discount_$i", -size => 3, -value => $form->format_amount(\%myconfig, $form->{"discount_$i"}))
320
                                  : $cgi->textfield(-name => "discount_$i", -size => 3, -value => $form->format_amount(\%myconfig, $form->{"discount_$i"}));
319
    $column_data{discount}    = (!$edit_discounts)
320
                                  ? $cgi->hidden(   -name => "discount_$i", -id => "discount_$i", -value => $discount_value) . $discount_value . ' %'
321
                                  : $cgi->textfield(-name => "discount_$i", -id => "discount_$i", -size => 3, -value => $discount_value);
321 322
    $column_data{linetotal}   = $form->format_amount(\%myconfig, $linetotal, 2);
322 323
    $column_data{bin}         = $form->{"bin_$i"};
323 324

  
......
325 326

  
326 327
    if ($form->{"id_${i}"} && !$is_delivery_order) {
327 328
      my $price_source = SL::PriceSource->new(record_item => $record_item, record => $record);
328
      my $price = $price_source->price_from_source($::form->{"active_price_source_$i"});
329
      my $price    = $price_source->price_from_source($::form->{"active_price_source_$i"});
330
      my $discount = $price_source->price_from_source($::form->{"active_discount_source_$i"});
329 331
      $column_data{price_source} .= $cgi->button(-value => $price->source_description, -onClick => "kivi.io.price_chooser($i)");
330 332
      if ($price->source) {
331 333
        $column_data{price_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $price->invalid, title => $price->invalid }) if $price->invalid;
332 334
        $column_data{price_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $price->missing, title => $price->missing }) if $price->missing;
333
        $column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png',   alt => t8('This price has since gone up'),      title => t8('This price has since gone up' )     }) if $price->price > $record_item->sellprice;
334
        $column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This price has since gone down'),    title => t8('This price has since gone down')    }) if $price->price < $record_item->sellprice;
335
        $column_data{price_source} .= ' ' . $cgi->img({src => 'image/ok.png',   alt => t8('There is a better price available'), title => t8('There is a better price available') }) if $price->source ne $price_source->best_price->source;
335
        if (!$price->missing && !$price->invalid) {
336
          $column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png',   alt => t8('This price has since gone up'),      title => t8('This price has since gone up' )     }) if $price->price > $record_item->sellprice;
337
          $column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This price has since gone down'),    title => t8('This price has since gone down')    }) if $price->price < $record_item->sellprice;
338
          $column_data{price_source} .= ' ' . $cgi->img({src => 'image/ok.png',   alt => t8('There is a better price available'), title => t8('There is a better price available') }) if $price->source ne $price_source->best_price->source;
339
        }
340
      }
341
      if ($discount->source) {
342
        $column_data{discount_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $discount->invalid, title => $discount->invalid }) if $discount->invalid;
343
        $column_data{discount_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $discount->missing, title => $discount->missing }) if $discount->missing;
344
        if (!$discount->missing && !$discount->invalid) {
345
          $column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png',   alt => t8('This discount has since gone up'),      title => t8('This discount has since gone up')      }) if $discount->discount * 100 > $record_item->discount;
346
          $column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This discount has since gone down'),    title => t8('This discount has since gone down')    }) if $discount->discount * 100 < $record_item->discount;
347
          $column_data{price_source} .= ' ' . $cgi->img({src => 'image/ok.png',   alt => t8('There is a better discount available'), title => t8('There is a better discount available') }) if $discount->source ne $price_source->best_discount->source;
348
        }
336 349
      }
337 350
    }
338 351

  
......
428 441
          $cgi->hidden("-name" => "unit_old_$i", "-value" => $form->{"selected_unit_$i"}),
429 442
          $cgi->hidden("-name" => "price_new_$i", "-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"})),
430 443
          map { ($cgi->hidden("-name" => $_, "-id" => $_, "-value" => $form->{$_})); } map { $_."_$i" }
431
            (qw(orderitems_id bo price_old id inventory_accno bin partsgroup partnotes active_price_source
444
            (qw(orderitems_id bo price_old id inventory_accno bin partsgroup partnotes active_price_source active_discount_source
432 445
                income_accno expense_accno listprice assembly taxaccounts ordnumber donumber transdate cusordnumber
433 446
                longdescription basefactor marge_absolut marge_percent marge_price_factor weight), @hidden_vars)
434 447
    );
......
469 482
  $::form->header;
470 483

  
471 484
  my @item_list = map {
472
    $_->{display_sellprice}  = $_->{sellprice} * (1 - $::form->{tradediscount});
473 485
    $_->{display_sellprice} /= $_->{price_factor} if ($_->{price_factor});
474 486
    $_;
475 487
  } @{ $::form->{item_list} };
......
536 548
    $::form->{"active_price_source_$i"} = $best_price->source;
537 549
  }
538 550

  
551
  my $best_discount = $price_source->best_discount;
552

  
553
  if ($best_discount) {
554
    $::form->{"discount_$i"}               = $best_discount->discount;
555
    $::form->{"active_discount_source_$i"} = $best_discount->source;
556
  }
557

  
539 558

  
540 559
  $form->{"marge_price_factor_$i"} = $new_item->{price_factor};
541 560

  
......
557 576
      $form->{"sellprice_$i"} =
558 577
        $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
559 578
    }
560

  
561
    # tradediscount
562
    if ($::form->{tradediscount}) {
563
      $::form->{"sellprice_$i"} *= 1 - $::form->{tradediscount};
564
    }
565 579
  }
566 580

  
567 581
  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
......
710 724
                transdate longdescription basefactor marge_total marge_percent
711 725
                marge_price_factor lastcost price_factor_id partnotes
712 726
                stock_out stock_in has_sernumber reqdate orderitems_id
713
                active_price_source);
727
                active_price_source active_discount_source);
714 728

  
715 729
  my $ic_cvar_configs = CVar->get_configs(module => 'IC');
716 730
  push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };

Auch abrufbar als: Unified diff