]> wagnertech.de Git - mfinanz.git/blobdiff - SL/IS.pm
Überflüssigen/unwirksamen Code entfernt.
[mfinanz.git] / SL / IS.pm
index 6c3dae2c923d19f5e12f2262895b8bc8cccbd89f..1ee47f20990f363c61a7bb3c86448697abfe895e 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -550,6 +550,12 @@ sub post_invoice {
 
     ($form->{id}) = $sth->fetchrow_array;
     $sth->finish;
+
+    if (!$form->{invnumber}) {
+      $form->{invnumber} =
+        $form->update_defaults($myconfig, $form->{type} eq "credit_note" ?
+                               "cnnumber" : "invnumber", $dbh);
+    }
   }
 
   map { $form->{$_} =~ s/\'/\'\'/g }
@@ -1856,8 +1862,7 @@ sub get_customer {
         $form->{"AR_amount_$i"} = "$ref->{accno}--$ref->{description}";
       }
       if ($ref->{category} eq 'A') {
-        $form->{ARselected} = $form->{AR_1} =
-          "$ref->{accno}--$ref->{description}";
+        $form->{ARselected} = $form->{AR_1} = $ref->{accno};
       }
     }
     $sth->finish;
@@ -2218,5 +2223,28 @@ sub get_pricegroups_for_parts {
   $main::lxdebug->leave_sub();
 }
 
+sub has_storno {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $myconfig, $form, $table) = @_;
+
+  $main::lxdebug->leave_sub() and return 0 unless ($form->{id});
+
+  # make sure there's no funny stuff in $table
+  # ToDO: die when this happens and throw an error
+  $main::lxdebug->leave_sub() and return 0 if ($table =~ /\W/);
+
+  my $dbh = $form->dbconnect($myconfig);
+
+  my $query = qq|SELECT storno FROM $table WHERE id = ?|;
+  my ($result) = selectrow_query($form, $dbh, $query, $form->{id});
+
+  $dbh->disconnect();
+
+  $main::lxdebug->leave_sub();
+
+  return $result;
+}
+
 1;