Revision 238d4a46
Von Bernd Bleßmann vor etwa 3 Jahren hinzugefügt
SL/IS.pm | ||
---|---|---|
1061 | 1061 |
my $transactions = SL::DB::Manager::AccTransaction->get_all(query => [ trans_id => $invoice_for_advance_payment->id ], sort_by => 'acc_trans_id ASC'); |
1062 | 1062 |
foreach my $transaction (@$transactions) { |
1063 | 1063 |
$form->{amount}->{$invoice_for_advance_payment->id}->{$transaction->chart->accno} = -1 * $transaction->amount; |
1064 |
$form->{memo} ->{$invoice_for_advance_payment->id}->{$transaction->chart->accno} = 'reverse booking by final invoice'; |
|
1064 | 1065 |
} |
1065 | 1066 |
} |
1066 | 1067 |
|
... | ... | |
1101 | 1102 |
|
1102 | 1103 |
if (!$payments_only && ($form->{amount}{$trans_id}{$accno} != 0)) { |
1103 | 1104 |
$query = |
1104 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link) |
|
1105 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link, memo)
|
|
1105 | 1106 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
1106 | 1107 |
(SELECT tax_id |
1107 | 1108 |
FROM taxkeys |
... | ... | |
1118 | 1119 |
AND startdate <= ? |
1119 | 1120 |
ORDER BY startdate DESC LIMIT 1), |
1120 | 1121 |
?, |
1121 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
1122 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_date($taxdate), conv_i($project_id), $accno); |
|
1122 |
(SELECT link FROM chart WHERE accno = ?), |
|
1123 |
?)|; |
|
1124 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_date($taxdate), conv_i($project_id), $accno, $form->{memo}{$trans_id}{$accno}); |
|
1123 | 1125 |
do_query($form, $dbh, $query, @values); |
1124 | 1126 |
$form->{amount}{$trans_id}{$accno} = 0; |
1125 | 1127 |
} |
... | ... | |
1130 | 1132 |
|
1131 | 1133 |
if (!$payments_only && ($form->{amount}{$trans_id}{$accno} != 0)) { |
1132 | 1134 |
$query = |
1133 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link) |
|
1135 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link, memo)
|
|
1134 | 1136 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
1135 | 1137 |
(SELECT tax_id |
1136 | 1138 |
FROM taxkeys |
... | ... | |
1147 | 1149 |
AND startdate <= ? |
1148 | 1150 |
ORDER BY startdate DESC LIMIT 1), |
1149 | 1151 |
?, |
1150 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
1151 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_date($taxdate), conv_i($project_id), $accno); |
|
1152 |
(SELECT link FROM chart WHERE accno = ?), |
|
1153 |
?)|; |
|
1154 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_date($taxdate), conv_i($project_id), $accno,$form->{memo}{$trans_id}{$accno}); |
|
1152 | 1155 |
do_query($form, $dbh, $query, @values); |
1153 | 1156 |
} |
1154 | 1157 |
} |
... | ... | |
2005 | 2008 |
do_query($form, $dbh, qq|UPDATE ar SET storno = 'f', paid = 0 WHERE id = ?|, $invoice_id); |
2006 | 2009 |
} |
2007 | 2010 |
|
2011 |
# if we delete a final invoice, the reverse bookings for the clearing account in the invoice for advance payment |
|
2012 |
# must be deleted as well |
|
2013 |
my $invoices_for_advance_payment = $self->_get_invoices_for_advance_payment($form->{convert_from_ar_ids} || $form->{id}); |
|
2014 |
my @trans_ids_to_consider = map { $_->id } @$invoices_for_advance_payment; |
|
2015 |
if (scalar @trans_ids_to_consider) { |
|
2016 |
my $query = sprintf 'DELETE FROM acc_trans WHERE memo LIKE ? AND trans_id IN (%s)', join ', ', ("?") x scalar @trans_ids_to_consider; |
|
2017 |
do_query($form, $dbh, $query, 'reverse booking by final invoice', @trans_ids_to_consider); |
|
2018 |
} |
|
2019 |
|
|
2008 | 2020 |
# delete spool files |
2009 | 2021 |
my @spoolfiles = selectall_array_query($form, $dbh, qq|SELECT spoolfile FROM status WHERE trans_id = ?|, @values); |
2010 | 2022 |
|
Auch abrufbar als: Unified diff
Anzahlungs-Rg.: Gegenbuchung bei Löschen der Schluss-Rg. löschen
Gegenbuchungen werden in acc_trans markiert (Text in memo)