if ($::form->{customer_id}) {
$::form->{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(where => [ cp_cv_id => $::form->{customer_id} ]);
- $::form->{email_recipient_invoice_address} = SL::DB::Manager::Customer->find_by(id => $::form->{customer_id})->invoice_mail;
+ 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 },
}
if (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())) {
- # calculate shipped qtys here to prevent calling calculate for every item via the items method
- SL::Helper::ShippedQty->new->calculate($self->order)->write_to_objects;
+ # Calculate shipped qtys here to prevent calling calculate for every item via the items method.
+ # Do not use write_to_objects to prevent order->delivered to be set, because this should be
+ # the value from db, which can be set manually or is set when linked delivery orders are saved.
+ SL::Helper::ShippedQty->new->calculate($self->order)->write_to(\@{$self->order->items});
}
if ($self->order->number && $::instance_conf->get_webdav) {