]> wagnertech.de Git - mfinanz.git/blobdiff - SL/IC.pm
Die Zahlungskonditionen sortierbar gemacht.
[mfinanz.git] / SL / IC.pm
index 6942c41c819c1716e691408b6abbc7df90f7abb4..933b80173b04b459b3597f5042eda689e5cdb20f 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -310,7 +310,8 @@ sub retrieve_buchungsgruppen {
 
   # get buchungsgruppen
   $query = qq|SELECT id, description
-              FROM buchungsgruppen|;
+              FROM buchungsgruppen
+              ORDER BY sortkey|;
   $sth = $dbh->prepare($query);
   $sth->execute || $form->dberror($query);
 
@@ -502,6 +503,7 @@ sub save {
              shop = '$form->{shop}',
               ve = '$form->{ve}',
               gv = '$form->{gv}',
+              ean = '$form->{ean}',
               not_discountable = '$form->{not_discountable}',
              microfiche = '$form->{microfiche}',
              partsgroup_id = $partsgroup_id
@@ -933,6 +935,11 @@ sub all_parts {
     }
   }
 
+  if ($form->{ean}) {
+    $var = $form->like(lc $form->{ean});
+    $where .= " AND lower(ean) LIKE '$var'";
+  }
+  
   if ($form->{searchitems} eq 'part') {
     $where .= " AND p.inventory_accno_id > 0";
   }
@@ -1510,7 +1517,7 @@ sub create_links {
   # get payment terms
   $query = qq|SELECT id, description
               FROM payment_terms
-             ORDER BY 1|;
+              ORDER BY sortkey|;
   $sth = $dbh->prepare($query);
   $sth->execute || $form->dberror($query);
 
@@ -1519,22 +1526,12 @@ sub create_links {
   }
   $sth->finish;
 
-  if ($form->{id}) {
-    $query = qq|SELECT weightunit
-                FROM defaults|;
+  if (!$form->{id}) {
+    $query = qq|SELECT current_date FROM defaults|;
     $sth = $dbh->prepare($query);
     $sth->execute || $form->dberror($query);
 
-    ($form->{weightunit}) = $sth->fetchrow_array;
-    $sth->finish;
-
-  } else {
-    $query = qq|SELECT weightunit, current_date
-                FROM defaults|;
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    ($form->{weightunit}, $form->{priceupdate}) = $sth->fetchrow_array;
+    ($form->{priceupdate}) = $sth->fetchrow_array;
     $sth->finish;
   }
 
@@ -1772,7 +1769,7 @@ sub retrieve_accounts {
 
   my ($query, $sth, $dbh);
 
-  return $main::lxdebug->leave_sub() if (!defined($form->{"taxzone_id"}));
+  $form->{"taxzone_id"} *= 1;
 
   $dbh = $form->dbconnect($myconfig);
 
@@ -1783,6 +1780,8 @@ sub retrieve_accounts {
     } else {
       $transdate = $form->{deliverydate};
     }
+  } elsif ($form->{type} eq "credit_note") {
+    $transdate = $form->{invdate};
   } else {
     $transdate = $form->{transdate};
   }
@@ -1817,7 +1816,7 @@ sub retrieve_accounts {
 
   if (!$ref) {
     $dbh->disconnect();
-    return $lxdebug->leave_sub();
+    return $main::lxdebug->leave_sub();
   }
 
   $ref->{"inventory_accno_id"} = undef unless ($ref->{"is_part"});
@@ -1852,7 +1851,10 @@ sub retrieve_accounts {
   $sth->finish();
   $dbh->disconnect();
 
-  return $main::lxdebug->leave_sub() unless ($ref);
+  unless ($ref) {
+    $main::lxdebug->leave_sub();
+    return;
+  }
 
   $form->{"taxaccounts_$index"} = $ref->{"accno"};
   if ($form->{"taxaccounts"} !~ /$ref->{accno}/) {
@@ -1867,8 +1869,6 @@ sub retrieve_accounts {
 #                           " || taxaccounts_$index " . $form->{"taxaccounts_$index"} .
 #                           " || taxaccounts " . $form->{"taxaccounts"});
 
-  $sth->finish();
-
   $main::lxdebug->leave_sub();
 }
 1;