Fixed bug 24531: @cus_nam@ in report filename wrongly replaced
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Mon, 19 Aug 2013 10:37:30 +0200
changeset 20995 16b6c6165ce8
parent 20994 b733b50a1016
child 20996 c29367b38105
Fixed bug 24531: @cus_nam@ in report filename wrongly replaced
It was replaced by the Business Partner name instead of the User/Contact name,
as it is done in email's subject and body
src/org/openbravo/erpCommon/utility/reporting/Report.java
src/org/openbravo/erpCommon/utility/reporting/Report_data.xsql
--- a/src/org/openbravo/erpCommon/utility/reporting/Report.java	Mon Aug 19 12:03:12 2013 +0200
+++ b/src/org/openbravo/erpCommon/utility/reporting/Report.java	Mon Aug 19 10:37:30 2013 +0200
@@ -57,6 +57,7 @@
   private String _MinDueDate; // Useful for Orders and Invoices
   private String _MaxDueDate; // Useful for Orders and Invoices
   private String _DocDescription;
+  private String _ContactName;
   private String _Filename;
   private File _targetDirectory;
   private boolean _isAttached;
@@ -126,6 +127,7 @@
       _MinDueDate = reportData[0].getField("minduedate");
       _MaxDueDate = reportData[0].getField("maxduedate");
       _DocDescription = reportData[0].getField("docdesc");
+      _ContactName = reportData[0].getField("contact_name");
       templateInfo = new TemplateInfo(connectionProvider, docTypeId, orgId, strLanguage, templateId);
 
       _Filename = generateReportFileName();
@@ -146,7 +148,7 @@
     String reportFilename = templateInfo.getReportFilename();
     reportFilename = reportFilename.replaceAll("@our_ref@", _OurReference);
     reportFilename = reportFilename.replaceAll("@cus_ref@", _CusReference);
-    reportFilename = reportFilename.replaceAll("@cus_nam@", _BPartnerName);
+    reportFilename = reportFilename.replaceAll("@cus_nam@", _ContactName);
     reportFilename = reportFilename.replaceAll("@bp_nam@", _BPartnerName);
     reportFilename = reportFilename.replaceAll("@doc_date@", _DocDate);
     reportFilename = reportFilename.replaceAll("@doc_nextduedate@", _MinDueDate);
--- a/src/org/openbravo/erpCommon/utility/reporting/Report_data.xsql	Mon Aug 19 12:03:12 2013 +0200
+++ b/src/org/openbravo/erpCommon/utility/reporting/Report_data.xsql	Mon Aug 19 10:37:30 2013 +0200
@@ -46,7 +46,8 @@
 				'' as docdate,
 				'' as minduedate,
 				'' as maxduedate,
-				'' as docdesc
+				'' as docdesc,
+				'' as contact_name
 			from
 				c_order
 			where
@@ -72,7 +73,7 @@
 				c_order.c_doctypetarget_id as docTypeTargetId,
 				c_order.documentno as ourreference,
 				c_order.poreference as cusreference,
-				ad_user.name as salnam,
+				salesrep.name as salnam,
 				c_order.c_bpartner_id as bpartner_id,
 				c_bpartner.name as bpartner_name,
 				c_bpartner.ad_language as bpartner_language,
@@ -87,11 +88,13 @@
                  where c_order.c_order_id = fin_payment_schedule.c_order_id
                  and fin_payment_schedule.outstandingamt > 0 
                 ) as maxduedate,
-				c_order.description as docdesc
+				c_order.description as docdesc,
+				customercontact.name as contact_name
 			from
 				c_order left join c_doctype on c_order.c_doctypetarget_id = c_doctype.c_doctype_id
 				left join c_bpartner on c_order.c_bpartner_id = c_bpartner.c_bpartner_id
-				left join ad_user on c_order.salesrep_id = ad_user.ad_user_id
+				left join ad_user salesrep on c_order.salesrep_id = salesrep.ad_user_id
+				left join ad_user customercontact on c_order.ad_user_id = customercontact.ad_user_id
 			where
 				c_order.c_order_id = ?		
 	        ]]>
@@ -112,7 +115,7 @@
 				c_invoice.c_doctypetarget_id as docTypeTargetId,
 				c_invoice.documentno as ourreference,
 				c_invoice.poreference as cusreference,
-				ad_user.name as salnam,
+				salesrep.name as salnam,
 				c_invoice.c_bpartner_id as bpartner_id,
 				c_invoice.issotrx as isSalesOrderTransaction,
 				c_bpartner.name as bpartner_name,
@@ -128,11 +131,13 @@
                  where c_invoice.c_invoice_id = fin_payment_schedule.c_invoice_id
                  and fin_payment_schedule.outstandingamt > 0 
                 ) as maxduedate,
-                c_invoice.description as docdesc
+                c_invoice.description as docdesc,
+                customercontact.name as contact_name
 			from
 				c_invoice left join c_doctype on c_invoice.c_doctypetarget_id = c_doctype.c_doctype_id
 				left join c_bpartner on c_invoice.c_bpartner_id = c_bpartner.c_bpartner_id
-				left join ad_user on c_invoice.salesrep_id = ad_user.ad_user_id
+				left join ad_user salesrep on c_invoice.salesrep_id = salesrep.ad_user_id
+				left join ad_user customercontact on c_invoice.ad_user_id = customercontact.ad_user_id
 			where
 				c_invoice.c_invoice_id = ?
 	        ]]>
@@ -152,7 +157,7 @@
 				m_inout.c_doctype_id as docTypeTargetId,
 				m_inout.documentno as ourreference,
 				m_inout.poreference as cusreference,
-				ad_user.name as salnam,
+				salesrep.name as salnam,
 				m_inout.c_bpartner_id as bpartner_id,
 				m_inout.issotrx as isSalesOrderTransaction,
 				c_bpartner.name as bpartner_name,
@@ -160,11 +165,13 @@
 				m_inout.movementdate as docdate,
 				null as minduedate,
 				null as maxduedate,
-				m_inout.description as docdesc
+				m_inout.description as docdesc,
+				customercontact.name as contact_name
 			from
 				m_inout left join c_doctype on m_inout.c_doctype_id = c_doctype.c_doctype_id
 				left join c_bpartner on m_inout.c_bpartner_id = c_bpartner.c_bpartner_id
-				left join ad_user on m_inout.salesrep_id = ad_user.ad_user_id
+				left join ad_user salesrep on m_inout.salesrep_id = salesrep.ad_user_id
+				left join ad_user customercontact on m_inout.ad_user_id = customercontact.ad_user_id
 			where
 				m_inout.m_inout_id = ?
 	        ]]>
@@ -197,7 +204,8 @@
                  from fin_payment_detail_v
                  where fin_payment.fin_payment_id = fin_payment_detail_v.fin_payment_id
                 ) as maxduedate,
-                fin_payment.description as docdesc
+                fin_payment.description as docdesc,
+                '' as contact_name
             from
                 fin_payment left join c_doctype on fin_payment.c_doctype_id = c_doctype.c_doctype_id
                 left join c_bpartner on fin_payment.c_bpartner_id = c_bpartner.c_bpartner_id