Revision 5d92bf35
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
462 | 462 |
push(@values, $form->{minamount}); |
463 | 463 |
} |
464 | 464 |
|
465 |
$query = |
|
466 |
qq|SELECT id |
|
467 |
FROM dunning_config |
|
468 |
WHERE dunning_level = (SELECT MAX(dunning_level) FROM dunning_config)|; |
|
469 |
my ($id_for_max_dunning_level) = selectrow_query($form, $dbh, $query); |
|
470 |
|
|
465 | 471 |
$query = |
466 | 472 |
qq|SELECT |
467 | 473 |
a.id, a.ordnumber, a.transdate, a.invnumber, a.amount, |
... | ... | |
486 | 492 |
LEFT JOIN dunning_config cfg ON (a.dunning_config_id = cfg.id) |
487 | 493 |
LEFT JOIN dunning_config nextcfg ON |
488 | 494 |
(nextcfg.id = |
489 |
(SELECT id |
|
490 |
FROM dunning_config |
|
491 |
WHERE dunning_level > |
|
492 |
COALESCE((SELECT dunning_level |
|
493 |
FROM dunning_config |
|
494 |
WHERE id = a.dunning_config_id |
|
495 |
ORDER BY dunning_level DESC |
|
496 |
LIMIT 1), |
|
497 |
0) |
|
498 |
LIMIT 1)) |
|
495 |
COALESCE( |
|
496 |
(SELECT id |
|
497 |
FROM dunning_config |
|
498 |
WHERE dunning_level > |
|
499 |
COALESCE((SELECT dunning_level |
|
500 |
FROM dunning_config |
|
501 |
WHERE id = a.dunning_config_id |
|
502 |
ORDER BY dunning_level DESC |
|
503 |
LIMIT 1), |
|
504 |
0) |
|
505 |
ORDER BY dunning_level ASC |
|
506 |
LIMIT 1) |
|
507 |
, ?)) |
|
499 | 508 |
LEFT JOIN dunning d ON ((d.trans_id = a.id) AND (cfg.dunning_level = d.dunning_level)) |
500 | 509 |
|
501 | 510 |
WHERE (a.paid < a.amount) |
... | ... | |
504 | 513 |
$where |
505 | 514 |
|
506 | 515 |
ORDER BY a.id, transdate, duedate, name|; |
507 |
my $sth = prepare_execute_query($form, $dbh, $query, @values); |
|
516 |
my $sth = prepare_execute_query($form, $dbh, $query, $id_for_max_dunning_level, @values);
|
|
508 | 517 |
|
509 | 518 |
$form->{DUNNINGS} = []; |
510 | 519 |
|
Auch abrufbar als: Unified diff
Mahnwesen:
1. Beim Erzeugen neuer Mahnungen wurden unter Umständen überall die falschen nächsten Mahnstufen vorausgewählt.
2. Rechnungen, die bereits auf der höchsten Mahnstufe waren, wurden nicht mehr angezeigt.