details: https://code.openbravo.com/erp/devel/pi/rev/64fd34510c40 changeset: 25877:64fd34510c40 user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Fri Feb 06 08:17:31 2015 +0100 summary: fixed issue 28862 backout changeset d45ee3d2e877
details: https://code.openbravo.com/erp/devel/pi/rev/52c6748ca22a changeset: 25878:52c6748ca22a user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Fri Feb 06 08:29:42 2015 +0100 summary: Related to issue 28862 add warning message when invoiced quantity is higher than delivered quantity when invoice terms are After Delivery diffstat: src-db/database/model/functions/C_INVOICE_POST.xml | 13 +----- src-db/database/sourcedata/AD_MESSAGE.xml | 4 +- src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java | 20 ++++++++- src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt_data.xsql | 19 ++++++++- 4 files changed, 38 insertions(+), 18 deletions(-) diffs (151 lines): diff -r 0c0527b41e73 -r 52c6748ca22a src-db/database/model/functions/C_INVOICE_POST.xml --- a/src-db/database/model/functions/C_INVOICE_POST.xml Thu Feb 05 17:30:40 2015 +0100 +++ b/src-db/database/model/functions/C_INVOICE_POST.xml Fri Feb 06 08:29:42 2015 +0100 @@ -1551,8 +1551,6 @@ p_DateInvoiced DATE; v_totalQtyInvoiced NUMBER; v_ODocumentNo C_ORDER.DocumentNo%TYPE; - v_invoiceRule C_ORDER.InvoiceRule%TYPE; - v_NewPendingToDeliver C_ORDERLINE.QtyDelivered%TYPE; v_NewPendingToInvoice NUMBER; v_deliveredQty NUMBER; v_inOutStatus varchar2(60) ; @@ -1566,19 +1564,12 @@ LOOP IF (CurLines.C_OrderLine_ID IS NOT NULL) THEN --Check that qty pending to invoice is higher or equal to the qty being invoiced - SELECT o.documentno, o.invoicerule, ABS(ol.qtydelivered) - ABS(ol.qtyinvoiced + CurLines.QtyInvoiced) , ABS(ol.qtyordered) - ABS(ol.qtyinvoiced + CurLines.QtyInvoiced), p.isquantityvariable - INTO v_ODocumentNo, v_invoiceRule, v_NewPendingToDeliver, v_NewPendingToInvoice, v_Isquantityvariable + SELECT o.documentno, ABS(ol.qtyordered) - ABS(ol.qtyinvoiced + CurLines.QtyInvoiced), p.isquantityvariable + INTO v_ODocumentNo, v_NewPendingToInvoice, v_Isquantityvariable FROM c_order o, c_orderline ol LEFT JOIN m_product p ON p.m_product_id = ol.m_product_id WHERE o.c_order_id = ol.c_order_id AND ol.c_orderline_id = CurLines.c_orderline_id; - IF (v_Isquantityvariable <> 'Y' AND v_invoiceRule = 'D' AND v_NewPendingToDeliver < 0) THEN - v_Message := '@NotPossibleCompleteInvoice@' || ' ' || v_DocumentNo; - v_Message := v_Message || ' ' || '@line@' || ' ' || CurLines.line || '. '; - v_Message := v_Message || '@OrderDocumentno@' || ' ' || v_ODocumentNo; - v_Message := v_Message || ': ' || '@QtyInvoicedHigherDelivered@' || '.'; - RAISE_APPLICATION_ERROR(-20000, v_Message); - END IF; IF (v_Isquantityvariable <> 'Y' AND v_NewPendingToInvoice <0) THEN v_Message := '@NotPossibleCompleteInvoice@' || ' ' || v_DocumentNo; v_Message := v_Message || ' ' || '@line@' || ' ' || CurLines.line || '. '; diff -r 0c0527b41e73 -r 52c6748ca22a src-db/database/sourcedata/AD_MESSAGE.xml --- a/src-db/database/sourcedata/AD_MESSAGE.xml Thu Feb 05 17:30:40 2015 +0100 +++ b/src-db/database/sourcedata/AD_MESSAGE.xml Fri Feb 06 08:29:42 2015 +0100 @@ -20067,8 +20067,8 @@ <!--64F35F2418B944BD88A146A3032D3717--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> <!--64F35F2418B944BD88A146A3032D3717--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> <!--64F35F2418B944BD88A146A3032D3717--> <VALUE><![CDATA[QtyInvoicedHigherDelivered]]></VALUE> -<!--64F35F2418B944BD88A146A3032D3717--> <MSGTEXT><![CDATA[Invoiced Quantity cannot be higher than Delivered Quantity when Invoice Terms are: After Delivery]]></MSGTEXT> -<!--64F35F2418B944BD88A146A3032D3717--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--64F35F2418B944BD88A146A3032D3717--> <MSGTEXT><![CDATA[Invoiced Quantity should not be higher than Delivered Quantity when Invoice Terms are After Delivery]]></MSGTEXT> +<!--64F35F2418B944BD88A146A3032D3717--> <MSGTYPE><![CDATA[W]]></MSGTYPE> <!--64F35F2418B944BD88A146A3032D3717--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID> <!--64F35F2418B944BD88A146A3032D3717--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--64F35F2418B944BD88A146A3032D3717--></AD_MESSAGE> diff -r 0c0527b41e73 -r 52c6748ca22a src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java --- a/src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java Thu Feb 05 17:30:40 2015 +0100 +++ b/src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java Fri Feb 06 08:29:42 2015 +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) 2001-2013 Openbravo SLU + * All portions are Copyright (C) 2001-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -69,11 +69,12 @@ String strGrossUnitPrice = vars.getNumericParameter("inpgrossUnitPrice"); String strBaseGrossUnitPrice = vars.getNumericParameter("inpgrosspricestd"); String strtaxbaseamt = vars.getNumericParameter("inptaxbaseamt"); + String strInvoicelineId = vars.getStringParameter("inpcInvoicelineId"); try { printPage(response, vars, strChanged, strQtyInvoice, strPriceActual, strInvoiceId, strProduct, strPriceLimit, strTabId, strPriceList, strPriceStd, strLineNetAmt, - strTaxId, strGrossUnitPrice, strBaseGrossUnitPrice, strtaxbaseamt); + strTaxId, strGrossUnitPrice, strBaseGrossUnitPrice, strtaxbaseamt, strInvoicelineId); } catch (ServletException ex) { pageErrorCallOut(response); } @@ -85,7 +86,8 @@ String strQtyInvoice, String strPriceActual, String strInvoiceId, String strProduct, String strPriceLimit, String strTabId, String strPriceList, String strPriceStd, String strLineNetAmt, String strTaxId, String strGrossUnitPrice, - String strBaseGrossUnitPrice, String strTaxBaseAmt) throws IOException, ServletException { + String strBaseGrossUnitPrice, String strTaxBaseAmt, String strInvoicelineId) + throws IOException, ServletException { if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); XmlDocument xmlDocument = xmlEngine.readXmlTemplate( @@ -93,6 +95,7 @@ SLInvoiceAmtData[] data = SLInvoiceAmtData.select(this, strInvoiceId); String strPrecision = "0", strPricePrecision = "0"; boolean enforcedLimit = false; + if (data != null && data.length > 0) { strPrecision = data[0].stdprecision.equals("") ? "0" : data[0].stdprecision; strPricePrecision = data[0].priceprecision.equals("") ? "0" : data[0].priceprecision; @@ -138,6 +141,17 @@ resultado.append("var calloutName='SL_Invoice_Amt';\n\n"); resultado.append("var respuesta = new Array("); + SLInvoiceAmtData[] qtydata = SLInvoiceAmtData.selectDeliverQty(this, strInvoicelineId); + + if (qtydata != null && qtydata.length > 0) { + if ((new BigDecimal(strQtyInvoice).compareTo(new BigDecimal(qtydata[0].deliverqty)) > 0) + && qtydata[0].invoicerule.equals("D")) { + StringBuffer strMessage = new StringBuffer(Utility.messageBD(this, + "QtyInvoicedHigherDelivered", vars.getLanguage())); + resultado.append("new Array('WARNING', \"" + strMessage.toString() + "\"),"); + } + } + if (strChanged.equals("inplinenetamt")) { if (qtyInvoice.compareTo(BigDecimal.ZERO) == 0) { priceActual = BigDecimal.ZERO; diff -r 0c0527b41e73 -r 52c6748ca22a src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt_data.xsql --- a/src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt_data.xsql Thu Feb 05 17:30:40 2015 +0100 +++ b/src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt_data.xsql Fri Feb 06 08:29:42 2015 +0100 @@ -12,7 +12,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) 2001-2010 Openbravo SLU + * All portions are Copyright (C) 2001-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -25,12 +25,27 @@ <SqlMethod name="select" type="preparedStatement" return="multiple"> <SqlMethodComment></SqlMethodComment> <Sql> - SELECT C_Currency.StdPrecision, C_Currency.PricePrecision, M_PriceList.EnforcePriceLimit, M_PriceList.M_PriceList_ID, C_Invoice.dateInvoiced, C_Invoice.C_BPartner_ID, C_Invoice.C_Invoice_ID as id + SELECT C_Currency.StdPrecision, C_Currency.PricePrecision, M_PriceList.EnforcePriceLimit, M_PriceList.M_PriceList_ID, C_Invoice.dateInvoiced, C_Invoice.C_BPartner_ID, C_Invoice.C_Invoice_ID as id, + '' deliverqty , '' invoicerule FROM C_Invoice, M_PriceList, C_Currency WHERE C_Invoice.M_PriceList_ID = M_PriceList.M_PriceList_ID AND M_PriceList.C_Currency_ID = C_Currency.C_Currency_ID AND C_Invoice.C_Invoice_ID = ? </Sql> <Parameter name="cInvoiceId"/> + </SqlMethod> + <SqlMethod name="selectDeliverQty" type="preparedStatement" return="multiple"> + <SqlMethodComment></SqlMethodComment> + <Sql> + SELECT (CASE WHEN il.M_INOUTLINE_ID IS NULL THEN (l.QtyOrdered-COALESCE(l.QTYINVOICED ,0)) ELSE il.MOVEMENTQTY END) AS deliverqty , o.invoicerule + FROM C_ORDERLINE l left join (SELECT M_InOutLine.* FROM M_InOutLine, M_InOut + WHERE M_InOut.M_InOut_ID = M_InOutLine.M_InOut_ID + AND M_InOutLine.IsInvoiced = 'N' + AND M_InOut.Processed='Y') il on l.C_OrderLine_ID = il.C_OrderLine_ID, C_Order o, c_invoiceline cil + WHERE l.C_Order_ID=o.C_Order_ID + AND cil.C_ORDERLINE_id=l.C_ORDERLINE_id + AND cil.c_invoiceline_id = ? + </Sql> + <Parameter name="cInvoiceId"/> </SqlMethod> </SqlClass> ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
