Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorSven Schöling <s.schoeling@linet-services.de>
Fri, 30 Dec 2011 16:29:46 +0000 (17:29 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Fri, 30 Dec 2011 16:29:46 +0000 (17:29 +0100)
SL/Controller/CsvImport.pm
SL/Controller/CsvImport/Part.pm
SL/DB/Manager/Unit.pm [new file with mode: 0644]
SL/DB/Unit.pm
locale/de/all
templates/webpages/csv_import/_form_parts.html

index 9cca6cd..e603faa 100644 (file)
@@ -4,6 +4,7 @@ use strict;
 
 use SL::DB::Buchungsgruppe;
 use SL::DB::CsvImportProfile;
+use SL::DB::Unit;
 use SL::Helper::Flash;
 use SL::SessionFile;
 use SL::Controller::CsvImport::Contact;
@@ -17,7 +18,7 @@ use parent qw(SL::Controller::Base);
 
 use Rose::Object::MakeMethods::Generic
 (
- scalar => [ qw(type profile file all_profiles all_charsets sep_char all_sep_chars quote_char all_quote_chars escape_char all_escape_chars all_buchungsgruppen
+ scalar => [ qw(type profile file all_profiles all_charsets sep_char all_sep_chars quote_char all_quote_chars escape_char all_escape_chars all_buchungsgruppen all_units
                 import_status errors headers raw_data_headers info_headers data num_imported num_importable displayable_columns) ],
 );
 
@@ -84,7 +85,7 @@ sub action_download_sample {
 
   $file->fh->close;
 
-  $self->send_file($file->file_name);
+  $self->send_file($file->file_name, name => $file_name);
 }
 
 #
@@ -142,7 +143,10 @@ sub render_inputs {
             : $self->type eq 'parts'             ? $::locale->text('CSV import: parts and services')
             : die;
 
-  $self->all_buchungsgruppen(SL::DB::Manager::Buchungsgruppe->get_all_sorted);
+  if ($self->{type} eq 'parts') {
+    $self->all_buchungsgruppen(SL::DB::Manager::Buchungsgruppe->get_all_sorted);
+    $self->all_units(SL::DB::Manager::Unit->get_all_sorted);
+  }
 
   $self->setup_help;
 
index 5ae7bdd..ca9d22a 100644 (file)
@@ -83,7 +83,7 @@ sub init_settings {
 
   return { map { ( $_ => $self->controller->profile->get($_) ) } qw(apply_buchungsgruppe default_buchungsgruppe article_number_policy
                                                                     sellprice_places sellprice_adjustment sellprice_adjustment_type
-                                                                    shoparticle_if_missing parts_type) };
+                                                                    shoparticle_if_missing parts_type default_unit) };
 }
 
 sub init_all_cvar_configs {
@@ -312,6 +312,8 @@ sub check_unit {
 
   my $object = $entry->{object};
 
+  $object->unit($self->settings->{default_unit}) unless $object->unit;
+
   # Check whether or unit is valid.
   if (!$self->units_by->{name}->{ $object->unit }) {
     push @{ $entry->{errors} }, $::locale->text('Error: Unit missing or invalid');
@@ -412,39 +414,39 @@ sub setup_displayable_columns {
   $self->SUPER::setup_displayable_columns;
   $self->add_cvar_columns_to_displayable_columns;
 
-  $self->add_displayable_columns({ name => 'bin',                description => $::locale->text('Bin')                           },
-                                 { name => 'buchungsgruppen_id', description => $::locale->text('Buchungsgruppe (database ID)')  },
-                                 { name => 'buchungsgruppe',     description => $::locale->text('Buchungsgruppe (name)')         },
-                                 { name => 'description',        description => $::locale->text('Description')                   },
-                                 { name => 'drawing',            description => $::locale->text('Drawing')                       },
-                                 { name => 'ean',                description => $::locale->text('EAN')                           },
-                                 { name => 'formel',             description => $::locale->text('Formula')                       },
-                                 { name => 'gv',                 description => $::locale->text('Business Volume')               },
-                                 { name => 'has_sernumber',      description => $::locale->text('Has serial number')             },
-                                 { name => 'image',              description => $::locale->text('Image')                         },
-                                 { name => 'lastcost',           description => $::locale->text('Last Cost')                     },
-                                 { name => 'listprice',          description => $::locale->text('List Price')                    },
-                                 { name => 'make_X',             description => $::locale->text('Make (with X being a number)')  },
-                                 { name => 'microfiche',         description => $::locale->text('Microfiche')                    },
-                                 { name => 'model_X',            description => $::locale->text('Model (with X being a number)') },
-                                 { name => 'not_discountable',   description => $::locale->text('Not Discountable')              },
-                                 { name => 'notes',              description => $::locale->text('Notes')                         },
-                                 { name => 'obsolete',           description => $::locale->text('Obsolete')                      },
-                                 { name => 'onhand',             description => $::locale->text('On Hand')                       },
-                                 { name => 'partnumber',         description => $::locale->text('Part Number')                   },
-                                 { name => 'partsgroup_id',      description => $::locale->text('Partsgroup (database ID)')      },
-                                 { name => 'partsgroup',         description => $::locale->text('Partsgroup (name)')             },
-                                 { name => 'payment_id',         description => $::locale->text('Payment terms (database ID)')   },
-                                 { name => 'payment',            description => $::locale->text('Payment terms (name)')          },
-                                 { name => 'price_factor_id',    description => $::locale->text('Price factor (database ID)')    },
-                                 { name => 'price_factor',       description => $::locale->text('Price factor (name)')           },
-                                 { name => 'rop',                description => $::locale->text('ROP')                           },
-                                 { name => 'sellprice',          description => $::locale->text('Sellprice')                     },
-                                 { name => 'shop',               description => $::locale->text('Shopartikel')                   },
-                                 { name => 'type',               description => $::locale->text('Article type (see below)')      },
-                                 { name => 'unit',               description => $::locale->text('Unit')                          },
-                                 { name => 've',                 description => $::locale->text('Verrechnungseinheit')           },
-                                 { name => 'weight',             description => $::locale->text('Weight')                        },
+  $self->add_displayable_columns({ name => 'bin',                description => $::locale->text('Bin')                                                  },
+                                 { name => 'buchungsgruppen_id', description => $::locale->text('Buchungsgruppe (database ID)')                         },
+                                 { name => 'buchungsgruppe',     description => $::locale->text('Buchungsgruppe (name)')                                },
+                                 { name => 'description',        description => $::locale->text('Description')                                          },
+                                 { name => 'drawing',            description => $::locale->text('Drawing')                                              },
+                                 { name => 'ean',                description => $::locale->text('EAN')                                                  },
+                                 { name => 'formel',             description => $::locale->text('Formula')                                              },
+                                 { name => 'gv',                 description => $::locale->text('Business Volume')                                      },
+                                 { name => 'has_sernumber',      description => $::locale->text('Has serial number')                                    },
+                                 { name => 'image',              description => $::locale->text('Image')                                                },
+                                 { name => 'lastcost',           description => $::locale->text('Last Cost')                                            },
+                                 { name => 'listprice',          description => $::locale->text('List Price')                                           },
+                                 { name => 'make_X',             description => $::locale->text('Make (with X being a number)')                         },
+                                 { name => 'microfiche',         description => $::locale->text('Microfiche')                                           },
+                                 { name => 'model_X',            description => $::locale->text('Model (with X being a number)')                        },
+                                 { name => 'not_discountable',   description => $::locale->text('Not Discountable')                                     },
+                                 { name => 'notes',              description => $::locale->text('Notes')                                                },
+                                 { name => 'obsolete',           description => $::locale->text('Obsolete')                                             },
+                                 { name => 'onhand',             description => $::locale->text('On Hand')                                              },
+                                 { name => 'partnumber',         description => $::locale->text('Part Number')                                          },
+                                 { name => 'partsgroup_id',      description => $::locale->text('Partsgroup (database ID)')                             },
+                                 { name => 'partsgroup',         description => $::locale->text('Partsgroup (name)')                                    },
+                                 { name => 'payment_id',         description => $::locale->text('Payment terms (database ID)')                          },
+                                 { name => 'payment',            description => $::locale->text('Payment terms (name)')                                 },
+                                 { name => 'price_factor_id',    description => $::locale->text('Price factor (database ID)')                           },
+                                 { name => 'price_factor',       description => $::locale->text('Price factor (name)')                                  },
+                                 { name => 'rop',                description => $::locale->text('ROP')                                                  },
+                                 { name => 'sellprice',          description => $::locale->text('Sellprice')                                            },
+                                 { name => 'shop',               description => $::locale->text('Shopartikel')                                          },
+                                 { name => 'type',               description => $::locale->text('Article type (see below)')                             },
+                                 { name => 'unit',               description => $::locale->text('Unit (if missing or empty default unit will be used)') },
+                                 { name => 've',                 description => $::locale->text('Verrechnungseinheit')                                  },
+                                 { name => 'weight',             description => $::locale->text('Weight')                                               },
                                 );
 
   foreach my $language (@{ $self->all_languages }) {
diff --git a/SL/DB/Manager/Unit.pm b/SL/DB/Manager/Unit.pm
new file mode 100644 (file)
index 0000000..8b3c138
--- /dev/null
@@ -0,0 +1,21 @@
+package SL::DB::Manager::Unit;
+
+use strict;
+
+use SL::DB::Helper::Manager;
+use base qw(SL::DB::Helper::Manager);
+
+use SL::DB::Helper::Sorted;
+
+sub object_class { 'SL::DB::Unit' }
+
+__PACKAGE__->make_manager_methods;
+
+sub _sort_spec {
+  return ( default => [ 'sortkey', 1 ],
+           columns => { SIMPLE => 'ALL',
+                        name   => 'lower(name)',
+                      });
+}
+
+1;
index 55a190b..54b104d 100644 (file)
@@ -1,14 +1,9 @@
-# This file has been auto-generated only because it didn't exist.
-# Feel free to modify it at will; it will not be overwritten automatically.
-
 package SL::DB::Unit;
 
 use strict;
 
 use SL::DB::MetaSetup::Unit;
-
-# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
-__PACKAGE__->meta->make_manager_class;
+use SL::DB::Manager::Unit;
 
 __PACKAGE__->meta->add_relationships(
   base => {
index 924d211..5bfbe31 100644 (file)
@@ -558,6 +558,7 @@ $self->{texts} = {
   'Default output medium'       => 'Standardausgabekanal',
   'Default printer'             => 'Standarddrucker',
   'Default template format'     => 'Standardvorlagenformat',
+  'Default unit'                => 'Standardeinheit',
   'Default value'               => 'Standardwert',
   'Defaults saved.'             => 'Die Standardeinstellungen wurden gespeichert.',
   'Delete'                      => 'Löschen',
@@ -1970,6 +1971,7 @@ $self->{texts} = {
   'Unchecked custom variables will not appear in orders and invoices.' => 'Unmarkierte Variablen werden für diesen Artikel nicht in Aufträgen und Rechnungen angezeigt.',
   'Unfinished follow-ups'       => 'Nicht erledigte Wiedervorlagen',
   'Unit'                        => 'Einheit',
+  'Unit (if missing or empty default unit will be used)' => 'Einheit (falls nicht vorhanden oder leer wird die Standardeinheit benutzt)',
   'Unit missing.'               => 'Die Einheit fehlt.',
   'Unit of measure'             => 'Maßeinheit',
   'Units marked for deletion will be deleted upon saving.' => 'Einheiten, die zum L&ouml;schen markiert sind, werden beim Speichern gel&ouml;scht.',
index 129113e..4962981 100644 (file)
   [% L.select_tag('settings.apply_buchungsgruppe', L.options_for_select(opts, default => SELF.profile.get('apply_buchungsgruppe')), style => 'width: 300px') %]
  </td>
 </tr>
+
+<tr>
+ <th align="right" valign="top">[%- LxERP.t8('Default unit') %]:</th>
+ <td colspan="10" valign="top">
+  [% opts = L.options_for_select(SELF.all_units, title => 'name', value => 'name', default => SELF.profile.get('default_unit')) %]
+  [% L.select_tag('settings.default_unit', opts, style => 'width: 300px') %]
+ </td>
+</tr>