Revision 0d37f1e8
Von Moritz Bunkus vor mehr als 9 Jahren hinzugefügt
bin/mozilla/ap.pl | ||
---|---|---|
32 | 32 |
#====================================================================== |
33 | 33 |
|
34 | 34 |
use POSIX qw(strftime); |
35 |
use List::Util qw(sum); |
|
35 |
use List::Util qw(max sum); |
|
36 |
use List::UtilsBy qw(sort_by); |
|
36 | 37 |
|
37 | 38 |
use SL::AP; |
38 | 39 |
use SL::FU; |
... | ... | |
187 | 188 |
$main::lxdebug->leave_sub(); |
188 | 189 |
} |
189 | 190 |
|
191 |
sub _sort_payments { |
|
192 |
my @fields = qw(acc_trans_id gldate datepaid source memo paid AR_paid paid_project_id); |
|
193 |
my @payments = |
|
194 |
grep { $_->{paid} != 0 } |
|
195 |
map { |
|
196 |
my $idx = $_; |
|
197 |
+{ map { ($_ => delete($::form->{"${_}_${idx}"})) } @fields } |
|
198 |
} (1..$::form->{paidaccounts}); |
|
199 |
|
|
200 |
@payments = sort_by { DateTime->from_kivitendo($_->{datepaid}) } @payments; |
|
201 |
|
|
202 |
$::form->{paidaccounts} = max scalar(@payments), 1; |
|
203 |
|
|
204 |
foreach my $idx (1 .. scalar(@payments)) { |
|
205 |
my $payment = $payments[$idx - 1]; |
|
206 |
$::form->{"${_}_${idx}"} = $payment->{$_} for @fields; |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
190 | 210 |
sub form_header { |
191 | 211 |
$main::lxdebug->enter_sub(); |
192 | 212 |
|
... | ... | |
372 | 392 |
|
373 | 393 |
$form->{totalpaid} = 0; |
374 | 394 |
|
395 |
_sort_payments(); |
|
396 |
|
|
375 | 397 |
if ( $form->{'paid_'. $form->{paidaccounts}} ) { |
376 | 398 |
$form->{paidaccounts}++; |
377 | 399 |
} |
Auch abrufbar als: Unified diff
Rechnungen: Zahlungsein-/-ausgänge nach Datum sortieren