Revision 40c2c37c
Von Moritz Bunkus vor etwa 15 Jahren hinzugefügt
SL/AR.pm | ||
---|---|---|
36 | 36 |
|
37 | 37 |
use Data::Dumper; |
38 | 38 |
use SL::DBUtils; |
39 |
use SL::IO; |
|
39 | 40 |
use SL::MoreCommon; |
40 | 41 |
|
41 | 42 |
use strict; |
... | ... | |
141 | 142 |
($null, $form->{department_id}) = split(/--/, $form->{department}); |
142 | 143 |
$form->{department_id} *= 1; |
143 | 144 |
|
144 |
# record last payment date in ar table |
|
145 |
$form->{datepaid} ||= $form->{transdate} ; |
|
146 |
my $datepaid = ($form->{paid} != 0) ? $form->{datepaid} : undef; |
|
147 |
|
|
148 | 145 |
# amount for AR account |
149 | 146 |
$form->{receivables} = $form->round_amount($form->{amount}, 2) * -1; |
150 | 147 |
|
... | ... | |
156 | 153 |
$query = |
157 | 154 |
qq|UPDATE ar set |
158 | 155 |
invnumber = ?, ordnumber = ?, transdate = ?, customer_id = ?, |
159 |
taxincluded = ?, amount = ?, duedate = ?, paid = ?, datepaid = ?,
|
|
156 |
taxincluded = ?, amount = ?, duedate = ?, paid = ?, |
|
160 | 157 |
netamount = ?, curr = ?, notes = ?, department_id = ?, |
161 | 158 |
employee_id = ?, storno = ?, storno_id = ? |
162 | 159 |
WHERE id = ?|; |
163 | 160 |
my @values = ($form->{invnumber}, $form->{ordnumber}, conv_date($form->{transdate}), conv_i($form->{customer_id}), $form->{taxincluded} ? 't' : 'f', $form->{amount}, |
164 |
conv_date($form->{duedate}), $form->{paid}, conv_date($datepaid), $form->{netamount}, $form->{currency}, $form->{notes}, conv_i($form->{department_id}),
|
|
161 |
conv_date($form->{duedate}), $form->{paid}, $form->{netamount}, $form->{currency}, $form->{notes}, conv_i($form->{department_id}), |
|
165 | 162 |
conv_i($form->{employee_id}), $form->{storno} ? 't' : 'f', $form->{storno_id}, conv_i($form->{id})); |
166 | 163 |
do_query($form, $dbh, $query, @values); |
167 | 164 |
|
... | ... | |
266 | 263 |
} |
267 | 264 |
} |
268 | 265 |
|
266 |
IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh); |
|
267 |
|
|
269 | 268 |
my $rc = 1; |
270 | 269 |
if (!$provided_dbh) { |
271 | 270 |
$rc = $dbh->commit(); |
... | ... | |
673 | 672 |
do_query($form, $dbh, $query, (values %$row)); |
674 | 673 |
} |
675 | 674 |
|
675 |
map { IO->set_datepaid(table => 'ap', id => $_, dbh => $dbh) } ($id, $new_id); |
|
676 |
|
|
676 | 677 |
$dbh->commit; |
677 | 678 |
|
678 | 679 |
$main::lxdebug->leave_sub(); |
Auch abrufbar als: Unified diff
Beim Buchen von Rechnungen/Zahlungen das Feld "datepaid" richtig setzen.
Zusätzlich noch ein Datenbankupgradescript, das die Felder in
bestehenden Einträgen berichtigt.