]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/Part.pm
behebt #273 Überschriftskonten nicht im Dialog bebuchen
[mfinanz.git] / SL / Controller / Part.pm
index 869a5248c85f97179caa2e95179c4630aee7cb34..461090bd9d99ce3b5b3f29fcf65b7786ee8f0742 100644 (file)
@@ -26,6 +26,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
                                   assortment assortment_items assembly assembly_items
                                   all_pricegroups all_translations all_partsgroups all_units
                                   all_buchungsgruppen all_payment_terms all_warehouses
+                                  parts_classification_filter
                                   all_languages all_units all_price_factors) ],
   'scalar'                => [ qw(warehouse bin) ],
 );
                                   all_languages all_units all_price_factors) ],
   'scalar'                => [ qw(warehouse bin) ],
 );
@@ -75,6 +76,9 @@ sub action_add_from_record {
 
   check_has_valid_part_type($::form->{part}{part_type});
 
 
   check_has_valid_part_type($::form->{part}{part_type});
 
+  die 'parts_classification_type must be "sales" or "purchases"'
+    unless $::form->{parts_classification_type} =~ m/^(sales|purchases)$/;
+
   $self->parse_form;
   $self->add;
 }
   $self->parse_form;
   $self->add;
 }
@@ -968,6 +972,15 @@ sub init_multi_items_models {
   );
 }
 
   );
 }
 
+sub init_parts_classification_filter {
+  return [] unless $::form->{parts_classification_type};
+
+  return [ used_for_sale     => 't' ] if $::form->{parts_classification_type} eq 'sales';
+  return [ used_for_purchase => 't' ] if $::form->{parts_classification_type} eq 'purchases';
+
+  die "no query rules for parts_classification_type " . $::form->{parts_classification_type};
+}
+
 # simple checks to run on $::form before saving
 
 sub form_check_part_description_exists {
 # simple checks to run on $::form before saving
 
 sub form_check_part_description_exists {
@@ -1286,6 +1299,17 @@ parameter part_type as an action. Example:
 
   controller.pl?action=Part/add&part_type=service
 
 
   controller.pl?action=Part/add&part_type=service
 
+=item C<action_add_from_record>
+
+When adding new items to records they can be created on the fly if the entered
+partnumber or description doesn't exist yet. After being asked what part type
+the new item should have the user is redirected to the correct edit page.
+
+Depending on whether the item was added from a sales or a purchase record, only
+the relevant part classifications should be selectable for new item, so this
+parameter is passed on via a hidden parts_classification_type in the new_item
+template.
+
 =item C<action_save>
 
 Saves the current part and then reloads the edit page for the part.
 =item C<action_save>
 
 Saves the current part and then reloads the edit page for the part.