Revision 0d37f1e8
Von Moritz Bunkus vor mehr als 9 Jahren hinzugefügt
bin/mozilla/ir.pl | ||
---|---|---|
37 | 37 |
use SL::PE; |
38 | 38 |
use SL::DB::Default; |
39 | 39 |
use List::Util qw(max sum); |
40 |
use List::UtilsBy qw(sort_by); |
|
40 | 41 |
|
41 | 42 |
require "bin/mozilla/io.pl"; |
42 | 43 |
require "bin/mozilla/invoice_io.pl"; |
... | ... | |
349 | 350 |
$main::lxdebug->leave_sub(); |
350 | 351 |
} |
351 | 352 |
|
353 |
sub _sort_payments { |
|
354 |
my @fields = qw(acc_trans_id gldate datepaid source memo paid AR_paid); |
|
355 |
my @payments = |
|
356 |
grep { $_->{paid} != 0 } |
|
357 |
map { |
|
358 |
my $idx = $_; |
|
359 |
+{ map { ($_ => delete($::form->{"${_}_${idx}"})) } @fields } |
|
360 |
} (1..$::form->{paidaccounts}); |
|
361 |
|
|
362 |
@payments = sort_by { DateTime->from_kivitendo($_->{datepaid}) } @payments; |
|
363 |
|
|
364 |
$::form->{paidaccounts} = max scalar(@payments), 1; |
|
365 |
|
|
366 |
foreach my $idx (1 .. scalar(@payments)) { |
|
367 |
my $payment = $payments[$idx - 1]; |
|
368 |
$::form->{"${_}_${idx}"} = $payment->{$_} for @fields; |
|
369 |
} |
|
370 |
} |
|
371 |
|
|
352 | 372 |
sub form_footer { |
353 | 373 |
$main::lxdebug->enter_sub(); |
354 | 374 |
|
... | ... | |
391 | 411 |
} |
392 | 412 |
|
393 | 413 |
# payments |
414 |
_sort_payments(); |
|
415 |
|
|
394 | 416 |
my $totalpaid = 0; |
395 | 417 |
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); |
396 | 418 |
$form->{paid_indices} = [ 1 .. $form->{paidaccounts} ]; |
Auch abrufbar als: Unified diff
Rechnungen: Zahlungsein-/-ausgänge nach Datum sortieren