Revision a04a47b1
Von Tamino Steinert vor fast 2 Jahren hinzugefügt
SL/DB/DeliveryOrder/TypeData.pm | ||
---|---|---|
45 | 45 |
transfer => 'out', |
46 | 46 |
transnumber => 'sdonumber', |
47 | 47 |
}, |
48 |
changes => { |
|
49 |
get_new_reqdate => sub { |
|
50 |
DateTime->today_local->next_workday(extra_days => 1); |
|
51 |
} |
|
52 |
}, |
|
48 | 53 |
part_classification_query => [ "used_for_sale" => 1 ], |
49 | 54 |
rights => { |
50 | 55 |
edit => "sales_delivery_order_edit", |
... | ... | |
77 | 82 |
transfer => 'in', |
78 | 83 |
transnumber => 'pdonumber', |
79 | 84 |
}, |
85 |
changes => { |
|
86 |
get_new_reqdate => sub { |
|
87 |
DateTime->today_local->next_workday(extra_days => 1); |
|
88 |
} |
|
89 |
}, |
|
80 | 90 |
part_classification_query => [ "used_for_purchase" => 1 ], |
81 | 91 |
rights => { |
82 | 92 |
edit => "purchase_delivery_order_edit", |
... | ... | |
114 | 124 |
transfer => 'out', |
115 | 125 |
transnumber => 'sudonumber', |
116 | 126 |
}, |
127 |
changes => { |
|
128 |
get_new_reqdate => sub { |
|
129 |
DateTime->today_local->next_workday(extra_days => 1); |
|
130 |
} |
|
131 |
}, |
|
117 | 132 |
part_classification_query => [ "used_for_purchase" => 1 ], |
118 | 133 |
rights => { |
119 | 134 |
edit => "purchase_delivery_order_edit", |
... | ... | |
146 | 161 |
transfer => 'in', |
147 | 162 |
transnumber => 'rdonumber', |
148 | 163 |
}, |
164 |
changes => { |
|
165 |
get_new_reqdate => sub { |
|
166 |
DateTime->today_local->next_workday(extra_days => 1); |
|
167 |
} |
|
168 |
}, |
|
149 | 169 |
part_classification_query => [ "used_for_sale" => 1 ], |
150 | 170 |
rights => { |
151 | 171 |
edit => "sales_delivery_order_edit", |
SL/DB/Helper/TypeDataProxy.pm | ||
---|---|---|
23 | 23 |
_via("get3", [ "properties" ], @_); |
24 | 24 |
} |
25 | 25 |
|
26 |
sub changes { |
|
27 |
_via("get3", [ "changes" ], @_); |
|
28 |
} |
|
29 |
|
|
26 | 30 |
sub show_menu { |
27 | 31 |
_via("get3", [ "show_menu" ], @_); |
28 | 32 |
} |
SL/DB/Order/TypeData.pm | ||
---|---|---|
47 | 47 |
is_customer => 1, |
48 | 48 |
nr_key => "ordnumber", |
49 | 49 |
}, |
50 |
changes => { |
|
51 |
get_new_reqdate => sub { |
|
52 |
if ($::instance_conf->get_deliverydate_on) { |
|
53 |
return DateTime->today_local->next_workday( |
|
54 |
extra_days => $::instance_conf->get_delivery_date_interval()); |
|
55 |
} else { |
|
56 |
return ; |
|
57 |
} |
|
58 |
}, |
|
59 |
}, |
|
50 | 60 |
part_classification_query => [ "used_for_sale" => 1 ], |
51 | 61 |
rights => { |
52 | 62 |
edit => "sales_order_edit", |
... | ... | |
81 | 91 |
is_customer => 0, |
82 | 92 |
nr_key => "ordnumber", |
83 | 93 |
}, |
94 |
changes => { |
|
95 |
get_new_reqdate => sub { return; }, |
|
96 |
}, |
|
84 | 97 |
part_classification_query => [ "used_for_purchase" => 1 ], |
85 | 98 |
rights => { |
86 | 99 |
edit => "purchase_order_edit", |
... | ... | |
115 | 128 |
is_customer => 1, |
116 | 129 |
nr_key => "quonumber", |
117 | 130 |
}, |
131 |
changes => { |
|
132 |
get_new_reqdate => sub { |
|
133 |
if ($::instance_conf->get_reqdate_on) { |
|
134 |
return DateTime->today_local->next_workday( |
|
135 |
extra_days => $::instance_conf->get_reqdate_interval()); |
|
136 |
} else { |
|
137 |
return ; |
|
138 |
} |
|
139 |
}, |
|
140 |
}, |
|
118 | 141 |
part_classification_query => [ "used_for_sale" => 1 ], |
119 | 142 |
rights => { |
120 | 143 |
edit => "sales_quotation_edit", |
... | ... | |
149 | 172 |
is_customer => 0, |
150 | 173 |
nr_key => "quonumber", |
151 | 174 |
}, |
175 |
changes => { |
|
176 |
get_new_reqdate => sub { return; }, |
|
177 |
}, |
|
152 | 178 |
part_classification_query => [ "used_for_purchase" => 1 ], |
153 | 179 |
rights => { |
154 | 180 |
edit => "purchase_quotation_edit", |
SL/DB/Reclamation/TypeData.pm | ||
---|---|---|
36 | 36 |
is_customer => 1, |
37 | 37 |
nr_key => "record_number", |
38 | 38 |
}, |
39 |
changes => { |
|
40 |
get_new_reqdate => sub { return; } |
|
41 |
}, |
|
39 | 42 |
part_classification_query => [ "used_for_sale" => 1 ], |
40 | 43 |
rights => { |
41 | 44 |
edit => "sales_reclamation_edit", |
... | ... | |
60 | 63 |
is_customer => 0, |
61 | 64 |
nr_key => "record_number", |
62 | 65 |
}, |
66 |
changes => { |
|
67 |
get_new_reqdate => sub { return; } |
|
68 |
}, |
|
63 | 69 |
part_classification_query => [ "used_for_purchase" => 1 ], |
64 | 70 |
rights => { |
65 | 71 |
edit => "purchase_reclamation_edit", |
SL/Model/Record.pm | ||
---|---|---|
13 | 13 |
use SL::DB::Invoice; |
14 | 14 |
use SL::DB::Status; |
15 | 15 |
use SL::DB::ValidityToken; |
16 |
use SL::DB::Helper::TypeDataProxy; |
|
16 | 17 |
|
17 | 18 |
use SL::Util qw(trim); |
18 | 19 |
use SL::Locale::String qw(t8); |
19 | 20 |
|
21 |
|
|
20 | 22 |
sub update_after_new { |
21 | 23 |
my ($class, $new_record, $subtype, %flags) = @_; |
22 | 24 |
|
23 |
my $type_info = { |
|
24 |
# order |
|
25 |
sales_quotation => { |
|
26 |
get_new_reqdate => sub { |
|
27 |
if ($::instance_conf->get_reqdate_on) { |
|
28 |
return DateTime->today_local->next_workday( |
|
29 |
extra_days => $::instance_conf->get_reqdate_interval()); |
|
30 |
} else { |
|
31 |
return ''; |
|
32 |
} |
|
33 |
}, |
|
34 |
}, |
|
35 |
sales_order => { |
|
36 |
get_new_reqdate => sub { |
|
37 |
if ($::instance_conf->get_deliverydate_on) { |
|
38 |
return DateTime->today_local->next_workday( |
|
39 |
extra_days => $::instance_conf->get_delivery_date_interval()); |
|
40 |
} else { |
|
41 |
return ''; |
|
42 |
} |
|
43 |
}, |
|
44 |
}, |
|
45 |
request_quotation => { |
|
46 |
get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); }, |
|
47 |
}, |
|
48 |
purchase_order => { |
|
49 |
get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); }, |
|
50 |
}, |
|
51 |
# delivery_order |
|
52 |
rma_delivery_order => { |
|
53 |
get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); }, |
|
54 |
}, |
|
55 |
sales_delivery_order => { |
|
56 |
get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); }, |
|
57 |
}, |
|
58 |
supplier_delivery_order => { |
|
59 |
get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); }, |
|
60 |
}, |
|
61 |
purchase_delivery_order => { |
|
62 |
get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); }, |
|
63 |
}, |
|
64 |
# reclamation |
|
65 |
sales_reclamation => { |
|
66 |
get_new_reqdate => sub { return; }, |
|
67 |
}, |
|
68 |
purchase_reclamation => { |
|
69 |
get_new_reqdate => sub { return; }, |
|
70 |
}, |
|
71 |
}; |
|
72 |
|
|
73 | 25 |
$new_record->transdate(DateTime->now_local()); |
74 |
$new_record->reqdate($type_info->{$subtype}->{get_new_reqdate}->()); |
|
26 |
|
|
27 |
# build TypeDataProxy |
|
28 |
# TODO: remove when type is set in record and not infered form customer/vendor_id |
|
29 |
my $type_data_proxy = SL::DB::Helper::TypeDataProxy->new(ref $new_record, $subtype); |
|
30 |
$new_record->reqdate($type_data_proxy->changes('get_new_reqdate')); |
|
75 | 31 |
|
76 | 32 |
# new_record: der neuerstellte objekt |
77 | 33 |
# flags: zusätzliche informationen zu der behanldung (soll ) |
... | ... | |
340 | 296 |
# - number muss überschrieben werden |
341 | 297 |
# - employee auf aktuellen setzen |
342 | 298 |
|
343 |
my $type_info = { |
|
344 |
# order |
|
345 |
sales_quotation => { |
|
346 |
get_new_reqdate => sub { |
|
347 |
if ($::instance_conf->get_reqdate_on) { |
|
348 |
return DateTime->today_local->next_workday( |
|
349 |
extra_days => $::instance_conf->get_reqdate_interval()); |
|
350 |
} else { |
|
351 |
return ''; |
|
352 |
} |
|
353 |
}, |
|
354 |
}, |
|
355 |
sales_order => { |
|
356 |
get_new_reqdate => sub { |
|
357 |
if ($::instance_conf->get_deliverydate_on) { |
|
358 |
return DateTime->today_local->next_workday( |
|
359 |
extra_days => $::instance_conf->get_delivery_date_interval()); |
|
360 |
} else { |
|
361 |
return ''; |
|
362 |
} |
|
363 |
}, |
|
364 |
}, |
|
365 |
request_quotation => { |
|
366 |
get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); }, |
|
367 |
}, |
|
368 |
purchase_order => { |
|
369 |
get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); }, |
|
370 |
}, |
|
371 |
# delivery_order |
|
372 |
rma_delivery_order => { |
|
373 |
get_new_reqdate => sub { |
|
374 |
DateTime->today_local->next_workday(extra_days => 1); |
|
375 |
}, |
|
376 |
}, |
|
377 |
sales_delivery_order => { |
|
378 |
get_new_reqdate => sub { |
|
379 |
DateTime->today_local->next_workday(extra_days => 1); |
|
380 |
}, |
|
381 |
}, |
|
382 |
supplier_delivery_order => { |
|
383 |
get_new_reqdate => sub { |
|
384 |
DateTime->today_local->next_workday(extra_days => 1); |
|
385 |
}, |
|
386 |
}, |
|
387 |
purchase_delivery_order => { |
|
388 |
get_new_reqdate => sub { |
|
389 |
DateTime->today_local->next_workday(extra_days => 1); |
|
390 |
}, |
|
391 |
}, |
|
392 |
# reclamation |
|
393 |
sales_reclamation => { |
|
394 |
get_new_reqdate => sub { |
|
395 |
''; |
|
396 |
}, |
|
397 |
}, |
|
398 |
purchase_reclamation => { |
|
399 |
get_new_reqdate => sub { |
|
400 |
''; |
|
401 |
}, |
|
402 |
}, |
|
403 |
}; |
|
404 |
|
|
405 | 299 |
# changed_record |
406 | 300 |
my %new_attrs; |
407 | 301 |
# Lets assign a new number if the user hasn't changed the previous one. |
... | ... | |
417 | 311 |
|
418 | 312 |
# Set new reqdate unless changed if it is enabled in client config |
419 | 313 |
if ($changed_record->reqdate == $saved_record->reqdate) { |
420 |
$new_attrs{reqdate} = $type_info->{$saved_record->type}->{get_new_reqdate}->();
|
|
314 |
$new_attrs{reqdate} = $changed_record->type_data->changes('get_new_reqdate');
|
|
421 | 315 |
} |
422 | 316 |
|
423 | 317 |
# Update employee |
Auch abrufbar als: Unified diff
Model::Record: move get_new_reqdate to TypeData