Kunden-/Lieferantenfelder richtig zur Verfügung stellen
[kivitendo-erp.git] / SL / DB / Helper / FlattenToForm.pm
index 710fb33..80dcf57 100644 (file)
@@ -16,8 +16,8 @@ sub flatten_to_form {
 
   _copy($self, $form, '', '', 0, qw(id type taxzone_id ordnumber quonumber invnumber donumber cusordnumber taxincluded shippingpoint shipvia notes intnotes curr cp_id
                                     employee_id salesman_id closed department_id language_id payment_id delivery_customer_id delivery_vendor_id shipto_id proforma
-                                    globalproject_id delivered transaction_description container_type accepted_by_customer orddate quodate reqdate gldate duedate deliverydate
-                                    datepaid invoice terms storno storno_id dunning_config_id));
+                                    globalproject_id delivered transaction_description container_type accepted_by_customer invoice terms storno storno_id dunning_config_id
+                                    orddate quodate reqdate gldate duedate deliverydate datepaid transdate));
 
   if (_has($self, 'transdate')) {
     my $transdate_idx = ref($self) eq 'SL::DB::Order'   ? ($self->quotation ? 'quodate' : 'orddate')
@@ -26,9 +26,16 @@ sub flatten_to_form {
     $form->{$transdate_idx} = $self->transdate->to_lxoffice;
   }
 
-  _copy($self,                          $form, '',              '', 1, qw(amount netamount marge_total marge_percent container_remaining_weight container_remaining_volume
-                                                                          paid));
-  _copy($self->$vc,                     $form, "${vc}_",        '', 0, map { $_->name } ref($self->$vc)->meta->columns);
+  $self->{vc} = $vc if ref($self) =~ /^SL::DB::.*Invoice/;
+
+  my @vc_fields          = (qw(account_number bank bank_code bic business city contact country creditlimit discount
+                               email fax homepage iban language name payment_terms phone street taxnumber zipcode),
+                            "${vc}number");
+  my @vc_prefixed_fields = qw(email fax notes number phone);
+
+  _copy($self,                          $form, '',              '', 1, qw(amount netamount marge_total marge_percent container_remaining_weight container_remaining_volume paid));
+  _copy($self->$vc,                     $form, '',              '', 0, @vc_fields);
+  _copy($self->$vc,                     $form, $vc,             '', 0, @vc_prefixed_fields);
   _copy($self->contact,                 $form, '',              '', 0, grep { /^cp_/    } map { $_->name } SL::DB::Contact->meta->columns) if _has($self, 'cp_id');
   _copy($self->shipto,                  $form, '',              '', 0, grep { /^shipto/ } map { $_->name } SL::DB::Shipto->meta->columns)  if _has($self, 'shipto_id');
   _copy($self->globalproject,           $form, 'globalproject', '', 0, qw(number description))                                             if _has($self, 'globalproject_id');