Revision abc7d88b
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/DB/Helper/FlattenToForm.pm | ||
---|---|---|
49 | 49 |
$form->{rowcount} = scalar(@{ $self->items }); |
50 | 50 |
|
51 | 51 |
my $idx = 0; |
52 |
my $format_amounts = $params{format_amounts}; |
|
52 |
my $format_amounts = $params{format_amounts} ? 1 : 0; |
|
53 |
my $format_notnull = $params{format_amounts} ? 2 : 0; |
|
53 | 54 |
foreach my $item (@{ $self->items }) { |
54 | 55 |
next if _has($item, 'assemblyitem'); |
55 | 56 |
|
... | ... | |
57 | 58 |
|
58 | 59 |
$form->{"id_${idx}"} = $item->parts_id; |
59 | 60 |
$form->{"number_${idx}"} = $item->part->partnumber; |
60 |
_copy($item, $form, '', "_${idx}", 0, qw(description project_id ship serialnumber pricegroup_id ordnumber cusordnumber unit
|
|
61 |
_copy($item, $form, '', "_${idx}", 0, qw(description project_id ship serialnumber pricegroup_id ordnumber cusordnumber unit
|
|
61 | 62 |
subtotal longdescription price_factor_id marge_price_factor approved_sellprice reqdate transdate)); |
62 |
_copy($item, $form, '', "_${idx}", $format_amounts, qw(qty sellprice discount marge_total marge_percent lastcost)); |
|
63 |
_copy($item, $form, '', "_${idx}", $format_amounts, qw(qty sellprice marge_total marge_percent lastcost)); |
|
64 |
_copy($item, $form, '', "_${idx}", $format_notnull, qw(discount)); |
|
63 | 65 |
_copy($item->project, $form, 'project', "_${idx}", 0, qw(number description)) if _has($item, 'project_id'); |
64 | 66 |
|
65 | 67 |
_copy_custom_variables($item, $form, 'ic_cvar_', "_${idx}"); |
... | ... | |
78 | 80 |
sub _copy { |
79 | 81 |
my ($src, $form, $prefix, $postfix, $format_amounts, @columns) = @_; |
80 | 82 |
|
81 |
map { $form->{"${prefix}${_}${postfix}"} = ref($src->$_) eq 'DateTime' ? $src->$_->to_lxoffice : $src->$_ if $src->can($_) } @columns if !$format_amounts; |
|
82 |
map { $form->{"${prefix}${_}${postfix}"} = $::form->format_amount(\%::myconfig, $src->$_ * 1, 2) if $src->can($_) } @columns if $format_amounts; |
|
83 |
@columns = grep { $src->can($_) } @columns; |
|
84 |
|
|
85 |
map { $form->{"${prefix}${_}${postfix}"} = ref($src->$_) eq 'DateTime' ? $src->$_->to_lxoffice : $src->$_ } @columns if !$format_amounts; |
|
86 |
map { $form->{"${prefix}${_}${postfix}"} = $::form->format_amount(\%::myconfig, $src->$_ * 1, 2) } @columns if $format_amounts == 1; |
|
87 |
map { $form->{"${prefix}${_}${postfix}"} = $src->$_ * 1 ? $::form->format_amount(\%::myconfig, $src->$_ * 1, 2) : 0 } @columns if $format_amounts == 2; |
|
83 | 88 |
|
84 | 89 |
return $src; |
85 | 90 |
} |
Auch abrufbar als: Unified diff
"discount" auf "0" setzen, wenn gleich 0, und nicht formatiert auf "0,00"
Zwecks Kompatibilität mit Druckvariante im Legacy-Code.