Revision 090de47c
Von Sven Schöling vor mehr als 17 Jahren hinzugefügt
SL/GL.pm | ||
---|---|---|
638 | 638 |
$main::lxdebug->leave_sub(); |
639 | 639 |
} |
640 | 640 |
|
641 |
sub storno { |
|
642 |
$main::lxdebug->enter_sub(); |
|
643 |
|
|
644 |
my ($self, $form, $myconfig, $id) = @_; |
|
645 |
|
|
646 |
my ($query, $new_id, $storno_row, $acc_trans_rows); |
|
647 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
648 |
|
|
649 |
$query = qq|SELECT nextval('glid')|; |
|
650 |
($new_id) = selectrow_query($form, $dbh, $query); |
|
651 |
|
|
652 |
$query = qq|SELECT * FROM gl WHERE id = ?|; |
|
653 |
$storno_row = selectfirst_hashref_query($form, $dbh, $query, $id); |
|
654 |
|
|
655 |
$storno_row->{id} = $new_id; |
|
656 |
$storno_row->{storno_id} = $id; |
|
657 |
$storno_row->{storno} = 't'; |
|
658 |
$storno_row->{reference} = 'Storno-' . $storno_row->{reference}; |
|
659 |
|
|
660 |
delete @$storno_row{qw(itime mtime)}; |
|
661 |
|
|
662 |
$query = sprintf 'INSERT INTO gl (%s) VALUES (%s)', join(', ', keys %$storno_row), join(', ', map '?', values %$storno_row); |
|
663 |
do_query($form, $dbh, $query, (values %$storno_row)); |
|
664 |
|
|
665 |
# now copy acc_trans entries |
|
666 |
$query = qq|SELECT * FROM acc_trans WHERE trans_id = ?|; |
|
667 |
my $rowref = selectall_hashref_query($form, $dbh, $query, $id); |
|
668 |
|
|
669 |
for my $row (@$rowref) { |
|
670 |
delete @$row{qw(itime mtime)}; |
|
671 |
$query = sprintf 'INSERT INTO acc_trans (%s) VALUES (%s)', join(', ', keys %$row), join(', ', map '?', values %$row); |
|
672 |
$row->{trans_id} = $new_id; |
|
673 |
$row->{amount} *= -1; |
|
674 |
do_query($form, $dbh, $query, (values %$row)); |
|
675 |
} |
|
676 |
|
|
677 |
$dbh->commit; |
|
678 |
|
|
679 |
$main::lxdebug->leave_sub(); |
|
680 |
} |
|
681 |
|
|
641 | 682 |
1; |
Auch abrufbar als: Unified diff
Stornomechanismus mal auf Dialogbuchen ausgeweitet