X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/0b780ffb90da061e2a75549bb471e15eb7a59630..80457526fe12b504d09c8ddf3db81c754c9938e2:/SL/BackgroundJob/ConvertTimeRecordings.pm diff --git a/SL/BackgroundJob/ConvertTimeRecordings.pm b/SL/BackgroundJob/ConvertTimeRecordings.pm index 810d9bccc..892e0d85c 100644 --- a/SL/BackgroundJob/ConvertTimeRecordings.pm +++ b/SL/BackgroundJob/ConvertTimeRecordings.pm @@ -30,6 +30,7 @@ sub run { my $data; $data = $db_obj->data_as_hash if $db_obj; + $self->{$_} = [] for qw(job_errors); # from/to date from data. Defaults to begining and end of last month. my $from_date; my $to_date; @@ -56,7 +57,6 @@ sub run { push @{ $time_recordings_by_customer_id{$_->customer_id} }, $_ for @$time_recordings; my @donumbers; - my $has_warnings; foreach my $customer_id (keys %time_recordings_by_customer_id) { my $do; if (!eval { @@ -65,7 +65,8 @@ sub run { }) { $::lxdebug->message(LXDebug->WARN(), "ConvertTimeRecordings: creating delivery order failed ($@) for time recording ids " . join ', ', map { $_->id } @{$time_recordings_by_customer_id{$customer_id}}); - $has_warnings = 1; + push @{ $self->{job_errors} }, "ConvertTimeRecordings: creating delivery order failed ($@) for time recording ids " . join ', ', map { $_->id } @{$time_recordings_by_customer_id{$customer_id}}; + } if ($do) { @@ -76,20 +77,25 @@ sub run { })) { $::lxdebug->message(LXDebug->WARN(), "ConvertTimeRecordings: saving delivery order failed for time recording ids " . join ', ', map { $_->id } @{$time_recordings_by_customer_id{$customer_id}}); - $has_warnings = 1; + push @{ $self->{job_errors} }, "ConvertTimeRecordings: saving delivery order failed for time recording ids " . join ', ', map { $_->id } @{$time_recordings_by_customer_id{$customer_id}}; } else { push @donumbers, $do->donumber; } } } - my $msg = t8('Number of deliveryorders created:'); + my $msg = t8('Number of delivery orders created:'); $msg .= ' '; $msg .= scalar @donumbers; $msg .= ' ('; $msg .= join ', ', @donumbers; $msg .= ').'; - $msg .= ' ' . t8('There are Warnings.') if $has_warnings; + # die if errors exists + if (@{ $self->{job_errors} }) { + $msg .= ' ' . t8('The following errors occurred:'); + $msg .= join "\n", @{ $self->{job_errors} }; + die $msg; + } return $msg; } @@ -119,6 +125,8 @@ Cnew_from_time_recordings>). =head1 CONFIGURATION Some data can be provided to configure this backgroung job. +If there is user data and it cannot be validated the background job +returns a error messages. =over 4 @@ -150,6 +158,45 @@ Example (format depends on your settings): customernumbers: [c1,22332,334343] +=item C + +The part id of a time based service which should be used to +book the times. If not set the clients config defaults is used. + +=item C + +If set the 0 no rounding of the times will be done otherwise +the times will be rounded up to th full quarters of an hour, +ie. 0.25h 0.5h 0.75h 1.25h ... +Defaults to rounding true (1). + +=item C + +If set the job tries to find a previous Order with the current +customer and project number and tries to do as much automatic +workflow processing as the UI. +Defaults to off. If set to true (1) the job will fail if there +is no Sales Orders which qualifies as a predecessor. +Conditions for a predeccesor: + + * Global project_id must match time_recording.project_id OR data.project_id + * Customer name must match time_recording.customer_id OR data.customernumbers + * The sales order must have at least one or more time related services + * The Project needs to be valid and active + +The job doesn't care if the Sales Order is already delivered or closed. +If the sales order is overdelivered some organisational stuff needs to be done. +The sales order may also already be closed, ie the amount is fully billed, but +the services are not yet fully delivered (simple case: 'Payment in advance'). + +Hint: take a look or extend the job CloseProjectsBelongingToClosedSalesOrder for +further automatisation of your organisational needs. + + +=item C + +Use this project_id instead of the project_id in the time recordings. + =back =head1 AUTHOR