Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a3e1833a

Von Bernd Bleßmann vor 7 Monaten hinzugefügt

  • ID a3e1833a242501fd7c0ab4349a1185175d8e12dc
  • Vorgänger 9b93901e
  • Nachfolger a0c6ec81

Auftrags-/Lieferschein-/Reklamation-Controller: Preis-/Rabattquellen mit S:M:Record

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
1055 1055
    $item->description($texts->{description});
1056 1056
    $item->longdescription($texts->{longdescription});
1057 1057

  
1058
    my $price_source = SL::PriceSource->new(record_item => $item, record => $self->order);
1059

  
1060
    my $price_src;
1061
    if ($item->part->is_assortment) {
1062
    # add assortment items with price 0, as the components carry the price
1063
      $price_src = $price_source->price_from_source("");
1064
      $price_src->price(0);
1065
    } else {
1066
      $price_src = $price_source->best_price
1067
                 ? $price_source->best_price
1068
                 : $price_source->price_from_source("");
1069
      $price_src->price(
1070
        $::form->round_amount($price_src->price / $self->order->exchangerate, 5)
1071
      ) if $self->order->exchangerate;
1072
      $price_src->price(0) if !$price_source->best_price;
1073
    }
1074

  
1058
    my ($price_src, undef) = SL::Model::Record->get_best_price_and_discount_source($self->order, $item, ignore_given => 1);
1075 1059
    $item->sellprice($price_src->price);
1076 1060
    $item->active_price_source($price_src);
1077 1061

  
......
1681 1665

  
1682 1666
  $item->assign_attributes(%$attr);
1683 1667

  
1684
  my $part         = SL::DB::Part->new(id => $attr->{parts_id})->load;
1685
  my $price_source = SL::PriceSource->new(
1686
    record_item => $item,
1687
    record => $record,
1688
  );
1689

  
1668
  my $part = SL::DB::Part->new(id => $attr->{parts_id})->load;
1669
  $item->qty(1.0)          if !$item->qty;
1690 1670
  $item->unit($part->unit) if !$item->unit;
1691 1671

  
1692
  my $price_src;
1693
  if ( $part->is_assortment ) {
1694
    # add assortment items with price 0, as the components carry the price
1695
    $price_src = $price_source->price_from_source("");
1696
    $price_src->price(0);
1697
  } elsif (defined $item->sellprice) {
1698
    $price_src = $price_source->price_from_source("");
1699
    $price_src->price($item->sellprice);
1700
  } else {
1701
    $price_src = $price_source->best_price
1702
               ? $price_source->best_price
1703
               : $price_source->price_from_source("");
1704
    $price_src->price(0) if !$price_source->best_price;
1705
  }
1706

  
1707
  my $discount_src;
1708
  if (defined $item->discount) {
1709
    $discount_src = $price_source->discount_from_source("");
1710
    $discount_src->discount($item->discount);
1711
  } else {
1712
    $discount_src = $price_source->best_discount
1713
                  ? $price_source->best_discount
1714
                  : $price_source->discount_from_source("");
1715
    $discount_src->discount(0) if !$price_source->best_discount;
1716
  }
1672
  my ($price_src, $discount_src) = SL::Model::Record->get_best_price_and_discount_source($record, $item, ignore_given => 0);
1717 1673

  
1718 1674
  my %new_attr;
1719 1675
  $new_attr{part}                   = $part;
SL/Controller/Order.pm
1079 1079
  $item->qty(1) if !$item->qty;
1080 1080
  $item->unit($item->part->unit);
1081 1081

  
1082
  my ($price_src, $discount_src) = get_best_price_and_discount_source($record, $item, 0);
1082
  my ($price_src, $discount_src) = SL::Model::Record->get_best_price_and_discount_source($record, $item, ignore_given => 0);
1083 1083

  
1084 1084
  $self->js
1085 1085
    ->val     ('#add_item_unit',                $item->unit)
......
1393 1393
    $item->description($texts->{description});
1394 1394
    $item->longdescription($texts->{longdescription});
1395 1395

  
1396
    my ($price_src, $discount_src) = get_best_price_and_discount_source($self->order, $item, 1);
1397

  
1396
    my ($price_src, $discount_src) = SL::Model::Record->get_best_price_and_discount_source($self->order, $item, ignore_given => 1);
1398 1397
    $item->sellprice($price_src->price);
1399 1398
    $item->active_price_source($price_src);
1400 1399
    $item->discount($discount_src->discount);
......
1972 1971
  $item->qty(1.0)                   if !$item->qty;
1973 1972
  $item->unit($item->part->unit)    if !$item->unit;
1974 1973

  
1975
  my ($price_src, $discount_src) = get_best_price_and_discount_source($record, $item, 0);
1974
  my ($price_src, $discount_src) = SL::Model::Record->get_best_price_and_discount_source($record, $item, ignore_given => 0);
1976 1975

  
1977 1976
  my %new_attr;
1978 1977
  $new_attr{description}            = $item->part->description     if ! $item->description;
......
2774 2773
  return $texts;
2775 2774
}
2776 2775

  
2777
sub get_best_price_and_discount_source {
2778
  my ($record, $item, $ignore_given) = @_;
2779

  
2780
  my $price_source = SL::PriceSource->new(record_item => $item, record => $record);
2781

  
2782
  my $price_src;
2783
  if ( $item->part->is_assortment ) {
2784
    # add assortment items with price 0, as the components carry the price
2785
    $price_src = $price_source->price_from_source("");
2786
    $price_src->price(0);
2787
  } elsif (!$ignore_given && defined $item->sellprice) {
2788
    $price_src = $price_source->price_from_source("");
2789
    $price_src->price($item->sellprice);
2790
  } else {
2791
    $price_src = $price_source->best_price
2792
               ? $price_source->best_price
2793
               : $price_source->price_from_source("");
2794
    $price_src->price($::form->round_amount($price_src->price / $record->exchangerate, 5)) if $record->exchangerate;
2795
    $price_src->price(0) if !$price_source->best_price;
2796
  }
2797

  
2798
  my $discount_src;
2799
  if (!$ignore_given && defined $item->discount) {
2800
    $discount_src = $price_source->discount_from_source("");
2801
    $discount_src->discount($item->discount);
2802
  } else {
2803
    $discount_src = $price_source->best_discount
2804
                  ? $price_source->best_discount
2805
                  : $price_source->discount_from_source("");
2806
    $discount_src->discount(0) if !$price_source->best_discount;
2807
  }
2808

  
2809
  return ($price_src, $discount_src);
2810
}
2811

  
2812 2776
sub nr_key {
2813 2777
  my ($self) = @_;
2814 2778

  
SL/Controller/Reclamation.pm
954 954
    $item->description($texts->{description});
955 955
    $item->longdescription($texts->{longdescription});
956 956

  
957
    my $price_source = SL::PriceSource->new(record_item => $item, record => $self->reclamation);
958

  
959
    my $price_src;
960
    if ($item->part->is_assortment) {
961
    # add assortment items with price 0, as the components carry the price
962
      $price_src = $price_source->price_from_source("");
963
      $price_src->price(0);
964
    } else {
965
      $price_src = $price_source->best_price
966
                 ? $price_source->best_price
967
                 : $price_source->price_from_source("");
968
      $price_src->price($::form->round_amount($price_src->price / $self->reclamation->exchangerate, 5)) if $self->reclamation->exchangerate;
969
      $price_src->price(0) if !$price_source->best_price;
970
    }
971

  
957
    my ($price_src, undef) = SL::Model::Record->get_best_price_and_discount_source($self->reclamation, $item, ignore_given => 1);
972 958
    $item->sellprice($price_src->price);
973 959
    $item->active_price_source($price_src);
974 960

  
......
1442 1428

  
1443 1429
  $item->assign_attributes(%$attr);
1444 1430

  
1445
  my $part         = SL::DB::Part->new(id => $attr->{parts_id})->load;
1446
  my $price_source = SL::PriceSource->new(record_item => $item, record => $record);
1431
  my $part = SL::DB::Part->new(id => $attr->{parts_id})->load;
1432
  $item->qty(1.0)          if !$item->qty;
1447 1433
  $item->unit($part->unit) if !$item->unit;
1448 1434

  
1449
  my $price_src;
1450
  if ( $part->is_assortment ) {
1451
    # add assortment items with price 0, as the components carry the price
1452
    $price_src = $price_source->price_from_source("");
1453
    $price_src->price(0);
1454
  } elsif (defined $item->sellprice) {
1455
    $price_src = $price_source->price_from_source("");
1456
    $price_src->price($item->sellprice);
1457
  } else {
1458
    $price_src = $price_source->best_price
1459
               ? $price_source->best_price
1460
               : $price_source->price_from_source("");
1461
    if ($record->exchangerate) {
1462
      $price_src->price($::form->round_amount($price_src->price / $record->exchangerate, 5));
1463
    }
1464
    $price_src->price(0) if !$price_source->best_price;
1465
  }
1466

  
1467
  my $discount_src;
1468
  if (defined $item->discount) {
1469
    $discount_src = $price_source->discount_from_source("");
1470
    $discount_src->discount($item->discount);
1471
  } else {
1472
    $discount_src = $price_source->best_discount
1473
                  ? $price_source->best_discount
1474
                  : $price_source->discount_from_source("");
1475
    $discount_src->discount(0) if !$price_source->best_discount;
1476
  }
1435
  my ($price_src, $discount_src) = SL::Model::Record->get_best_price_and_discount_source($record, $item, ignore_given => 0);
1477 1436

  
1478 1437
  my %new_attr;
1479 1438
  $new_attr{part}                   = $part;

Auch abrufbar als: Unified diff