Mahnungen: Metadaten der Mitarbeiter (Bearbeiter/Verkäufer) setzen
[kivitendo-erp.git] / SL / AP.pm
index ae75dc9..46b25ea 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -25,7 +25,8 @@
 # GNU General Public License for more details.
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
 #======================================================================
 #
 # Accounts Payables database backend routines
@@ -65,8 +66,6 @@ sub _post_transaction {
   $form->{defaultcurrency} = $form->get_default_currency($myconfig);
   $form->{taxincluded} = 0 unless $form->{taxincluded};
 
-  ($null, $form->{department_id}) = split(/--/, $form->{department});
-
   if ($form->{currency} eq $form->{defaultcurrency}) {
     $form->{exchangerate} = 1;
   } else {
@@ -403,7 +402,8 @@ sub delete_transaction {
   SL::DB->client->with_transaction(sub {
     my $query = qq|DELETE FROM ap WHERE id = ?|;
     do_query($form, SL::DB->client->dbh, $query, $form->{id});
-  });
+    1;
+  }) or do { die SL::DB->client->error };
 
   $main::lxdebug->leave_sub();
 
@@ -461,13 +461,9 @@ sub ap_transactions {
     $where .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
     push(@values, (like($form->{"cp_name"}))x2);
   }
-  if ($form->{department}) {
-    # ähnlich wie commit 0bbfb33b6aa8e38bb6c81d1684ab7d08e5b5c5af abteilung
-    # wird so nicht mehr als zeichenkette zusammengebaut
-    # hätte zu ee9f9f9aa4c3b9d5d20ab10a45c12bcaa6aa78d0 auffallen können ;-) jan
-    #my ($null, $department_id) = split /--/, $form->{department};
+  if ($form->{department_id}) {
     $where .= " AND a.department_id = ?";
-    push(@values, $form->{department});
+    push(@values, $form->{department_id});
   }
   if ($form->{invnumber}) {
     $where .= " AND a.invnumber ILIKE ?";
@@ -564,7 +560,7 @@ sub get_transdate {
   my ($self, $myconfig, $form) = @_;
 
   # connect to database
-  my $dbh = $form->dbconnect($myconfig);
+  my $dbh = SL::DB->client->dbh;
 
   my $query =
     "SELECT COALESCE(" .
@@ -573,8 +569,6 @@ sub get_transdate {
     "  current_date)";
   ($form->{transdate}) = $dbh->selectrow_array($query);
 
-  $dbh->disconnect;
-
   $main::lxdebug->leave_sub();
 }