[UOM Management] Merge with pi.
authorDavid Miguelez <david.miguelez@openbravo.com>
Fri, 02 Dec 2016 12:34:27 +0100
changeset 30927 cde4e226d8de
parent 30926 a57c4aa5d672 (current diff)
parent 30804 df94c05f6b89 (diff)
child 30928 2218f18f1eaa
[UOM Management] Merge with pi.
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql
--- a/src-db/database/model/views/C_INVOICE_CANDIDATE_V.xml	Fri Dec 02 12:32:08 2016 +0100
+++ b/src-db/database/model/views/C_INVOICE_CANDIDATE_V.xml	Fri Dec 02 12:34:27 2016 +0100
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>
   <database name="VIEW C_INVOICE_CANDIDATE_V">
-    <view name="C_INVOICE_CANDIDATE_V"><![CDATA[SELECT o.ad_client_id, o.ad_org_id, o.c_bpartner_id, o.c_order_id, o.documentno, o.dateordered, o.c_doctype_id, o.totallines AS amountlines, o.grandtotal AS amountlinesgross, sum(round((l.qtyordered - l.qtyinvoiced) * l.priceactual, c.stdprecision)) AS notinvoicedlines, round(sum(round((l.qtyordered - l.qtyinvoiced) * l.priceactual, c.stdprecision) * (1 + t.rate / 100)), c.stdprecision) AS notinvoicedlinesgross, o.invoicerule AS term, sum(round((l.qtydelivered - l.qtyinvoiced) * l.priceactual, c.stdprecision)) AS pendinglines, round(sum(round((l.qtydelivered - l.qtyinvoiced) * l.priceactual, c.stdprecision) * (1 + t.rate / 100)), c.stdprecision) AS pendinglinesgross, sum(abs(l.qtyordered)) AS qtyordered, sum(abs(l.qtydelivered)) AS qtydelivered FROM c_order o JOIN c_doctype dt ON o.c_doctype_id = dt.c_doctype_id JOIN c_bpartner bp ON o.c_bpartner_id = bp.c_bpartner_id JOIN c_currency c ON o.c_currency_id = c.c_currency_id JOIN c_orderline l ON o.c_order_id = l.c_order_id JOIN c_tax t ON t.c_tax_id = l.c_tax_id LEFT JOIN c_invoiceschedule si ON bp.c_invoiceschedule_id = si.c_invoiceschedule_id WHERE (o.docstatus = 'CO' OR o.docstatus = 'CL' OR o.docstatus = 'IP') AND (o.invoicerule = 'I' OR o.invoicerule = 'O' OR o.invoicerule = 'D' OR o.invoicerule = 'S') AND dt.docbasetype = 'SOO' AND (dt.docsubtypeso <> 'ON' OR dt.docsubtypeso <> 'OB' OR dt.docsubtypeso <> 'WR') AND (si.invoicefrequency IS NULL OR (si.invoicefrequency = 'D' OR si.invoicefrequency = 'W' OR si.invoicefrequency = 'T') AND trunc(o.dateordered) <= (trunc(now(), 'MM') + si.invoicedaycutoff - 1) AND trunc(now()) >= (trunc(o.dateordered, 'MM') + si.invoiceday - 1) OR trunc(o.dateordered) <= (trunc(now(), 'MM') + si.invoicedaycutoff + 14) AND trunc(now()) >= (trunc(o.dateordered, 'MM') + si.invoiceday + 14) OR si.invoicefrequency = 'M' AND trunc(o.dateordered) <= (trunc(now(), 'MM') + si.invoicedaycutoff - 1) AND trunc(now()) >= (trunc(o.dateordered, 'MM') + si.invoiceday - 1)) AND (abs(l.qtyordered - l.qtyinvoiced) <> 0 OR abs(l.qtydelivered - l.qtyinvoiced) <> 0) GROUP BY o.ad_client_id, o.ad_org_id, o.c_bpartner_id, o.c_order_id, o.documentno, o.dateordered, o.c_doctype_id, o.totallines, o.grandtotal, o.invoicerule, c.c_currency_id, c.stdprecision]]></view>
+    <view name="C_INVOICE_CANDIDATE_V"><![CDATA[SELECT o.ad_client_id, o.ad_org_id, o.c_bpartner_id, o.c_order_id, o.documentno, o.dateordered, o.c_doctype_id, o.totallines AS amountlines, o.grandtotal AS amountlinesgross, sum(round((l.qtyordered - l.qtyinvoiced) * l.priceactual, c.stdprecision)) AS notinvoicedlines, round(sum(round((l.qtyordered - l.qtyinvoiced) * l.priceactual, c.stdprecision) * (1 + t.rate / 100)), c.stdprecision) AS notinvoicedlinesgross, o.invoicerule AS term, sum(round((l.qtydelivered - l.qtyinvoiced) * l.priceactual, c.stdprecision)) AS pendinglines, round(sum(round((l.qtydelivered - l.qtyinvoiced) * l.priceactual, c.stdprecision) * (1 + t.rate / 100)), c.stdprecision) AS pendinglinesgross, sum(abs(l.qtyordered)) AS qtyordered, sum(abs(l.qtydelivered)) AS qtydelivered FROM c_order o JOIN c_doctype dt ON o.c_doctype_id = dt.c_doctype_id JOIN c_bpartner bp ON o.c_bpartner_id = bp.c_bpartner_id JOIN c_currency c ON o.c_currency_id = c.c_currency_id JOIN c_orderline l ON o.c_order_id = l.c_order_id JOIN c_tax t ON t.c_tax_id = l.c_tax_id LEFT JOIN c_invoiceschedule si ON bp.c_invoiceschedule_id = si.c_invoiceschedule_id WHERE (o.docstatus = 'CO' OR o.docstatus = 'CL' OR o.docstatus = 'IP') AND dt.docbasetype = 'SOO' AND (dt.docsubtypeso <> 'ON' OR dt.docsubtypeso <> 'OB' OR dt.docsubtypeso <> 'WR') AND (o.invoicerule = 'I' OR o.invoicerule = 'O' OR o.invoicerule = 'D' OR o.invoicerule = 'S' AND (si.invoicefrequency IS NULL OR si.invoicefrequency = 'D' OR si.invoicefrequency = 'W' OR si.invoicefrequency = 'T' AND trunc(o.dateordered) <= (trunc(now(), 'MM') + si.invoicedaycutoff - 1) AND trunc(now()) >= (trunc(o.dateordered, 'MM') + si.invoiceday - 1) OR trunc(o.dateordered) <= (trunc(now(), 'MM') + si.invoicedaycutoff + 14) AND trunc(now()) >= (trunc(o.dateordered, 'MM') + si.invoiceday + 14) OR si.invoicefrequency = 'M' AND trunc(o.dateordered) <= (trunc(now(), 'MM') + si.invoicedaycutoff - 1) AND trunc(now()) >= (trunc(o.dateordered, 'MM') + si.invoiceday - 1))) AND (abs(l.qtyordered - l.qtyinvoiced) <> 0 OR abs(l.qtydelivered - l.qtyinvoiced) <> 0) GROUP BY o.ad_client_id, o.ad_org_id, o.c_bpartner_id, o.c_order_id, o.documentno, o.dateordered, o.c_doctype_id, o.totallines, o.grandtotal, o.invoicerule, c.c_currency_id, c.stdprecision]]></view>
   </database>
--- a/src/org/openbravo/configuration/ConfigurationApp.java	Fri Dec 02 12:32:08 2016 +0100
+++ b/src/org/openbravo/configuration/ConfigurationApp.java	Fri Dec 02 12:34:27 2016 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2014 - 2015 Openbravo SLU
+ * All portions are Copyright (C) 2014 - 2016 Openbravo SLU
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -51,6 +51,7 @@
 
   private final static String BASEDIR = getUserDir();
   private final static String BASEDIR_CONFIG = BASEDIR + "/config/";
+  private final static String BASEDIR_TEST = BASEDIR + "/src-test/";
   private final static String SUFFIX_AUX = ".aux";
   private final static String OPENBRAVO_PROPERTIES = BASEDIR_CONFIG + "Openbravo.properties";
   private final static String OPENBRAVO_PROPERTIES_AUX = BASEDIR_CONFIG + "Openbravo.properties"
@@ -740,6 +741,7 @@
     fileCopyTemplate(LOG4J_LCF + ".template", LOG4J_LCF, p);
     fileCopyTemplate(USERCONFIG_XML + ".template", USERCONFIG_XML, p);
     fileCopyTemplate(CLASSPATH + ".template", CLASSPATH, p);
+    fileCopyTemplate(BASEDIR_TEST + CLASSPATH + ".template", BASEDIR_TEST + CLASSPATH, p);
   }
 
   /**
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql	Fri Dec 02 12:32:08 2016 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql	Fri Dec 02 12:34:27 2016 +0100
@@ -161,7 +161,7 @@
         AND ic.C_BPartner_ID = ?
         AND pl.istaxincluded = ? 
         AND o.C_Order_Id = ic.C_Order_Id
-        AND ((ic.term = 'D' AND ic.qtydelivered <>0) OR (ic.term = 'I' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = o.C_ORDER_ID group by ol.c_orderline_id having SUM(ol.QTYORDERED)-SUM(ol.QTYINVOICED)<>0)) OR (ic.term <> 'N' AND (ic.term IN ('O','S') AND (ic.qtyordered = ic.qtydelivered) )) )
+        AND ((ic.term = 'D' AND ic.qtydelivered <>0) OR (ic.term = 'I' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = o.C_ORDER_ID group by ol.c_orderline_id having SUM(ol.QTYORDERED)-SUM(ol.QTYINVOICED)<>0)) OR (ic.term IN ('O','S') AND (ic.qtyordered = ic.qtydelivered) ) )
         GROUP BY o.C_ORDER_ID, o.DocumentNo, o.DateOrdered, o.GrandTotal 
         ORDER BY NAME
       ]]>
@@ -508,10 +508,7 @@
                     HAVING ( l.movementqty >= 0 AND l.movementqty > Sum(COALESCE(CASE WHEN i.docstatus = 'CO' THEN il.qtyinvoiced ELSE 0 END, 0)) )
                       OR ( l.movementqty < 0 AND l.movementqty < Sum(COALESCE(CASE WHEN i.docstatus = 'CO' THEN il.qtyinvoiced ELSE 0 END, 0)) )
                     )
-        AND NOT EXISTS (SELECT 1 FROM C_INVOICE_CANDIDATE_V ic, C_ORDER o 
-        WHERE o.C_ORDER_ID = s.C_ORDER_ID
-        AND o.C_ORDER_ID = ic.C_ORDER_ID
-        AND ic.term = 'N')
+        AND NOT EXISTS (SELECT 1 FROM C_ORDER o WHERE o.C_ORDER_ID = s.C_ORDER_ID AND o.invoicerule = 'N')
         AND NOT EXISTS (SELECT 1
         FROM C_ORDER o , C_ORDERLINE ol
         WHERE o.C_ORDER_ID = s.C_ORDER_ID
--- a/src/org/openbravo/erpCommon/ad_forms/GenerateInvoicesmanual_data.xsql	Fri Dec 02 12:32:08 2016 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/GenerateInvoicesmanual_data.xsql	Fri Dec 02 12:34:27 2016 +0100
@@ -38,7 +38,7 @@
       AND ic.C_DocType_ID=dt.C_DocType_ID
       AND l.value = ic.term
       AND ord.C_ORDER_ID=ic.C_ORDER_ID
-      AND ((ic.term ='D' AND ic.qtydelivered <>0  AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYDELIVERED-ol.QTYINVOICED <> 0)) OR (ic.term = 'I' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYORDERED-ol.QTYINVOICED <> 0)) OR (ic.term <> 'N' AND (ic.term IN ('O') AND (ic.qtyordered = ic.qtydelivered) )) OR (ic.term = 'S' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYDELIVERED <> 0 AND ol.QTYDELIVERED <> ol.QTYINVOICED)))
+      AND ((ic.term ='D' AND ic.qtydelivered <>0  AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYDELIVERED-ol.QTYINVOICED <> 0)) OR (ic.term = 'I' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYORDERED-ol.QTYINVOICED <> 0)) OR (ic.term IN ('O') AND (ic.qtyordered = ic.qtydelivered)) OR (ic.term = 'S' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYDELIVERED <> 0 AND ol.QTYDELIVERED <> ol.QTYINVOICED)))
       AND AD_Reference_ID='150'
       AND ic.ad_client_id in ('1')
       AND ic.ad_org_id in ('1')
@@ -70,7 +70,7 @@
       AND ic.C_DocType_ID=dt.C_DocType_ID
       AND l.value = ic.term
       AND ord.C_ORDER_ID=ic.C_ORDER_ID
-      AND ((ic.term ='D' AND ic.qtydelivered <>0) OR (ic.term = 'I' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYORDERED-ol.QTYINVOICED <> 0)) OR (ic.term <> 'N' AND (ic.term IN ('O') AND (ic.qtyordered = ic.qtydelivered) )) OR (ic.term = 'S' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYDELIVERED <> 0 AND ol.QTYDELIVERED <> ol.QTYINVOICED)))
+      AND ((ic.term ='D' AND ic.qtydelivered <>0) OR (ic.term = 'I' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYORDERED-ol.QTYINVOICED <> 0)) OR (ic.term IN ('O') AND (ic.qtyordered = ic.qtydelivered)) OR (ic.term = 'S' AND exists (SELECT 1 FROM C_ORDERLINE ol WHERE ol.C_ORDER_ID = ord.C_ORDER_ID AND ol.QTYDELIVERED <> 0 AND ol.QTYDELIVERED <> ol.QTYINVOICED)))
       AND AD_Reference_ID='150'
       AND ic.ad_client_id in ('1')
       AND ic.ad_org_id in ('1')