]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Rechnungs- und Gutschriftsnummern werden nun direkt innerhalb der Backend-Routinen...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 1 Mar 2007 14:19:20 +0000 (14:19 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 1 Mar 2007 14:19:20 +0000 (14:19 +0000)
SL/AR.pm
SL/Form.pm
SL/IS.pm
bin/mozilla/ar.pl
bin/mozilla/io.pl
bin/mozilla/is.pl

index 17dbd64999b68b82cb0f8c56f142c47d24403f8d..96e66ef4be2434c39d21a3a5e4af18c703d95436 100644 (file)
--- a/SL/AR.pm
+++ b/SL/AR.pm
@@ -170,6 +170,10 @@ sub post_transaction {
 
     $query = qq|INSERT INTO ar (id, invnumber, employee_id) VALUES (?, 'dummy', ?)|;
     do_query($form, $dbh, $query, $form->{id}, $form->{employee_id});
+
+    if (!$form->{invnumber}) {
+      $form->{invnumber} = $form->update_defaults($myconfig, "invnumber", $dbh);
+    }
   }
 
   # update department
index 157bb61b0833a2c6229a8860ed526bf66579cd19..edf5de978038c3254fb921ce745626f5cc6ce1e1 100644 (file)
@@ -2448,9 +2448,14 @@ sub save_status {
 sub update_defaults {
   $main::lxdebug->enter_sub();
 
-  my ($self, $myconfig, $fld) = @_;
+  my ($self, $myconfig, $fld, $provided_dbh) = @_;
 
-  my $dbh   = $self->dbconnect_noauto($myconfig);
+  my $dbh;
+  if ($provided_dbh) {
+    $dbh = $provided_dbh;
+  } else {
+    $dbh = $self->dbconnect_noauto($myconfig);
+  }
   my $query = qq|SELECT $fld FROM defaults FOR UPDATE|;
   my $sth   = $dbh->prepare($query);
 
@@ -2464,8 +2469,10 @@ sub update_defaults {
               SET $fld = '$var'|;
   $dbh->do($query) || $self->dberror($query);
 
-  $dbh->commit;
-  $dbh->disconnect;
+  if (!$provided_dbh) {
+    $dbh->commit;
+    $dbh->disconnect;
+  }
 
   $main::lxdebug->leave_sub();
 
index a7b09917c065bf453723b6d38c91eaca98f8cdc5..6b69bb24909367cfdb9fde72ad9aa7a25be21e74 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 }
index da4315b2ec7838a6c2ced993b8af5285d4db5fa0..5b3e3b2a1fdb76537b3f8c6eeb011e99ca568ed0 100644 (file)
@@ -1050,9 +1050,6 @@ sub post {
 
   $form->{AR}{receivables} = $form->{ARselected};
 
-  $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
-    unless $form->{invnumber};
-
   $form->{id} = 0 if $form->{postasnew};
   if (AR->post_transaction(\%myconfig, \%$form)) {
     # saving the history
index f38ffe20a817ca48b6af5e9fcab301f693b1159c..6fa6718a71e345c01f90fa68905d4a03404517da 100644 (file)
@@ -1864,7 +1864,7 @@ sub print_form {
 
   # assign number
   $form->{what_done} = $form->{formname};
-  if (!$form->{"${inv}number"} && !$form->{preview}) {
+  if (!$form->{"${inv}number"} && !$form->{preview} && !$form->{id}) {
     $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
     if ($form->{media} ne 'email') {
 
index 9b6da27c60bf5c538ee6ffdbf6ca0f4ccdf40ee0..33a049f171131b2bbe53d9bd7be3a6313534bbbb 100644 (file)
@@ -1441,13 +1441,14 @@ sub post {
   $form->{id} = 0 if $form->{postasnew};
 
   # get new invnumber in sequence if no invnumber is given or if posasnew was requested
-  if (!$form->{invnumber} || $form->{postasnew}) {
+  if ($form->{postasnew}) {
     if ($form->{type} eq "credit_note") {
-      $form->{invnumber} = $form->update_defaults(\%myconfig, "cnnumber");
+      undef($form->{cnnumber});
     } else {
-      $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber");
+      undef($form->{invnumber});
     }
   }
+
   relink_accounts();
   if ($print_post) {
     if (!(IS->post_invoice(\%myconfig, \%$form))) {