From: Bernd Bleßmann Date: Wed, 7 Nov 2018 10:15:04 +0000 (+0100) Subject: Inventur: Schwellwert in Mandantenkonfig. für Warnung bei Mengenabweichung X-Git-Tag: release-3.5.4~238 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6c20bff1fde66612b803b2716589f97b1441612a;p=kivitendo-erp.git Inventur: Schwellwert in Mandantenkonfig. für Warnung bei Mengenabweichung In der Mandantenkonfiguration kann ein Mengenschwellwert eingegeben werden. Wenn die bei der Inventur gezählte/eingegebene Zielmenge mehr als dieser Schwellwert von der Menge in der Datenbank abweicht, dann wird eine Warnung angezeigt. Hintergrund: Mitarbeiter lesen den Artikel mit einem Barcode-Scanner ein und vergessen manchmal, die vorher eingegebene Menge zu speichern. Dann wird die Artikelnummer oder EAN in das Mengenfeld geschrieben und ein "Enter" ausgelöst. Dann ist die Zielmenge sehr groß und falsch. Das kann damit verhindert bzw. abgeschwächt werden. --- diff --git a/SL/Controller/Inventory.pm b/SL/Controller/Inventory.pm index 792aa2c9b..b417f69ce 100644 --- a/SL/Controller/Inventory.pm +++ b/SL/Controller/Inventory.pm @@ -30,13 +30,13 @@ use Rose::Object::MakeMethods::Generic ( __PACKAGE__->run_before('_check_auth'); __PACKAGE__->run_before('_check_warehouses'); -__PACKAGE__->run_before('load_part_from_form', only => [ qw(stock_in part_changed mini_stock stock stocktaking_part_changed save_stocktaking) ]); -__PACKAGE__->run_before('load_unit_from_form', only => [ qw(stock_in part_changed mini_stock stock stocktaking_part_changed save_stocktaking) ]); -__PACKAGE__->run_before('load_wh_from_form', only => [ qw(stock_in warehouse_changed stock stocktaking save_stocktaking) ]); -__PACKAGE__->run_before('load_bin_from_form', only => [ qw(stock_in stock stocktaking save_stocktaking) ]); +__PACKAGE__->run_before('load_part_from_form', only => [ qw(stock_in part_changed mini_stock stock stocktaking_part_changed stocktaking_get_warn_qty_threshold save_stocktaking) ]); +__PACKAGE__->run_before('load_unit_from_form', only => [ qw(stock_in part_changed mini_stock stock stocktaking_part_changed stocktaking_get_warn_qty_threshold save_stocktaking) ]); +__PACKAGE__->run_before('load_wh_from_form', only => [ qw(stock_in warehouse_changed stock stocktaking stocktaking_get_warn_qty_threshold save_stocktaking) ]); +__PACKAGE__->run_before('load_bin_from_form', only => [ qw(stock_in stock stocktaking stocktaking_get_warn_qty_threshold save_stocktaking) ]); __PACKAGE__->run_before('set_target_from_part', only => [ qw(part_changed) ]); __PACKAGE__->run_before('mini_stock', only => [ qw(stock_in mini_stock) ]); -__PACKAGE__->run_before('sanitize_target', only => [ qw(stock_usage stock_in warehouse_changed part_changed stocktaking stocktaking_part_changed save_stocktaking) ]); +__PACKAGE__->run_before('sanitize_target', only => [ qw(stock_usage stock_in warehouse_changed part_changed stocktaking stocktaking_part_changed stocktaking_get_warn_qty_threshold save_stocktaking) ]); __PACKAGE__->run_before('set_layout'); sub action_stock_in { @@ -603,6 +603,34 @@ sub action_stocktaking_journal { $self->prepare_stocktaking_report(full => 1); $self->report_generator_list_objects(report => $self->{report}, objects => $self->stocktaking_models->get); } + +sub action_stocktaking_get_warn_qty_threshold { + my ($self) = @_; + + return $_[0]->render(\ !!0, { type => 'text' }) if $::form->{target_qty} eq ''; + return $_[0]->render(\ !!0, { type => 'text' }) if 0 == $::instance_conf->get_stocktaking_qty_threshold; + + my $target_qty = $::form->parse_amount(\%::myconfig, $::form->{target_qty}); + my $stocked_qty = _get_stocked_qty($self->part, + warehouse_id => $self->warehouse->id, + bin_id => $self->bin->id, + chargenumber => $::form->{chargenumber}, + bestbefore => $::form->{bestbefore},); + my $stocked_qty_in_form_units = $self->part->unit_obj->convert_to($stocked_qty, $self->unit); + my $qty = $target_qty - $stocked_qty_in_form_units; + $qty = abs($qty); + + my $warn; + if ($qty > $::instance_conf->get_stocktaking_qty_threshold) { + $warn = t8('The target quantity of #1 differs more than the threshold quantity of #2.', + $::form->{target_qty} . " " . $self->unit->name, + $::form->format_amount(\%::myconfig, $::instance_conf->get_stocktaking_qty_threshold, 2)); + $warn .= "\n"; + $warn .= t8('Choose "continue" if you want to use this value. Choose "cancel" otherwise.'); + } + return $_[0]->render(\ $warn, { type => 'text' }); +} + #================================================================ sub _check_auth { @@ -930,6 +958,7 @@ sub setup_stock_stocktaking_action_bar { $bar->add( action => [ t8('Save'), + checks => [ 'kivi.Inventory.check_stocktaking_qty_threshold' ], call => [ 'kivi.Inventory.save_stocktaking' ], accesskey => 'enter', ], @@ -1016,9 +1045,16 @@ and the current employee. The history is displayed via javascript. This action is called after the user selected or changed the part. +=item C + +This action checks if a warning should be shown and returns the warning text via +ajax. The warning will be shown if the given target value is greater than the +threshold given in the client configuration. + =item C This is a method to check if actions are called from stocktaking form. +This actions should contain "stocktaking" in their name. =back diff --git a/SL/DB/MetaSetup/Default.pm b/SL/DB/MetaSetup/Default.pm index c994f463d..1dff040f3 100644 --- a/SL/DB/MetaSetup/Default.pm +++ b/SL/DB/MetaSetup/Default.pm @@ -142,6 +142,7 @@ __PACKAGE__->meta->columns( sqnumber => { type => 'text' }, stocktaking_bin_id => { type => 'integer' }, stocktaking_cutoff_date => { type => 'date' }, + stocktaking_qty_threshold => { type => 'numeric', default => '0', precision => 25, scale => 5 }, stocktaking_warehouse_id => { type => 'integer' }, taxnumber => { type => 'text' }, templates => { type => 'text' }, diff --git a/js/kivi.Inventory.js b/js/kivi.Inventory.js index 64e877fb0..cf5bdbe07 100644 --- a/js/kivi.Inventory.js +++ b/js/kivi.Inventory.js @@ -52,6 +52,28 @@ namespace('kivi.Inventory', function(ns) { $('#already_counted_dialog').dialog("close"); }; + ns.check_stocktaking_qty_threshold = function() { + var data = $('#stocktaking_form').serializeArray(); + data.push({ name: 'action', value: 'Inventory/stocktaking_get_warn_qty_threshold' }); + + var warn = false; + $.ajax({ + url: 'controller.pl', + data: data, + method: "GET", + async: false, + dataType: 'text', + success: function(val) { + warn = val; + } + }); + + if (warn) { + return confirm(warn); + } else { + return true; + } + }; }); $(function(){ diff --git a/locale/de/all b/locale/de/all index 47a9da13d..9a3d123cc 100755 --- a/locale/de/all +++ b/locale/de/all @@ -600,6 +600,7 @@ $self->{texts} = { 'Check on purchase invoice' => 'Prüfen bei Einkaufsrechnung', 'Check on sales invoice' => 'Prüfen bei Verkaufsrechnung', 'Checks' => 'Schecks', + 'Choose "continue" if you want to use this value. Choose "cancel" otherwise.' => 'Wählen Sie "Ok" um diesen Wert zu übernehmen. Andernfalls wählen Sie "Abbrechen".', 'Choose Customer' => 'Endkunde wählen:', 'Choose Outputformat' => 'Ausgabeformat auswählen...', 'Choose Vendor' => 'Händler wählen', @@ -1566,6 +1567,7 @@ $self->{texts} = { 'If searching a part from a document and no part is found then offer to create a new part.' => 'Wenn bei der Artikelsuche aus einem Dokument heraus kein Artikel gefunden wird, dann wird ermöglicht, von dort aus einen neuen Artikel anzulegen.', 'If the article type is set to \'mixed\' then a column called \'part_type\' or called \'pclass\' must be present.' => 'Falls der Artikeltyp auf \'mixed\' gesetzt ist muss entweder eine Spalte \'part_type\' oder \'pclass\' im Import vorhanden sein', 'If the automatic creation of invoices for fees and interest is switched on for a dunning level then the following accounts will be used for the invoice.' => 'Wenn das automatische Erstellen einer Rechnung über Mahngebühren und Zinsen für ein Mahnlevel aktiviert ist, so werden die folgenden Konten für die Rechnung benutzt.', + 'If the counted quantity differs more than this threshold from the quantity in the database, a warning will be shown. Set to 0 to switch of this feature.' => 'Wenn die gezählte Menge mehr als dieser Schwellwert von der Menge in der Datenbank abweicht, wird eine Warnmeldung angezeigt. Setzen Sie den Schwellwert auf 0, um dieses Feature abzuschalten.', 'If the database user listed above does not have the right to create a database then enter the name and password of the superuser below:' => 'Falls der oben genannte Datenbankbenutzer nicht die Berechtigung zum Anlegen neuer Datenbanken hat, so können Sie hier den Namen und das Passwort des Datenbankadministratoraccounts angeben:', 'If the default transfer out always succeed use this bin for negative stock quantity.' => 'Standardlagerplatz für Auslagern ohne Prüfung auf Bestand', 'If yes, delivery order positions are considered "delivered" only if they have been stocked out of the inventory. Otherwise saving the delivery order is considered delivered.' => 'Wenn diese Option aktiviert ist, gelten Lieferscheinpositionen nur dann als geliefert wenn sie im Lieferschein ausgelagert wurden, und die Ware aus dem Lager ausgebucht wurde. Andernfalls gilt das Speichern des Lieferscheins als Lieferung.', @@ -3365,6 +3367,7 @@ $self->{texts} = { 'The subject is missing.' => 'Der Betreff fehlt.', 'The tables for user management and authentication do not exist. They will be created in the next step in the following database:' => 'Die Tabellen zum Speichern der Benutzerdaten und zur Benutzerauthentifizierung wurden nicht gefunden. Sie werden in der folgenden Datenbank angelegt:', 'The tabulator character' => 'Das Tabulator-Symbol', + 'The target quantity of #1 differs more than the threshold quantity of #2.' => 'Die Abweichung der Zielmenge #1 ist größer als der Mengenschwellwert #2.', 'The task server does not appear to be running.' => 'Der Task-Server scheint nicht zu laufen.', 'The task server is already running.' => 'Der Task-Server läuft bereits.', 'The task server is not running at the moment but needed for this module' => 'Der Taskserver wird für dieses Modul benötigt, läuft aber im Moment nicht.', @@ -3531,6 +3534,7 @@ $self->{texts} = { 'This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?' => 'Dies wird die Rechnung nicht mehr als offen anzeigen, auch wenn der unbezahlte Betrag nicht dem Rechnungsbetrag entspricht. Fortfahren?', 'This will set an exact price.' => 'Diese Option setzt einen festen Preis.', 'Three Options:' => 'Drei Optionen:', + 'Threshold for warning on quantity difference' => 'Schwellwert für Warnung bei Mengenabweichung', 'Time' => 'Zeit', 'Time Format' => 'Uhrzeitformat', 'Time and price estimate' => 'Zeit- und Preisschätzung', diff --git a/locale/en/all b/locale/en/all index 1eed48d5c..c2ee36627 100644 --- a/locale/en/all +++ b/locale/en/all @@ -600,6 +600,7 @@ $self->{texts} = { 'Check on purchase invoice' => '', 'Check on sales invoice' => '', 'Checks' => '', + 'Choose "continue" if you want to use this value. Choose "cancel" otherwise.' => '', 'Choose Customer' => '', 'Choose Outputformat' => '', 'Choose Vendor' => '', @@ -1566,6 +1567,7 @@ $self->{texts} = { 'If searching a part from a document and no part is found then offer to create a new part.' => '', 'If the article type is set to \'mixed\' then a column called \'part_type\' or called \'pclass\' must be present.' => '', 'If the automatic creation of invoices for fees and interest is switched on for a dunning level then the following accounts will be used for the invoice.' => '', + 'If the counted quantity differs more than this threshold from the quantity in the database, a warning will be shown. Set to 0 to switch of this feature.' => '', 'If the database user listed above does not have the right to create a database then enter the name and password of the superuser below:' => '', 'If the default transfer out always succeed use this bin for negative stock quantity.' => '', 'If yes, delivery order positions are considered "delivered" only if they have been stocked out of the inventory. Otherwise saving the delivery order is considered delivered.' => '', @@ -3364,6 +3366,7 @@ $self->{texts} = { 'The subject is missing.' => '', 'The tables for user management and authentication do not exist. They will be created in the next step in the following database:' => '', 'The tabulator character' => '', + 'The target quantity of #1 differs more than the threshold quantity of #2.' => '', 'The task server does not appear to be running.' => '', 'The task server is already running.' => '', 'The task server is not running at the moment but needed for this module' => '', @@ -3530,6 +3533,7 @@ $self->{texts} = { 'This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?' => '', 'This will set an exact price.' => '', 'Three Options:' => '', + 'Threshold for warning on quantity difference' => '', 'Time' => '', 'Time Format' => '', 'Time and price estimate' => '', diff --git a/sql/Pg-upgrade2/add_stocktaking_qty_threshold_client_config_default.sql b/sql/Pg-upgrade2/add_stocktaking_qty_threshold_client_config_default.sql new file mode 100644 index 000000000..a0393650e --- /dev/null +++ b/sql/Pg-upgrade2/add_stocktaking_qty_threshold_client_config_default.sql @@ -0,0 +1,5 @@ +-- @tag: add_stocktaking_qty_threshold_client_config_default +-- @description: Konfigurations-Option für Mengen-Schwellwert zur Inventur +-- @depends: add_stocktaking_preselects_client_config_default + +ALTER TABLE defaults ADD COLUMN stocktaking_qty_threshold NUMERIC(25,5) DEFAULT 0; diff --git a/templates/webpages/client_config/_stocktaking.html b/templates/webpages/client_config/_stocktaking.html index 6306f5c6c..d95d2a51f 100644 --- a/templates/webpages/client_config/_stocktaking.html +++ b/templates/webpages/client_config/_stocktaking.html @@ -35,5 +35,14 @@ + + [% LxERP.t8('Threshold for warning on quantity difference') %] + [% L.input_tag('defaults.stocktaking_qty_threshold_as_number', SELF.defaults.stocktaking_qty_threshold_as_number, size=15, class="numeric") %] + + [% LxERP.t8('If the counted quantity differs more than this threshold from the quantity in the database, a warning will be shown. Set to 0 to switch of this feature.') %]
+ + + +