X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FHelper%2FFlattenToForm.pm;h=3cb7b5f498dddced5eee747ee0307c33c1e3246d;hb=6418adee39dc8d7331df12b716096f0a8611ef5d;hp=a9c0264ef419bbc5a9c3802f4247189d436e5ef0;hpb=b103ea259f681f2ca5036e7b0915423c2a8ccc7a;p=kivitendo-erp.git diff --git a/SL/DB/Helper/FlattenToForm.pm b/SL/DB/Helper/FlattenToForm.pm index a9c0264ef..3cb7b5f49 100644 --- a/SL/DB/Helper/FlattenToForm.pm +++ b/SL/DB/Helper/FlattenToForm.pm @@ -28,7 +28,7 @@ sub flatten_to_form { $form->{vc} = $vc if ref($self) =~ m{^SL::DB::(?:.*Invoice|Order)}; my @vc_fields = (qw(account_number bank bank_code bic business city contact country creditlimit - department_1 department_2 discount email fax homepage iban language name + department_1 department_2 discount email fax gln homepage iban language name payment_terms phone street taxnumber ustid zipcode), "${vc}number", ($vc eq 'customer')? 'c_vendor_id': 'v_customer_id'); @@ -47,8 +47,14 @@ sub flatten_to_form { $form->{employee} = $self->employee->name if _has($self, 'employee_id'); $form->{language} = $self->language->template_code if _has($self, 'language_id'); $form->{department} = $self->department->description if _has($self, 'department_id'); + $form->{business} = $self->$vc->business->description if _has($self->$vc, 'business_id'); $form->{rowcount} = scalar(@{ $self->items }); + my $items_name = ref($self) eq 'SL::DB::Order' ? 'orderitems' + : ref($self) eq 'SL::DB::DeliveryOrder' ? 'delivery_order_items' + : ref($self) eq 'SL::DB::Invoice' ? 'invoice' + : ''; + my $idx = 0; my $format_amounts = $params{format_amounts} ? 1 : 0; my $format_notnull = $params{format_amounts} ? 2 : 0; @@ -60,14 +66,16 @@ sub flatten_to_form { $idx++; $form->{"partsgroup_${idx}"} = $item->part->partsgroup->partsgroup if _has($item->part, 'partsgroup_id'); - _copy($item->part, $form, '', "_${idx}", 0, qw(id partnumber weight)); - _copy($item->part, $form, '', "_${idx}", 0, qw(listprice)); - _copy($item, $form, '', "_${idx}", 0, qw(description project_id ship serialnumber pricegroup_id ordnumber donumber cusordnumber unit - subtotal longdescription price_factor_id marge_price_factor approved_sellprice reqdate transdate)); - _copy($item, $form, '', "_${idx}", $format_noround, qw(qty sellprice)); - _copy($item, $form, '', "_${idx}", $format_amounts, qw(marge_total marge_percent lastcost)); - _copy($item, $form, '', "_${idx}", $format_percent, qw(discount)); - _copy($item->project, $form, 'project', "_${idx}", 0, qw(number description)) if _has($item, 'project_id'); + _copy($item, $form, "${items_name}_", "_${idx}", 0, qw(id)) if $items_name; + _copy($item->part, $form, '', "_${idx}", 0, qw(id partnumber weight)); + _copy($item->part, $form, '', "_${idx}", 0, qw(listprice)); + _copy($item, $form, '', "_${idx}", 0, qw(description project_id ship serialnumber pricegroup_id ordnumber donumber cusordnumber unit + subtotal longdescription price_factor_id marge_price_factor approved_sellprice reqdate transdate + active_price_source active_discount_source)); + _copy($item, $form, '', "_${idx}", $format_noround, qw(qty sellprice)); + _copy($item, $form, '', "_${idx}", $format_amounts, qw(marge_total marge_percent lastcost)); + _copy($item, $form, '', "_${idx}", $format_percent, qw(discount)); + _copy($item->project, $form, 'project', "_${idx}", 0, qw(number description)) if _has($item, 'project_id'); _copy_custom_variables($item, $form, 'ic_cvar_', "_${idx}"); @@ -94,10 +102,10 @@ sub _copy { @columns = grep { $src->can($_) } @columns; map { $form->{"${prefix}${_}${postfix}"} = ref($src->$_) eq 'DateTime' ? $src->$_->to_lxoffice : $src->$_ } @columns if !$format_amounts; - map { $form->{"${prefix}${_}${postfix}"} = $::form->format_amount(\%::myconfig, $src->$_ * 1, 2) } @columns if $format_amounts == 1; - map { $form->{"${prefix}${_}${postfix}"} = $src->$_ * 1 ? $::form->format_amount(\%::myconfig, $src->$_ * 1, 2) : 0 } @columns if $format_amounts == 2; + map { $form->{"${prefix}${_}${postfix}"} = $::form->format_amount(\%::myconfig, $src->$_ * 1, 2) } @columns if $format_amounts == 1; + map { $form->{"${prefix}${_}${postfix}"} = $src->$_ * 1 ? $::form->format_amount(\%::myconfig, $src->$_ * 1, 2) : 0 } @columns if $format_amounts == 2; map { $form->{"${prefix}${_}${postfix}"} = $src->$_ * 1 ? $::form->format_amount(\%::myconfig, $src->$_ * 100, 2) : 0 } @columns if $format_amounts == 3; - map { $form->{"${prefix}${_}${postfix}"} = $src->$_ * 1 ? $::form->format_amount(\%::myconfig, $src->$_ * 1) : 0 } @columns if $format_amounts == 4; + map { $form->{"${prefix}${_}${postfix}"} = $src->$_ * 1 ? $::form->format_amount(\%::myconfig, $src->$_ * 1, -2) : 0 } @columns if $format_amounts == 4; return $src; }