From: Moritz Bunkus Date: Mon, 11 Jun 2007 08:35:36 +0000 (+0000) Subject: Mahnwesen: X-Git-Tag: release-2.4.3^2~167 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5d92bf355c0df5643c0ba1e282fdcb8c98d1be14;p=kivitendo-erp.git 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. --- diff --git a/SL/DN.pm b/SL/DN.pm index 711a88463..4f0827104 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -462,6 +462,12 @@ sub get_invoices { push(@values, $form->{minamount}); } + $query = + qq|SELECT id + FROM dunning_config + WHERE dunning_level = (SELECT MAX(dunning_level) FROM dunning_config)|; + my ($id_for_max_dunning_level) = selectrow_query($form, $dbh, $query); + $query = qq|SELECT a.id, a.ordnumber, a.transdate, a.invnumber, a.amount, @@ -486,16 +492,19 @@ sub get_invoices { LEFT JOIN dunning_config cfg ON (a.dunning_config_id = cfg.id) LEFT JOIN dunning_config nextcfg ON (nextcfg.id = - (SELECT id - FROM dunning_config - WHERE dunning_level > - COALESCE((SELECT dunning_level - FROM dunning_config - WHERE id = a.dunning_config_id - ORDER BY dunning_level DESC - LIMIT 1), - 0) - LIMIT 1)) + COALESCE( + (SELECT id + FROM dunning_config + WHERE dunning_level > + COALESCE((SELECT dunning_level + FROM dunning_config + WHERE id = a.dunning_config_id + ORDER BY dunning_level DESC + LIMIT 1), + 0) + ORDER BY dunning_level ASC + LIMIT 1) + , ?)) LEFT JOIN dunning d ON ((d.trans_id = a.id) AND (cfg.dunning_level = d.dunning_level)) WHERE (a.paid < a.amount) @@ -504,7 +513,7 @@ sub get_invoices { $where ORDER BY a.id, transdate, duedate, name|; - my $sth = prepare_execute_query($form, $dbh, $query, @values); + my $sth = prepare_execute_query($form, $dbh, $query, $id_for_max_dunning_level, @values); $form->{DUNNINGS} = [];