Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0409db7c

Von Sven Schöling vor etwa 10 Jahren hinzugefügt

  • ID 0409db7c50da81e1eb613bd33663fb5b07935a01
  • Vorgänger eebe8e90
  • Nachfolger df1b03d5

PriceSource: Mehr Informationen an Preise übergeben

record + record_item verfügbar gemacht
best_price für pricegroups
Price: spec/source entzerrt

Unterschiede anzeigen:

bin/mozilla/io.pl
218 218

  
219 219
  my $totalweight = 0;
220 220

  
221
  my $record = _make_record();
221 222
  # rows
222 223

  
223 224
  my @ROWS;
......
233 234
      $form->{"sellprice_$i"} = $form->{"price_new_$i"};
234 235
    }
235 236

  
236
    my $record_item = _make_record_item($i);
237
    my $record_item = $record->items->[$i-1];
237 238

  
238 239
# unit begin
239 240
    $form->{"unit_old_$i"}      ||= $form->{"unit_$i"};
......
322 323
    $column_data{weight}      = $form->format_amount(\%myconfig, $form->{"qty_$i"} * $form->{"weight_$i"}, 3) . ' ' . $defaults->{weightunit} if $defaults->{show_weight};
323 324

  
324 325
    if ($form->{"id_${i}"}) {
325
      my $price_source = SL::PriceSource->new(record_item => $record_item);
326
      my $price_source = SL::PriceSource->new(record_item => $record_item, record => $record);
326 327
      my $price = $price_source->price_from_source($::form->{"active_price_source_$i"});
327 328
      $::form->{price_sources}[$i] = $price_source;
328 329
      $column_data{price_source} .= $cgi->button(-value => $price->full_description, -onClick => "toggle_price_source($i)");
......
1890 1891
  $::form->{rowcount} -= $removed_rows;
1891 1892
}
1892 1893

  
1894
# TODO: both of these are makeshift so that price sources can operate on rdbo objects. if
1895
# this ever gets rewritten in controller style, throw this out
1893 1896
sub _make_record_item {
1894 1897
  my ($row) = @_;
1895 1898

  
......
1918 1921
    next unless $obj->meta->column($method);
1919 1922
    if ($obj->meta->column($method)->isa('Rose::DB::Object::Metadata::Column::Date')) {
1920 1923
      $obj->${\"$method\_as_date"}($::form->{"$method\_$row"});
1924
    } elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::(?:Numeric|Float|DoublePrecsion)$/) {
1925
      $obj->${\"$method\_as\_number"}($::form->{$method});
1921 1926
    } else {
1922 1927
      $obj->$method($::form->{"$method\_$row"});
1923 1928
    }
......
1929 1934

  
1930 1935
  return $obj;
1931 1936
}
1937

  
1938
sub _make_record {
1939
  my $class = {
1940
    sales_order             => 'Order',
1941
    purchase_oder           => 'Order',
1942
    sales_quotation         => 'Order',
1943
    request_quotation       => 'Order',
1944
    invoice                 => 'Invoice',
1945
    purchase_invoice        => 'PurchaseInvoice',
1946
    purchase_delivery_order => 'DeliveryOrder',
1947
    sales_delivery_order    => 'DeliveryOrder',
1948
  }->{$::form->{type}};
1949

  
1950
  return unless $class;
1951

  
1952
  $class = 'SL::DB::' . $class;
1953

  
1954
  eval "require $class";
1955

  
1956
  my $obj = $::form->{id}
1957
          ? $class->meta->convention_manager->auto_manager_class_name->find_by(id => $::form->{id})
1958
          : $class->new;
1959

  
1960
  for my $method (keys %$::form) {
1961
    next unless $obj->can($method);
1962
    next unless $obj->meta->column($method);
1963

  
1964
    if ($obj->meta->column($method)->isa('Rose::DB::Object::Metadata::Column::Date')) {
1965
      $obj->${\"$method\_as_date"}($::form->{$method});
1966
    } elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::(?:Numeric|Float|DoublePrecsion)$/) {
1967
      $obj->${\"$method\_as\_number"}($::form->{$method});
1968
    } else {
1969
      $obj->$method($::form->{$method});
1970
    }
1971
  }
1972

  
1973
  my @items;
1974
  for my $i (1 .. $::form->{rowcount}) {
1975
    next unless $::form->{"id_$i"};
1976
    push @items, _make_record_item($i)
1977
  }
1978

  
1979
  $obj->orderitems(@items);
1980

  
1981
  return $obj;
1982
}
1983

  

Auch abrufbar als: Unified diff