+  $::request->{layout}->add_javascripts("$_.js") for qw (kivi.CustomerVendor kivi.File kivi.CustomerVendorTurnover ckeditor/ckeditor ckeditor/adapters/jquery);
+
+  $self->_setup_form_action_bar;
+}
+
+sub _setup_form_action_bar {
+  my ($self) = @_;
+
+  my $no_rights = $self->user_has_edit_rights ? undef
+                : $self->{cv}->is_customer    ? t8("You don't have the rights to edit this customer.")
+                :                               t8("You don't have the rights to edit this vendor.");
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      combobox => [
+        action => [
+          t8('Save'),
+          submit    => [ '#form', { action => "CustomerVendor/save" } ],
+          checks    => [ 'check_taxzone_and_ustid' ],
+          accesskey => 'enter',
+          disabled  => $no_rights,
+        ],
+        action => [
+          t8('Save and Close'),
+          submit => [ '#form', { action => "CustomerVendor/save_and_close" } ],
+          checks => [ 'check_taxzone_and_ustid' ],
+          disabled => $no_rights,
+        ],
+      ], # end of combobox "Save"
+
+      combobox => [
+        action => [ t8('Workflow') ],
+        (action => [
+          t8('Save and AP Transaction'),
+          submit => [ '#form', { action => "CustomerVendor/save_and_ap_transaction" } ],
+          checks => [ 'check_taxzone_and_ustid' ],
+          disabled => $no_rights,
+        ]) x !!$self->is_vendor,
+        (action => [
+          t8('Save and AR Transaction'),
+          submit => [ '#form', { action => "CustomerVendor/save_and_ar_transaction" } ],
+          checks => [ 'check_taxzone_and_ustid' ],
+          disabled => $no_rights,
+        ]) x !$self->is_vendor,
+        action => [
+          t8('Save and Invoice'),
+          submit => [ '#form', { action => "CustomerVendor/save_and_invoice" } ],
+          checks => [ 'check_taxzone_and_ustid' ],
+          disabled => $no_rights,
+        ],
+        action => [
+          t8('Save and Order'),
+          submit => [ '#form', { action => "CustomerVendor/save_and_order" } ],
+          checks => [ 'check_taxzone_and_ustid' ],
+          disabled => $no_rights,
+        ],
+        (action => [
+          t8('Save and RFQ'),
+          submit => [ '#form', { action => "CustomerVendor/save_and_rfq" } ],
+          checks => [ 'check_taxzone_and_ustid' ],
+          disabled => $no_rights,
+        ]) x !!$self->is_vendor,
+        (action => [
+          t8('Save and Quotation'),
+          submit => [ '#form', { action => "CustomerVendor/save_and_quotation" } ],
+          checks => [ 'check_taxzone_and_ustid' ],
+          disabled => $no_rights,
+        ]) x !$self->is_vendor,
+      ], # end of combobox "Workflow"
+
+      action => [
+        t8('Delete'),
+        submit   => [ '#form', { action => "CustomerVendor/delete" } ],
+        confirm  => t8('Do you really want to delete this object?'),
+        disabled => !$self->{cv}->id    ? t8('This object has not been saved yet.')
+                  : !$self->is_orphaned ? t8('This object has already been used.')
+                  :                       $no_rights,
+      ],
+
+      'separator',
+
+      action => [
+        t8('History'),
+        call     => [ 'kivi.CustomerVendor.showHistoryWindow', $self->{cv}->id ],
+        disabled => !$self->{cv}->id ? t8('This object has not been saved yet.') : undef,
+      ],
+    );
+  }
+}
+
+sub _prepare_cvar_configs_for_ajaj {
+  my ($self, $cvars) = @_;
+
+  return {
+    map {
+      my $cvar   = $_;
+      my $result = { type => $cvar->config->type };
+
+      if ($cvar->config->type eq 'number') {
+        $result->{value} = $::form->format_amount(\%::myconfig, $cvar->value, -2);
+
+      } elsif ($result->{type} eq 'date') {
+        $result->{value} = $cvar->value ? $cvar->value->to_kivitendo : undef;
+
+      } elsif ($result->{type} =~ m{customer|vendor|part}) {
+        my $object       = $cvar->value;
+        my $method       = $result->{type} eq 'part' ? 'description' : 'name';
+
+        $result->{id}    = int($cvar->number_value) || undef;
+        $result->{value} = $object ? $object->$method // '' : '';
+
+      } else {
+        $result->{value} = $cvar->value;
+      }
+
+      ( $cvar->config->name => $result )
+
+    } grep { $_->is_valid } @{ $cvars }
+  };
+}
+
+sub normalize_name {
+  my ($self) = @_;
+
+  # check if feature is enabled (select normalize_vc_names from defaults)
+  return unless ($::instance_conf->get_normalize_vc_names);
+
+  return unless $self->{cv};
+  my $name = $self->{cv}->name;
+  $name =~ s/\s+$//;
+  $name =~ s/^\s+//;
+  $name =~ s/\s+/ /g;
+  $self->{cv}->name($name);
+}
+
+sub home_address_for_google_maps {
+  my ($self)  = @_;
+
+  my $address = $::instance_conf->get_address // '';
+  $address    =~ s{^\s+|\s+$|\r+}{}g;
+  $address    =~ s{\n+}{,}g;
+  $address    =~ s{\s+}{ }g;
+
+  return $address;
+}
+
+sub init_customer_models {
+  my ($self) = @_;
+
+  SL::Controller::Helper::GetModels->new(
+    controller   => $self,
+    model        => 'Customer',
+    sorted => {
+      _default  => {
+        by => 'customernumber',
+        dir  => 1,
+      },
+      customernumber => t8('Customer Number'),
+    },
+  );
+}
+
+sub init_vendor_models {
+  my ($self) = @_;
+
+  SL::Controller::Helper::GetModels->new(
+    controller => $self,
+    model      => 'Vendor',
+    sorted => {
+      _default  => {
+        by => 'vendornumber',
+        dir  => 1,
+      },
+      vendornumber => t8('Vendor Number'),
+    },
+  );
+}
+
+sub init_zugferd_settings {
+  return [
+    [ -1, t8('Use settings from client configuration') ],
+    @SL::ZUGFeRD::customer_settings,
+  ],
+}
+
+sub _new_customer_vendor_object {
+  my ($self) = @_;
+
+  my $class  = 'SL::DB::' . ($self->is_vendor ? 'Vendor' : 'Customer');
+  my $object = $class->new(
+    contacts         => [],
+    shipto           => [],
+    custom_variables => [],
+  );
+
+  $object->additional_billing_addresses([]) if $self->is_customer;
+
+  return $object;
+}
+
+sub _new_contact_object {
+  my ($self) = @_;
+
+  return SL::DB::Contact->new(custom_variables => []);