]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/Part.pm
Banktransaction: Kontoauszug verbuchen überarbeitet
[mfinanz.git] / SL / Controller / Part.pm
index 5622193c48fb9a0f6c349e68d1671f9ded0a1170..23b4eff1ee0d204332ae2d5be832ea419897feaf 100644 (file)
@@ -23,7 +23,7 @@ use Rose::Object::MakeMethods::Generic (
                                   assortment assortment_items assembly assembly_items
                                   all_pricegroups all_translations all_partsgroups all_units
                                   all_buchungsgruppen all_payment_terms all_warehouses
-                                  all_languages all_units all_pricefactors) ],
+                                  all_languages all_units all_price_factors) ],
   'scalar'                => [ qw(warehouse bin) ],
 );
 
@@ -457,20 +457,23 @@ sub action_reorder_items {
 sub action_warehouse_changed {
   my ($self) = @_;
 
-  $self->warehouse(SL::DB::Manager::Warehouse->find_by_or_create(id => $::form->{warehouse_id}));
-  die unless ref($self->warehouse) eq 'SL::DB::Warehouse';
+  if ($::form->{warehouse_id} ) {
+    $self->warehouse(SL::DB::Manager::Warehouse->find_by_or_create(id => $::form->{warehouse_id}));
+    die unless ref($self->warehouse) eq 'SL::DB::Warehouse';
 
-  if ( $self->warehouse->id and @{$self->warehouse->bins} ) {
-    $self->bin($self->warehouse->bins->[0]);
-    $self->js
-      ->html('#bin', $self->build_bin_select)
-      ->focus('#part_bin_id');
-  } else {
-    # no warehouse was selected, empty the bin field and reset the id
-    $self->js
-        ->val('#part_bin_id', undef)
-        ->html('#bin', '');
-  };
+    if ( $self->warehouse->id and @{$self->warehouse->bins} ) {
+      $self->bin($self->warehouse->bins->[0]);
+      $self->js
+        ->html('#bin', $self->build_bin_select)
+        ->focus('#part_bin_id');
+      return $self->js->render;
+    }
+  }
+
+  # no warehouse was selected, empty the bin field and reset the id
+  $self->js
+       ->val('#part_bin_id', undef)
+       ->html('#bin', '');
 
   return $self->js->render;
 }
@@ -872,7 +875,8 @@ sub init_all_languages {
 }
 
 sub init_all_partsgroups {
-  SL::DB::Manager::PartsGroup->get_all_sorted;
+  my ($self) = @_;
+  SL::DB::Manager::PartsGroup->get_all_sorted(query => [ or => [ id => $self->part->partsgroup_id, obsolete => 0 ] ]);
 }
 
 sub init_all_buchungsgruppen {
@@ -894,7 +898,8 @@ sub init_all_units {
 }
 
 sub init_all_payment_terms {
-  SL::DB::Manager::PaymentTerm->get_all_sorted;
+  my ($self) = @_;
+  SL::DB::Manager::PaymentTerm->get_all_sorted(query => [ or => [ id => $self->part->payment_id, obsolete => 0 ] ]);
 }
 
 sub init_all_price_factors {