]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Form.pm
Bugfix für einen meiner letzten Commits: Beim Anklicken von "Lieferadresse" blieb...
[mfinanz.git] / SL / Form.pm
index 4bea5f094d4dc51386abb29df1940b52289e6e98..8b76128374df245303517174b874e8f3f4cfaa96 100644 (file)
@@ -146,7 +146,7 @@ sub new {
   $self->{action} = lc $self->{action};
   $self->{action} =~ s/( |-|,|\#)/_/g;
 
-  $self->{version}   = "2.4.0";
+  $self->{version}   = "2.4.1";
 
   $main::lxdebug->leave_sub();
 
@@ -868,10 +868,10 @@ sub parse_template {
           open(OUT, $self->{OUT})
             or $self->error($self->cleanup . "$self->{OUT} : $!");
         } else {
-
+          $self->{attachment_filename} = $self->{tmpfile} if ($self->{attachment_filename} eq '');
           # launch application
           print qq|Content-Type: | . $template->get_mime_type() . qq|
-Content-Disposition: attachment; filename="$self->{tmpfile}"
+Content-Disposition: attachment; filename="$self->{attachment_filename}"
 Content-Length: $numbytes
 
 |;
@@ -1136,6 +1136,14 @@ sub set_payment_options {
   
     ($self->{terms_netto}, $self->{terms_skonto}, $self->{percent_skonto}, $self->{payment_terms}) = $sth->fetchrow_array;
 
+    if ($transdate eq "") {
+      if ($self->{invdate}) {
+        $transdate = $self->{invdate};
+      } else {
+        $transdate = $self->{transdate};
+      }
+    }
+
     $sth->finish;
     my $query = qq|SELECT date '$transdate' + $self->{terms_netto} AS netto_date,date '$transdate' + $self->{terms_skonto} AS skonto_date  FROM payment_terms
                   LIMIT 1|;
@@ -1144,7 +1152,9 @@ sub set_payment_options {
     ($self->{netto_date}, $self->{skonto_date}) = $sth->fetchrow_array;
     $sth->finish;
 
-    $self->{skonto_amount} = $self->format_amount($myconfig, ($self->parse_amount($myconfig, $self->{subtotal}) * $self->{percent_skonto}), 2);
+    my $total = ($self->{invtotal}) ? $self->{invtotal} : $self->{ordtotal};
+
+    $self->{skonto_amount} = $self->format_amount($myconfig, ($self->parse_amount($myconfig, $total) * $self->{percent_skonto}), 2);
 
     $self->{payment_terms} =~ s/<%netto_date%>/$self->{netto_date}/g;
     $self->{payment_terms} =~ s/<%skonto_date%>/$self->{skonto_date}/g;