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
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;
}
}
'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',
'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',
<tr>
<td align="right">[% LxERP.t8('Sales Quotation valid interval') %]</td>
<td>[% L.input_tag('defaults.reqdate_interval', LxERP.format_amount(SELF.defaults.reqdate_interval, 0), style=style) %]</td>
- <td>[% 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).') %]</td>
+ <td>[% 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.') %]</td>
</tr>
</table>
</div>