Merge branch 'gewicht'
[kivitendo-erp.git] / SL / IS.pm
index 8f91a23..1dc1eff 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -154,7 +154,7 @@ sub invoice_details {
        partnotes serialnumber reqdate sellprice listprice netprice
        discount p_discount discount_sub nodiscount_sub
        linetotal  nodiscount_linetotal tax_rate projectnumber projectdescription
-       price_factor price_factor_name partsgroup);
+       price_factor price_factor_name partsgroup weight lineweight);
 
   push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
 
@@ -164,6 +164,7 @@ sub invoice_details {
 
   map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays, @tax_arrays, @payment_arrays);
 
+  my $totalweight = 0;
   foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
     $i = $item->[0];
 
@@ -280,6 +281,13 @@ sub invoice_details {
       push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} },              $projectnumbers{$form->{"project_id_$i"}});
       push(@{ $form->{TEMPLATE_ARRAYS}->{projectdescription} },         $projectdescriptions{$form->{"project_id_$i"}});
 
+      my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"};
+      $totalweight += $lineweight;
+      push @{ $form->{TEMPLATE_ARRAYS}->{weight} },            $form->format_amount($myconfig, $form->{"weight_$i"}, 3);
+      push @{ $form->{TEMPLATE_ARRAYS}->{weight_nofmt} },      $form->{"weight_$i"};
+      push @{ $form->{TEMPLATE_ARRAYS}->{lineweight} },        $form->format_amount($myconfig, $lineweight, 3);
+      push @{ $form->{TEMPLATE_ARRAYS}->{lineweight_nofmt} },  $lineweight;
+
       @taxaccounts = split(/ /, $form->{"taxaccounts_$i"});
       $taxrate     = 0;
       $taxdiff     = 0;
@@ -366,6 +374,11 @@ sub invoice_details {
     }
   }
 
+  $form->{totalweight}       = $form->format_amount($myconfig, $totalweight, 3);
+  $form->{totalweight_nofmt} = $totalweight;
+  my $defaults = AM->get_defaults();
+  $form->{weightunit}        = $defaults->{weightunit};
+
   foreach my $item (sort keys %taxaccounts) {
     $tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
 
@@ -1941,7 +1954,7 @@ sub retrieve_item {
          p.unit, p.assembly, p.onhand,
          p.notes AS partnotes, p.notes AS longdescription,
          p.not_discountable, p.formel, p.payment_id AS part_payment_id,
-         p.price_factor_id,
+         p.price_factor_id, p.weight,
 
          pfac.factor AS price_factor,