X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fic.pl;h=28d41f3b3928c0aaac41a001517a5b4fe21ca44f;hb=b6133a726fa261cb97f2c105ea4a93161609d6ca;hp=4a333421fa361bbe4236a9397d34f613511353ee;hpb=728729b6163701a522eff7f5396a2fc44a80fb64;p=kivitendo-erp.git
diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl
index 4a333421f..28d41f3b3 100644
--- a/bin/mozilla/ic.pl
+++ b/bin/mozilla/ic.pl
@@ -1549,7 +1549,7 @@ sub generate_report {
$form->{ledgerchecks} = 'Y' if ( $form->{bought} || $form->{sold} || $form->{onorder}
|| $form->{ordered} || $form->{rfq} || $form->{quoted});
- # if something should be aktivated if something else is active, enter it here
+ # if something should be activated if something else is active, enter it here
my %dependencies = (
onhand => [ qw(l_onhand) ],
short => [ qw(l_onhand) ],
@@ -1685,8 +1685,7 @@ sub generate_report {
);
map { $column_defs{$_}->{visible} = $form->{"l_$_"} ? 1 : 0 } @columns;
-
- my %column_alignment = map { $_ => 'right' } qw(onhand sellprice listprice lastcost linetotalsellprice linetotallastcost linetotallistprice rop weight soldtotal);
+ map { $column_defs{$_}->{align} = 'right' } qw(onhand sellprice listprice lastcost linetotalsellprice linetotallastcost linetotallistprice rop weight soldtotal);
my @hidden_variables = (qw(l_subtotal l_linetotal searchitems itemstatus bom), @itemstatus_keys, @callback_keys, map { "l_$_" } @columns);
my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
@@ -1715,7 +1714,7 @@ sub generate_report {
'output_format' => 'HTML',
'title' => $form->{title},
'attachment_basename' => $attachment_basenames{$form->{searchitems}} . strftime('_%Y%m%d', localtime time),
- );
+ );
$report->set_options_from_form();
$report->set_columns(%column_defs);
@@ -1729,28 +1728,26 @@ sub generate_report {
my %subtotals = map { $_ => 0 } ('onhand', @subtotal_columns);
my %totals = map { $_ => 0 } @subtotal_columns;
my $idx = 0;
+ my $same_item = $form->{parts}[0]{ $form->{sort} } if (scalar @{ $form->{parts} });
+ # postprocess parts
foreach my $ref (@{ $form->{parts} }) {
- my $row = { };
- foreach (@columns) {
- $row->{$_} = {
- 'align' => $column_alignment{$_},
- 'data' => $ref->{$_},
- };
- }
+ # fresh row, for inserting later
+ my $row = { map { $_ => { 'data' => $ref->{$_} } } @columns };
- $ref->{exchangerate} = 1 unless $ref->{exchangerate};
- $ref->{sellprice} *= $ref->{exchangerate};
- $ref->{listprice} *= $ref->{exchangerate};
- $ref->{lastcost} *= $ref->{exchangerate};
+ $ref->{exchangerate} ||= 1;
+ $ref->{price_factor} ||= 1;
+ $ref->{sellprice} *= $ref->{exchangerate} / $ref->{price_factor};
+ $ref->{listprice} *= $ref->{exchangerate} / $ref->{price_factor};
+ $ref->{lastcost} *= $ref->{exchangerate} / $ref->{price_factor};
# use this for assemblies
my $onhand = $ref->{onhand};
if ($ref->{assemblyitem}) {
- $row->{partnumber}->{align} = 'right';
- $row->{onhand}->{data} = 0;
+ $row->{partnumber}{align} = 'right';
+ $row->{onhand}{data} = 0;
$onhand = 0 if ($form->{sold});
}
@@ -1759,11 +1756,11 @@ sub generate_report {
$row->{description}->{link} = $edit_link;
foreach (qw(sellprice listprice lastcost)) {
- $row->{$_}->{data} = $form->format_amount(\%myconfig, $ref->{$_}, -2);
- $row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{$_}, 2);
+ $row->{$_}{data} = $form->format_amount(\%myconfig, $ref->{$_}, -2);
+ $row->{"linetotal$_"}{data} = $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{$_}, 2);
}
- map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $ref->{$_}); } qw(onhand rop weight soldtotal);
+ map { $row->{$_}{data} = $form->format_amount(\%myconfig, $ref->{$_}); } qw(onhand rop weight soldtotal);
if (!$ref->{assemblyitem}) {
foreach my $col (@subtotal_columns) {
@@ -1774,29 +1771,32 @@ sub generate_report {
$subtotals{onhand} += $onhand;
}
+ # set module stuff
if ($ref->{module} eq 'oe') {
my $edit_oe_link = build_std_url("script=oe.pl", 'action=edit', 'type=' . E($ref->{type}), 'id=' . E($ref->{trans_id}), 'callback');
- $row->{ordnumber}->{link} = $edit_oe_link;
- $row->{quonumber}->{link} = $edit_oe_link if (!$ref->{ordnumber});
+ $row->{ordnumber}{link} = $edit_oe_link;
+ $row->{quonumber}{link} = $edit_oe_link if (!$ref->{ordnumber});
} else {
- $row->{invnumber}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'type=invoice', 'id=' . E($ref->{trans_id}), 'callback');
+ $row->{invnumber}{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'type=invoice', 'id=' . E($ref->{trans_id}), 'callback');
}
+ # set properties of images
if ($ref->{image} && (lc $report->{options}->{output_format} eq 'html')) {
- $row->{image}->{data} = '';
- $row->{image}->{raw_data} = '';
+ $row->{image}{data} = '';
+ $row->{image}{raw_data} = '
';
}
- map { $row->{$_}->{link} = $ref->{$_} } qw(drawing microfiche);
+ map { $row->{$_}{link} = $ref->{$_} } qw(drawing microfiche);
$report->add_data($row);
- my $next_ref = $form->{parts}->[$idx + 1];
+ my $next_ref = $form->{parts}[$idx + 1];
+ # insert subtotal rows
if (($form->{l_subtotal} eq 'Y') &&
(!$next_ref ||
- (!$next_ref->{assemblyitem} && ($ref->{$form->{sort}} ne $next_ref->{$form->{sort}})))) {
- my $row = { map { $_ => { 'class' => 'listsubtotal', 'align' => 'right' } } @columns };
+ (!$next_ref->{assemblyitem} && ($same_item ne $next_ref->{ $form->{sort} })))) {
+ my $row = { map { $_ => { 'class' => 'listsubtotal', } } @columns };
if (($form->{searchitems} ne 'assembly') || !$form->{bom}) {
$row->{onhand}->{data} = $form->format_amount(\%myconfig, $subtotals{onhand});
@@ -1806,13 +1806,15 @@ sub generate_report {
map { $subtotals{$_} = 0 } ('onhand', @subtotal_columns);
$report->add_data($row);
+
+ $same_item = $next_ref->{ $form->{sort} };
}
$idx++;
}
if ($form->{"l_linetotal"}) {
- my $row = { map { $_ => { 'class' => 'listtotal', 'align' => 'right' } } @columns };
+ my $row = { map { $_ => { 'class' => 'listtotal', } } @columns };
map { $row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $totals{$_}, 2) } @subtotal_columns;
@@ -1985,6 +1987,7 @@ sub form_header {
my ($notdiscountableok, $notdiscountable);
my ($formula, $formula_label, $imagelinks, $obsolete, $shopok, $shop);
+ $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
map({ $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, -2) }
qw(sellprice listprice lastcost gv));
@@ -2325,6 +2328,22 @@ sub form_header {
$unit_select .= AM->unit_select_html($units, "unit", $form->{"unit"});
}
+ my $price_factor;
+ if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) {
+ my @values = ('', map { $_->{id} } @{ $form->{ALL_PRICE_FACTORS} });
+ my %labels = map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} };
+
+ $price_factor =
+ qq|