Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2b3f8b3a

Von Sven Schöling vor mehr als 17 Jahren hinzugefügt

  • ID 2b3f8b3a8e518497566e3281dae387db2d98500a
  • Vorgänger 85f48169
  • Nachfolger d467f40d

und das ganze nochmal für Kreditorenbuchungen und deren Stornos

Unterschiede anzeigen:

SL/AP.pm
745 745
  $main::lxdebug->leave_sub();
746 746
}
747 747

  
748
sub storno {
749
  $main::lxdebug->enter_sub();
750

  
751
  my ($self, $form, $myconfig, $id) = @_;
752

  
753
  my ($query, $new_id, $storno_row, $acc_trans_rows);
754
  my $dbh = $form->get_standard_dbh($myconfig);
755

  
756
  $query = qq|SELECT nextval('glid')|;
757
  ($new_id) = selectrow_query($form, $dbh, $query);
758

  
759
  $query = qq|SELECT * FROM ap WHERE id = ?|;
760
  $storno_row = selectfirst_hashref_query($form, $dbh, $query, $id);
761

  
762
  $storno_row->{id}         = $new_id;
763
  $storno_row->{storno_id}  = $id;
764
  $storno_row->{storno}     = 't';
765
  $storno_row->{invnumber}  = 'Storno-' . $storno_row->{invnumber};
766
  $storno_row->{amount}    *= -1;
767
  $storno_row->{netamount} *= -1;
768
  $storno_row->{paid}       = $storno_amount->{amount};
769

  
770
  delete @$storno_row{qw(itime mtime)};
771

  
772
  $query = sprintf 'INSERT INTO ap (%s) VALUES (%s)', join(', ', keys %$storno_row), join(', ', map '?', values %$storno_row);
773
  do_query($form, $dbh, $query, (values %$storno_row));
774

  
775
  $query = qq|UPDATE ap SET paid = amount + paid, storno = 't' WHERE id = ?|;
776
  do_query($form, $dbh, $query, $id);
777

  
778
  # now copy acc_trans entries
779
  $query = qq|SELECT * FROM acc_trans WHERE trans_id = ?|;
780
  for my $row (@{ selectall_hashref_query($form, $dbh, $query, $id) }) {
781
    delete @$row{qw(itime mtime)};
782
    $query = sprintf 'INSERT INTO acc_trans (%s) VALUES (%s)', join(', ', keys %$row), join(', ', map '?', values %$row);
783
    $row->{trans_id}   = $new_id;
784
    $row->{amount}    *= -1;
785
    do_query($form, $dbh, $query, (values %$row));
786
  }
787

  
788
  $dbh->commit;
789

  
790
  $main::lxdebug->leave_sub();
791
}
792

  
748 793
1;
749 794

  

Auch abrufbar als: Unified diff