Revision 0d37f1e8
Von Moritz Bunkus vor mehr als 9 Jahren hinzugefügt
bin/mozilla/is.pl | ||
---|---|---|
39 | 39 |
use DateTime; |
40 | 40 |
use List::MoreUtils qw(uniq); |
41 | 41 |
use List::Util qw(max sum); |
42 |
use List::UtilsBy qw(sort_by); |
|
42 | 43 |
use English qw(-no_match_vars); |
43 | 44 |
|
44 | 45 |
use SL::DB::Default; |
... | ... | |
400 | 401 |
$main::lxdebug->leave_sub(); |
401 | 402 |
} |
402 | 403 |
|
404 |
sub _sort_payments { |
|
405 |
my @fields = qw(acc_trans_id gldate datepaid source memo paid AR_paid); |
|
406 |
my @payments = |
|
407 |
grep { $_->{paid} != 0 } |
|
408 |
map { |
|
409 |
my $idx = $_; |
|
410 |
+{ map { ($_ => delete($::form->{"${_}_${idx}"})) } @fields } |
|
411 |
} (1..$::form->{paidaccounts}); |
|
412 |
|
|
413 |
@payments = sort_by { DateTime->from_kivitendo($_->{datepaid}) } @payments; |
|
414 |
|
|
415 |
$::form->{paidaccounts} = max scalar(@payments), 1; |
|
416 |
|
|
417 |
foreach my $idx (1 .. scalar(@payments)) { |
|
418 |
my $payment = $payments[$idx - 1]; |
|
419 |
$::form->{"${_}_${idx}"} = $payment->{$_} for @fields; |
|
420 |
} |
|
421 |
} |
|
422 |
|
|
403 | 423 |
sub form_footer { |
404 | 424 |
$main::lxdebug->enter_sub(); |
405 | 425 |
|
... | ... | |
446 | 466 |
} |
447 | 467 |
|
448 | 468 |
# payments |
469 |
_sort_payments(); |
|
470 |
|
|
449 | 471 |
my $totalpaid = 0; |
450 | 472 |
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); |
451 | 473 |
$form->{paid_indices} = [ 1 .. $form->{paidaccounts} ]; |
Auch abrufbar als: Unified diff
Rechnungen: Zahlungsein-/-ausgänge nach Datum sortieren