From ff49435544248198707e0ea661c40e365063a14a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 4 Feb 2015 14:16:56 +0100 Subject: [PATCH] =?utf8?q?Konfigurierbares=20Angebotsg=C3=BCltigkeits-Inte?= =?utf8?q?rvall:=20Arbeitstagspr=C3=BCfung=20nach=20Addieren?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Die Funktionsweise wurde so geändert, dass zuerst der hier angegebene Wert (oder 1, wenn kein Wert angegeben) zum aktuellen Datum addiert wird. Danach wird auf Wochenende geprüft und auf den nächsten Werktag justiert, sofern notwendig. --- SL/OE.pm | 12 +++++----- bin/mozilla/oe.pl | 23 +++++-------------- locale/de/all | 2 +- .../client_config/_posting_configuration.html | 2 +- 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/SL/OE.pm b/SL/OE.pm index 55e488346..ab4e8774b 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -850,14 +850,14 @@ sub retrieve { my $is_collective_order = scalar @ids; if (!$form->{id}) { - my $wday = (localtime(time))[6]; - my $next_workday = $wday == 5 ? 3 : $wday == 6 ? 2 : 1; + my $extra_days = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1; + my $next_workday = DateTime->today_local->add(days => $extra_days); + my $day_of_week = $next_workday->day_of_week; - # if we have a client configured interval for sales quotation, we add this - $next_workday += $::instance_conf->get_reqdate_interval if ($::instance_conf->get_reqdate_interval && - $form->{type} eq 'sales_quotation' ); + $next_workday->add(days => (8 - $day_of_week)) if $day_of_week >= 6; - $query_add = qq|, current_date AS transdate, date(current_date + interval '${next_workday} days') AS reqdate|; + $form->{transdate} = DateTime->today_local->to_kivitendo; + $form->{reqdate} = $next_workday->to_kivitendo; } # get default accounts diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index fd12a2d6e..e81cb48f8 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1637,25 +1637,14 @@ sub save_as_new { if ( $form->{reqdate} && $form->{id} ) { my $saved_order = OE->retrieve_simple(id => $form->{id}); if ( $saved_order && $saved_order->{reqdate} eq $form->{reqdate} && $saved_order->{transdate} eq $form->{transdate} ) { + my $extra_days = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1; + my $next_workday = DateTime->today_local->add(days => $extra_days); + my $day_of_week = $next_workday->day_of_week; - my $dbh = $form->get_standard_dbh; + $next_workday->add(days => (8 - $day_of_week)) if $day_of_week >= 6; - my $wday = (localtime(time))[6]; - my $next_workday = $wday == 5 ? 3 : $wday == 6 ? 2 : 1; - - # if we have a client configured interval for sales quotation, we add this - $next_workday += $::instance_conf->get_reqdate_interval if ($::instance_conf->get_reqdate_interval && - $form->{type} eq 'sales_quotation' ); - - my $query = 'SELECT - date(current_date + interval \''. $next_workday .' days\') AS reqdate, - date(current_date) AS transdate'; - my $ref = selectfirst_hashref_query($form, $dbh, $query); - - map( - { $form->{$_} = $ref->{$_} } - keys %{$ref} - ); + $form->{transdate} = DateTime->today_local->to_kivitendo; + $form->{reqdate} = $next_workday->to_kivitendo; } } diff --git a/locale/de/all b/locale/de/all index 8909686f9..d249ee0fb 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2903,7 +2903,6 @@ $self->{texts} = { 'Updating the client fields in the database "#1" on host "#2:#3" failed.' => 'Die Aktualisierung der Mandantenfelder in der Datenbank "#1" auf Host "#2:#3" schlug fehl.', 'Uploaded at' => 'Hochgeladen um', 'Uploaded on #1, size #2 kB' => 'Am #1 hochgeladen, Größe #2 kB', - 'Usally the sales quotation is valid until the next working day. This entry will be added to this date (i.e. 14, 28).' => 'Standardmässig ist ein Verkaufsangebot bis zum nächsten Werktag gültig. Dieses Intervall wird dann noch hinzugerechnet, bspw. nächster Werktag plus 14, 28 etc. .Daher sind Intervallwerte die durch 7 teilbar sind, sinnvoll.', 'Use As New' => 'Als neu verwenden', 'Use WebDAV Repository' => 'WebDAV-Ablage verwenden', 'Use existing templates' => 'Vorhandene Druckvorlagen verwenden', @@ -2923,6 +2922,7 @@ $self->{texts} = { 'Users with access' => 'Benutzer mit Zugriff', 'Users with access to this client' => 'Benutzer mit Zugriff auf diesen Mandanten', 'Users, Clients and User Groups' => 'Benutzer, Mandanten und Benutzergruppen', + 'Usually the sales quotation is valid until the next working day. If a value is set here then the quotation will be valid for at least that many days. The resulting date will be adjusted to the next working day if it ends up on a weekend.' => 'Standardmäßig ist ein Verkaufsangebot bis zum nächsten Werktag gültig. Ist hier ein Wert angegeben, so ist ein Angebot mindestens so viele Tage gültig. Sollte das dabei herauskommende Datum auf ein Wochenende fallen, so wird statt dessen der nachfolgende Arbeitstag genommen.', 'VAT ID' => 'UStdID-Nr', 'Valid' => 'Gültig', 'Valid from' => 'Gültig ab', diff --git a/templates/webpages/client_config/_posting_configuration.html b/templates/webpages/client_config/_posting_configuration.html index 2d4733dc7..4f2d31dfc 100644 --- a/templates/webpages/client_config/_posting_configuration.html +++ b/templates/webpages/client_config/_posting_configuration.html @@ -89,7 +89,7 @@ [% LxERP.t8('Sales Quotation valid interval') %] [% L.input_tag('defaults.reqdate_interval', LxERP.format_amount(SELF.defaults.reqdate_interval, 0), style=style) %] - [% LxERP.t8('Usally the sales quotation is valid until the next working day. This entry will be added to this date (i.e. 14, 28).') %] + [% LxERP.t8('Usually the sales quotation is valid until the next working day. If a value is set here then the quotation will be valid for at least that many days. The resulting date will be adjusted to the next working day if it ends up on a weekend.') %] -- 2.20.1