Revision 85d21849
Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt
SL/BackgroundJob/ConvertTimeRecordings.pm | ||
---|---|---|
79 | 79 |
or => [booked => 0, booked => undef], |
80 | 80 |
%customer_where], |
81 | 81 |
with_objects => ['customer']); |
82 |
|
|
82 | 83 |
# no time recordings at all ? -> better exit here before iterating a empty hash |
83 | 84 |
# return undef or message unless ref $time_recordings->[0] eq SL::DB::Manager::TimeRecording; |
85 |
|
|
84 | 86 |
my %time_recordings_by_customer_id; |
85 |
# push @{ $time_recordings_by_customer_id{$_->customer_id} }, $_ for @$time_recordings; |
|
86 |
# loop over all entries and add default or user defined params: |
|
87 |
|
|
88 |
for my $source_entry (@$time_recordings) { |
|
89 |
# set user defaults for processing |
|
90 |
$source_entry->{$_} = $self->$_ for qw(rounding link_project); |
|
91 |
foreach (qw(project_id parts_id)) { |
|
92 |
$source_entry->{$_} = $self->{$_} if length ($self->{$_}); |
|
93 |
} |
|
94 |
push @{ $time_recordings_by_customer_id{$source_entry->customer_id} }, $source_entry; |
|
95 |
} |
|
87 |
push @{ $time_recordings_by_customer_id{$_->customer_id} }, $_ for @$time_recordings; |
|
88 |
|
|
89 |
my %convert_params = map { $_ => $data->{$_} } qw(rounding link_project part_id project_id); |
|
90 |
|
|
96 | 91 |
my @donumbers; |
97 | 92 |
foreach my $customer_id (keys %time_recordings_by_customer_id) { |
98 | 93 |
my $do; |
99 | 94 |
if (!eval { |
100 |
$do = SL::DB::DeliveryOrder->new_from_time_recordings($time_recordings_by_customer_id{$customer_id}); |
|
95 |
$do = SL::DB::DeliveryOrder->new_from_time_recordings($time_recordings_by_customer_id{$customer_id}, %convert_params);
|
|
101 | 96 |
1; |
102 | 97 |
}) { |
103 | 98 |
$::lxdebug->message(LXDebug->WARN(), |
SL/DB/DeliveryOrder.pm | ||
---|---|---|
207 | 207 |
# - merge same descriptions (todo) |
208 | 208 |
# |
209 | 209 |
|
210 |
### config
|
|
211 |
my $default_partnummer = 6;
|
|
212 |
my $default_part_id = SL::DB::Manager::Part->find_by(partnumber => $default_partnummer)->id;
|
|
210 |
my $default_part_id = $params{default_part_id} ? $params{default_part_id}
|
|
211 |
: $params{default_partnumber} ? SL::DB::Manager::Part->find_by(partnumber => $params{default_partnumber})->id
|
|
212 |
: undef;
|
|
213 | 213 |
|
214 | 214 |
# check parts and collect entries |
215 | 215 |
my %part_by_part_id; |
... | ... | |
227 | 227 |
} |
228 | 228 |
|
229 | 229 |
my $date = $source->start_time->to_kivitendo; |
230 |
$entries->{$part_id}->{$date}->{duration} += $source->{rounding}
|
|
230 |
$entries->{$part_id}->{$date}->{duration} += $params{rounding}
|
|
231 | 231 |
? nhimult(0.25, ($source->duration_in_hours)) |
232 | 232 |
: _round_total($source->duration_in_hours); |
233 | 233 |
# add content if not already in description |
Auch abrufbar als: Unified diff
Zeiterfassung: Parameter f. Konvertierung in params übergeben