From 459b3c8dd86d8aa35e5b2cdff0e3e8c42216a7e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 5 May 2021 17:18:54 +0200 Subject: [PATCH] Zeiterfassung: Konvertierung: POD-Update und Kosmetik --- SL/BackgroundJob/ConvertTimeRecordings.pm | 65 ++++++++++++++++------- SL/DB/DeliveryOrder.pm | 16 +++++- 2 files changed, 59 insertions(+), 22 deletions(-) diff --git a/SL/BackgroundJob/ConvertTimeRecordings.pm b/SL/BackgroundJob/ConvertTimeRecordings.pm index e02603833..75c09ad34 100644 --- a/SL/BackgroundJob/ConvertTimeRecordings.pm +++ b/SL/BackgroundJob/ConvertTimeRecordings.pm @@ -38,11 +38,11 @@ sub run { my %customer_where; %customer_where = ('customer_id' => $self->params->{customer_ids}) if scalar @{ $self->params->{customer_ids} }; - my $time_recordings = SL::DB::Manager::TimeRecording->get_all(where => [date => { ge_lt => [ $self->params->{from_date}, $self->params->{to_date} ]}, - or => [booked => 0, booked => undef], - '!duration' => 0, - '!duration' => undef, - %customer_where]); + my $time_recordings = SL::DB::Manager::TimeRecording->get_all(where => [date => { ge_lt => [ $self->params->{from_date}, $self->params->{to_date} ]}, + or => [booked => 0, booked => undef], + '!duration' => 0, + '!duration' => undef, + %customer_where]); return t8('No time recordings to convert') if scalar @$time_recordings == 0; @@ -257,7 +257,7 @@ sub get_order_for_time_recording { if (!$tr->order_id) { # check project my $project_id; - #$project_id = $self->overide_project_id; + #$project_id = $self->override_project_id; $project_id = $self->params->{project_id}; $project_id ||= $tr->project_id; #$project_id ||= $self->default_project_id; @@ -300,7 +300,7 @@ sub get_order_for_time_recording { # check part my $part_id; - #$part_id = $self->overide_part_id; + #$part_id = $self->override_part_id; $part_id ||= $tr->part_id; #$part_id ||= $self->default_part_id; $part_id ||= $self->params->{part_id}; @@ -358,10 +358,6 @@ sub log_error { 1; -# possible data -# from_date: 01.12.2020 -# to_date: 15.12.2020 -# customernumbers: [1,2,3] __END__ =pod @@ -383,7 +379,13 @@ Cnew_from_time_recordings>). 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. +fails. + +Example: + + from_date: 01.12.2020 + to_date: 15.12.2020 + customernumbers: [1,2,3] =over 4 @@ -408,29 +410,29 @@ to_date: 15.12.2020 =item C An array with the customer numbers for which time recordings should -be collected. If not given, time recordings for customers are -collected. This is the default. +be collected. If not given, time recordings for all customers are +collected. 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. +book the times if no part is set in the time recording entry. =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, +the times will be rounded up to the 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 links the created delivery order with with the order +If set the job links the created delivery order with the order given in the time recording entry. If there is no order given, then -it tries to find an order with with the current customer and project -number and tries to do as much automatic workflow processing as the +it tries to find an order with the current customer and project +number. It 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 order which qualifies as a predecessor. @@ -450,11 +452,34 @@ 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 TODO + +=over 4 + +=item * part and project parameters as numbers + +Add parameters to give part and project not with their ids, but with their +numbers. E.g. (default_/override_)part_number, +(default_/override_)project_number. + +=item * part and project parameters override and default + +In the moment, the part id given as parameter is used as the default value. +This means, it will be used if there is no part in the time recvording entry. + +The project id given is used as override parameter. It overrides the project +given in the time recording entry. + +To solve this, there should be parameters named override_part_id, +default_part_id, override_project_id and default_project_id. + + =back =head1 AUTHOR diff --git a/SL/DB/DeliveryOrder.pm b/SL/DB/DeliveryOrder.pm index f082db6ae..8a0ada7e1 100644 --- a/SL/DB/DeliveryOrder.pm +++ b/SL/DB/DeliveryOrder.pm @@ -191,7 +191,7 @@ sub new_from_time_recordings { # - ordered and summed by date # - each description goes to an ordered list # - (as time recording descriptions are formatted text by now, use stripped text) - # - merge same descriptions (todo) + # - merge same descriptions # my $default_part_id = $params{default_part_id} ? $params{default_part_id} @@ -434,7 +434,7 @@ Creates a new C instance from the time recordings given as C<$sources>. All time recording entries must belong to the same customer. Time recordings are sorted by article and date. For each article a new delivery order item is created. If no article is associated with an -entry, a default article will be used (hard coded). +entry, a default article will be used. Entries of the same date (for each article) are summed together and form a list entry in the long description of the item. @@ -451,6 +451,18 @@ C<%params> can include the following options: An optional hash reference. If it exists then it is used to set attributes of the newly created delivery order object. +=item C + +An optional C object. If it exists then it is used to +generate the delivery order from that via C. +The generated items are created from a suitable item of the related +order. If no suitable item is found, an exception is thrown. + +=item C + +An optional boolean value. If truish, then the durations of the time entries +are rounded up to the full quarters of an hour. + =back =item C -- 2.20.1