Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a5a87c23

Von Tamino Steinert vor 1 Tag hinzugefügt

  • ID a5a87c237c6e5caac918b49740b3832f0a45fb56
  • Vorgänger 5508a801
  • Nachfolger 6d9402c5

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

Unterschiede anzeigen:

SL/Controller/Order.pm
1184 1184
  $self->js->render();
1185 1185
}
1186 1186

  
1187
sub action_add_discount_item {
1188
  my ($self) = @_;
1189
  $self->recalc();
1190

  
1191
  my $discount_part_id = $::instance_conf->get_discount_part_id
1192
    or die "no discount part set in client config";
1193
  my $discount_part = SL::DB::Part->load_cached($discount_part_id);
1194

  
1195
  my $discount_type = $::form->{discount}->{type}
1196
    or die "discount.type needed";
1197
  my $discount_value_as_number = $::form->{discount}->{value};
1198
  my $discount_value = $::form->parse_amount(\%::myconfig, $discount_value_as_number);
1199
  $discount_value *= -1 if $discount_value > 0;
1200

  
1201
  $::form->{add_item}->{parts_id} = $discount_part_id;
1202
  $::form->{add_item}->{qty_as_number} = 1;
1203
  $::form->{add_item}->{unit} = $discount_part->unit;
1204
  $::form->{add_item}->{discount_as_percent} = 0;
1205

  
1206
  my $sellprice_as_number;
1207
  my $texts = get_part_texts($discount_part, $self->order->language_id);
1208
  my $description = $texts->{description};
1209

  
1210
  if ($discount_type eq 'absolute') {
1211
    $sellprice_as_number = $::form->format_amount(\%::myconfig, $discount_value, 2, 0);
1212
    my $price_as_text = $::form->format_amount(\%::myconfig, -1 * $discount_value, 2, 0);
1213

  
1214
    my $currency = $self->order->currency->name;
1215
    $description =~ s/<%discount_value%>/$price_as_text $currency/;
1216
  } elsif ($discount_type eq 'percent') {
1217
    $sellprice_as_number = $::form->format_amount(
1218
      \%::myconfig,
1219
      $self->order->amount * $::form->parse_amount(\%::myconfig, $discount_value) / 100,
1220
      2, 0
1221
    );
1222
    my $procent_as_text = $::form->format_amount(\%::myconfig, -1 * $discount_value);
1223

  
1224
    $description =~ s/<%discount_value%>/$procent_as_text%/;
1225
  } else {
1226
    die "unknown discount.type $discount_type";
1227
  }
1228

  
1229
  $::form->{add_item}->{sellprice_as_number} = $sellprice_as_number;
1230
  $::form->{add_item}->{description} = $description;
1231

  
1232
  $self->action_add_item();
1233
}
1234

  
1187 1235
# recalculate all linetotals, amounts and taxes and redisplay them
1188 1236
sub action_recalc_amounts_and_taxes {
1189 1237
  my ($self) = @_;

Auch abrufbar als: Unified diff