Revision 232a9153
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
|
||
package DN;
|
||
|
||
use SL::Template;
|
||
use SL::IS;
|
||
use SL::Common;
|
||
use SL::DBUtils;
|
||
use Data::Dumper;
|
||
use SL::IS;
|
||
use SL::Mailer;
|
||
use SL::MoreCommon;
|
||
use SL::Template;
|
||
|
||
sub get_config {
|
||
$main::lxdebug->enter_sub();
|
||
... | ... | |
$ref->{interest_rate} = $form->format_amount($myconfig, ($ref->{interest_rate} * 100));
|
||
}
|
||
|
||
$query =
|
||
qq|SELECT
|
||
dunning_create_invoices_for_fees, dunning_ar_amount_fee,
|
||
dunning_ar_amount_interest, dunning_ar
|
||
FROM defaults|;
|
||
($form->{create_invoices_for_fees}, $form->{AR_amount_fee},
|
||
$form->{AR_amount_interest}, $form->{AR} ) = selectrow_query($form, $dbh, $query);
|
||
|
||
$dbh->disconnect();
|
||
|
||
$main::lxdebug->leave_sub();
|
||
... | ... | |
}
|
||
}
|
||
|
||
$dbh->commit;
|
||
$dbh->disconnect;
|
||
$query = qq|UPDATE defaults SET dunning_create_invoices_for_fees = ?|;
|
||
@values = ($form->{create_invoices_for_fees} ? 't' : 'f');
|
||
|
||
if ($form->{create_invoices_for_fees}) {
|
||
$query .= qq|, dunning_ar_amount_fee = ?, dunning_ar_amount_interest = ?, dunning_ar = ?|;
|
||
push @values, conv_i($form->{AR_amount_fee}), conv_i($form->{AR_amount_interest}), conv_i($form->{AR});
|
||
}
|
||
|
||
do_query($form, $dbh, $query, @values);
|
||
|
||
$dbh->commit();
|
||
$dbh->disconnect();
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub create_invoice_for_fees {
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my ($self, $myconfig, $form, $dbh, $dunning_id) = @_;
|
||
|
||
my ($query, @values, $sth, $ref);
|
||
|
||
$query =
|
||
qq|SELECT
|
||
dunning_create_invoices_for_fees, dunning_ar_amount_fee,
|
||
dunning_ar_amount_interest, dunning_ar
|
||
FROM defaults|;
|
||
($form->{create_invoices_for_fees}, $form->{AR_amount_fee},
|
||
$form->{AR_amount_interest}, $form->{AR} ) = selectrow_query($form, $dbh, $query);
|
||
|
||
if (!$form->{create_invoices_for_fees}) {
|
||
$main::lxdebug->leave_sub();
|
||
return;
|
||
}
|
||
|
||
$query =
|
||
qq|SELECT
|
||
fee,
|
||
COALESCE((
|
||
SELECT MAX(d_fee.fee)
|
||
FROM dunning d_fee
|
||
WHERE (d_fee.trans_id = d.trans_id)
|
||
AND (d_fee.dunning_id <> ?)
|
||
AND NOT (d_fee.fee_interest_ar_id ISNULL)
|
||
), 0)
|
||
AS max_previous_fee,
|
||
interest,
|
||
COALESCE((
|
||
SELECT MAX(d_interest.interest)
|
||
FROM dunning d_interest
|
||
WHERE (d_interest.trans_id = d.trans_id)
|
||
AND (d_interest.dunning_id <> ?)
|
||
AND NOT (d_interest.fee_interest_ar_id ISNULL)
|
||
), 0)
|
||
AS max_previous_interest
|
||
FROM dunning d
|
||
WHERE dunning_id = ?|;
|
||
@values = ($dunning_id, $dunning_id, $dunning_id);
|
||
$sth = prepare_execute_query($form, $dbh, $query, @values);
|
||
|
||
my ($fee_remaining, $interest_remaining) = (0, 0);
|
||
my ($fee_total, $interest_total) = (0, 0);
|
||
|
||
while (my $ref = $sth->fetchrow_hashref()) {
|
||
$fee_remaining += $form->round_amount($ref->{fee}, 2);
|
||
$fee_remaining -= $form->round_amount($ref->{max_previous_fee}, 2);
|
||
$fee_total += $form->round_amount($ref->{fee}, 2);
|
||
$interest_remaining += $form->round_amount($ref->{interest}, 2);
|
||
$interest_remaining -= $form->round_amount($ref->{max_previous_interest}, 2);
|
||
$interest_total += $form->round_amount($ref->{interest}, 2);
|
||
}
|
||
|
||
$sth->finish();
|
||
|
||
my $amount = $fee_remaining + $interest_remaining;
|
||
|
||
if (!$amount) {
|
||
$main::lxdebug->leave_sub();
|
||
return;
|
||
}
|
||
|
||
my ($ar_id) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|);
|
||
|
||
$query =
|
||
qq|INSERT INTO ar (id, invnumber, transdate, gldate, customer_id,
|
||
taxincluded, amount, netamount, paid, duedate,
|
||
invoice, curr, notes,
|
||
employee_id)
|
||
VALUES (
|
||
?, -- id
|
||
?, -- invnumber
|
||
current_date, -- transdate
|
||
current_date, -- gldate
|
||
-- customer_id:
|
||
(SELECT ar.customer_id
|
||
FROM dunning dn
|
||
LEFT JOIN ar ON (dn.trans_id = ar.id)
|
||
WHERE dn.dunning_id = ?
|
||
LIMIT 1),
|
||
'f', -- taxincluded
|
||
?, -- amount
|
||
?, -- netamount
|
||
0, -- paid
|
||
-- duedate:
|
||
(SELECT duedate FROM dunning WHERE dunning_id = ?),
|
||
'f', -- invoice
|
||
?, -- curr
|
||
?, -- notes
|
||
-- employee_id:
|
||
(SELECT id FROM employee WHERE login = ?)
|
||
)|;
|
||
@values = ($ar_id, # id
|
||
$form->update_defaults($myconfig, 'invnumber', $dbh), # invnumber
|
||
$dunning_id, # customer_id
|
||
$amount,
|
||
$amount,
|
||
$dunning_id, # duedate
|
||
(split m/:/, $myconfig->{currency})[0], # currency
|
||
sprintf($main::locale->text('Automatically created invoice for fee and interest for dunning %s'), $dunning_id), # notes
|
||
$form->{login}); # employee_id
|
||
do_query($form, $dbh, $query, @values);
|
||
|
||
$query =
|
||
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, taxkey)
|
||
VALUES (?, ?, ?, current_date, current_date, 0)|;
|
||
$sth = prepare_query($form, $dbh, $query);
|
||
|
||
@values = ($ar_id, conv_i($form->{AR_amount_fee}), $fee_remaining);
|
||
do_statement($form, $sth, $query, @values);
|
||
|
||
if ($interest_remaining) {
|
||
@values = ($ar_id, conv_i($form->{AR_amount_interest}), $interest_remaining);
|
||
do_statement($form, $sth, $query, @values);
|
||
}
|
||
|
||
@values = ($ar_id, conv_i($form->{AR}), -1 * $amount);
|
||
do_statement($form, $sth, $query, @values);
|
||
|
||
$sth->finish();
|
||
|
||
$query = qq|UPDATE dunning SET fee_interest_ar_id = ? WHERE dunning_id = ?|;
|
||
do_query($form, $dbh, $query, $ar_id, $dunning_id);
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
... | ... | |
my $h_update_ar = prepare_query($form, $dbh, $q_update_ar);
|
||
|
||
my $q_insert_dunning =
|
||
qq|INSERT INTO dunning (dunning_id, dunning_config_id, dunning_level,
|
||
trans_id, fee, interest, transdate, duedate)
|
||
qq|INSERT INTO dunning (dunning_id, dunning_config_id, dunning_level, trans_id,
|
||
fee, interest, transdate, duedate)
|
||
VALUES (?, ?,
|
||
(SELECT dunning_level FROM dunning_config WHERE id = ?),
|
||
?,
|
||
... | ... | |
$h_update_ar->finish();
|
||
$h_insert_dunning->finish();
|
||
|
||
$form->{DUNNING_PDFS_EMAIL} = [];
|
||
|
||
$self->create_invoice_for_fees($myconfig, $form, $dbh, $dunning_id);
|
||
|
||
$self->print_invoice_for_fees($myconfig, $form, $dunning_id, $dbh);
|
||
$self->print_dunning($myconfig, $form, $dunning_id, $dbh);
|
||
|
||
$form->{dunning_id} = $dunning_id;
|
||
|
||
if ($send_email) {
|
||
$self->send_email($myconfig, $form, $dunning_id, $dbh);
|
||
}
|
||
|
||
# $dbh->commit();
|
||
$dbh->disconnect();
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub send_email {
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my ($self, $myconfig, $form, $dunning_id, $dbh) = @_;
|
||
|
||
my $query =
|
||
qq|SELECT
|
||
ar.invnumber, ar.ordnumber, ar.amount, ar.netamount,
|
||
ar.transdate, ar.duedate, ar.paid, ar.amount - ar.paid AS open_amount,
|
||
da.fee, da.interest, da.transdate AS dunning_date, da.duedate AS dunning_duedate
|
||
FROM ar
|
||
LEFT JOIN dunning_config cfg ON (cfg.id = ar.dunning_config_id)
|
||
LEFT JOIN dunning da ON (ar.id = da.trans_id AND cfg.dunning_level = da.dunning_level)
|
||
WHERE ar.id IN (|
|
||
. join(", ", map { "?" } @invoice_ids) . qq|)|;
|
||
dcfg.email_body, dcfg.email_subject, dcfg.email_attachment,
|
||
c.email AS recipient
|
||
|
||
my $sth = prepare_execute_query($form, $dbh, $query, @invoice_ids);
|
||
my $first = 1;
|
||
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
||
if ($first) {
|
||
map({ $form->{"dn_$_"} = []; } keys(%{$ref}));
|
||
$first = 0;
|
||
}
|
||
FROM dunning d
|
||
LEFT JOIN dunning_config dcfg ON (d.dunning_config_id = dcfg.id)
|
||
LEFT JOIN ar ON (d.trans_id = ar.id)
|
||
LEFT JOIN customer c ON (ar.customer_id = c.id)
|
||
WHERE (d.dunning_id = ?)
|
||
LIMIT 1|;
|
||
my $ref = selectfirst_hashref_query($form, $dbh, $query, $dunning_id);
|
||
|
||
$ref->{interest_rate} = $form->format_amount($myconfig, $ref->{interest_rate} * 100);
|
||
map { $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2) } qw(amount netamount paid open_amount fee interest);
|
||
map { push(@{ $form->{"dn_$_"} }, $ref->{$_})} keys %$ref;
|
||
map { $form->{$_} = $ref->{$_} } keys %{ $ref };
|
||
if (!$ref || !$ref->{recipient} || !$myconfig->{email}) {
|
||
$main::lxdebug->leave_sub();
|
||
return;
|
||
}
|
||
$sth->finish;
|
||
|
||
$query =
|
||
qq|SELECT id AS customer_id, name, street, zipcode, city, country, department_1, department_2, email
|
||
FROM customer
|
||
WHERE id = ?|;
|
||
$ref = selectfirst_hashref_query($form, $dbh, $query, $customer_id);
|
||
map { $form->{$_} = $ref->{$_} } keys %{ $ref };
|
||
my $template = PlainTextTemplate->new(undef, $form, $myconfig);
|
||
my $mail = Mailer->new();
|
||
$mail->{from} = $myconfig->{email};
|
||
$mail->{to} = $ref->{recipient};
|
||
$mail->{subject} = $template->parse_block($ref->{email_subject});
|
||
$mail->{message} = $template->parse_block($ref->{email_body});
|
||
|
||
$query =
|
||
qq|SELECT
|
||
cfg.interest_rate, cfg.template AS formname,
|
||
cfg.email_subject, cfg.email_body, cfg.email_attachment,
|
||
(SELECT SUM(fee)
|
||
FROM dunning
|
||
WHERE dunning_id = ?)
|
||
AS fee,
|
||
(SELECT SUM(interest)
|
||
FROM dunning
|
||
WHERE dunning_id = ?)
|
||
AS total_interest,
|
||
(SELECT SUM(amount) - SUM(paid)
|
||
FROM ar
|
||
WHERE id IN (| . join(", ", map { "?" } @invoice_ids) . qq|))
|
||
AS total_open_amount
|
||
FROM dunning_config cfg
|
||
WHERE id = ?|;
|
||
$ref = selectfirst_hashref_query($form, $dbh, $query, $dunning_id, $dunning_id, @invoice_ids, $next_dunning_config_id);
|
||
map { $form->{$_} = $ref->{$_} } keys %{ $ref };
|
||
if ($myconfig->{signature}) {
|
||
$mail->{message} .= "\n-- \n$myconfig->{signature}";
|
||
}
|
||
|
||
$form->{interest_rate} = $form->format_amount($myconfig, $ref->{interest_rate} * 100);
|
||
$form->{fee} = $form->format_amount($myconfig, $ref->{fee}, 2);
|
||
$form->{total_interest} = $form->format_amount($myconfig, $form->round_amount($ref->{total_interest}, 2), 2);
|
||
$form->{total_open_amount} = $form->format_amount($myconfig, $form->round_amount($ref->{total_open_amount}, 2), 2);
|
||
$form->{total_amount} = $form->format_amount($myconfig, $form->round_amount($ref->{fee} + $ref->{total_interest} + $ref->{total_open_amount}, 2), 2);
|
||
$mail->{message} =~ s/\r\n/\n/g;
|
||
|
||
if ($ref->{email_attachment} && @{ $form->{DUNNING_PDFS_EMAIL} }) {
|
||
$mail->{attachments} = $form->{DUNNING_PDFS_EMAIL};
|
||
}
|
||
|
||
$mail->send();
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub set_template_options {
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my ($self, $myconfig, $form) = @_;
|
||
|
||
$form->{templates} = "$myconfig->{templates}";
|
||
$form->{language} = $form->get_template_language(\%myconfig);
|
||
$form->{printer_code} = $form->get_printer_code(\%myconfig);
|
||
$form->{language} = $form->get_template_language($myconfig);
|
||
$form->{printer_code} = $form->get_printer_code($myconfig);
|
||
|
||
if ($form->{language} ne "") {
|
||
$form->{language} = "_" . $form->{language};
|
||
... | ... | |
$form->{printer_code} = "_" . $form->{printer_code};
|
||
}
|
||
|
||
$form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
|
||
if ($form->{format} eq 'postscript') {
|
||
$form->{postscript} = 1;
|
||
$form->{IN} =~ s/html$/tex/;
|
||
} elsif ($form->{"format"} =~ /pdf/) {
|
||
$form->{pdf} = 1;
|
||
if ($form->{"format"} =~ /opendocument/) {
|
||
$form->{IN} =~ s/html$/odt/;
|
||
} else {
|
||
$form->{IN} =~ s/html$/tex/;
|
||
}
|
||
} elsif ($form->{"format"} =~ /opendocument/) {
|
||
$form->{"opendocument"} = 1;
|
||
$form->{"IN"} =~ s/html$/odt/;
|
||
}
|
||
|
||
if ($send_email && ($form->{email} ne "")) {
|
||
$form->{media} = 'email';
|
||
}
|
||
|
||
$form->{keep_tmpfile} = 0;
|
||
if ($form->{media} eq 'email') {
|
||
$form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
|
||
unless $form->{subject};
|
||
if (!$form->{email_attachment}) {
|
||
$form->{do_not_attach} = 1;
|
||
} else {
|
||
$form->{do_not_attach} = 0;
|
||
}
|
||
$form->{subject} = parse_strings($myconfig, $form, $userspath, $form->{email_subject});
|
||
$form->{message} = parse_strings($myconfig, $form, $userspath, $form->{email_body});
|
||
|
||
$form->{OUT} = "$sendmail";
|
||
$form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
|
||
$form->{pdf} = 1;
|
||
|
||
if ($form->{"format"} =~ /opendocument/) {
|
||
$form->{IN} =~ s/html$/odt/;
|
||
} else {
|
||
|
||
my $filename = Common::unique_id() . $form->{login} . ".pdf";
|
||
$form->{OUT} = ">$spool/$filename";
|
||
push(@{ $form->{DUNNING_PDFS} }, $filename);
|
||
$form->{keep_tmpfile} = 1;
|
||
$form->{IN} =~ s/html$/tex/;
|
||
}
|
||
|
||
delete($form->{tmpfile});
|
||
$form->parse_template($myconfig, $userspath);
|
||
|
||
$dbh->commit;
|
||
$dbh->disconnect;
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
... | ... | |
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub parse_strings {
|
||
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my ($myconfig, $form, $userspath, $string) = @_;
|
||
|
||
local (*IN, *OUT);
|
||
|
||
my $format = $form->{format};
|
||
$form->{format} = "html";
|
||
|
||
$tmpstring = "parse_string.html";
|
||
$tmpfile = "$myconfig->{templates}/$tmpstring";
|
||
open(OUT, ">", $tmpfile) or $form->error("$tmpfile : $!");
|
||
|
||
print(OUT $string);
|
||
close(OUT);
|
||
|
||
my $in = $form->{IN};
|
||
$form->{IN} = $tmpstring;
|
||
$template = HTMLTemplate->new($tmpstring, $form, $myconfig, $userspath);
|
||
|
||
my $fileid = time;
|
||
$form->{tmpfile} = "$userspath/${fileid}.$tmpstring";
|
||
|
||
open(OUT, ">", $form->{tmpfile}) or $form->error("$form->{OUT} : $!");
|
||
if (!$template->parse(*OUT)) {
|
||
$form->cleanup();
|
||
$form->error("$form->{IN} : " . $template->get_error());
|
||
}
|
||
|
||
close(OUT);
|
||
my $result = "";
|
||
open(IN, "<", $form->{tmpfile}) or $form->error($form->cleanup . "$form->{tmpfile} : $!");
|
||
|
||
while (<IN>) {
|
||
$result .= $_;
|
||
}
|
||
|
||
close(IN);
|
||
# unlink($tmpfile);
|
||
# unlink($form->{tmpfile});
|
||
$form->{IN} = $in;
|
||
$form->{format} = $format;
|
||
|
||
$main::lxdebug->leave_sub();
|
||
return $result;
|
||
}
|
||
|
||
sub melt_pdfs {
|
||
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my ($self, $myconfig, $form, $userspath) = @_;
|
||
|
||
local (*IN, *OUT);
|
||
my ($self, $myconfig, $form, $copies) = @_;
|
||
|
||
# Don't allow access outside of $userspath.
|
||
# Don't allow access outside of $spool.
|
||
map { $_ =~ s|.*/||; } @{ $form->{DUNNING_PDFS} };
|
||
|
||
my $inputfiles = join " ", map { "$userspath/$_" } @{ $form->{DUNNING_PDFS} };
|
||
my $outputfile = "$userspath/dunning.pdf";
|
||
$copies *= 1;
|
||
$copies = 1 unless $copies;
|
||
my $inputfiles = join " ", map { "${main::spool}/$_ " x $copies } @{ $form->{DUNNING_PDFS} };
|
||
my $dunning_id = $form->{dunning_id};
|
||
|
||
system("gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$outputfile $inputfiles");
|
||
$dunning_id =~ s|[^\d]||g;
|
||
|
||
map { unlink("$userspath/$_") } @{ $form->{DUNNING_PDFS} };
|
||
my $in = IO::File->new("gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=- $inputfiles |");
|
||
$form->error($main::locale->text('Could not spawn ghostscript.')) unless $in;
|
||
|
||
my $numbytes = (-s $outputfile);
|
||
open(IN, $outputfile) || $form->error($self->cleanup() . "$outputfile : $!");
|
||
my $out;
|
||
|
||
$form->{copies} = 1 unless $form->{media} eq 'printer';
|
||
|
||
chdir($self->{cwd});
|
||
|
||
for my $i (1 .. $form->{copies}) {
|
||
# launch application
|
||
print qq|Content-Type: Application/PDF
|
||
Content-Disposition: attachment; filename="$outputfile"
|
||
Content-Length: $numbytes
|
||
|
||
|;
|
||
|
||
open(OUT, ">-") or $form->error($form->cleanup . "$!: STDOUT");
|
||
|
||
while (<IN>) {
|
||
print OUT $_;
|
||
if ($form->{media} eq 'printer') {
|
||
$form->get_printer_code($myconfig);
|
||
if ($form->{printer_command}) {
|
||
$out = IO::File->new("| $form->{printer_command}");
|
||
}
|
||
|
||
close(OUT);
|
||
$form->error($main::locale->text('Could not spawn the printer command.')) unless $out;
|
||
|
||
} else {
|
||
$out = IO::File->new('>-');
|
||
$out->print(qq|Content-Type: Application/PDF\n| .
|
||
qq|Content-Disposition: attachment; filename="dunning_${dunning_id}.pdf"\n\n|);
|
||
}
|
||
|
||
seek(IN, 0, 0);
|
||
while (my $line = <$in>) {
|
||
$out->print($line);
|
||
}
|
||
|
||
close(IN);
|
||
unlink($outputfile);
|
||
$in->close();
|
||
$out->close();
|
||
|
||
map { unlink("${main::spool}/$_") } @{ $form->{DUNNING_PDFS} };
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
... | ... | |
sub print_dunning {
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my ($self, $myconfig, $form, $dunning_id, $userspath, $spool, $sendmail) = @_;
|
||
my ($self, $myconfig, $form, $dunning_id, $provided_dbh) = @_;
|
||
|
||
# connect to database
|
||
my $dbh = $form->dbconnect_noauto($myconfig);
|
||
my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig);
|
||
|
||
$dunning_id =~ s|[^\d]||g;
|
||
|
||
my $query =
|
||
qq|SELECT invnumber, ordnumber, customer_id, amount, netamount,
|
||
ar.transdate, ar.duedate, paid, amount - paid AS open_amount,
|
||
template AS formname, email_subject, email_body, email_attachment,
|
||
da.fee, da.interest, da.transdate AS dunning_date, da.duedate AS dunning_duedate
|
||
qq|SELECT
|
||
da.fee, da.interest,
|
||
da.transdate AS dunning_date,
|
||
da.duedate AS dunning_duedate,
|
||
|
||
dcfg.template AS formname,
|
||
dcfg.email_subject, dcfg.email_body, dcfg.email_attachment,
|
||
|
||
ar.transdate, ar.duedate, ar.customer_id,
|
||
ar.invnumber, ar.ordnumber,
|
||
ar.amount, ar.netamount, ar.paid,
|
||
ar.amount - ar.paid AS open_amount
|
||
|
||
FROM dunning da
|
||
LEFT JOIN dunning_config ON (dunning_config.id = da.dunning_config_id)
|
||
LEFT JOIN dunning_config dcfg ON (dcfg.id = da.dunning_config_id)
|
||
LEFT JOIN ar ON (ar.id = da.trans_id)
|
||
WHERE (da.dunning_id = ?)|;
|
||
|
||
... | ... | |
map { $form->{$_} = $ref->{$_} } keys %$ref;
|
||
map { push @{ $form->{"dn_$_"} }, $ref->{$_}} keys %$ref;
|
||
}
|
||
$sth->finish;
|
||
$sth->finish();
|
||
|
||
$query =
|
||
qq|SELECT id AS customer_id, name, street, zipcode, city, country, department_1, department_2, email
|
||
FROM customer
|
||
WHERE id =
|
||
(SELECT customer_id
|
||
FROM dunning d
|
||
LEFT JOIN ar ON (d.trans_id = ar.id)
|
||
WHERE d.id = ?)|;
|
||
qq|SELECT
|
||
c.id AS customer_id, c.name, c.street, c.zipcode, c.city,
|
||
c.country, c.department_1, c.department_2, c.email
|
||
FROM dunning d
|
||
LEFT JOIN ar ON (d.trans_id = ar.id)
|
||
LEFT JOIN customer c ON (ar.customer_id = c.id)
|
||
WHERE (d.dunning_id = ?)
|
||
LIMIT 1|;
|
||
$ref = selectfirst_hashref_query($form, $dbh, $query, $dunning_id);
|
||
map { $form->{$_} = $ref->{$_} } keys %{ $ref };
|
||
|
||
... | ... | |
$form->{total_open_amount} = $form->format_amount($myconfig, $form->round_amount($ref->{total_open_amount}, 2), 2);
|
||
$form->{total_amount} = $form->format_amount($myconfig, $form->round_amount($ref->{fee} + $ref->{total_interest} + $ref->{total_open_amount}, 2), 2);
|
||
|
||
$self->set_template_options($myconfig, $form);
|
||
|
||
$form->{templates} = "$myconfig->{templates}";
|
||
my $filename = "dunning_${dunning_id}_" . Common::unique_id() . ".pdf";
|
||
$form->{OUT} = ">${main::spool}/$filename";
|
||
$form->{keep_tmpfile} = 1;
|
||
|
||
$form->{language} = $form->get_template_language(\%myconfig);
|
||
$form->{printer_code} = $form->get_printer_code(\%myconfig);
|
||
delete $form->{tmpfile};
|
||
|
||
if ($form->{language} ne "") {
|
||
$form->{language} = "_" . $form->{language};
|
||
}
|
||
push @{ $form->{DUNNING_PDFS} }, $filename;
|
||
push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'filename' => $filename,
|
||
'name' => "dunning_${dunning_id}.pdf" };
|
||
|
||
if ($form->{printer_code} ne "") {
|
||
$form->{printer_code} = "_" . $form->{printer_code};
|
||
$form->parse_template($myconfig, $main::userspath);
|
||
|
||
$dbh->disconnect() unless $provided_dbh;
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub print_invoice_for_fees {
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my ($self, $myconfig, $form, $dunning_id, $provided_dbh) = @_;
|
||
|
||
my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect($myconfig);
|
||
|
||
my ($query, @values, $sth);
|
||
|
||
$query =
|
||
qq|SELECT
|
||
d.fee_interest_ar_id,
|
||
dcfg.template
|
||
FROM dunning d
|
||
LEFT JOIN dunning_config dcfg ON (d.dunning_config_id = dcfg.id)
|
||
WHERE d.dunning_id = ?|;
|
||
my ($ar_id, $template) = selectrow_query($form, $dbh, $query, $dunning_id);
|
||
|
||
if (!$ar_id) {
|
||
$main::lxdebug->leave_sub();
|
||
return;
|
||
}
|
||
|
||
$form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
|
||
if ($form->{format} eq 'postscript') {
|
||
$form->{postscript} = 1;
|
||
$form->{IN} =~ s/html$/tex/;
|
||
} elsif ($form->{"format"} =~ /pdf/) {
|
||
$form->{pdf} = 1;
|
||
if ($form->{"format"} =~ /opendocument/) {
|
||
$form->{IN} =~ s/html$/odt/;
|
||
my $saved_form = save_form();
|
||
|
||
$query = qq|SELECT SUM(fee), SUM(interest) FROM dunning WHERE id = ?|;
|
||
my ($fee_total, $interest_total) = selectrow_query($form, $dbh, $query, $dunning_id);
|
||
|
||
$query =
|
||
qq|SELECT
|
||
ar.invnumber, ar.transdate, ar.amount, ar.netamount,
|
||
ar.duedate, ar.notes, ar.notes AS invoicenotes,
|
||
|
||
c.name, c.department_1, c.department_2, c.street, c.zipcode, c.city, c.country,
|
||
c.contact, c.customernumber, c.phone, c.fax, c.email,
|
||
c.taxnumber, c.sic_code, c.greeting
|
||
|
||
FROM ar
|
||
LEFT JOIN customer c ON (ar.customer_id = c.id)
|
||
WHERE ar.id = ?|;
|
||
$ref = selectfirst_hashref_query($form, $dbh, $query, $ar_id);
|
||
map { $form->{$_} = $ref->{$_} } keys %{ $ref };
|
||
|
||
$query = qq|SELECT * FROM employee WHERE login = ?|;
|
||
$ref = selectfirst_hashref_query($form, $dbh, $query, $form->{login});
|
||
map { $form->{"employee_${_}"} = $ref->{$_} } keys %{ $ref };
|
||
|
||
$query = qq|SELECT * FROM acc_trans WHERE trans_id = ? ORDER BY oid ASC|;
|
||
$sth = prepare_execute_query($form, $dbh, $query, $ar_id);
|
||
|
||
my ($row, $fee, $interest) = (0, 0, 0);
|
||
|
||
while ($ref = $sth->fetchrow_hashref()) {
|
||
next if ($ref->{amount} < 0);
|
||
|
||
$row++;
|
||
|
||
if ($row == 1) {
|
||
$fee = $ref->{amount};
|
||
} else {
|
||
$form->{IN} =~ s/html$/tex/;
|
||
$interest = $ref->{amount};
|
||
}
|
||
} elsif ($form->{"format"} =~ /opendocument/) {
|
||
$form->{"opendocument"} = 1;
|
||
$form->{"IN"} =~ s/html$/odt/;
|
||
}
|
||
|
||
if ($form->{"send_email"} && ($form->{email} ne "")) {
|
||
$form->{media} = 'email';
|
||
}
|
||
$form->{fee} = $form->round_amount($fee, 2);
|
||
$form->{interest} = $form->round_amount($interest, 2);
|
||
$form->{invamount} = $form->round_amount($fee + $interest, 2);
|
||
$form->{dunning_id} = $dunning_id;
|
||
$form->{formname} = "${template}_invoice";
|
||
|
||
$form->{keep_tmpfile} = 0;
|
||
if ($form->{media} eq 'email') {
|
||
$form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
|
||
unless $form->{subject};
|
||
if (!$form->{email_attachment}) {
|
||
$form->{do_not_attach} = 1;
|
||
} else {
|
||
$form->{do_not_attach} = 0;
|
||
}
|
||
$form->{subject} = parse_strings($myconfig, $form, $userspath, $form->{email_subject});
|
||
$form->{message} = parse_strings($myconfig, $form, $userspath, $form->{email_body});
|
||
map { $form->{$_} = $form->format_amount($myconfig, $form->{$_}, 2) } qw(fee interest invamount);
|
||
|
||
$form->{OUT} = "$sendmail";
|
||
$self->set_template_options($myconfig, $form);
|
||
|
||
} else {
|
||
my $filename = Common::unique_id() . "dunning_invoice_${dunning_id}.pdf";
|
||
|
||
my $filename = Common::unique_id() . $form->{login} . ".pdf";
|
||
$form->{OUT} = ">$main::spool/$filename";
|
||
$form->{keep_tmpfile} = 1;
|
||
delete $form->{tmpfile};
|
||
|
||
push(@{ $form->{DUNNING_PDFS} }, $filename);
|
||
$form->{keep_tmpfile} = 1;
|
||
}
|
||
map { delete $form->{$_} } grep /^[a-z_]+_\d+$/, keys %{ $form };
|
||
|
||
$form->parse_template($myconfig, $userspath);
|
||
$form->parse_template($myconfig, $main::userspath);
|
||
|
||
$dbh->commit;
|
||
$dbh->disconnect;
|
||
restore_form($saved_form);
|
||
|
||
push @{ $form->{DUNNING_PDFS} }, $filename;
|
||
push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'filename' => $filename,
|
||
'name' => "dunning_invoice_${dunning_id}.pdf" };
|
||
|
||
$dbh->disconnect() unless $provided_dbh;
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
bin/mozilla/dn.pl | ||
---|---|---|
#
|
||
#======================================================================
|
||
|
||
use POSIX;
|
||
|
||
use SL::IS;
|
||
use SL::PE;
|
||
use SL::DN;
|
||
use Data::Dumper;
|
||
|
||
require "bin/mozilla/common.pl";
|
||
require "bin/mozilla/io.pl";
|
||
... | ... | |
$lxdebug->enter_sub();
|
||
|
||
DN->get_config(\%myconfig, \%$form);
|
||
$form->get_lists('charts' => { 'key' => 'ALL_CHARTS',
|
||
'transdate' => 'current_date' });
|
||
|
||
$form->{SELECT_AR_AMOUNT} = [];
|
||
$form->{SELECT_AR} = [];
|
||
|
||
foreach my $chart (@{ $form->{ALL_CHARTS} }) {
|
||
$chart->{LINKS} = { map { $_, 1 } split m/:/, $chart->{link} };
|
||
|
||
if ($chart->{LINKS}->{AR}) {
|
||
$chart->{AR_selected} = "selected" if $chart->{id} == $form->{AR};
|
||
push @{ $form->{SELECT_AR} }, $chart;
|
||
}
|
||
|
||
if ($chart->{LINKS}->{AR_amount}) {
|
||
$chart->{AR_amount_fee_selected} = "selected" if $chart->{id} == $form->{AR_amount_fee};
|
||
$chart->{AR_amount_interest_selected} = "selected" if $chart->{id} == $form->{AR_amount_interest};
|
||
push @{ $form->{SELECT_AR_AMOUNT} }, $chart;
|
||
}
|
||
}
|
||
|
||
$form->{title} = $locale->text('Edit Dunning Process Config');
|
||
$form->{callback} ||= build_std_url("action=edit_config");
|
||
... | ... | |
map { $row->{$_} = $form->format_amount(\%myconfig, $row->{$_} * 1, -2) } qw(amount fee interest);
|
||
}
|
||
|
||
$form->get_lists('printers' => 'printers',
|
||
'languages' => 'languages');
|
||
|
||
$form->{type} = 'dunning';
|
||
$form->{rowcount} = scalar @{ $form->{DUNNINGS} };
|
||
$form->{jsscript} = 1;
|
||
$form->{callback} ||= build_std_url("action=show_invoices", qw(login password customer invnumber ordnumber groupinvoices minamount dunning_level notes));
|
||
|
||
$form->{PRINT_OPTIONS} = print_options({ 'inline' => 1 });
|
||
$form->{PRINT_OPTIONS} = print_options({ 'inline' => 1,
|
||
'no_queue' => 1,
|
||
'no_postscript' => 1,
|
||
'no_html' => 1,
|
||
'no_opendocument' => 1, });
|
||
|
||
$form->header();
|
||
print $form->parse_html_template("dunning/show_invoices");
|
||
... | ... | |
foreach my $level (values %{ $levels }) {
|
||
next unless scalar @{ $level };
|
||
|
||
DN->save_dunning(\%myconfig, \%$form, $level, $userspath, $spool, $sendmail);
|
||
DN->save_dunning(\%myconfig, $form, $level, $userspath, $spool, $sendmail);
|
||
}
|
||
}
|
||
|
||
... | ... | |
"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);
|
||
DN->save_dunning(\%myconfig, $form, $level, $userspath, $spool, $sendmail);
|
||
}
|
||
}
|
||
|
||
if($form->{DUNNING_PDFS}) {
|
||
DN->melt_pdfs(\%myconfig, \%$form,$spool);
|
||
DN->melt_pdfs(\%myconfig, $form);
|
||
}
|
||
|
||
# saving the history
|
||
... | ... | |
}
|
||
# /saving the history
|
||
|
||
$form->redirect($locale->text('Dunning Process started for selected invoices!'));
|
||
$form->redirect($locale->text('Dunning Process started for selected invoices!')) if ($form->{media} eq 'printer');
|
||
|
||
$lxdebug->leave_sub();
|
||
}
|
||
... | ... | |
ransdatefrom transdateto dunningfrom dunningto notes showold));
|
||
}
|
||
|
||
$form->{title} = $locale->text('Dunning overview');
|
||
$form->get_lists('printers' => 'printers',
|
||
'languages' => 'languages');
|
||
|
||
$form->{type} = 'dunning';
|
||
$form->{PRINT_OPTIONS} = print_options({ 'inline' => 1,
|
||
'no_queue' => 1,
|
||
'no_postscript' => 1,
|
||
'no_html' => 1,
|
||
'no_opendocument' => 1, });
|
||
$form->{title} = $locale->text('Dunning overview');
|
||
|
||
$form->header();
|
||
|
||
print $form->parse_html_template("dunning/show_dunning");
|
||
... | ... | |
sub print_dunning {
|
||
$lxdebug->enter_sub();
|
||
|
||
DN->print_dunning(\%myconfig, \%$form, $form->{dunning_id}, $userspath, $spool, $sendmail);
|
||
$form->{rowcount} = 1;
|
||
$form->{selected_1} = 1;
|
||
$form->{dunning_id_1} = $form->{dunning_id};
|
||
|
||
print_multiple();
|
||
|
||
$lxdebug->leave_sub();
|
||
}
|
||
|
||
sub print_multiple {
|
||
$lxdebug->enter_sub();
|
||
|
||
$form->{title} = $locale->text('Print dunnings');
|
||
|
||
my @dunning_ids = map { $form->{"dunning_id_$_"} } grep { $form->{"selected_$_"} } (1..$form->{rowcount});
|
||
|
||
if (!scalar @dunning_ids) {
|
||
$form->error($locale->text('No dunnings have been selected for printing.'));
|
||
}
|
||
|
||
$form->{DUNNING_PDFS} = [];
|
||
|
||
foreach my $dunning_id (@dunning_ids) {
|
||
DN->print_invoice_for_fees(\%myconfig, $form, $dunning_id);
|
||
DN->print_dunning(\%myconfig, $form, $dunning_id);
|
||
}
|
||
|
||
if (scalar @{ $form->{DUNNING_PDFS} }) {
|
||
$form->{dunning_id} = strftime("%Y%m%d", localtime time);
|
||
DN->melt_pdfs(\%myconfig, $form, $form->{copies});
|
||
|
||
if ($form->{media} eq 'printer') {
|
||
$form->header();
|
||
$form->info($locale->text('The dunnings have been printed.'));
|
||
}
|
||
|
||
if($form->{DUNNING_PDFS}) {
|
||
DN->melt_pdfs(\%myconfig, \%$form,$spool);
|
||
} else {
|
||
$form->redirect($locale->text('Could not create dunning copy!'));
|
||
$form->redirect($locale->text('Could not print dunning.'));
|
||
}
|
||
|
||
$lxdebug->leave_sub();
|
||
|
||
}
|
||
|
||
# end of main
|
bin/mozilla/io.pl | ||
---|---|---|
sub print {
|
||
$lxdebug->enter_sub();
|
||
|
||
if ($form->{print_nextsub}) {
|
||
call_sub($form->{print_nextsub});
|
||
$lxdebug->leave_sub();
|
||
return;
|
||
}
|
||
|
||
# if this goes to the printer pass through
|
||
if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
|
||
$form->error($locale->text('Select postscript or PDF!'))
|
js/common.js | ||
---|---|---|
return string;
|
||
}
|
||
|
||
function escape_more(s) {
|
||
s = escape(s);
|
||
return s.replace(/\+/g, '%2b');
|
||
}
|
||
|
||
function set_longdescription_window(input_name) {
|
||
var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes";
|
||
var name = document.getElementsByName(input_name)[0].value;
|
||
... | ... | |
"action=set_longdescription&" +
|
||
"login=" + encodeURIComponent(document.getElementsByName("login")[0].value)+ "&"+
|
||
"password=" + encodeURIComponent(document.getElementsByName("password")[0].value) + "&" +
|
||
"longdescription=" + escape(document.getElementsByName(input_name)[0].value) + "&" +
|
||
"input_name=" + escape(input_name) + "&"
|
||
"longdescription=" + escape_more(document.getElementsByName(input_name)[0].value) + "&" +
|
||
"input_name=" + escape_more(input_name) + "&"
|
||
window.open(url, "_new_generic", parm);
|
||
}
|
||
|
js/dunning.js | ||
---|---|---|
"action=set_email&" +
|
||
"login=" + encodeURIComponent(document.getElementsByName("login")[0].value)+ "&"+
|
||
"password=" + encodeURIComponent(document.getElementsByName("password")[0].value) + "&" +
|
||
"email_subject=" + escape(document.getElementsByName(input_subject)[0].value) + "&" +
|
||
"email_body=" + escape(document.getElementsByName(input_body)[0].value) + "&" +
|
||
"email_attachment=" + escape(document.getElementsByName(input_attachment)[0].value) + "&" +
|
||
"input_subject=" + escape(input_subject) + "&" +
|
||
"input_body=" + escape(input_body) + "&" +
|
||
"input_attachment=" + escape(input_attachment);
|
||
"email_subject=" + escape_more(document.getElementsByName(input_subject)[0].value) + "&" +
|
||
"email_body=" + escape_more(document.getElementsByName(input_body)[0].value) + "&" +
|
||
"email_attachment=" + escape_more(document.getElementsByName(input_attachment)[0].value) + "&" +
|
||
"input_subject=" + escape_more(input_subject) + "&" +
|
||
"input_body=" + escape_more(input_body) + "&" +
|
||
"input_attachment=" + escape_more(input_attachment);
|
||
window.open(url, "_new_generic", parm);
|
||
}
|
locale/de/all | ||
---|---|---|
'Account Type' => 'Kontoart',
|
||
'Account Type missing!' => 'Kontoart fehlt!',
|
||
'Account deleted!' => 'Konto gel?scht!',
|
||
'Account for fees' => 'Konto für Gebühren',
|
||
'Account for interest' => 'Konto für Zinsen',
|
||
'Account saved!' => 'Konto gespeichert!',
|
||
'Accounting Group deleted!' => 'Buchungsgruppe gelöscht!',
|
||
'Accounting Group saved!' => 'Buchungsgruppe gespeichert!',
|
||
... | ... | |
'Aug' => 'Aug',
|
||
'August' => 'August',
|
||
'Auto Send?' => 'Auto. Versand?',
|
||
'Automatically create customer invoices for fees and interests' => 'Automatisches Erstellen von Debitorenrechnungen über Mahngebühren und Zinsen',
|
||
'Automatically created invoice for fee and interest for dunning %s' => 'Automatisch erzeugte Rechnung f?r Geb?hren und Zinsen zu Mahnung %s',
|
||
'BOM' => 'St?ckliste',
|
||
'BWA' => 'BWA',
|
||
'Back' => 'Zurück',
|
||
... | ... | |
'Could not copy %s to %s. Reason: %s' => 'Die Datei "%s" konnte nicht nach "%s" kopiert werden. Grund: %s',
|
||
'Could not create dunning copy!' => 'Eine Kopie der Zahlungserinnerung konnte nicht erstellt werden.',
|
||
'Could not open the file users/members.' => 'Die Datei "users/members" konnte nicht geöffnet werden.',
|
||
'Could not print dunning.' => 'Die Mahnungen konnten nicht gedruckt werden.',
|
||
'Could not rename %s to %s. Reason: %s' => 'Die Datei "%s" konnte nicht in "%s" umbenannt werden. Grund: %s',
|
||
'Could not spawn ghostscript.' => 'Die Anwendung "ghostscript" konnte nicht gestartet werden.',
|
||
'Could not spawn the printer command.' => 'Die Druckanwendung konnte nicht gestartet werden.',
|
||
'Could not update prices!' => 'Preise konnten nicht aktualisiert werden!',
|
||
'Country' => 'Land',
|
||
'Create Buchungsgruppen' => 'Buchungsgruppe erfassen',
|
||
... | ... | |
'No customer has been selected yet.' => 'Es wurde noch kein Kunde ausgew?hlt.',
|
||
'No databases have been found on this server.' => 'Auf diesem Server wurden keine Datenbanken gefunden.',
|
||
'No datasets have been selected.' => 'Es wurden keine Datenbanken ausgewählt.',
|
||
'No dunnings have been selected for printing.' => 'Es wurden keine Mahnungen zum Drucken ausgewählt.',
|
||
'No employee was found matching the search parameters.' => 'Es wurde kein Angestellter gefunden, auf den die Suchparameter zutreffen.',
|
||
'No entries were found which had no unit assigned to them.' => 'Es wurden keine Einträge gefunden, denen keine Einheit zugeordnet war.',
|
||
'No licenses were found that match the search criteria.' => 'Es wurden keine Lizenzen gefunden, auf die die Suchkriterien zutreffen.',
|
||
... | ... | |
'Pricegroups' => 'Preisgruppen',
|
||
'Print' => 'Drucken',
|
||
'Print and Post' => 'Drucken und Buchen',
|
||
'Print dunnings' => 'Mahnungen drucken',
|
||
'Print options' => 'Druckoptionen',
|
||
'Printer' => 'Drucker',
|
||
'Printer Command' => 'Druckbefehl',
|
||
... | ... | |
'The dataset name is missing.' => 'Der Datenbankname fehlt.',
|
||
'The directory %s does not exist.' => 'Das Verzeichnis %s existiert nicht.',
|
||
'The dunning process started' => 'Der Mahnprozess ist gestartet.',
|
||
'The dunnings have been printed.' => 'Die Mahnung(en) wurden gedruckt.',
|
||
'The email address is missing.' => 'Die Emailadresse fehlt.',
|
||
'The factor is missing in row %d.' => 'Der Faktor fehlt in Zeile %d.',
|
||
'The factor is missing.' => 'Der Faktor fehlt.',
|
locale/de/dn | ||
---|---|---|
'Attempt to call an undefined sub named \'%s\'' => 'Es wurde versucht, eine nicht definierte Unterfunktion namens \'%s\' aufzurufen.',
|
||
'Aug' => 'Aug',
|
||
'August' => 'August',
|
||
'Automatically created invoice for fee and interest for dunning %s' => 'Automatisch erzeugte Rechnung f?r Geb?hren und Zinsen zu Mahnung %s',
|
||
'Billing Address' => 'Rechnungsadresse',
|
||
'Bin' => 'Lagerplatz',
|
||
'Bin List' => 'Lagerliste',
|
||
... | ... | |
'Confirmation' => 'Auftragsbest?tigung',
|
||
'Contact' => 'Kontakt',
|
||
'Continue' => 'Weiter',
|
||
'Could not create dunning copy!' => 'Eine Kopie der Zahlungserinnerung konnte nicht erstellt werden.',
|
||
'Could not print dunning.' => 'Die Mahnungen konnten nicht gedruckt werden.',
|
||
'Could not spawn ghostscript.' => 'Die Anwendung "ghostscript" konnte nicht gestartet werden.',
|
||
'Could not spawn the printer command.' => 'Die Druckanwendung konnte nicht gestartet werden.',
|
||
'Country' => 'Land',
|
||
'Credit Note' => 'Gutschrift',
|
||
'Customer Number' => 'Kundennummer',
|
||
... | ... | |
'No Customer was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Endkunde gefunden',
|
||
'No Vendor was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein H?ndler gefunden',
|
||
'No customer has been selected yet.' => 'Es wurde noch kein Kunde ausgew?hlt.',
|
||
'No dunnings have been selected for printing.' => 'Es wurden keine Mahnungen zum Drucken ausgewählt.',
|
||
'No employee was found matching the search parameters.' => 'Es wurde kein Angestellter gefunden, auf den die Suchparameter zutreffen.',
|
||
'No part was found matching the search parameters.' => 'Es wurde kein Artikel gefunden, auf den die Suchparameter zutreffen.',
|
||
'No project was found matching the search parameters.' => 'Es wurde kein Projekt gefunden, auf das die Suchparameter zutreffen.',
|
||
... | ... | |
'Postscript' => 'Postscript',
|
||
'Price' => 'Preis',
|
||
'Pricegroup' => 'Preisgruppe',
|
||
'Print dunnings' => 'Mahnungen drucken',
|
||
'Printer' => 'Drucker',
|
||
'Proforma Invoice' => 'Proformarechnung',
|
||
'Project' => 'Projekt',
|
||
... | ... | |
'Subtotal' => 'Zwischensumme',
|
||
'Terms missing in row ' => '+Tage fehlen in Zeile ',
|
||
'The \'tag\' field must only consist of alphanumeric characters or the carachters - _ ( )' => 'Das Feld \'tag\' darf nur aus alphanumerischen Zeichen und den Zeichen - _ ( ) bestehen.',
|
||
'The dunnings have been printed.' => 'Die Mahnung(en) wurden gedruckt.',
|
||
'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.',
|
||
'Unit' => 'Einheit',
|
||
'Unknown dependency \'%s\'.' => 'Unbekannte Abhängigkeit \'%s\'.',
|
||
... | ... | |
'print' => 'print',
|
||
'print_dunning' => 'print_dunning',
|
||
'print_form' => 'print_form',
|
||
'print_multiple' => 'print_multiple',
|
||
'print_options' => 'print_options',
|
||
'project_selected' => 'project_selected',
|
||
'project_selection_internal' => 'project_selection_internal',
|
||
... | ... | |
'vendor_invoice' => 'vendor_invoice',
|
||
'vendor_selection' => 'vendor_selection',
|
||
'weiter' => 'continue',
|
||
'drucken' => 'print',
|
||
'speichern' => 'save',
|
||
};
|
||
|
sql/Pg-upgrade2/dunning_invoices_for_fees.sql | ||
---|---|---|
-- @tag: dunning_invoices_for_fees
|
||
-- @description: Konfiguration für das automatische Erzeugen von Rechnungen über Mahngebühren sowie eine Verknüpfung zwischen Mahnungen und den dazu erzeugten Rechnungen.
|
||
-- @depends: release_2_4_2
|
||
ALTER TABLE defaults ADD COLUMN dunning_create_invoices_for_fees boolean;
|
||
ALTER TABLE defaults ADD COLUMN dunning_AR_amount_fee integer;
|
||
ALTER TABLE defaults ADD COLUMN dunning_AR_amount_interest integer;
|
||
ALTER TABLE defaults ADD COLUMN dunning_AR integer;
|
||
UPDATE defaults SET dunning_create_invoices_for_fees = 'f';
|
||
|
||
ALTER TABLE dunning ADD COLUMN fee_interest_ar_id integer;
|
||
ALTER TABLE dunning ADD FOREIGN KEY (fee_interest_ar_id) REFERENCES ar (id);
|
templates/webpages/dunning/edit_config_de.html | ||
---|---|---|
<script type="text/javascript" src="js/common.js"></script>
|
||
<script type="text/javascript" src="js/dunning.js"></script>
|
||
|
||
<script type="text/javascript">
|
||
<!--
|
||
function enable_invoice_controls(enable) {
|
||
document.Form.AR.disabled = !enable;
|
||
document.Form.AR_amount_fee.disabled = !enable;
|
||
document.Form.AR_amount_interest.disabled = !enable;
|
||
}
|
||
-->
|
||
</script>
|
||
|
||
<div class="listtop" width="100%"><TMPL_VAR title></div>
|
||
|
||
<form method="post" action="dn.pl">
|
||
<form method="post" action="dn.pl" name="Form">
|
||
<table>
|
||
<tr height="5"></tr>
|
||
|
||
... | ... | |
</tr>
|
||
</table>
|
||
|
||
<input type="hidden" name="rowcount" value="<TMPL_VAR rowcount ESCAPE=HTML>">
|
||
|
||
<hr size="3" noshade>
|
||
|
||
<p>
|
||
<input type="checkbox" name="create_invoices_for_fees" id="create_invoices_for_fees"
|
||
<TMPL_IF create_invoices_for_fees>checked</TMPL_IF>
|
||
value="1" onclick="enable_invoice_controls(this.checked);">
|
||
<label for="create_invoices_for_fees">Automatisches Erstellen von Debitorenrechnungen über Mahngebühren und Zinsen</label>
|
||
</p>
|
||
|
||
<table>
|
||
<tr>
|
||
<th align="right">Konto für Gebühren</th>
|
||
<td>
|
||
<select name="AR_amount_fee" <TMPL_UNLESS create_invoices_for_fees>disabled</TMPL_UNLESS>>
|
||
<TMPL_LOOP SELECT_AR_AMOUNT><option value="<TMPL_VAR id ESCAPE=HTML>" <TMPL_IF AR_amount_fee_selected>selected</TMPL_IF>><TMPL_VAR accno ESCAPE=HTML>--<TMPL_VAR description ESCAPE=HTML></option>
|
||
</TMPL_LOOP>
|
||
</select>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<th align="right">Konto für Zinsen</th>
|
||
<td>
|
||
<select name="AR_amount_interest" <TMPL_UNLESS create_invoices_for_fees>disabled</TMPL_UNLESS>>
|
||
<TMPL_LOOP SELECT_AR_AMOUNT><option value="<TMPL_VAR id ESCAPE=HTML>" <TMPL_IF AR_amount_interest_selected>selected</TMPL_IF>><TMPL_VAR accno ESCAPE=HTML>--<TMPL_VAR description ESCAPE=HTML></option>
|
||
</TMPL_LOOP>
|
||
</select>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<th align="right">Buchen auf</th>
|
||
<td>
|
||
<select name="AR" <TMPL_UNLESS create_invoices_for_fees>disabled</TMPL_UNLESS>>
|
||
<TMPL_LOOP SELECT_AR><option value="<TMPL_VAR id ESCAPE=HTML>" <TMPL_IF AR_selected>selected</TMPL_IF>><TMPL_VAR accno ESCAPE=HTML>--<TMPL_VAR description ESCAPE=HTML></option>
|
||
</TMPL_LOOP>
|
||
</select>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
|
||
<hr size="3" noshade>
|
||
|
||
<input type="hidden" name="rowcount" value="<TMPL_VAR rowcount ESCAPE=HTML>">
|
||
<input type="hidden" name="callback" value="<TMPL_VAR callback ESCAPE=HTML>">
|
||
|
||
<input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
|
templates/webpages/dunning/edit_config_master.html | ||
---|---|---|
<script type="text/javascript" src="js/common.js"></script>
|
||
<script type="text/javascript" src="js/dunning.js"></script>
|
||
|
||
<script type="text/javascript">
|
||
<!--
|
||
function enable_invoice_controls(enable) {
|
||
document.Form.AR.disabled = !enable;
|
||
document.Form.AR_amount_fee.disabled = !enable;
|
||
document.Form.AR_amount_interest.disabled = !enable;
|
||
}
|
||
-->
|
||
</script>
|
||
|
||
<div class="listtop" width="100%"><TMPL_VAR title></div>
|
||
|
||
<form method="post" action="dn.pl">
|
||
<form method="post" action="dn.pl" name="Form">
|
||
<table>
|
||
<tr height="5"></tr>
|
||
|
||
... | ... | |
</tr>
|
||
</table>
|
||
|
||
<input type="hidden" name="rowcount" value="<TMPL_VAR rowcount ESCAPE=HTML>">
|
||
|
||
<hr size="3" noshade>
|
||
|
||
<p>
|
||
<input type="checkbox" name="create_invoices_for_fees" id="create_invoices_for_fees"
|
||
<TMPL_IF create_invoices_for_fees>checked</TMPL_IF>
|
||
value="1" onclick="enable_invoice_controls(this.checked);">
|
||
<label for="create_invoices_for_fees"><translate>Automatically create customer invoices for fees and interests</translate></label>
|
||
</p>
|
||
|
||
<table>
|
||
<tr>
|
||
<th align="right"><translate>Account for fees</translate></th>
|
||
<td>
|
||
<select name="AR_amount_fee" <TMPL_UNLESS create_invoices_for_fees>disabled</TMPL_UNLESS>>
|
||
<TMPL_LOOP SELECT_AR_AMOUNT><option value="<TMPL_VAR id ESCAPE=HTML>" <TMPL_IF AR_amount_fee_selected>selected</TMPL_IF>><TMPL_VAR accno ESCAPE=HTML>--<TMPL_VAR description ESCAPE=HTML></option>
|
||
</TMPL_LOOP>
|
||
</select>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<th align="right"><translate>Account for interest</translate></th>
|
||
<td>
|
||
<select name="AR_amount_interest" <TMPL_UNLESS create_invoices_for_fees>disabled</TMPL_UNLESS>>
|
||
<TMPL_LOOP SELECT_AR_AMOUNT><option value="<TMPL_VAR id ESCAPE=HTML>" <TMPL_IF AR_amount_interest_selected>selected</TMPL_IF>><TMPL_VAR accno ESCAPE=HTML>--<TMPL_VAR description ESCAPE=HTML></option>
|
||
</TMPL_LOOP>
|
||
</select>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<th align="right"><translate>Record in</translate></th>
|
||
<td>
|
||
<select name="AR" <TMPL_UNLESS create_invoices_for_fees>disabled</TMPL_UNLESS>>
|
||
<TMPL_LOOP SELECT_AR><option value="<TMPL_VAR id ESCAPE=HTML>" <TMPL_IF AR_selected>selected</TMPL_IF>><TMPL_VAR accno ESCAPE=HTML>--<TMPL_VAR description ESCAPE=HTML></option>
|
||
</TMPL_LOOP>
|
||
</select>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
|
||
<hr size="3" noshade>
|
||
|
||
<input type="hidden" name="rowcount" value="<TMPL_VAR rowcount ESCAPE=HTML>">
|
||
<input type="hidden" name="callback" value="<TMPL_VAR callback ESCAPE=HTML>">
|
||
|
||
<input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
|
templates/webpages/dunning/set_email_de.html | ||
---|---|---|
|
||
<tr>
|
||
<td valign="top">PDF anh?ngen</td>
|
||
<td valign="top"><input id="email_attachment" type="checkbox" name="email_attachment" value="1" "<TMPL_VAR email_attachment ESCAPE=HTML>"></td>
|
||
<td valign="top"><input id="email_attachment" type="checkbox" name="email_attachment" value="1" <TMPL_IF email_attachment>checked</TMPL_IF>></td>
|
||
</tr>
|
||
</table>
|
||
|
templates/webpages/dunning/set_email_master.html | ||
---|---|---|
|
||
<tr>
|
||
<td valign="top"><translate>Attach PDF:</translate></td>
|
||
<td valign="top"><input id="email_attachment" type="checkbox" name="email_attachment" value="1" "<TMPL_VAR email_attachment ESCAPE=HTML>"></td>
|
||
<td valign="top"><input id="email_attachment" type="checkbox" name="email_attachment" value="1" <TMPL_IF email_attachment>checked</TMPL_IF>></td>
|
||
</tr>
|
||
</table>
|
||
|
templates/webpages/dunning/show_dunning_de.html | ||
---|---|---|
|
||
<div class="listtop" width="100%"><TMPL_VAR title></div>
|
||
|
||
<p>
|
||
<table width="100%">
|
||
<tr>
|
||
<th class="listheading">Mahnlevel</th>
|
||
<th class="listheading">Kundenname</th>
|
||
<th class="listheading">Rechnungsnummer</th>
|
||
<th class="listheading">Rechnungsdatum</th>
|
||
<th class="listheading">F?lligkeitsdatum</th>
|
||
<th class="listheading">Betrag</th>
|
||
<th class="listheading">Mahndatum</th>
|
||
<th class="listheading">Zahlbar bis</th>
|
||
<th class="listheading">Kumulierte Geb?hren</th>
|
||
<th class="listheading">Zinsen</th>
|
||
</tr>
|
||
|
||
<!-- Ausgabe der einzelnen Zeilen -->
|
||
|
||
<TMPL_LOOP DUNNINGS>
|
||
<tr class="listrow<TMPL_VAR listrow_odd_even>">
|
||
<td>
|
||
<TMPL_IF first_row_for_dunning>
|
||
<a href="dn.pl?action=print_dunning&format=pdf&media=screen&dunning_id=<TMPL_VAR dunning_id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>">
|
||
<TMPL_VAR dunning_description ESCAPE=HTML>
|
||
</a>
|
||
<TMPL_ELSE>
|
||
|
||
</TMPL_IF>
|
||
</td>
|
||
|
||
<td><TMPL_IF first_row_for_dunning><TMPL_VAR customername ESCAPE=HTML><TMPL_ELSE> </TMPL_IF></td>
|
||
|
||
<td><a href="is.pl?action=edit&id=<TMPL_VAR id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>"><TMPL_VAR invnumber ESCAPE=HTML></a></td>
|
||
|
||
<td align="right"><TMPL_VAR transdate ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR duedate ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR amount ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR dunning_date ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR dunning_duedate ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR fee ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR interest ESCAPE=HTML></td>
|
||
<form method="post" action="dn.pl">
|
||
|
||
<input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
|
||
<input type="hidden" name="password" value="<TMPL_VAR password ESCAPE=HTML>">
|
||
|
||
<p>
|
||
<table width="100%">
|
||
<tr>
|
||
<th class="listheading"> </th>
|
||
<th class="listheading">Mahnlevel</th>
|
||
<th class="listheading">Kundenname</th>
|
||
<th class="listheading">Rechnungsnummer</th>
|
||
<th class="listheading">Rechnungsdatum</th>
|
||
<th class="listheading">F?lligkeitsdatum</th>
|
||
<th class="listheading">Betrag</th>
|
||
<th class="listheading">Mahndatum</th>
|
||
<th class="listheading">Zahlbar bis</th>
|
||
<th class="listheading">Kumulierte Geb?hren</th>
|
||
<th class="listheading">Zinsen</th>
|
||
</tr>
|
||
</TMPL_LOOP>
|
||
|
||
<tr><td colspan="10"><hr size="3" noshade></td></tr>
|
||
</table>
|
||
</p>
|
||
<!-- Ausgabe der einzelnen Zeilen -->
|
||
|
||
<TMPL_LOOP DUNNINGS>
|
||
<tr class="listrow<TMPL_VAR listrow_odd_even>">
|
||
<td>
|
||
<TMPL_IF first_row_for_dunning>
|
||
<input type="checkbox" name="selected_<TMPL_VAR __counter__>" value="1">
|
||
<input type="hidden" name="dunning_id_<TMPL_VAR __counter__>" value="<TMPL_VAR dunning_id ESCAPE=HTML>">
|
||
</TMPL_IF>
|
||
</td>
|
||
|
||
<td>
|
||
<TMPL_IF first_row_for_dunning>
|
||
<a href="dn.pl?action=print_dunning&format=pdf&media=screen&dunning_id=<TMPL_VAR dunning_id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>">
|
||
<TMPL_VAR dunning_description ESCAPE=HTML>
|
||
</a>
|
||
<TMPL_ELSE>
|
||
|
||
</TMPL_IF>
|
||
</td>
|
||
|
||
<td><TMPL_IF first_row_for_dunning><TMPL_VAR customername ESCAPE=HTML><TMPL_ELSE> </TMPL_IF></td>
|
||
|
||
<td><a href="is.pl?action=edit&id=<TMPL_VAR id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>"><TMPL_VAR invnumber ESCAPE=HTML></a></td>
|
||
|
||
<td align="right"><TMPL_VAR transdate ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR duedate ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR amount ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR dunning_date ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR dunning_duedate ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR fee ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR interest ESCAPE=HTML></td>
|
||
</tr>
|
||
|
||
<TMPL_IF __last__><input type="hidden" name="rowcount" value="<TMPL_VAR __counter__>"></TMPL_IF>
|
||
</TMPL_LOOP>
|
||
<tr><td colspan="11"><hr size="3" noshade></td></tr>
|
||
</table>
|
||
</p>
|
||
|
||
|
||
<p><TMPL_VAR PRINT_OPTIONS></p>
|
||
|
||
<p>
|
||
<input type="hidden" name="print_nextsub" value="print_multiple">
|
||
<input type="submit" class="submit" name="action" value="Drucken">
|
||
</p>
|
||
|
||
</form>
|
||
|
||
</body>
|
templates/webpages/dunning/show_dunning_master.html | ||
---|---|---|
|
||
<div class="listtop" width="100%"><TMPL_VAR title></div>
|
||
|
||
<p>
|
||
<table width="100%">
|
||
<tr>
|
||
<th class="listheading"><translate>Dunning Level</translate></th>
|
||
<th class="listheading"><translate>Customername</translate></th>
|
||
<th class="listheading"><translate>Invnumber</translate></th>
|
||
<th class="listheading"><translate>Invdate</translate></th>
|
||
<th class="listheading"><translate>Invoice Duedate</translate></th>
|
||
<th class="listheading"><translate>Amount</translate></th>
|
||
<th class="listheading"><translate>Dunning Date</translate></th>
|
||
<th class="listheading"><translate>Dunning Duedate</translate></th>
|
||
<th class="listheading"><translate>Total Fees</translate></th>
|
||
<th class="listheading"><translate>Interest</translate></th>
|
||
</tr>
|
||
|
||
<!-- Ausgabe der einzelnen Zeilen -->
|
||
|
||
<TMPL_LOOP DUNNINGS>
|
||
<tr class="listrow<TMPL_VAR listrow_odd_even>">
|
||
<td>
|
||
<TMPL_IF first_row_for_dunning>
|
||
<a href="dn.pl?action=print_dunning&format=pdf&media=screen&dunning_id=<TMPL_VAR dunning_id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>">
|
||
<TMPL_VAR dunning_description ESCAPE=HTML>
|
||
</a>
|
||
<TMPL_ELSE>
|
||
|
||
</TMPL_IF>
|
||
</td>
|
||
|
||
<td><TMPL_IF first_row_for_dunning><TMPL_VAR customername ESCAPE=HTML><TMPL_ELSE> </TMPL_IF></td>
|
||
|
||
<td><a href="is.pl?action=edit&id=<TMPL_VAR id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>"><TMPL_VAR invnumber ESCAPE=HTML></a></td>
|
||
|
||
<td align="right"><TMPL_VAR transdate ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR duedate ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR amount ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR dunning_date ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR dunning_duedate ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR fee ESCAPE=HTML></td>
|
||
<td align="right"><TMPL_VAR interest ESCAPE=HTML></td>
|
||
<form method="post" action="dn.pl">
|
||
|
||
<input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
|
||
<input type="hidden" name="password" value="<TMPL_VAR password ESCAPE=HTML>">
|
||
|
||
<p>
|
||
<table width="100%">
|
||
<tr>
|
||
<th class="listheading"> </th>
|
||
<th class="listheading"><translate>Dunning Level</translate></th>
|
||
<th class="listheading"><translate>Customername</translate></th>
|
||
<th class="listheading"><translate>Invnumber</translate></th>
|
||
<th class="listheading"><translate>Invdate</translate></th>
|
||
<th class="listheading"><translate>Invoice Duedate</translate></th>
|
||
<th class="listheading"><translate>Amount</translate></th>
|
||
<th class="listheading"><translate>Dunning Date</translate></th>
|
||
<th class="listheading"><translate>Dunning Duedate</translate></th>
|
||
<th class="listheading"><translate>Total Fees</translate></th>
|
||
<th class="listheading"><translate>Interest</translate></th>
|
||
</tr>
|
Auch abrufbar als: Unified diff
Mahnwesen:
1. Neues Feature: Automatisches Erzeugen von Debitorenrechnungen über die Mahngebühren und -zinsen. Diese werden ebenfalls als PDFs ausgegeben.
2. Neues Feature: Beim Bericht über aktive Mahnungen ermöglichen, dass mehrere Mahnungen und die eventuell dazu erstellen Debitorenrechnungen auf einmal ausgedruckt werden können.
3. Neues Feature: Mahnungen können wahlweise am Bildschirm oder direkt auf Druckern ausgegeben werden. Zusätzlich können andere Sprachen ausgewählt werden.
4. Bugfix: Beim Bearbeiten von Emaileinstellungen in der Mahnkonfiguration wurden +-Zeichen falsch escapet und verschwanden.
5. Code zum Ersetzen von $form-Variablen in Strings entfernt und durch die Verwendung von PlainTextTemplate ersetzt.
Fixes für Bugs 473 und 553.