X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FTimeRecording.pm;h=575e219fbd176a758ef45f76569f1803686d7596;hb=2436f6e94ca447e5c6f5c3002e5cd6767d025173;hp=9b1a2e351dd9df83b15f9c2ff1e5d00a7fe39f2c;hpb=33823a7743de188f6e37802716ee5bd877a3ec5f;p=kivitendo-erp.git diff --git a/SL/DB/TimeRecording.pm b/SL/DB/TimeRecording.pm index 9b1a2e351..575e219fb 100644 --- a/SL/DB/TimeRecording.pm +++ b/SL/DB/TimeRecording.pm @@ -38,6 +38,11 @@ sub validate { push @errors, t8('Employee must not be empty.') if !$self->employee_id; push @errors, t8('Description must not be empty.') if !$self->description; push @errors, t8('Start time must be earlier than end time.') if $self->is_time_in_wrong_order; + push @errors, t8('Assigned order must be a sales order.') if $self->order_id && 'sales_order' ne $self->order->type; + push @errors, t8('Customer of assigned order must match customer.') if $self->order_id && $self->order->customer_id != $self->customer_id; + push @errors, t8('Customer of assigned project must match customer.') if $self->project_id && $self->project->customer_id && $self->project->customer_id != $self->customer_id; + push @errors, t8('Project of assigned order must match assigned project.') + if $self->project_id && $self->order_id && $self->order->globalproject_id && $self->project_id != $self->order->globalproject_id; my $conflict = $self->is_time_overlapping; push @errors, t8('Entry overlaps with "#1".', $conflict->displayable_times) if $conflict; @@ -115,11 +120,19 @@ sub is_duration_used { sub displayable_times { my ($self) = @_; - # placeholder - my $ph = $::locale->format_date_object(DateTime->new(year => 1111, month => 11, day => 11, hour => 11, minute => 11), precision => 'minute'); - $ph =~ s{1}{-}g; + my $text; - return ($self->start_time_as_timestamp||$ph) . ' - ' . ($self->end_time_as_timestamp||$ph); + if ($self->is_duration_used) { + $text = $self->date_as_date . ': ' . ($self->duration_as_duration_string || '--:--'); + + } else { + # placeholder + my $ph = $::locale->format_date_object(DateTime->new(year => 1111, month => 11, day => 11, hour => 11, minute => 11), precision => 'minute'); + $ph =~ s{1}{-}g; + $text = ($self->start_time_as_timestamp||$ph) . ' - ' . ($self->end_time_as_timestamp||$ph); + } + + return $text; } 1;