From 8f98fc19d76ab2d20022b3103ac22618bbde5656 Mon Sep 17 00:00:00 2001
From: Philip Reetz
Date: Mon, 12 Feb 2007 10:50:49 +0000
Subject: [PATCH] Bei hoeheren Mahnstufen wurde die Rechnung mehrmals
angezeigt. In der Uebersicht der Mahnungen hat ein Klick auf die
Rechnungsnummer nicht die Rechnungsmaske geoeffnet
---
SL/DN.pm | 8 ++++----
bin/mozilla/dn.pl | 10 +++++++---
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/SL/DN.pm b/SL/DN.pm
index 058de2703..c706ee4a2 100644
--- a/SL/DN.pm
+++ b/SL/DN.pm
@@ -138,7 +138,7 @@ sub save_dunning {
$dbh->do($query) || $form->dberror($query);
}
- 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 FROM ar LEFT JOIN dunning_config ON (dunning_config.id=ar.dunning_id) LEFT JOIN dunning da ON (ar.id=da.trans_id) where ar.id IN $form->{inv_ids}|;
+ 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 FROM ar LEFT JOIN dunning_config ON (dunning_config.id=ar.dunning_id) LEFT JOIN dunning da ON (ar.id=da.trans_id AND dunning_config.dunning_level=da.dunning_level) where ar.id IN $form->{inv_ids}|;
my $sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
my $first = 1;
@@ -278,7 +278,7 @@ sub get_invoices {
FROM dunning_config dnn, ar a
JOIN customer ct ON (a.customer_id = ct.id)
LEFT JOIN dunning_config dn ON (dn.id = a.dunning_id)
- LEFT JOIN dunning da ON (da.trans_id=a.id)
+ LEFT JOIN dunning da ON (da.trans_id=a.id AND dunning_config.dunning_level=da.dunning_level)
$where|;
my $sth = $dbh->prepare($query);
@@ -359,7 +359,7 @@ sub get_dunning {
$where .= " ORDER by $sortorder";
- $query = qq|SELECT a.id, a.ordnumber, a.transdate, a.invnumber,a.amount, ct.name AS customername, a.duedate,da.fee ,da.interest, dn.dunning_description, da.transdate AS dunning_date, da.duedate AS dunning_duedate, da.dunning_id
+ $query = qq|SELECT a.id, a.ordnumber,a.invoice, a.transdate, a.invnumber,a.amount, ct.name AS customername, a.duedate,da.fee ,da.interest, dn.dunning_description, da.transdate AS dunning_date, da.duedate AS dunning_duedate, da.dunning_id
FROM ar a
JOIN customer ct ON (a.customer_id = ct.id),
dunning da LEFT JOIN dunning_config dn ON (da.dunning_id=dn.id)
@@ -502,7 +502,7 @@ sub print_dunning {
my $dbh = $form->dbconnect_noauto($myconfig);
- 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 FROM ar LEFT JOIN dunning_config ON (dunning_config.id=ar.dunning_id) LEFT JOIN dunning da ON (ar.id=da.trans_id) where ar.dunning_id=$dunning_id|;
+ 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 FROM ar LEFT JOIN dunning_config ON (dunning_config.id=ar.dunning_id) LEFT JOIN dunning da ON (ar.id=da.trans_id AND dunning_config.dunning_level=da.dunning_level) where ar.dunning_id=$dunning_id|;
my $sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
my $first = 1;
diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl
index f0f2a57e2..2ec5ab005 100644
--- a/bin/mozilla/dn.pl
+++ b/bin/mozilla/dn.pl
@@ -896,8 +896,12 @@ sub show_dunning {
$dunning = qq||;
-
-
+ my $script = "";
+ if ($ref->{invoice}) {
+ $script = "is.pl";
+ } else {
+ $script = "ar.pl";
+ }
$column_data{dunning_description} = qq|