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

  
bin/mozilla/ap.pl
1497 1497
    $form->error($locale->text("Transaction has already been cancelled!"));
1498 1498
  }
1499 1499

  
1500
  # negate amount/taxes
1501
  for my $i (1 .. $form->{rowcount}) {
1502
    $form->{"amount_$i"} *= -1;
1503
    $form->{"tax_$i"}    *= -1; 
1504
  }
1505

  
1506
  # format things
1507
  for my $i (1 .. $form->{rowcount}) {
1508
    for (qw(amount tax)) {
1509
      $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) if $form->{"${_}_$i"};
1510
    }
1511
  }
1512

  
1513
  $form->{storno}      = 1;
1514
  $form->{storno_id}   = $form->{id};
1515
  $form->{id}          = 0;
1516

  
1517
  $form->{invnumber}   = "Storno-" . $form->{invnumber};
1518

  
1519
  post();
1500
  AP->storno($form, \%myconfig, $form->{id});
1520 1501

  
1521 1502
  # saving the history
1522 1503
  if(!exists $form->{addition} && $form->{id} ne "") {
......
1526 1507
  }
1527 1508
  # /saving the history 
1528 1509

  
1510
  $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); 
1511

  
1529 1512
  $lxdebug->leave_sub();
1530 1513
}

Auch abrufbar als: Unified diff