Revision 3f24ab6b
Von Bernd Bleßmann vor etwa 9 Jahren hinzugefügt
SL/Helper/DateTime.pm | ||
---|---|---|
82 | 82 |
return $self->truncate(to => 'month')->add(months => 1)->subtract(days => 1); |
83 | 83 |
} |
84 | 84 |
|
85 |
sub next_workday { |
|
86 |
my ($self, %params) = @_; |
|
87 |
|
|
88 |
my $extra_days = $params{extra_days} // 1; |
|
89 |
$self->add(days => $extra_days); |
|
90 |
|
|
91 |
my $day_of_week = $self->day_of_week; |
|
92 |
$self->add(days => (8 - $day_of_week)) if $day_of_week >= 6; |
|
93 |
|
|
94 |
return $self; |
|
95 |
} |
|
96 |
|
|
85 | 97 |
1; |
86 | 98 |
|
87 | 99 |
__END__ |
... | ... | |
131 | 143 |
Sets the object to the last day of object's month at midnight. Returns |
132 | 144 |
the object itself. |
133 | 145 |
|
146 |
=item C<next_workday %params> |
|
147 |
|
|
148 |
Sets the object to the next workday. The recognized parameter is: |
|
149 |
|
|
150 |
=over 2 |
|
151 |
|
|
152 |
=item * C<extra_days> - optional: If C<extra_days> is given, then |
|
153 |
that amount of days is added to the objects date and if the resulting |
|
154 |
date is not a workday, the object is set to the next workday. |
|
155 |
Defaults to 1. |
|
156 |
|
|
157 |
=back |
|
158 |
|
|
159 |
Returns the object itself. |
|
160 |
|
|
134 | 161 |
=back |
135 | 162 |
|
136 | 163 |
=head1 AUTHOR |
SL/OE.pm | ||
---|---|---|
876 | 876 |
$form->{useasnew} = 1 if $is_collective_order == 1; |
877 | 877 |
|
878 | 878 |
if (!$form->{id}) { |
879 |
my $extra_days = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1; |
|
880 |
my $next_workday = DateTime->today_local->add(days => $extra_days); |
|
881 |
my $day_of_week = $next_workday->day_of_week; |
|
882 |
|
|
883 |
$next_workday->add(days => (8 - $day_of_week)) if $day_of_week >= 6; |
|
884 |
|
|
879 |
my $extra_days = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1; |
|
880 |
$form->{reqdate} = DateTime->today_local->next_workday(extra_days => $extra_days)->to_kivitendo; |
|
885 | 881 |
$form->{transdate} = DateTime->today_local->to_kivitendo; |
886 |
$form->{reqdate} = $next_workday->to_kivitendo; |
|
887 | 882 |
} |
888 | 883 |
|
889 | 884 |
# get default accounts |
bin/mozilla/oe.pl | ||
---|---|---|
1667 | 1667 |
if ( $form->{reqdate} && $form->{id} ) { |
1668 | 1668 |
my $saved_order = OE->retrieve_simple(id => $form->{id}); |
1669 | 1669 |
if ( $saved_order && $saved_order->{reqdate} eq $form->{reqdate} && $saved_order->{transdate} eq $form->{transdate} ) { |
1670 |
my $extra_days = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1; |
|
1671 |
my $next_workday = DateTime->today_local->add(days => $extra_days); |
|
1672 |
my $day_of_week = $next_workday->day_of_week; |
|
1673 |
|
|
1674 |
$next_workday->add(days => (8 - $day_of_week)) if $day_of_week >= 6; |
|
1675 |
|
|
1670 |
my $extra_days = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1; |
|
1671 |
$form->{reqdate} = DateTime->today_local->next_workday(extra_days => $extra_days)->to_kivitendo; |
|
1676 | 1672 |
$form->{transdate} = DateTime->today_local->to_kivitendo; |
1677 |
$form->{reqdate} = $next_workday->to_kivitendo; |
|
1678 | 1673 |
} |
1679 | 1674 |
} |
1680 | 1675 |
|
Auch abrufbar als: Unified diff
Berechnung des nächsten Arbeitstages aus oe.pl und OE.pm in DateTime-Helper …
… verschoben, damit der Code nicht doppelt in OE.pm und oe.pl ist und auch von
woanders verwendet werden kann.