X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/c26b9ddd1e6110ed8a2b2d062ec506dd4c4dc140..5be160844da9f03e9b95fec066418a99832d8cca:/SL/Controller/DeliveryOrder.pm diff --git a/SL/Controller/DeliveryOrder.pm b/SL/Controller/DeliveryOrder.pm index 095381141..06647f4c6 100644 --- a/SL/Controller/DeliveryOrder.pm +++ b/SL/Controller/DeliveryOrder.pm @@ -1,4 +1,4 @@ -package SL::Controller::Order; +package SL::Controller::DeliveryOrder; use strict; use parent qw(SL::Controller::Base); @@ -52,10 +52,6 @@ use Rose::Object::MakeMethods::Generic # safety __PACKAGE__->run_before('check_auth'); -__PACKAGE__->run_before('recalc', - only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_ap_transaction - print send_email) ]); - __PACKAGE__->run_before('get_unalterable_data', only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_ap_transaction print send_email) ]); @@ -81,7 +77,7 @@ sub action_add { $self->pre_render(); $self->render( - 'order/form', + 'delivery_order/form', title => $self->get_title_for('add'), %{$self->{template_args}} ); @@ -107,10 +103,9 @@ sub action_edit { $_->{render_second_row} = 1 for @{ $self->order->items_sorted }; } - $self->recalc(); $self->pre_render(); $self->render( - 'order/form', + 'delivery_order/form', title => $self->get_title_for('edit'), %{$self->{template_args}} ); @@ -133,15 +128,15 @@ sub action_edit_collective { # fall back to save as new if only one id is given if (scalar @multi_ids == 1) { - $self->order(SL::DB::Order->new(id => $multi_ids[0])->load); + $self->order(SL::DB::DeliveryOrder->new(id => $multi_ids[0])->load); $self->action_save_as_new(); return; } # make new order from given orders - my @multi_orders = map { SL::DB::Order->new(id => $_)->load } @multi_ids; + my @multi_orders = map { SL::DB::DeliveryOrder->new(id => $_)->load } @multi_ids; $self->{converted_from_oe_id} = join ' ', map { $_->id } @multi_orders; - $self->order(SL::DB::Order->new_from_multi(\@multi_orders, sort_sources_by => 'transdate')); + $self->order(SL::DB::DeliveryOrder->new_from_multi(\@multi_orders, sort_sources_by => 'transdate')); $self->action_edit(); } @@ -211,7 +206,7 @@ sub action_save_as_new { } # load order from db to check if values changed - my $saved_order = SL::DB::Order->new(id => $order->id)->load; + my $saved_order = SL::DB::DeliveryOrder->new(id => $order->id)->load; my %new_attrs; # Lets assign a new number if the user hasn't changed the previous one. @@ -244,7 +239,7 @@ sub action_save_as_new { $new_attrs{employee} = SL::DB::Manager::Employee->current; # Create new record from current one - $self->order(SL::DB::Order->new_from($order, destination_type => $order->type, attributes => \%new_attrs)); + $self->order(SL::DB::DeliveryOrder->new_from($order, destination_type => $order->type, attributes => \%new_attrs)); # no linked records on save as new delete $::form->{$_} for qw(converted_from_oe_id converted_from_orderitems_ids); @@ -520,109 +515,6 @@ sub action_send_email { $self->redirect_to(@redirect_params); } -# open the periodic invoices config dialog -# -# If there are values in the form (i.e. dialog was opened before), -# then use this values. Create new ones, else. -sub action_show_periodic_invoices_config_dialog { - my ($self) = @_; - - my $config = make_periodic_invoices_config_from_yaml(delete $::form->{config}); - $config ||= SL::DB::Manager::PeriodicInvoicesConfig->find_by(oe_id => $::form->{id}) if $::form->{id}; - $config ||= SL::DB::PeriodicInvoicesConfig->new(periodicity => 'm', - order_value_periodicity => 'p', # = same as periodicity - start_date_as_date => $::form->{transdate_as_date} || $::form->current_date, - extend_automatically_by => 12, - active => 1, - email_subject => GenericTranslations->get( - language_id => $::form->{language_id}, - translation_type =>"preset_text_periodic_invoices_email_subject"), - email_body => GenericTranslations->get( - language_id => $::form->{language_id}, - translation_type =>"preset_text_periodic_invoices_email_body"), - ); - $config->periodicity('m') if none { $_ eq $config->periodicity } @SL::DB::PeriodicInvoicesConfig::PERIODICITIES; - $config->order_value_periodicity('p') if none { $_ eq $config->order_value_periodicity } ('p', @SL::DB::PeriodicInvoicesConfig::ORDER_VALUE_PERIODICITIES); - - $::form->get_lists(printers => "ALL_PRINTERS", - charts => { key => 'ALL_CHARTS', - transdate => 'current_date' }); - - $::form->{AR} = [ grep { $_->{link} =~ m/(?:^|:)AR(?::|$)/ } @{ $::form->{ALL_CHARTS} } ]; - - if ($::form->{customer_id}) { - $::form->{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(where => [ cp_cv_id => $::form->{customer_id} ]); - my $customer_object = SL::DB::Manager::Customer->find_by(id => $::form->{customer_id}); - $::form->{postal_invoice} = $customer_object->postal_invoice; - $::form->{email_recipient_invoice_address} = $::form->{postal_invoice} ? '' : $customer_object->invoice_mail; - $config->send_email(0) if $::form->{postal_invoice}; - } - - $self->render('oe/edit_periodic_invoices_config', { layout => 0 }, - popup_dialog => 1, - popup_js_close_function => 'kivi.Order.close_periodic_invoices_config_dialog()', - popup_js_assign_function => 'kivi.Order.assign_periodic_invoices_config()', - config => $config, - %$::form); -} - -# assign the values of the periodic invoices config dialog -# as yaml in the hidden tag and set the status. -sub action_assign_periodic_invoices_config { - my ($self) = @_; - - $::form->isblank('start_date_as_date', $::locale->text('The start date is missing.')); - - my $config = { active => $::form->{active} ? 1 : 0, - terminated => $::form->{terminated} ? 1 : 0, - direct_debit => $::form->{direct_debit} ? 1 : 0, - periodicity => (any { $_ eq $::form->{periodicity} } @SL::DB::PeriodicInvoicesConfig::PERIODICITIES) ? $::form->{periodicity} : 'm', - order_value_periodicity => (any { $_ eq $::form->{order_value_periodicity} } ('p', @SL::DB::PeriodicInvoicesConfig::ORDER_VALUE_PERIODICITIES)) ? $::form->{order_value_periodicity} : 'p', - start_date_as_date => $::form->{start_date_as_date}, - end_date_as_date => $::form->{end_date_as_date}, - first_billing_date_as_date => $::form->{first_billing_date_as_date}, - print => $::form->{print} ? 1 : 0, - printer_id => $::form->{print} ? $::form->{printer_id} * 1 : undef, - copies => $::form->{copies} * 1 ? $::form->{copies} : 1, - extend_automatically_by => $::form->{extend_automatically_by} * 1 || undef, - ar_chart_id => $::form->{ar_chart_id} * 1, - send_email => $::form->{send_email} ? 1 : 0, - email_recipient_contact_id => $::form->{email_recipient_contact_id} * 1 || undef, - email_recipient_address => $::form->{email_recipient_address}, - email_sender => $::form->{email_sender}, - email_subject => $::form->{email_subject}, - email_body => $::form->{email_body}, - }; - - my $periodic_invoices_config = SL::YAML::Dump($config); - - my $status = $self->get_periodic_invoices_status($config); - - $self->js - ->remove('#order_periodic_invoices_config') - ->insertAfter(hidden_tag('order.periodic_invoices_config', $periodic_invoices_config), '#periodic_invoices_status') - ->run('kivi.Order.close_periodic_invoices_config_dialog') - ->html('#periodic_invoices_status', $status) - ->flash('info', t8('The periodic invoices config has been assigned.')) - ->render($self); -} - -sub action_get_has_active_periodic_invoices { - my ($self) = @_; - - my $config = make_periodic_invoices_config_from_yaml(delete $::form->{config}); - $config ||= SL::DB::Manager::PeriodicInvoicesConfig->find_by(oe_id => $::form->{id}) if $::form->{id}; - - my $has_active_periodic_invoices = - $self->type eq sales_order_type() - && $config - && $config->active - && (!$config->end_date || ($config->end_date > DateTime->today_local)) - && $config->get_previous_billed_period_start_date; - - $_[0]->render(\ !!$has_active_periodic_invoices, { type => 'text' }); -} - # save the order and redirect to the frontend subroutine for a new # delivery order sub action_save_and_delivery_order { @@ -682,7 +574,6 @@ sub action_customer_vendor_changed { my ($self) = @_; setup_order_from_cv($self->order); - $self->recalc(); my $cv_method = $self->cv; @@ -715,7 +606,6 @@ sub action_customer_vendor_changed { ->focus( '#order_' . $self->cv . '_id') ->run('kivi.Order.update_exchangerate'); - $self->js_redisplay_amounts_and_taxes; $self->js_redisplay_cvpartnumbers; $self->js->render(); } @@ -764,12 +654,9 @@ sub action_unit_changed { my $old_unit_obj = SL::DB::Unit->new(name => $::form->{old_unit})->load; $item->sellprice($item->unit_obj->convert_to($item->sellprice, $old_unit_obj)); - $self->recalc(); - $self->js ->run('kivi.Order.update_sellprice', $::form->{item_id}, $item->sellprice_as_number); $self->js_redisplay_line_values; - $self->js_redisplay_amounts_and_taxes; $self->js->render(); } @@ -787,12 +674,10 @@ sub action_add_item { $self->order->add_items($item); - $self->recalc(); - $self->get_item_cvpartnumber($item); my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); - my $row_as_html = $self->p->render('order/tabs/_row', + my $row_as_html = $self->p->render('delivery_order/tabs/_row', ITEM => $item, ID => $item_id, SELF => $self, @@ -820,10 +705,9 @@ sub action_add_item { $item->discount(1) unless $assortment_item->charge; $self->order->add_items( $item ); - $self->recalc(); $self->get_item_cvpartnumber($item); my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); - my $row_as_html = $self->p->render('order/tabs/_row', + my $row_as_html = $self->p->render('delivery_order/tabs/_row', ITEM => $item, ID => $item_id, SELF => $self, @@ -846,7 +730,6 @@ sub action_add_item { $self->js->run('kivi.Order.row_table_scroll_down') if !$::form->{insert_before_item_id}; - $self->js_redisplay_amounts_and_taxes; $self->js->render(); } @@ -878,12 +761,10 @@ sub action_add_multi_items { } $self->order->add_items(@items); - $self->recalc(); - foreach my $item (@items) { $self->get_item_cvpartnumber($item); my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); - my $row_as_html = $self->p->render('order/tabs/_row', + my $row_as_html = $self->p->render('delivery_order/tabs/_row', ITEM => $item, ID => $item_id, SELF => $self, @@ -906,18 +787,6 @@ sub action_add_multi_items { $self->js->run('kivi.Order.row_table_scroll_down') if !$::form->{insert_before_item_id}; - $self->js_redisplay_amounts_and_taxes; - $self->js->render(); -} - -# recalculate all linetotals, amounts and taxes and redisplay them -sub action_recalc_amounts_and_taxes { - my ($self) = @_; - - $self->recalc(); - - $self->js_redisplay_line_values; - $self->js_redisplay_amounts_and_taxes; $self->js->render(); } @@ -927,7 +796,6 @@ sub action_update_exchangerate { my $data = { is_standard => $self->order->currency_id == $::instance_conf->get_currency_id, currency_name => $self->order->currency->name, - exchangerate => $self->order->daily_exchangerate_as_null_number, }; $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 }); @@ -1015,7 +883,6 @@ sub action_return_from_create_part { $item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); } - $self->recalc(); $self->get_unalterable_data(); $self->pre_render(); @@ -1026,7 +893,7 @@ sub action_return_from_create_part { $_->{render_longdescription} = 1 for @{ $self->order->items_sorted }; $self->render( - 'order/form', + 'delivery_order/form', title => $self->get_title_for('edit'), %{$self->{template_args}} ); @@ -1040,8 +907,6 @@ sub action_return_from_create_part { sub action_load_second_rows { my ($self) = @_; - $self->recalc() if $self->order->is_sales; # for margin calculation - foreach my $item_id (@{ $::form->{item_ids} }) { my $idx = first_index { $_ eq $item_id } @{ $::form->{orderitem_ids} }; my $item = $self->order->items_sorted->[$idx]; @@ -1097,9 +962,7 @@ sub action_update_row_from_master_data { } } - $self->recalc(); $self->js_redisplay_line_values; - $self->js_redisplay_amounts_and_taxes; $self->js->render(); } @@ -1117,7 +980,7 @@ sub js_load_second_row { $item->parse_custom_variable_values; } - my $row_as_html = $self->p->render('order/tabs/_second_row', ITEM => $item, TYPE => $self->type); + my $row_as_html = $self->p->render('delivery_order/tabs/_second_row', ITEM => $item, TYPE => $self->type); $self->js ->html('#second_row_' . $item_id, $row_as_html) @@ -1149,41 +1012,6 @@ sub js_redisplay_line_values { ->run('kivi.Order.redisplay_line_values', $is_sales, \@data); } -sub js_redisplay_amounts_and_taxes { - my ($self) = @_; - - if (scalar @{ $self->{taxes} }) { - $self->js->show('#taxincluded_row_id'); - } else { - $self->js->hide('#taxincluded_row_id'); - } - - if ($self->order->taxincluded) { - $self->js->hide('#subtotal_row_id'); - } else { - $self->js->show('#subtotal_row_id'); - } - - if ($self->order->is_sales) { - my $is_neg = $self->order->marge_total < 0; - $self->js - ->html('#marge_total_id', $::form->format_amount(\%::myconfig, $self->order->marge_total, 2)) - ->html('#marge_percent_id', $::form->format_amount(\%::myconfig, $self->order->marge_percent, 2)) - ->action_if( $is_neg, 'addClass', '#marge_total_id', 'plus0') - ->action_if( $is_neg, 'addClass', '#marge_percent_id', 'plus0') - ->action_if( $is_neg, 'addClass', '#marge_percent_sign_id', 'plus0') - ->action_if(!$is_neg, 'removeClass', '#marge_total_id', 'plus0') - ->action_if(!$is_neg, 'removeClass', '#marge_percent_id', 'plus0') - ->action_if(!$is_neg, 'removeClass', '#marge_percent_sign_id', 'plus0'); - } - - $self->js - ->html('#netamount_id', $::form->format_amount(\%::myconfig, $self->order->netamount, -2)) - ->html('#amount_id', $::form->format_amount(\%::myconfig, $self->order->amount, -2)) - ->remove('.tax_row') - ->insertBefore($self->build_tax_rows, '#amount_row_id'); -} - sub js_redisplay_cvpartnumbers { my ($self) = @_; @@ -1343,50 +1171,16 @@ sub build_shipto_inputs { # Needed, if customer/vendor changed. sub build_business_info_row { - $_[0]->p->render('order/tabs/_business_info_row', SELF => $_[0]); + $_[0]->p->render('delivery_order/tabs/_business_info_row', SELF => $_[0]); } -# build the rows for displaying taxes -# -# Called if amounts where recalculated and redisplayed. -sub build_tax_rows { - my ($self) = @_; - - my $rows_as_html; - foreach my $tax (sort { $a->{tax}->rate cmp $b->{tax}->rate } @{ $self->{taxes} }) { - $rows_as_html .= $self->p->render('order/tabs/_tax_row', TAX => $tax, TAXINCLUDED => $self->order->taxincluded); - } - return $rows_as_html; -} - - -sub render_price_dialog { - my ($self, $record_item) = @_; - - my $price_source = SL::PriceSource->new(record_item => $record_item, record => $self->order); - - $self->js - ->run( - 'kivi.io.price_chooser_dialog', - t8('Available Prices'), - $self->render('order/tabs/_price_sources_dialog', { output => 0 }, price_source => $price_source) - ) - ->reinit_widgets; - -# if (@errors) { -# $self->js->text('#dialog_flash_error_content', join ' ', @errors); -# $self->js->show('#dialog_flash_error'); -# } - - $self->js->render; -} sub load_order { my ($self) = @_; return if !$::form->{id}; - $self->order(SL::DB::Order->new(id => $::form->{id})->load); + $self->order(SL::DB::DeliveryOrder->new(id => $::form->{id})->load); # Add an empty custom shipto to the order, so that the dialog can render the cvar inputs. # You need a custom shipto object to call cvars_by_config to get the cvars. @@ -1408,8 +1202,8 @@ sub make_order { # be retrieved via items until the order is saved. Adding empty items to new # order here solves this problem. my $order; - $order = SL::DB::Order->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id}; - $order ||= SL::DB::Order->new(orderitems => [], + $order = SL::DB::DeliveryOrder->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id}; + $order ||= SL::DB::DeliveryOrder->new(orderitems => [], quotation => (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type())), currency_id => $::instance_conf->get_currency_id(),); @@ -1420,17 +1214,11 @@ sub make_order { } my $form_orderitems = delete $::form->{order}->{orderitems}; - my $form_periodic_invoices_config = delete $::form->{order}->{periodic_invoices_config}; $order->assign_attributes(%{$::form->{order}}); $self->setup_custom_shipto_from_form($order, $::form); - if (my $periodic_invoices_config_attrs = $form_periodic_invoices_config ? SL::YAML::Load($form_periodic_invoices_config) : undef) { - my $periodic_invoices_config = $order->periodic_invoices_config || $order->periodic_invoices_config(SL::DB::PeriodicInvoicesConfig->new); - $periodic_invoices_config->assign_attributes(%$periodic_invoices_config_attrs); - } - # remove deleted items $self->item_ids_to_delete([]); foreach my $idx (reverse 0..$#{$order->orderitems}) { @@ -1469,7 +1257,7 @@ sub make_item { # add_custom_variables adds cvars to an orderitem with no cvars for saving, but # they cannot be retrieved via custom_variables until the order/orderitem is # saved. Adding empty custom_variables to new orderitem here solves this problem. - $item ||= SL::DB::OrderItem->new(custom_variables => []); + $item ||= SL::DB::DeliveryOrderItem->new(custom_variables => []); $item->assign_attributes(%$attr); @@ -1489,7 +1277,7 @@ sub make_item { sub new_item { my ($record, $attr) = @_; - my $item = SL::DB::OrderItem->new; + my $item = SL::DB::DeliveryOrderItem->new; # Remove attributes where the user left or set the inputs empty. # So these attributes will be undefined and we can distinguish them @@ -1517,7 +1305,6 @@ sub new_item { $price_src = $price_source->best_price ? $price_source->best_price : $price_source->price_from_source(""); - $price_src->price($::form->round_amount($price_src->price / $record->exchangerate, 5)) if $record->exchangerate; $price_src->price(0) if !$price_source->best_price; } @@ -1597,25 +1384,6 @@ sub setup_custom_shipto_from_form { } } -# recalculate prices and taxes -# -# Using the PriceTaxCalculator. Store linetotals in the item objects. -sub recalc { - my ($self) = @_; - - my %pat = $self->order->calculate_prices_and_taxes(); - - $self->{taxes} = []; - foreach my $tax_id (keys %{ $pat{taxes_by_tax_id} }) { - my $netamount = sum0 map { $pat{amounts}->{$_}->{amount} } grep { $pat{amounts}->{$_}->{tax_id} == $tax_id } keys %{ $pat{amounts} }; - - push(@{ $self->{taxes} }, { amount => $pat{taxes_by_tax_id}->{$tax_id}, - netamount => $netamount, - tax => SL::DB::Tax->new(id => $tax_id)->load }); - } - pairwise { $a->{linetotal} = $b->{linetotal} } @{$self->order->items_sorted}, @{$pat{items}}; -} - # get data for saving, printing, ..., that is not changed in the form # # Only cvars for now. @@ -1672,14 +1440,14 @@ sub save { $self->order->custom_shipto(undef); } - SL::DB::OrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete || []}; + SL::DB::DeliveryOrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete || []}; $self->order->save(cascade => 1); # link records if ($::form->{converted_from_oe_id}) { my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; foreach my $converted_from_oe_id (@converted_from_oe_ids) { - my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load; + my $src = SL::DB::DeliveryOrder->new(id => $converted_from_oe_id)->load; $src->update_attributes(closed => 1) if $src->type =~ /_quotation$/; $src->link_to_record($self->order); } @@ -1719,7 +1487,7 @@ sub workflow_sales_or_request_for_quotation { my $destination_type = $::form->{type} eq sales_order_type() ? sales_quotation_type() : request_quotation_type(); - $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type)); + $self->order(SL::DB::DeliveryOrder->new_from($self->order, destination_type => $destination_type)); $self->{converted_from_oe_id} = delete $::form->{id}; # set item ids to new fake id, to identify them as new items @@ -1733,7 +1501,6 @@ sub workflow_sales_or_request_for_quotation { $self->cv ($self->init_cv); $self->check_auth; - $self->recalc(); $self->get_unalterable_data(); $self->pre_render(); @@ -1743,7 +1510,7 @@ sub workflow_sales_or_request_for_quotation { $_->{render_second_row} = 1 for @{ $self->order->items_sorted }; $self->render( - 'order/form', + 'delivery_order/form', title => $self->get_title_for('edit'), %{$self->{template_args}} ); @@ -1771,10 +1538,10 @@ sub workflow_sales_or_purchase_order { my $custom_shipto; if ( $::form->{type} eq sales_order_type() && $destination_type eq purchase_order_type() && $::form->{use_shipto} && $self->order->shipto) { - $custom_shipto = $self->order->shipto->clone('SL::DB::Order'); + $custom_shipto = $self->order->shipto->clone('SL::DB::DeliveryOrder'); } - $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type)); + $self->order(SL::DB::DeliveryOrder->new_from($self->order, destination_type => $destination_type)); $self->{converted_from_oe_id} = delete $::form->{id}; # set item ids to new fake id, to identify them as new items @@ -1797,7 +1564,6 @@ sub workflow_sales_or_purchase_order { $self->cv ($self->init_cv); $self->check_auth; - $self->recalc(); $self->get_unalterable_data(); $self->pre_render(); @@ -1807,7 +1573,7 @@ sub workflow_sales_or_purchase_order { $_->{render_second_row} = 1 for @{ $self->order->items_sorted }; $self->render( - 'order/form', + 'delivery_order/form', title => $self->get_title_for('edit'), %{$self->{template_args}} ); @@ -1831,7 +1597,6 @@ sub pre_render { obsolete => 0 ] ]); $self->{all_delivery_terms} = SL::DB::Manager::DeliveryTerm->get_all_sorted(); $self->{current_employee_id} = SL::DB::Manager::Employee->current->id; - $self->{periodic_invoices_status} = $self->get_periodic_invoices_status($self->order->periodic_invoices_config); $self->{order_probabilities} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ]; $self->{positions_scrollbar_height} = SL::Helper::UserPreferences::PositionsScrollbar->new()->get_height(); @@ -1876,7 +1641,7 @@ sub pre_render { $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted}; $::request->{layout}->use_javascript("${_}.js") for qw(kivi.SalesPurchase kivi.Order kivi.File ckeditor/ckeditor ckeditor/adapters/jquery - edit_periodic_invoices_config calculate_qty kivi.Validator follow_up show_history); + calculate_qty kivi.Validator follow_up show_history); $self->setup_edit_action_bar; } @@ -1895,12 +1660,10 @@ sub setup_edit_action_bar { call => [ 'kivi.Order.save', 'save', $::instance_conf->get_order_warn_duplicate_parts, $::instance_conf->get_order_warn_no_deliverydate, ], - checks => [ 'kivi.Order.check_save_active_periodic_invoices', ['kivi.validate_form','#order_form'] ], ], action => [ t8('Save as new'), call => [ 'kivi.Order.save', 'save_as_new', $::instance_conf->get_order_warn_duplicate_parts ], - checks => [ 'kivi.Order.check_save_active_periodic_invoices' ], disabled => !$self->order->id ? t8('This object has not been saved yet.') : undef, ], ], # end of combobox "Save" @@ -1911,17 +1674,17 @@ sub setup_edit_action_bar { ], action => [ t8('Save and Quotation'), - submit => [ '#order_form', { action => "Order/sales_quotation" } ], + submit => [ '#order_form', { action => "DeliveryOrder/sales_quotation" } ], only_if => (any { $self->type eq $_ } (sales_order_type())), ], action => [ t8('Save and RFQ'), - submit => [ '#order_form', { action => "Order/request_for_quotation" } ], + submit => [ '#order_form', { action => "DeliveryOrder/request_for_quotation" } ], only_if => (any { $self->type eq $_ } (purchase_order_type())), ], action => [ t8('Save and Sales Order'), - submit => [ '#order_form', { action => "Order/sales_order" } ], + submit => [ '#order_form', { action => "DeliveryOrder/sales_order" } ], only_if => (any { $self->type eq $_ } (sales_quotation_type(), purchase_order_type())), ], action => [ @@ -1934,13 +1697,11 @@ sub setup_edit_action_bar { call => [ 'kivi.Order.save', 'save_and_delivery_order', $::instance_conf->get_order_warn_duplicate_parts, $::instance_conf->get_order_warn_no_deliverydate, ], - checks => [ 'kivi.Order.check_save_active_periodic_invoices' ], only_if => (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())) ], action => [ t8('Save and Invoice'), call => [ 'kivi.Order.save', 'save_and_invoice', $::instance_conf->get_order_warn_duplicate_parts ], - checks => [ 'kivi.Order.check_save_active_periodic_invoices' ], ], action => [ t8('Save and AP Transaction'), @@ -2104,29 +1865,6 @@ sub get_files_for_email_dialog { return %files; } -sub make_periodic_invoices_config_from_yaml { - my ($yaml_config) = @_; - - return if !$yaml_config; - my $attr = SL::YAML::Load($yaml_config); - return if 'HASH' ne ref $attr; - return SL::DB::PeriodicInvoicesConfig->new(%$attr); -} - - -sub get_periodic_invoices_status { - my ($self, $config) = @_; - - return if $self->type ne sales_order_type(); - return t8('not configured') if !$config; - - my $active = ('HASH' eq ref $config) ? $config->{active} - : ('SL::DB::PeriodicInvoicesConfig' eq ref $config) ? $config->active - : die "Cannot get status of periodic invoices config"; - - return $active ? t8('active') : t8('inactive'); -} - sub get_title_for { my ($self, $action) = @_; @@ -2354,11 +2092,11 @@ and ajax. the controller -=item * C