Revision ffd6f21b
Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt
t/background_job/convert_time_recordings.t | ||
---|---|---|
1 |
use Test::More tests => 18;
|
|
1 |
use Test::More tests => 20;
|
|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
... | ... | |
11 | 11 |
use Rose::DB::Object::Helpers qw(forget_related); |
12 | 12 |
|
13 | 13 |
use SL::DB::BackgroundJob; |
14 |
use SL::DB::DeliveryOrder; |
|
14 | 15 |
|
15 | 16 |
use_ok 'SL::BackgroundJob::ConvertTimeRecordings'; |
16 | 17 |
|
... | ... | |
218 | 219 |
clear_up(); |
219 | 220 |
|
220 | 221 |
|
222 |
######################################## |
|
223 |
# two time recordings, one with start/end one with date/duration |
|
224 |
######################################## |
|
225 |
$part = new_service(partnumber => 'Serv1', unit => 'min')->save; |
|
226 |
$customer = new_customer()->save; |
|
227 |
|
|
228 |
@time_recordings = (); |
|
229 |
push @time_recordings, new_time_recording( |
|
230 |
start_time => DateTime->new(year => 2021, month => 4, day => 19, hour => 10, minute => 10), |
|
231 |
end_time => DateTime->new(year => 2021, month => 4, day => 19, hour => 11, minute => 10), |
|
232 |
customer => $customer, |
|
233 |
part => $part, |
|
234 |
)->save; |
|
235 |
|
|
236 |
push @time_recordings, new_time_recording( |
|
237 |
date => DateTime->new(year => 2021, month => 4, day => 19), |
|
238 |
duration => 120, |
|
239 |
start_time => undef, |
|
240 |
end_time => undef, |
|
241 |
customer => $customer, |
|
242 |
part => $part, |
|
243 |
)->save; |
|
244 |
|
|
245 |
%data = ( |
|
246 |
link_project => 0, |
|
247 |
from_date => '01.04.2021', |
|
248 |
to_date => '30.04.2021', |
|
249 |
); |
|
250 |
$db_obj = SL::DB::BackgroundJob->new(); |
|
251 |
$db_obj->set_data(%data); |
|
252 |
$job = SL::BackgroundJob::ConvertTimeRecordings->new; |
|
253 |
$ret = $job->run($db_obj); |
|
254 |
|
|
255 |
my $dos = SL::DB::Manager::DeliveryOrder->get_all(where => [customer_id => $customer->id]); |
|
256 |
is($dos->[0]->items->[0]->qty*1, 180/60, 'date/duration and start/end: qty in delivery order'); |
|
257 |
is($dos->[0]->items->[0]->base_qty*1, 180, 'date/duration and start/end2: base_qty in delivery order'); |
|
258 |
|
|
259 |
clear_up(); |
|
260 |
|
|
261 |
|
|
221 | 262 |
######################################## |
222 | 263 |
|
223 | 264 |
$::locale = $old_locale; |
Auch abrufbar als: Unified diff
Zeiterfassung: Unit-Test Eintrag mit Datum/Dauer