]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DO.pm
Fix DB-Upgrade »Wiedervorlagen löschen, wenn dazugehörige Belege gelöscht werden«
[mfinanz.git] / SL / DO.pm
index cec2e9b5d61fc91fd41e14c36280c4adc78615b8..bc651c8ed6b896b49a276cae16114d6a4753a164 100644 (file)
--- a/SL/DO.pm
+++ b/SL/DO.pm
@@ -725,6 +725,8 @@ sub order_details {
   my @partsgroup = ();
   my $partsgroup;
   my $position = 0;
   my @partsgroup = ();
   my $partsgroup;
   my $position = 0;
+  my $subtotal_header = 0;
+  my $subposition = 0;
 
   my (@project_ids, %projectnumbers, %projectdescriptions);
 
 
   my (@project_ids, %projectnumbers, %projectdescriptions);
 
@@ -797,8 +799,6 @@ sub order_details {
 
     next if (!$form->{"id_$i"});
 
 
     next if (!$form->{"id_$i"});
 
-    $position++;
-
     if ($item->[1] ne $sameitem) {
       push(@{ $form->{description} }, qq|$item->[1]|);
       $sameitem = $item->[1];
     if ($item->[1] ne $sameitem) {
       push(@{ $form->{description} }, qq|$item->[1]|);
       $sameitem = $item->[1];
@@ -809,6 +809,19 @@ sub order_details {
     $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
 
     # add number, description and qty to $form->{number}, ....
     $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
 
     # add number, description and qty to $form->{number}, ....
+    if ($form->{"subtotal_$i"} && !$subtotal_header) {
+      $subtotal_header = $i;
+      $position = int($position);
+      $subposition = 0;
+      $position++;
+    } elsif ($subtotal_header) {
+      $subposition += 1;
+      $position = int($position);
+      $position = $position.".".$subposition;
+    } else {
+      $position = int($position);
+      $position++;
+    }
 
     my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 };
 
 
     my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 };
 
@@ -826,6 +839,10 @@ sub order_details {
     push @{ $form->{TEMPLATE_ARRAYS}{projectdescription} },
       $projectdescriptions{$form->{"project_id_$i"}};
 
     push @{ $form->{TEMPLATE_ARRAYS}{projectdescription} },
       $projectdescriptions{$form->{"project_id_$i"}};
 
+    if ($form->{"subtotal_$i"} && $subtotal_header && ($subtotal_header != $i)) {
+      $subtotal_header     = 0;
+    }
+
     my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"};
     $totalweight += $lineweight;
     push @{ $form->{TEMPLATE_ARRAYS}->{weight} },            $form->format_amount($myconfig, $form->{"weight_$i"}, 3);
     my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"};
     $totalweight += $lineweight;
     push @{ $form->{TEMPLATE_ARRAYS}->{weight} },            $form->format_amount($myconfig, $form->{"weight_$i"}, 3);
@@ -895,6 +912,7 @@ sub order_details {
   $h_bin_wh->finish();
 
   $form->{delivery_term} = SL::DB::Manager::DeliveryTerm->find_by(id => $form->{delivery_term_id} || undef);
   $h_bin_wh->finish();
 
   $form->{delivery_term} = SL::DB::Manager::DeliveryTerm->find_by(id => $form->{delivery_term_id} || undef);
+  $form->{delivery_term}->description_long($form->{delivery_term}->translated_attribute('description_long', $form->{language_id})) if $form->{delivery_term} && $form->{language_id};
 
   $form->{username} = $myconfig->{name};
 
 
   $form->{username} = $myconfig->{name};