Commit fce5def2 authored by Ruslan Zakirov's avatar Ruslan Zakirov
Browse files

fix and improve handling of Starts date

* fix for a problem of recent refactoring.

* Instead of StartImmediately admins can use
  Starts agreement. It has all options like
  other agreements have, but it has default
  value if not defined.
parent 1721793c
......@@ -347,6 +347,16 @@ sub Agreement {
my $meta = $RT::ServiceAgreements{'Levels'}{ $args{'Level'} };
return undef unless $meta;
if ( exists $meta->{'StartImmediately'} || !defined $meta->{'Starts'} ) {
$meta->{'Starts'} = {
delete $meta->{'StartImmediately'}
? ( )
: ( BusinessMinutes => 0 )
,
};
}
return undef unless $meta->{ $args{'Type'} };
my %res;
......@@ -359,10 +369,6 @@ sub Agreement {
return undef;
}
if ( defined $meta->{'StartImmediately'} ) {
$res{'StartImmediately'} = $meta->{'StartImmediately'};
}
if ( $args{'Time'} and my $tmp = $meta->{'OutOfHours'}{ $args{'Type'} } ) {
if ( $self->CalcBusinessHours( $meta, first_after => $args{'Time'} ) != $args{'Time'} ) {
foreach ( qw(RealMinutes BusinessMinutes) ) {
......@@ -393,10 +399,16 @@ sub Due {
my $res = $args{'Time'};
if ( defined $agreement->{'BusinessMinutes'} ) {
$res = $self->CalcBusinessHours(
$agreement,
add_seconds => $res, 60 * $agreement->{'BusinessMinutes'},
);
if ( $agreement->{'BusinessMinutes'} ) {
$res = $self->CalcBusinessHours(
$agreement,
add_seconds => $res,
60 * $agreement->{'BusinessMinutes'},
);
}
else {
$res = $self->CalcBusinessHours( $agreement, first_after => $res );
}
}
$res += 60 * $agreement->{'RealMinutes'}
if defined $agreement->{'RealMinutes'};
......@@ -406,16 +418,7 @@ sub Due {
sub Starts {
my $self = shift;
my %args = ( Level => undef, Time => undef, @_ );
my $agreement = $self->Agreement( %args );
return undef unless $agreement;
return $args{'Time'} if $agreement->{'StartImmediately'};
return $self->CalcBusinessHours(
$agreement, first_after => $args{'Time'},
);
return $self->Due( @_, Type => 'Starts' );
}
sub GetCustomField {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment