summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
780f79a)
This patch will, when appropriate, roll due dates forward by full weeks,
rather than single days.
Sponsored-by: Cheshire West and Chester Council
Sponsored-by: Cheshire East Council
Sponsored-by: Newcastle City Council
Sponsored-by: Sefton Council
Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
$unit ||= 'days'; # default days ?
my $dt;
$unit ||= 'days'; # default days ?
my $dt;
if ( $unit eq 'hours' ) {
# Fixed for legacy support. Should be set as a branch parameter
my $return_by_hour = 10;
if ( $unit eq 'hours' ) {
# Fixed for legacy support. Should be set as a branch parameter
my $return_by_hour = 10;
# days
$dt = $self->addDays($startdate, $add_duration);
}
# days
$dt = $self->addDays($startdate, $add_duration);
}
- } else { # Days or Datedue
+ } else { # Days, Datedue or Dayweek
# use straight days, then use calendar to push
# use straight days, then use calendar to push
- # the date to the next open day if Datedue
+ # the date to the next open day as appropriate
+ # if Datedue or Dayweek
$base_date->add_duration($days_duration);
$base_date->add_duration($days_duration);
- if ( $self->{days_mode} eq 'Datedue' ) {
- # Datedue, then use the calendar to push
+ if ( $self->{days_mode} eq 'Datedue' ||
+ $self->{days_mode} eq 'Dayweek') {
+ # Datedue or Dayweek, then use the calendar to push
# the date to the next open day if holiday
if ( $self->is_holiday($base_date) ) {
# the date to the next open day if holiday
if ( $self->is_holiday($base_date) ) {
+ my $dow = $base_date->day_of_week;
+ my $days = $days_duration->in_units('days');
+ my $push_amt = (
+ # We're using Dayweek useDaysMode option
+ $self->{days_mode} eq 'Dayweek' &&
+ # It's period based on weeks
+ $days % 7 == 0 &&
+ # It's not a permanently closed day
+ !$self->{weekly_closed_days}->[$dow] == 1
+ ) ? 7 : 1;
if ( $days_duration->is_negative() ) {
if ( $days_duration->is_negative() ) {
- $base_date = $self->prev_open_day($base_date);
+ $base_date = $self->prev_open_days($base_date, $push_amt);
- $base_date = $self->next_open_day($base_date);
+ $base_date = $self->next_open_days($base_date, $push_amt);
my $base_date = $dt->clone();
$base_date->add(days => $to_add);
my $base_date = $dt->clone();
$base_date->add(days => $to_add);
while ($self->is_holiday($base_date)) {
$base_date->add(days => $to_add);
}
while ($self->is_holiday($base_date)) {
$base_date->add(days => $to_add);
}