X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdn.pl;h=ee77c822472979bf01d347700a039ec46b22ce4c;hb=599030d5e26bcef0f9850ddbbedba106ded70ebb;hp=844abf5b588bd10d22f980ddcc4dac9252521ccf;hpb=cd3dc84b8687e1571c7012d91a5138b9444c246c;p=kivitendo-erp.git diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl index 844abf5b5..ee77c8224 100644 --- a/bin/mozilla/dn.pl +++ b/bin/mozilla/dn.pl @@ -54,7 +54,7 @@ sub edit_config { "$form->{script}?action=edit_config&login=$form->{login}&password=$form->{password}" unless $form->{callback}; - @column_index = qw(dunning_level dunning_description active auto email payment_terms terms fee interest template); + @column_index = qw(dunning_level dunning_description active auto email payment_terms terms fee interest_rate template); $column_header{dunning_level} = qq|
$form->{title} | +$form->{title} | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$ref->{dunning_level}: $dunning | |; + $column_data{dunning_description} = + qq|| + . qq|| + . qq|| + . ($ref->{dunning_level} ? $ref->{dunning_level} : " ") + . qq| | |; + $column_data{dunning_description_next} = + qq|| + . qq|| + . qq| | |; my $active = ($ref->{active}) ? "checked" : ""; $column_data{active} = qq||; my $email = ($ref->{email}) ? "checked" : ""; - $column_data{email} = - qq| | |; - $column_data{next_duedate} = qq| | $ref->{next_duedate} | |; + $column_data{email} = + qq||; + $column_data{next_duedate} = qq| | $ref->{next_duedate} | |; $column_data{inv_duedate} = qq|$ref->{duedate} | |; $column_data{invdate} = qq|$ref->{transdate} | |; $column_data{invnumber} = qq|$ref->{invnumber} | |; $column_data{customername} = qq|$ref->{customername} | |; - $column_data{invamount} = qq|$ref->{amount} | |; - $column_data{fee} = qq|$ref->{fee} | |; - $column_data{interest} = qq|$ref->{interest} | |; - + map { $column_data{$_} = + qq|| + . H($form->format_amount(\%myconfig, $ref->{$_} * 1, -2)) + . qq| | | + } qw(amount fee interest); map { print "$column_data{$_}\n" } @column_index; @@ -578,55 +563,64 @@ sub save_dunning { my $active=1; my @rows = (); undef($form->{DUNNING_PDFS}); + if ($form->{groupinvoices}) { - while ($active) { - $lastcustomer = 0; - $form->{inv_ids} = []; - $active = 0; - @rows = (); - for my $i (1 .. $form->{rowcount}) { - $form->{"active_$i"} *= 1; - $lastcustomer = $form->{"customer_id_$i"} unless ($lastcustomer); - if ($form->{"active_$i"} && ($form->{"customer_id_$i"} == $lastcustomer)) { - push(@{ $form->{inv_ids} }, $form->{"inv_id_$i"}); - $form->{"active_$i"} = 0; - $form->{"customer_id_$i"} = 0; - push(@rows, $i); - } elsif ($form->{"active_$i"}) { - $active = 1; - } else { - $form->{"customer_id_$i"} = 0; - } - } - if (scalar(@{ $form->{inv_ids} }) != 0) { - DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath, $spool, $sendmail); + my %dunnings_for; + + for my $i (1 .. $form->{rowcount}) { + next unless ($form->{"active_$i"}); + + $dunnings_for{$form->{"customer_id_$i"}} ||= {}; + my $dunning_levels = $dunnings_for{$form->{"customer_id_$i"}}; + + $dunning_levels->{$form->{"next_dunning_config_id_$i"}} ||= []; + my $level = $dunning_levels->{$form->{"next_dunning_config_id_$i"}}; + + push @{ $level }, { "row" => $i, + "invoice_id" => $form->{"inv_id_$i"}, + "customer_id" => $form->{"customer_id_$i"}, + "next_dunning_config_id" => $form->{"next_dunning_config_id_$i"}, + "email" => $form->{"email_$i"}, }; + } + + foreach my $levels (values %dunnings_for) { + foreach my $level (values %{ $levels }) { + next unless scalar @{ $level }; + + DN->save_dunning(\%myconfig, \%$form, $level, $userspath, $spool, $sendmail); } } + } else { for my $i (1 .. $form->{rowcount}) { - if ($form->{"active_$i"}) { - @rows = (); - $form->{inv_ids} = [ $form->{"inv_id_$i"} ]; - push(@rows, $i); - DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath, $spool, $sendmail); - } + next unless $form->{"active_$i"}; + + my $level = [ { "row" => $i, + "invoice_id" => $form->{"inv_id_$i"}, + "customer_id" => $form->{"customer_id_$i"}, + "next_dunning_config_id" => $form->{"next_dunning_config_id_$i"}, + "email" => $form->{"email_$i"}, } ]; + DN->save_dunning(\%myconfig, \%$form, $level, $userspath, $spool, $sendmail); } } + if($form->{DUNNING_PDFS}) { DN->melt_pdfs(\%myconfig, \%$form,$spool); } + # saving the history if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"}; $form->{addition} = "DUNNING STARTED"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history + $form->redirect($locale->text('Dunning Process started for selected invoices!')); $lxdebug->leave_sub(); } - + sub set_email { $lxdebug->enter_sub(); @@ -878,7 +872,7 @@ sub show_dunning { . qq||; $column_header{interest} = qq|| - . $locale->text('Total Interest') + . $locale->text('Interest') . qq| | |; $form->header; @@ -931,8 +925,7 @@ sub show_dunning { - foreach (qw(dunning_date dunning_duedate duedate transdate customername - amount fee interest)) { + foreach (qw(dunning_date dunning_duedate duedate transdate customername amount fee interest)) { my $col = $columns{$_} ? $columns{$_} : $_; $column_data{$col} = "" . H($ref->{$_}) . " | "; }