Revision 47b2bb2b
Von Bernd Bleßmann vor mehr als 1 Jahr hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
77 | 77 |
my ($self) = @_; |
78 | 78 |
|
79 | 79 |
$self->order->transdate(DateTime->now_local()); |
80 |
my $extra_days = $self->type eq sales_quotation_type() ? $::instance_conf->get_reqdate_interval : |
|
81 |
$self->type eq sales_order_type() ? $::instance_conf->get_delivery_date_interval : 1; |
|
80 |
my $extra_days = $self->type eq sales_quotation_type() ? $::instance_conf->get_reqdate_interval : |
|
81 |
$self->type eq sales_order_type() ? $::instance_conf->get_delivery_date_interval : |
|
82 |
$self->type eq sales_order_intake_type() ? $::instance_conf->get_delivery_date_interval : 1; |
|
82 | 83 |
|
83 |
if ( ($self->type eq sales_order_type() && $::instance_conf->get_deliverydate_on) |
|
84 |
if (($self->type eq sales_order_intake_type() && $::instance_conf->get_deliverydate_on) |
|
85 |
|| ($self->type eq sales_order_type() && $::instance_conf->get_deliverydate_on) |
|
84 | 86 |
|| ($self->type eq sales_quotation_type() && $::instance_conf->get_reqdate_on) |
85 | 87 |
&& (!$self->order->reqdate)) { |
86 | 88 |
$self->order->reqdate(DateTime->today_local->next_workday(extra_days => $extra_days)); |
... | ... | |
207 | 209 |
return $self->js->render(); |
208 | 210 |
} |
209 | 211 |
|
210 |
my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been deleted') |
|
211 |
: $self->type eq purchase_order_type() ? $::locale->text('The order has been deleted') |
|
212 |
: $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been deleted') |
|
213 |
: $self->type eq request_quotation_type() ? $::locale->text('The rfq has been deleted') |
|
212 |
my $text = $self->type eq sales_order_intake_type() ? $::locale->text('The order intake has been deleted') |
|
213 |
: $self->type eq sales_order_type() ? $::locale->text('The order confirmation has been deleted') |
|
214 |
: $self->type eq purchase_order_type() ? $::locale->text('The order has been deleted') |
|
215 |
: $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been deleted') |
|
216 |
: $self->type eq request_quotation_type() ? $::locale->text('The rfq has been deleted') |
|
214 | 217 |
: ''; |
215 | 218 |
flash_later('info', $text); |
216 | 219 |
|
... | ... | |
233 | 236 |
return $self->js->render(); |
234 | 237 |
} |
235 | 238 |
|
236 |
my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved') |
|
237 |
: $self->type eq purchase_order_type() ? $::locale->text('The order has been saved') |
|
238 |
: $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved') |
|
239 |
: $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved') |
|
239 |
my $text = $self->type eq sales_order_intake_type() ? $::locale->text('The order intake has been saved') |
|
240 |
: $self->type eq sales_order_type() ? $::locale->text('The order confirmation has been saved') |
|
241 |
: $self->type eq purchase_order_type() ? $::locale->text('The order has been saved') |
|
242 |
: $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved') |
|
243 |
: $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved') |
|
240 | 244 |
: ''; |
241 | 245 |
flash_later('info', $text); |
242 | 246 |
|
... | ... | |
303 | 307 |
|
304 | 308 |
# Set new reqdate unless changed if it is enabled in client config |
305 | 309 |
if ($order->reqdate == $saved_order->reqdate) { |
306 |
my $extra_days = $self->type eq sales_quotation_type() ? $::instance_conf->get_reqdate_interval : |
|
307 |
$self->type eq sales_order_type() ? $::instance_conf->get_delivery_date_interval : 1; |
|
310 |
my $extra_days = $self->type eq sales_quotation_type() ? $::instance_conf->get_reqdate_interval : |
|
311 |
$self->type eq sales_order_type() ? $::instance_conf->get_delivery_date_interval : |
|
312 |
$self->type eq sales_order_intake_type() ? $::instance_conf->get_delivery_date_interval : 1; |
|
308 | 313 |
|
309 |
if ( ($self->type eq sales_order_type() && !$::instance_conf->get_deliverydate_on) |
|
310 |
|| ($self->type eq sales_quotation_type() && !$::instance_conf->get_reqdate_on)) { |
|
314 |
if ( ($self->type eq sales_order_intake_type() && !$::instance_conf->get_deliverydate_on) |
|
315 |
|| ($self->type eq sales_order_type() && !$::instance_conf->get_deliverydate_on) |
|
316 |
|| ($self->type eq sales_quotation_type() && !$::instance_conf->get_reqdate_on)) { |
|
311 | 317 |
$new_attrs{reqdate} = ''; |
312 | 318 |
} else { |
313 | 319 |
$new_attrs{reqdate} = DateTime->today_local->next_workday(extra_days => $extra_days); |
... | ... | |
927 | 933 |
my $destination_type = $::form->{to_type} ? $::form->{to_type} : ''; |
928 | 934 |
|
929 | 935 |
my $from_side = $self->order->is_sales ? 'sales' : 'purchase'; |
930 |
my $to_side = (any { $destination_type eq $_ } (sales_order_type(), sales_quotation_type())) ? 'sales' : 'purchase'; |
|
936 |
my $to_side = (any { $destination_type eq $_ } (sales_order_intake_type(), sales_order_type(), sales_quotation_type())) ? 'sales' : 'purchase';
|
|
931 | 937 |
|
932 | 938 |
# check for direct delivery |
933 | 939 |
# copy shipto in custom shipto (custom shipto will be copied by new_from() in case) |
... | ... | |
1707 | 1713 |
# |
1708 | 1714 |
|
1709 | 1715 |
sub init_valid_types { |
1710 |
[ sales_order_type(), purchase_order_type(), sales_quotation_type(), request_quotation_type() ]; |
|
1716 |
[ sales_order_intake_type(), sales_order_type(), purchase_order_type(), sales_quotation_type(), request_quotation_type() ];
|
|
1711 | 1717 |
} |
1712 | 1718 |
|
1713 | 1719 |
sub init_type { |
... | ... | |
1723 | 1729 |
sub init_cv { |
1724 | 1730 |
my ($self) = @_; |
1725 | 1731 |
|
1726 |
my $cv = (any { $self->type eq $_ } (sales_order_type(), sales_quotation_type())) ? 'customer'
|
|
1727 |
: (any { $self->type eq $_ } (purchase_order_type(), request_quotation_type())) ? 'vendor' |
|
1732 |
my $cv = (any { $self->type eq $_ } (sales_order_intake_type(), sales_order_type(), sales_quotation_type())) ? 'customer'
|
|
1733 |
: (any { $self->type eq $_ } (purchase_order_type(), request_quotation_type())) ? 'vendor'
|
|
1728 | 1734 |
: die "Not a valid type for order"; |
1729 | 1735 |
|
1730 | 1736 |
return $cv; |
... | ... | |
1784 | 1790 |
my ($self) = @_; |
1785 | 1791 |
|
1786 | 1792 |
my $right_for = { map { $_ => $_.'_edit' . ' | ' . $_.'_view' } @{$self->valid_types} }; |
1793 |
$right_for->{ sales_order_intake_type() } = 'sales_order_edit | sales_order_view'; |
|
1787 | 1794 |
|
1788 | 1795 |
my $right = $right_for->{ $self->type }; |
1789 | 1796 |
$right ||= 'DOES_NOT_EXIST'; |
... | ... | |
1795 | 1802 |
my ($self) = @_; |
1796 | 1803 |
|
1797 | 1804 |
my $right_for = { map { $_ => $_.'_edit' } @{$self->valid_types} }; |
1805 |
$right_for->{ sales_order_intake_type() } = 'sales_order_edit'; |
|
1798 | 1806 |
|
1799 | 1807 |
my $right = $right_for->{ $self->type }; |
1800 | 1808 |
$right ||= 'DOES_NOT_EXIST'; |
... | ... | |
1945 | 1953 |
$order = SL::DB::Order->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id}; |
1946 | 1954 |
$order ||= SL::DB::Order->new(orderitems => [], |
1947 | 1955 |
quotation => (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type())), |
1956 |
intake => (any { $self->type eq $_ } (sales_order_intake_type())), |
|
1948 | 1957 |
currency_id => $::instance_conf->get_currency_id(),); |
1949 | 1958 |
|
1950 | 1959 |
my $cv_id_method = $self->cv . '_id'; |
... | ... | |
2331 | 2340 |
$item->active_discount_source($price_source->discount_from_source($item->active_discount_source)); |
2332 | 2341 |
} |
2333 | 2342 |
|
2334 |
if (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())) { |
|
2343 |
if (any { $self->type eq $_ } (sales_order_intake_type(), sales_order_type(), purchase_order_type())) {
|
|
2335 | 2344 |
# Calculate shipped qtys here to prevent calling calculate for every item via the items method. |
2336 | 2345 |
# Do not use write_to_objects to prevent order->delivered to be set, because this should be |
2337 | 2346 |
# the value from db, which can be set manually or is set when linked delivery orders are saved. |
... | ... | |
2350 | 2359 |
} } @all_objects; |
2351 | 2360 |
} |
2352 | 2361 |
|
2353 |
if ( (any { $self->type eq $_ } (sales_quotation_type(), sales_order_type())) |
|
2362 |
if ( (any { $self->type eq $_ } (sales_quotation_type(), sales_order_intake_type(), sales_order_type()))
|
|
2354 | 2363 |
&& $::instance_conf->get_transport_cost_reminder_article_number_id ) { |
2355 | 2364 |
$self->{template_args}->{transport_cost_reminder_article} = SL::DB::Part->new(id => $::instance_conf->get_transport_cost_reminder_article_number_id)->load; |
2356 | 2365 |
} |
... | ... | |
2369 | 2378 |
my ($self, %params) = @_; |
2370 | 2379 |
|
2371 | 2380 |
my $deletion_allowed = (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type())) |
2372 |
|| (($self->type eq sales_order_type()) && $::instance_conf->get_sales_order_show_delete) |
|
2373 |
|| (($self->type eq purchase_order_type()) && $::instance_conf->get_purchase_order_show_delete); |
|
2381 |
|| (($self->type eq sales_order_type()) && $::instance_conf->get_sales_order_show_delete) |
|
2382 |
|| (($self->type eq sales_order_intake_type()) && $::instance_conf->get_sales_order_show_delete) |
|
2383 |
|| (($self->type eq purchase_order_type()) && $::instance_conf->get_purchase_order_show_delete); |
|
2374 | 2384 |
|
2375 | 2385 |
my @req_trans_cost_art = qw(kivi.Order.check_transport_cost_article_presence) x!!$::instance_conf->get_transport_cost_reminder_article_number_id; |
2376 |
my @req_cusordnumber = qw(kivi.Order.check_cusordnumber_presence) x($self->type eq sales_order_type() && $::instance_conf->get_order_warn_no_cusordnumber);
|
|
2386 |
my @req_cusordnumber = qw(kivi.Order.check_cusordnumber_presence) x(( any {$self->type eq $_} (sales_order_intake_type(), sales_order_type()) ) && $::instance_conf->get_order_warn_no_cusordnumber);
|
|
2377 | 2387 |
|
2378 | 2388 |
my $has_invoice_for_advance_payment; |
2379 | 2389 |
if ($self->order->id && $self->type eq sales_order_type()) { |
... | ... | |
2388 | 2398 |
} |
2389 | 2399 |
|
2390 | 2400 |
my $right_for = { map { $_ => $_.'_edit' } @{$self->valid_types} }; |
2401 |
$right_for->{ sales_order_intake_type() } = 'sales_order_edit'; |
|
2391 | 2402 |
my $right = $right_for->{ $self->type }; |
2392 | 2403 |
$right ||= 'DOES_NOT_EXIST'; |
2393 | 2404 |
my $may_edit_create = $::auth->assert($right, 'may fail'); |
... | ... | |
2452 | 2463 |
t8('Save and Quotation'), |
2453 | 2464 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => sales_quotation_type()), '#order_form' ], |
2454 | 2465 |
checks => [ @req_trans_cost_art, @req_cusordnumber ], |
2455 |
only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())), |
|
2466 |
only_if => (any { $self->type eq $_ } (sales_order_intake_type(), sales_order_type(), request_quotation_type())),
|
|
2456 | 2467 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2457 | 2468 |
], |
2458 | 2469 |
action => [ |
2459 | 2470 |
t8('Save and RFQ'), |
2460 | 2471 |
call => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => request_quotation_type() } ], |
2461 |
only_if => (any { $self->type eq $_ } (sales_order_type(), sales_quotation_type(), purchase_order_type())), |
|
2472 |
only_if => (any { $self->type eq $_ } (sales_order_intake_type(), sales_order_type(), sales_quotation_type(), purchase_order_type())),
|
|
2462 | 2473 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2463 | 2474 |
], |
2464 | 2475 |
action => [ |
2465 |
t8('Save and Sales Order'), |
|
2476 |
t8('Save and Sales Order Intake'), |
|
2477 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => sales_order_intake_type()), '#order_form' ], |
|
2478 |
only_if => (any { $self->type eq $_ } (sales_quotation_type())), |
|
2479 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
|
2480 |
], |
|
2481 |
action => [ |
|
2482 |
t8('Save and Sales Order Confirmation'), |
|
2466 | 2483 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => sales_order_type()), '#order_form' ], |
2467 | 2484 |
checks => [ @req_trans_cost_art ], |
2468 |
only_if => (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type(), purchase_order_type())), |
|
2485 |
only_if => (any { $self->type eq $_ } (sales_quotation_type(), sales_order_intake_type(), request_quotation_type(), purchase_order_type())),
|
|
2469 | 2486 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2470 | 2487 |
], |
2471 | 2488 |
action => [ |
2472 | 2489 |
t8('Save and Purchase Order'), |
2473 | 2490 |
call => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => purchase_order_type() } ], |
2474 | 2491 |
checks => [ @req_trans_cost_art, @req_cusordnumber ], |
2475 |
only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())), |
|
2492 |
only_if => (any { $self->type eq $_ } (sales_order_intake_type(), sales_order_type(), request_quotation_type())),
|
|
2476 | 2493 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2477 | 2494 |
], |
2478 | 2495 |
action => [ |
... | ... | |
2526 | 2543 |
@req_trans_cost_art, @req_cusordnumber, |
2527 | 2544 |
], |
2528 | 2545 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2546 |
not_if => (any { $self->type eq $_ } (sales_order_intake_type())), |
|
2529 | 2547 |
], |
2530 | 2548 |
action => [ |
2531 | 2549 |
($has_invoice_for_advance_payment ? t8('Save and Further Invoice for Advance Payment') : t8('Save and Invoice for Advance Payment')), |
... | ... | |
2764 | 2782 |
return '' if none { lc($action)} qw(add edit); |
2765 | 2783 |
|
2766 | 2784 |
# for locales: |
2785 |
# $::locale->text("Add Sales Order Intake"); |
|
2767 | 2786 |
# $::locale->text("Add Sales Order"); |
2768 | 2787 |
# $::locale->text("Add Purchase Order"); |
2769 | 2788 |
# $::locale->text("Add Quotation"); |
2770 | 2789 |
# $::locale->text("Add Request for Quotation"); |
2790 |
# $::locale->text("Edit Sales Order Intake"); |
|
2771 | 2791 |
# $::locale->text("Edit Sales Order"); |
2772 | 2792 |
# $::locale->text("Edit Purchase Order"); |
2773 | 2793 |
# $::locale->text("Edit Quotation"); |
2774 | 2794 |
# $::locale->text("Edit Request for Quotation"); |
2775 | 2795 |
|
2776 | 2796 |
$action = ucfirst(lc($action)); |
2777 |
return $self->type eq sales_order_type() ? $::locale->text("$action Sales Order") |
|
2778 |
: $self->type eq purchase_order_type() ? $::locale->text("$action Purchase Order") |
|
2779 |
: $self->type eq sales_quotation_type() ? $::locale->text("$action Quotation") |
|
2780 |
: $self->type eq request_quotation_type() ? $::locale->text("$action Request for Quotation") |
|
2797 |
return $self->type eq sales_order_intake_type() ? $::locale->text("$action Sales Order Intake") |
|
2798 |
: $self->type eq sales_order_type() ? $::locale->text("$action Sales Order") |
|
2799 |
: $self->type eq purchase_order_type() ? $::locale->text("$action Purchase Order") |
|
2800 |
: $self->type eq sales_quotation_type() ? $::locale->text("$action Quotation") |
|
2801 |
: $self->type eq request_quotation_type() ? $::locale->text("$action Request for Quotation") |
|
2781 | 2802 |
: ''; |
2782 | 2803 |
} |
2783 | 2804 |
|
... | ... | |
2855 | 2876 |
return ($price_src, $discount_src); |
2856 | 2877 |
} |
2857 | 2878 |
|
2879 |
sub sales_order_intake_type { |
|
2880 |
'sales_order_intake'; |
|
2881 |
} |
|
2882 |
|
|
2858 | 2883 |
sub sales_order_type { |
2859 | 2884 |
'sales_order'; |
2860 | 2885 |
} |
... | ... | |
2872 | 2897 |
} |
2873 | 2898 |
|
2874 | 2899 |
sub nr_key { |
2875 |
return $_[0]->type eq sales_order_type() ? 'ordnumber' |
|
2876 |
: $_[0]->type eq purchase_order_type() ? 'ordnumber' |
|
2877 |
: $_[0]->type eq sales_quotation_type() ? 'quonumber' |
|
2878 |
: $_[0]->type eq request_quotation_type() ? 'quonumber' |
|
2900 |
return $_[0]->type eq sales_order_intake_type() ? 'ordnumber' |
|
2901 |
: $_[0]->type eq sales_order_type() ? 'ordnumber' |
|
2902 |
: $_[0]->type eq purchase_order_type() ? 'ordnumber' |
|
2903 |
: $_[0]->type eq sales_quotation_type() ? 'quonumber' |
|
2904 |
: $_[0]->type eq request_quotation_type() ? 'quonumber' |
|
2879 | 2905 |
: ''; |
2880 | 2906 |
} |
2881 | 2907 |
|
... | ... | |
2889 | 2915 |
return $self->js->render(); |
2890 | 2916 |
} |
2891 | 2917 |
|
2892 |
my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved') |
|
2893 |
: $self->type eq purchase_order_type() ? $::locale->text('The order has been saved') |
|
2894 |
: $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved') |
|
2895 |
: $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved') |
|
2918 |
my $text = $self->type eq sales_order_intake_type() ? $::locale->text('The order intake has been saved') |
|
2919 |
: $self->type eq sales_order_type() ? $::locale->text('The order confirmation has been saved') |
|
2920 |
: $self->type eq purchase_order_type() ? $::locale->text('The order has been saved') |
|
2921 |
: $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved') |
|
2922 |
: $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved') |
|
2896 | 2923 |
: ''; |
2897 | 2924 |
flash_later('info', $text); |
2898 | 2925 |
|
Auch abrufbar als: Unified diff
Auftrags-Eingang: Controller