Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2dfa3a4c

Von Sven Schöling vor fast 8 Jahren hinzugefügt

  • ID 2dfa3a4c75b6f68ab75df739a3e82ceb1b61dcff
  • Vorgänger 87b283bd
  • Nachfolger 49f71dba

Preisquellen: Support für editierbare Preisquellen

Unterschiede anzeigen:

SL/PriceSource/Price.pm
5 5
use parent 'SL::DB::Object';
6 6
use Rose::Object::MakeMethods::Generic (
7 7
  scalar => [ qw(price description spec price_source invalid missing) ],
8
  'scalar --get_set_init' => [ qw(priority) ],
8
  'scalar --get_set_init' => [ qw(priority editable) ],
9 9
);
10 10

  
11 11
require SL::DB::Helper::Attr;
......
43 43
  3
44 44
}
45 45

  
46
sub init_editable {
47
  0
48
}
49

  
46 50
1;
47 51

  
48 52
__END__
......
119 123
OPTIONAL. Prices may supply a numerical priority. Higher will trump lower, even when
120 124
supplying higher prices. Defaults to 3 (as in middle of 1-5).
121 125

  
126
=item C<editable>
127

  
128
OPTIONAL. Prices may flag themselves as editable. An editable price will still
129
be subject to checks for higher or lower prices, but will be rendered in a
130
fashion that allows the user to overwrite it.
131

  
132
This is potentially very distracting if the price is usually a default price
133
and will be changed in a lot of instances so use with caution.
134

  
135
On the other hand it can provide the capability that users unfamiliar with the
136
system will intuitively expect so it can be a good way to introduce the system.
137

  
122 138
=item C<missing>
123 139

  
124 140
OPTIONAL. Both indicator and localized message that the price with this spec
bin/mozilla/io.pl
218 218

  
219 219
  # special alignings
220 220
  my %align  = map { $_ => 'right' } qw(qty ship right discount linetotal stock_in_out weight ship_missing);
221
  my %nowrap = map { $_ => 1 }       qw(description unit);
221
  my %nowrap = map { $_ => 1 }       qw(description unit  price_source);
222 222

  
223 223
  $form->{marge_total}           = 0;
224 224
  $form->{sellprice_total}       = 0;
......
336 336
      $column_data{ship_missing} = $form->format_amount(\%myconfig, $ship_missing_qty) . ' ' . $form->{"unit_$i"} . '; ' . $form->format_amount(\%myconfig, $ship_missing_amount, $decimalplaces);
337 337
    }
338 338

  
339
    my $sellprice_value = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
340
    my $discount_value  = $form->format_amount(\%myconfig, $form->{"discount_$i"});
341
    my $edit_prices     = $main::auth->assert('edit_prices', 1) && !$::form->{"active_price_source_$i"};
342
    my $edit_discounts  = $main::auth->assert('edit_prices', 1) && !$::form->{"active_discount_source_$i"};
343
    $column_data{sellprice}   = (!$edit_prices)
344
                                ? $cgi->hidden(   -name => "sellprice_$i", -id => "sellprice_$i", -value => $sellprice_value) . $sellprice_value
345
                                : $cgi->textfield(-name => "sellprice_$i", -id => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $sellprice_value);
346
    $column_data{discount}    = (!$edit_discounts)
347
                                  ? $cgi->hidden(   -name => "discount_$i", -id => "discount_$i", -value => $discount_value) . $discount_value . ' %'
348
                                  : $cgi->textfield(-name => "discount_$i", -id => "discount_$i", -size => 3, -value => $discount_value);
349 339
    $column_data{linetotal}   = $form->format_amount(\%myconfig, $linetotal, 2);
350 340
    $column_data{bin}         = $form->{"bin_$i"};
351 341

  
352 342
    $column_data{weight}      = $form->format_amount(\%myconfig, $form->{"qty_$i"} * $form->{"weight_$i"}, 3) . ' ' . $defaults->{weightunit} if $defaults->{show_weight};
353 343

  
344
    my $sellprice_value = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
345
    my $discount_value  = $form->format_amount(\%myconfig, $form->{"discount_$i"});
346

  
347
    my $price;
354 348
    if ($form->{"id_${i}"} && !$is_delivery_order) {
355 349
      my $price_source  = SL::PriceSource->new(record_item => $record_item, record => $record);
356
      my $price         = $price_source->price_from_source($::form->{"active_price_source_$i"});
350
         $price         = $price_source->price_from_source($::form->{"active_price_source_$i"});
357 351
      my $discount      = $price_source->discount_from_source($::form->{"active_discount_source_$i"});
358 352
      my $best_price    = $price_source->best_price;
359 353
      my $best_discount = $price_source->best_discount;
......
378 372
      }
379 373
    }
380 374

  
375
    my $edit_prices     = $main::auth->assert('edit_prices', 1) && (!$::form->{"active_price_source_$i"} || !$price || $price->editable);
376
    my $edit_discounts  = $main::auth->assert('edit_prices', 1) && !$::form->{"active_discount_source_$i"};
377
    $column_data{sellprice}   = (!$edit_prices)
378
                                ? $cgi->hidden(   -name => "sellprice_$i", -id => "sellprice_$i", -value => $sellprice_value) . $sellprice_value
379
                                : $cgi->textfield(-name => "sellprice_$i", -id => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $sellprice_value);
380
    $column_data{discount}    = (!$edit_discounts)
381
                                  ? $cgi->hidden(   -name => "discount_$i", -id => "discount_$i", -value => $discount_value) . $discount_value . ' %'
382
                                  : $cgi->textfield(-name => "discount_$i", -id => "discount_$i", -size => 3, -value => $discount_value);
383

  
381 384
    if ($is_delivery_order) {
382 385
      $column_data{stock_in_out} =  calculate_stock_in_out($i);
383 386
    }

Auch abrufbar als: Unified diff