Auftrags-Controller: Preisfaktor berücksichtigen
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 1 Feb 2016 15:45:22 +0000 (16:45 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 11 Mar 2016 11:53:26 +0000 (12:53 +0100)
SL/Controller/Order.pm
templates/webpages/order/tabs/_row.html
templates/webpages/order/tabs/basic_data.html

index eba061c..6e88036 100644 (file)
@@ -21,6 +21,7 @@ use SL::DB::Project;
 use SL::DB::Default;
 use SL::DB::Unit;
 use SL::DB::Price;
+use SL::DB::PriceFactor;
 use SL::DB::Part;
 use SL::DB::Printer;
 use SL::DB::Language;
@@ -39,7 +40,7 @@ use File::Spec;
 use Rose::Object::MakeMethods::Generic
 (
  scalar => [ qw(item_ids_to_delete) ],
- 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models) ],
+ 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors) ],
 );
 
 
@@ -413,7 +414,11 @@ sub action_add_item {
   $self->_recalc();
 
   my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
-  my $row_as_html = $self->p->render('order/tabs/_row', ITEM => $item, ID => $item_id);
+  my $row_as_html = $self->p->render('order/tabs/_row',
+                                     ITEM              => $item,
+                                     ID                => $item_id,
+                                     ALL_PRICE_FACTORS => $self->all_price_factors
+  );
 
   $self->js
     ->append('#row_table_id', $row_as_html)
@@ -472,7 +477,11 @@ sub action_add_multi_items {
 
   foreach my $item (@items) {
     my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
-    my $row_as_html = $self->p->render('order/tabs/_row', ITEM => $item, ID => $item_id);
+    my $row_as_html = $self->p->render('order/tabs/_row',
+                                       ITEM              => $item,
+                                       ID                => $item_id,
+                                       ALL_PRICE_FACTORS => $self->all_price_factors
+    );
 
     $self->js
         ->append('#row_table_id', $row_as_html)
@@ -629,6 +638,10 @@ sub init_multi_items_models {
   );
 }
 
+sub init_all_price_factors {
+  SL::DB::Manager::PriceFactor->get_all;
+}
+
 sub _check_auth {
   my ($self) = @_;
 
@@ -797,8 +810,9 @@ sub _new_item {
 
   my %new_attr;
   $new_attr{part}                   = $part;
-  $new_attr{description}            = $part->description if ! $item->description;
-  $new_attr{qty}                    = 1.0                if ! $item->qty;
+  $new_attr{description}            = $part->description     if ! $item->description;
+  $new_attr{qty}                    = 1.0                    if ! $item->qty;
+  $new_attr{price_factor_id}        = $part->price_factor_id if ! $item->price_factor_id;
   $new_attr{sellprice}              = $price_src->price;
   $new_attr{discount}               = $discount_src->discount;
   $new_attr{active_price_source}    = $price_src;
index bfd14cc..af03599 100644 (file)
                       class="recalc reformat_number numeric") %]
     </td>
     <td>
-      [%- L.input_tag("order.orderitems[].price_factor",
-                      ITEM.price_factor,
-                      size = 5,
-                      class="recalc numeric") %]
+      [%- L.select_tag("order.orderitems[].price_factor_id",
+                       ALL_PRICE_FACTORS,
+                       default = ITEM.price_factor_id,
+                       title_key = 'description',
+                       with_empty = 1,
+                       class="recalc") %]
     </td>
     <td nowrap>
       [%- L.select_tag("order.orderitems[].unit",
index b3c9fa0..7732c22 100644 (file)
             </thead>
 
             [%- FOREACH item = SELF.order.items_sorted %]
-              [%- PROCESS order/tabs/_row.html ITEM=item ID=item.id %]
+              [%- PROCESS order/tabs/_row.html ITEM=item ID=item.id ALL_PRICE_FACTORS=SELF.all_price_factors %]
             [%- END %]
 
           </table>