X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/d066fc37f559491011c5d9633ba501411cefe8f3..12cee6b016e8c461770f4ae198f09a1e705d65be:/SL/DB/Helper/FlattenToForm.pm diff --git a/SL/DB/Helper/FlattenToForm.pm b/SL/DB/Helper/FlattenToForm.pm index 04101c3f0..83f36cde3 100644 --- a/SL/DB/Helper/FlattenToForm.pm +++ b/SL/DB/Helper/FlattenToForm.pm @@ -25,7 +25,7 @@ sub flatten_to_form { $form->{$transdate_idx} = $self->transdate->to_lxoffice; } - $form->{vc} = $vc if ref($self) =~ /^SL::DB::.*Invoice/; + $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 @@ -53,6 +53,7 @@ sub flatten_to_form { my $format_amounts = $params{format_amounts} ? 1 : 0; my $format_notnull = $params{format_amounts} ? 2 : 0; my $format_percent = $params{format_amounts} ? 3 : 0; + my $format_noround = $params{format_amounts} ? 4 : 0; foreach my $item (@{ $self->items_sorted }) { next if _has($item, 'assemblyitem'); @@ -63,7 +64,8 @@ sub flatten_to_form { _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_amounts, qw(qty sellprice marge_total marge_percent lastcost)); + _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'); @@ -92,9 +94,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, -2) : 0 } @columns if $format_amounts == 4; return $src; }