Revision fd6900cc
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
bin/mozilla/dn.pl | ||
---|---|---|
54 | 54 |
"$form->{script}?action=edit_config&login=$form->{login}&password=$form->{password}" |
55 | 55 |
unless $form->{callback}; |
56 | 56 |
|
57 |
@column_index = qw(dunning_level dunning_description active auto email payment_terms terms fee interest template); |
|
57 |
@column_index = qw(dunning_level dunning_description active auto email payment_terms terms fee interest_rate template);
|
|
58 | 58 |
|
59 | 59 |
$column_header{dunning_level} = |
60 | 60 |
qq|<th class=listheading>| |
... | ... | |
88 | 88 |
qq|<th class=listheading>| |
89 | 89 |
. $locale->text('Fee') |
90 | 90 |
. qq|</th>|; |
91 |
$column_header{interest} = |
|
91 |
$column_header{interest_rate} =
|
|
92 | 92 |
qq|<th class=listheading>| |
93 | 93 |
. $locale->text('Interest Rate') |
94 | 94 |
. qq|</th>|; |
... | ... | |
141 | 141 |
$column_data{payment_terms} = qq|<td><input name=payment_terms_$i size=3 value="$ref->{payment_terms}"></td>|; |
142 | 142 |
$column_data{terms} = qq|<td><input name=terms_$i size=3 value="$ref->{terms}"></td>|; |
143 | 143 |
$column_data{fee} = qq|<td><input name=fee_$i size=5 value="$ref->{fee}"></td>|; |
144 |
$column_data{interest} = qq|<td><input name=interest_$i size=4 value="$ref->{interest}">%</td>|;
|
|
144 |
$column_data{interest_rate} = qq|<td><input name=interest_rate_$i size=4 value="$ref->{interest}">%</td>|;
|
|
145 | 145 |
$column_data{template} = qq|<td><input name=template_$i value="$ref->{template}"></td>|; |
146 | 146 |
|
147 | 147 |
|
... | ... | |
174 | 174 |
$column_data{payment_terms} = qq|<td><input size=3 name=payment_terms_$i></td>|; |
175 | 175 |
$column_data{terms} = qq|<td><input size=3 name=terms_$i></td>|; |
176 | 176 |
$column_data{fee} = qq|<td><input size=5 name=fee_$i></td>|; |
177 |
$column_data{interest} = qq|<td><input size=4 name=interest_$i>%</td>|;
|
|
177 |
$column_data{interest_rate} = qq|<td><input size=4 name=interest_rate_$i>%</td>|;
|
|
178 | 178 |
$column_data{template} = qq|<td><input name=template_$i></td>|; |
179 | 179 |
|
180 | 180 |
|
... | ... | |
260 | 260 |
<td colspan=3><select name=department>$form->{selectdepartment}</select></td> |
261 | 261 |
</tr> |
262 | 262 |
| if $form->{selectdepartment}; |
263 |
$form->{title} = $locale->text('Start Dunning Process'); |
|
264 |
$form->{nextsub} = "show_invoices"; |
|
265 |
|
|
266 |
# use JavaScript Calendar or not |
|
267 |
$form->{jsscript} = $jscalendar; |
|
268 |
$jsscript = ""; |
|
269 |
if ($form->{jsscript}) { |
|
270 |
|
|
271 |
# with JavaScript Calendar |
|
272 |
$button1 = qq| |
|
273 |
<td><input name=paymentuntil id=paymentuntil size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"> |
|
274 |
<input type=button name=paymentuntil id="trigger1" value=| |
|
275 |
. $locale->text('button') . qq|></td> |
|
276 |
|; |
|
277 | 263 |
|
278 |
#write Trigger |
|
279 |
$jsscript = |
|
280 |
Form->write_trigger(\%myconfig, "1", "paymentuntil", "BR", "trigger1"); |
|
281 |
} else { |
|
264 |
$form->{title} = $locale->text('Start Dunning Process'); |
|
265 |
$form->{nextsub} = "show_invoices"; |
|
282 | 266 |
|
283 |
# without JavaScript Calendar |
|
284 |
$button1 = |
|
285 |
qq|<td><input name=paymentuntil id=paymentuntil size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|; |
|
286 |
} |
|
287 |
$form->{fokus} = "search.customer"; |
|
267 |
$form->{jsscript} = 1; |
|
268 |
$form->{fokus} = "search.customer"; |
|
288 | 269 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|; |
289 |
$form->header; |
|
270 |
$form->header(); |
|
271 |
|
|
290 | 272 |
$onload = qq|focus()|; |
291 | 273 |
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; |
292 | 274 |
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; |
275 |
|
|
293 | 276 |
print qq| |
294 | 277 |
<body onLoad="$onload"> |
295 | 278 |
|
... | ... | |
319 | 302 |
<th align=right nowrap>| . $locale->text('Notes') . qq|</th> |
320 | 303 |
<td colspan=3><input name=notes size=40></td> |
321 | 304 |
</tr> |
322 |
<tr> |
|
323 |
<th align=right nowrap>| . $locale->text('Payment until') . qq|</th> |
|
324 |
$button1 |
|
325 |
</tr> |
|
326 | 305 |
</table> |
327 | 306 |
</td> |
328 | 307 |
</tr> |
... | ... | |
390 | 369 |
"$form->{script}?action=show_invoices&login=$form->{login}&password=$form->{password}&customer=$form->{customer}&invnumber=$form->{invnumber}&ordnumber=$form->{ordnumber}&paymentuntil=$form->{paymentuntil}&groupinvoices=$form->{groupinvoices}&minamount=$form->{minamount}&dunning_level=$form->{dunning_level}¬es=$form->{notes}" |
391 | 370 |
unless $form->{callback}; |
392 | 371 |
|
393 |
@column_index = qw(dunning_description active email customername invnumber invdate inv_duedate invamount next_duedate fee interest );
|
|
372 |
@column_index = qw(dunning_description dunning_description_next active email customername invnumber invdate inv_duedate amount next_duedate fee interest );
|
|
394 | 373 |
|
395 | 374 |
$column_header{dunning_description} = |
396 |
qq|<th class=listheading>|
|
|
375 |
qq|<th class="listheading" colspan="2">|
|
|
397 | 376 |
. $locale->text('Current / Next Level') |
398 | 377 |
. qq|</th>|; |
399 | 378 |
$column_header{active} = |
400 | 379 |
qq|<th class=listheading>| |
401 | 380 |
. NTI($cgi->checkbox('-name' => 'selectall_active', |
402 | 381 |
'-label' => $locale->text('Active?'), |
403 |
'-checked' => 1,
|
|
382 |
'-checked' => 0,
|
|
404 | 383 |
'-onclick' => "checkbox_check_all('selectall_active', 'active_', 1, " . scalar(@{ $form->{DUNNINGS} }) . ")")) |
405 | 384 |
. qq|</th>|; |
406 | 385 |
$column_header{email} = |
... | ... | |
430 | 409 |
qq|<th class=listheading>| |
431 | 410 |
. $locale->text('Invdate') |
432 | 411 |
. qq|</th>|; |
433 |
$column_header{invamount} =
|
|
412 |
$column_header{amount} = |
|
434 | 413 |
qq|<th class=listheading>| |
435 | 414 |
. $locale->text('Amount') |
436 | 415 |
. qq|</th>|; |
... | ... | |
440 | 419 |
. qq|</th>|; |
441 | 420 |
$column_header{interest} = |
442 | 421 |
qq|<th class=listheading>| |
443 |
. $locale->text('Total Interest')
|
|
422 |
. $locale->text('Interest') |
|
444 | 423 |
. qq|</th>|; |
445 | 424 |
|
446 | 425 |
$form->header; |
... | ... | |
455 | 434 |
|
456 | 435 |
<table width=100%> |
457 | 436 |
<tr> |
458 |
<th class=listtop colspan=11>$form->{title}</th>
|
|
437 |
<th class=listtop colspan=12>$form->{title}</th>
|
|
459 | 438 |
</tr> |
460 | 439 |
<tr height="5"></tr> |
461 | 440 |
<tr>|; |
462 |
map { print "$column_header{$_}\n" } @column_index; |
|
441 |
map { print "$column_header{$_}\n" if $column_header{$_}; } @column_index;
|
|
463 | 442 |
|
464 | 443 |
print qq| |
465 | 444 |
</tr> |
... | ... | |
474 | 453 |
<tr valign=top class=listrow$j> |
475 | 454 |
|; |
476 | 455 |
|
477 |
$form->{selectdunning} =~ s/ selected//g; |
|
478 |
if ($ref->{next_dunning_config_id} ne "") { |
|
479 |
$form->{selectdunning} =~ s/value=$ref->{next_dunning_config_id}/value=$ref->{next_dunning_config_id} selected/; |
|
480 |
} |
|
481 |
|
|
482 |
|
|
483 |
$dunning = qq|<select name=next_dunning_config_id_$i>$form->{selectdunning}</select>|; |
|
484 |
|
|
456 |
$form->{selectdunning} =~ s/ selected//g; |
|
457 |
if ($ref->{next_dunning_config_id} ne "") { |
|
458 |
$form->{selectdunning} =~ s/value=$ref->{next_dunning_config_id}/value=$ref->{next_dunning_config_id} selected/; |
|
459 |
} |
|
485 | 460 |
|
486 |
$column_data{dunning_description} = qq|<td><input type=hidden name=inv_id_$i size=2 value="$ref->{id}"><input type=hidden name=customer_id_$i size=2 value="$ref->{customer_id}">$ref->{dunning_level}: $dunning</td>|; |
|
461 |
$column_data{dunning_description} = |
|
462 |
qq|<td>| |
|
463 |
. qq|<input type=hidden name=inv_id_$i size=2 value="$ref->{id}">| |
|
464 |
. qq|<input type=hidden name=customer_id_$i size=2 value="$ref->{customer_id}">| |
|
465 |
. ($ref->{dunning_level} ? $ref->{dunning_level} : " ") |
|
466 |
. qq|</td>|; |
|
467 |
$column_data{dunning_description_next} = |
|
468 |
qq|<td>| |
|
469 |
. qq|<select name=next_dunning_config_id_$i>$form->{selectdunning}</select>| |
|
470 |
. qq|</td>|; |
|
487 | 471 |
my $active = ($ref->{active}) ? "checked" : ""; |
488 | 472 |
$column_data{active} = |
489 | 473 |
qq|<td><input type=checkbox name=active_$i value=1 $active></td>|; |
490 | 474 |
my $email = ($ref->{email}) ? "checked" : ""; |
491 |
$column_data{email} = |
|
492 |
qq|<td><input type=checkbox name=email_$i value=1 $email></td>|; |
|
493 |
$column_data{next_duedate} = qq|<td><input type=hidden name=next_duedate_$i size=6 value="$ref->{next_duedate}">$ref->{next_duedate}</td>|;
|
|
475 |
$column_data{email} =
|
|
476 |
qq|<td><input type=checkbox name=email_$i value=1 $email></td>|;
|
|
477 |
$column_data{next_duedate} = qq|<td>$ref->{next_duedate}</td>|; |
|
494 | 478 |
|
495 | 479 |
$column_data{inv_duedate} = qq|<td><input type=hidden name=inv_duedate_$i size=6 value="$ref->{duedate}">$ref->{duedate}</td>|; |
496 | 480 |
$column_data{invdate} = qq|<td><input type=hidden name=invdate_$i size=6 value="$ref->{transdate}">$ref->{transdate}</td>|; |
497 | 481 |
$column_data{invnumber} = qq|<td><input type=hidden name=invnumber_$i size=6 value="$ref->{invnumber}">$ref->{invnumber}</td>|; |
498 | 482 |
$column_data{customername} = qq|<td><input type=hidden name=customername_$i size=6 value="$ref->{customername}">$ref->{customername}</td>|; |
499 |
$column_data{invamount} = qq|<td><input type=hidden name=invamount_$i size=6 value="$ref->{amount}">$ref->{amount}</td>|; |
|
500 |
$column_data{fee} = qq|<td><input type=hidden name=fee_$i size=5 value="$ref->{fee}">$ref->{fee}</td>|; |
|
501 |
$column_data{interest} = qq|<td><input type=hidden name=interest_$i size=4 value="$ref->{interest}">$ref->{interest}</td>|; |
|
502 |
|
|
503 | 483 |
|
484 |
map { $column_data{$_} = |
|
485 |
qq|<td align="right">| |
|
486 |
. H($form->format_amount(\%myconfig, $ref->{$_} * 1, -2)) |
|
487 |
. qq|</td>| |
|
488 |
} qw(amount fee interest); |
|
504 | 489 |
|
505 | 490 |
map { print "$column_data{$_}\n" } @column_index; |
506 | 491 |
|
... | ... | |
578 | 563 |
my $active=1; |
579 | 564 |
my @rows = (); |
580 | 565 |
undef($form->{DUNNING_PDFS}); |
566 |
|
|
581 | 567 |
if ($form->{groupinvoices}) { |
582 |
while ($active) { |
|
583 |
$lastcustomer = 0; |
|
584 |
$form->{inv_ids} = []; |
|
585 |
$active = 0; |
|
586 |
@rows = (); |
|
587 |
for my $i (1 .. $form->{rowcount}) { |
|
588 |
$form->{"active_$i"} *= 1; |
|
589 |
$lastcustomer = $form->{"customer_id_$i"} unless ($lastcustomer); |
|
590 |
if ($form->{"active_$i"} && ($form->{"customer_id_$i"} == $lastcustomer)) { |
|
591 |
push(@{ $form->{inv_ids} }, $form->{"inv_id_$i"}); |
|
592 |
$form->{"active_$i"} = 0; |
|
593 |
$form->{"customer_id_$i"} = 0; |
|
594 |
push(@rows, $i); |
|
595 |
} elsif ($form->{"active_$i"}) { |
|
596 |
$active = 1; |
|
597 |
} else { |
|
598 |
$form->{"customer_id_$i"} = 0; |
|
599 |
} |
|
600 |
} |
|
601 |
if (scalar(@{ $form->{inv_ids} }) != 0) { |
|
602 |
DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath, $spool, $sendmail); |
|
568 |
my %dunnings_for; |
|
569 |
|
|
570 |
for my $i (1 .. $form->{rowcount}) { |
|
571 |
next unless ($form->{"active_$i"}); |
|
572 |
|
|
573 |
$dunnings_for{$form->{"customer_id_$i"}} ||= {}; |
|
574 |
my $dunning_levels = $dunnings_for{$form->{"customer_id_$i"}}; |
|
575 |
|
|
576 |
$dunning_levels->{$form->{"next_dunning_config_id_$i"}} ||= []; |
|
577 |
my $level = $dunning_levels->{$form->{"next_dunning_config_id_$i"}}; |
|
578 |
|
|
579 |
push @{ $level }, { "row" => $i, |
|
580 |
"invoice_id" => $form->{"inv_id_$i"}, |
|
581 |
"customer_id" => $form->{"customer_id_$i"}, |
|
582 |
"next_dunning_config_id" => $form->{"next_dunning_config_id_$i"}, |
|
583 |
"email" => $form->{"email_$i"}, }; |
|
584 |
} |
|
585 |
|
|
586 |
foreach my $levels (values %dunnings_for) { |
|
587 |
foreach my $level (values %{ $levels }) { |
|
588 |
next unless scalar @{ $level }; |
|
589 |
|
|
590 |
DN->save_dunning(\%myconfig, \%$form, $level, $userspath, $spool, $sendmail); |
|
603 | 591 |
} |
604 | 592 |
} |
593 |
|
|
605 | 594 |
} else { |
606 | 595 |
for my $i (1 .. $form->{rowcount}) { |
607 |
if ($form->{"active_$i"}) { |
|
608 |
@rows = (); |
|
609 |
$form->{inv_ids} = [ $form->{"inv_id_$i"} ]; |
|
610 |
push(@rows, $i); |
|
611 |
DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath, $spool, $sendmail); |
|
612 |
} |
|
596 |
next unless $form->{"active_$i"}; |
|
597 |
|
|
598 |
my $level = [ { "row" => $i, |
|
599 |
"invoice_id" => $form->{"inv_id_$i"}, |
|
600 |
"customer_id" => $form->{"customer_id_$i"}, |
|
601 |
"next_dunning_config_id" => $form->{"next_dunning_config_id_$i"}, |
|
602 |
"email" => $form->{"email_$i"}, } ]; |
|
603 |
DN->save_dunning(\%myconfig, \%$form, $level, $userspath, $spool, $sendmail); |
|
613 | 604 |
} |
614 | 605 |
} |
606 |
|
|
615 | 607 |
if($form->{DUNNING_PDFS}) { |
616 | 608 |
DN->melt_pdfs(\%myconfig, \%$form,$spool); |
617 | 609 |
} |
610 |
|
|
618 | 611 |
# saving the history |
619 | 612 |
if(!exists $form->{addition} && $form->{id} ne "") { |
620 | 613 |
$form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"}; |
621 | 614 |
$form->{addition} = "DUNNING STARTED"; |
622 | 615 |
$form->save_history($form->dbconnect(\%myconfig)); |
623 | 616 |
} |
624 |
# /saving the history |
|
617 |
# /saving the history |
|
618 |
|
|
625 | 619 |
$form->redirect($locale->text('Dunning Process started for selected invoices!')); |
626 | 620 |
|
627 | 621 |
$lxdebug->leave_sub(); |
628 | 622 |
} |
629 |
|
|
623 |
|
|
630 | 624 |
sub set_email { |
631 | 625 |
$lxdebug->enter_sub(); |
632 | 626 |
|
... | ... | |
878 | 872 |
. qq|</th>|; |
879 | 873 |
$column_header{interest} = |
880 | 874 |
qq|<th class=listheading>| |
881 |
. $locale->text('Total Interest')
|
|
875 |
. $locale->text('Interest') |
|
882 | 876 |
. qq|</th>|; |
883 | 877 |
|
884 | 878 |
$form->header; |
... | ... | |
931 | 925 |
|
932 | 926 |
|
933 | 927 |
|
934 |
foreach (qw(dunning_date dunning_duedate duedate transdate customername |
|
935 |
amount fee interest)) { |
|
928 |
foreach (qw(dunning_date dunning_duedate duedate transdate customername amount fee interest)) { |
|
936 | 929 |
my $col = $columns{$_} ? $columns{$_} : $_; |
937 | 930 |
$column_data{$col} = "<td>" . H($ref->{$_}) . "</td>"; |
938 | 931 |
} |
Auch abrufbar als: Unified diff
Große Teile des Mahncodes neu geschrieben bzw. umgeschrieben. Mehrere Fehler behoben:
1. Rechnungen, die bereits gemahnt wurden, wurden zu früh erneut zur Mahnung angeboten, weil der Mahnzeitraum auf das ursprüngliche Fälligkeitsdatum der Rechnung bezogen wurde und nicht auf das Fälligkeitsdatum der vorhergehenden Mahnstufe.
2. Wurden gleichzeitig Mahnungen für mehrere Mahnstufen generiert, so wurden die falschen Vorlagen benutzt.
3. Die kummulierten Mahnkosten und die Zinsen wurden in der Liste der neu zu erstellenden Mahnungen falsch angezeigt.
Weiterhin wurde die Dokumentation für die Vorlagenvariablen um eine Sektion über Mahnungen erweitert.