Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0dd80ce0

Von Tamino Steinert vor 5 Tagen hinzugefügt

  • ID 0dd80ce016ddfc894734cf4dbb06ad18e2a9fc64
  • Vorgänger 2d3180e2

S:C:Order: Standard Rabattartikel einfach hinzufügen

Unterschiede anzeigen:

SL/Controller/Order.pm
1178 1178
  $self->js->render();
1179 1179
}
1180 1180

  
1181
sub action_add_discount_item {
1182
  my ($self) = @_;
1183
  $self->recalc();
1184

  
1185
  my $discount_part_id = $::instance_conf->get_discount_part_id
1186
    or die "no discount part set in client config";
1187
  my $discount_part = SL::DB::Part->load_cached($discount_part_id);
1188

  
1189
  my $discount_type = $::form->{discount}->{type}
1190
    or die "discount.type needed";
1191
  my $discount_value_as_number = $::form->{discount}->{value};
1192
  my $discount_value = $::form->parse_amount(\%::myconfig, $discount_value_as_number);
1193
  $discount_value *= -1 if $discount_value > 0;
1194

  
1195
  $::form->{add_item}->{parts_id} = $discount_part_id;
1196
  $::form->{add_item}->{qty_as_number} = 1;
1197
  $::form->{add_item}->{unit} = $discount_part->unit;
1198
  $::form->{add_item}->{discount_as_percent} = 0;
1199

  
1200
  my $sellprice_as_number;
1201
  my $texts = get_part_texts($discount_part, $self->order->language_id);
1202
  my $description = $texts->{description};
1203

  
1204
  if ($discount_type eq 'absolute') {
1205
    $sellprice_as_number = $::form->format_amount(\%::myconfig, $discount_value, 2, 0);
1206
    my $price_as_text = $::form->format_amount(\%::myconfig, -1 * $discount_value, 2, 0);
1207

  
1208
    my $currency = $self->order->currency->name;
1209
    $description =~ s/<%discount_value%>/$price_as_text $currency/;
1210
  } elsif ($discount_type eq 'percent') {
1211
    $sellprice_as_number = $::form->format_amount(
1212
      \%::myconfig,
1213
      $self->order->amount * $::form->parse_amount(\%::myconfig, $discount_value) / 100,
1214
      2, 0
1215
    );
1216
    my $procent_as_text = $::form->format_amount(\%::myconfig, -1 * $discount_value);
1217

  
1218
    $description =~ s/<%discount_value%>/$procent_as_text%/;
1219
  } else {
1220
    die "unkown discount.type $discount_type";
1221
  }
1222

  
1223
  $::form->{add_item}->{sellprice_as_number} = $sellprice_as_number;
1224
  $::form->{add_item}->{description} = $description;
1225

  
1226
  $self->action_add_item();
1227
}
1228

  
1181 1229
# recalculate all linetotals, amounts and taxes and redisplay them
1182 1230
sub action_recalc_amounts_and_taxes {
1183 1231
  my ($self) = @_;

Auch abrufbar als: Unified diff