details: https://code.openbravo.com/erp/devel/pi/rev/6dc419f9cc80 changeset: 29735:6dc419f9cc80 user: Mark <markmm82 <at> gmail.com> date: Fri Jul 01 10:44:01 2016 -0400 summary: Fixes issue 33273: Fix posting Reversed Invoice document not defined as "return" Fixed posting for reversed sales invoices documents when are not defined as "return" and the related order is prepaid
details: https://code.openbravo.com/erp/devel/pi/rev/85ac34e36934 changeset: 29736:85ac34e36934 user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Wed Jul 06 16:26:46 2016 +0200 summary: Related to issue 33273: code review improvements Avoid to run the isReversedInvoice() method several times diffstat: src/org/openbravo/erpCommon/ad_forms/DocInvoice.java | 21 ++++++++++++-- src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql | 11 +++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diffs (92 lines): diff -r 89ad9b716896 -r 85ac34e36934 src/org/openbravo/erpCommon/ad_forms/DocInvoice.java --- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java Wed Jul 06 10:55:04 2016 +0200 +++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java Wed Jul 06 16:26:46 2016 +0200 @@ -57,6 +57,7 @@ DocLine[] p_lines_taxes = null; boolean isCashVAT = false; + boolean isReversedInvoice = false; String prepaymentamt; String SeqNo = "0"; @@ -98,11 +99,23 @@ m_payments = loadPayments(); m_debt_payments = loadDebtPayments(); isCashVAT = StringUtils.equals("Y", data[0].getField("iscashvat")); + isReversedInvoice = isReversedInvoice(); prepaymentamt = data[0].getField("prepaymentamt"); + return true; } + private boolean isReversedInvoice() { + try { + DocInvoiceData[] revInv = DocInvoiceData.getIsReversedInvoice(connectionProvider, Record_ID); + return (revInv != null && revInv.length != 0); + } catch (ServletException e) { + log4jDocInvoice.warn(e); + } + return false; + } + private DocLine[] loadLines() { ArrayList<Object> list = new ArrayList<Object>(); DocLineInvoiceData[] data = null; @@ -367,7 +380,7 @@ BigDecimal difference = grossamt.abs().subtract(prepayment.abs()); if (!prepaymentamt.equals("0")) { if (grossamt.abs().compareTo(prepayment.abs()) > 0) { - if (IsReturn.equals("Y")) { + if (IsReturn.equals("Y") || isReversedInvoice) { fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, true, true, conn), this.C_Currency_ID, "", prepaymentamt, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn); @@ -383,7 +396,7 @@ nextSeqNo(SeqNo), DocumentType, conn); } } else { - if (IsReturn.equals("Y")) { + if (IsReturn.equals("Y") || isReversedInvoice) { fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, true, true, conn), this.C_Currency_ID, "", prepaymentamt, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn); @@ -736,7 +749,7 @@ BigDecimal difference = grossamt.abs().subtract(prepayment.abs()); if (!prepaymentamt.equals("0")) { if (grossamt.abs().compareTo(prepayment.abs()) > 0) { - if (IsReturn.equals("Y")) { + if (IsReturn.equals("Y") || isReversedInvoice) { fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, false, true, conn), this.C_Currency_ID, prepaymentamt, "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn); @@ -752,7 +765,7 @@ nextSeqNo(SeqNo), DocumentType, conn); } } else { - if (IsReturn.equals("Y")) { + if (IsReturn.equals("Y") || isReversedInvoice) { fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, false, true, conn), this.C_Currency_ID, prepaymentamt, "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn); diff -r 89ad9b716896 -r 85ac34e36934 src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql --- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql Wed Jul 06 10:55:04 2016 +0200 +++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql Wed Jul 06 16:26:46 2016 +0200 @@ -62,6 +62,17 @@ </Sql> <Parameter name="client"/> <Parameter name="id"/> + </SqlMethod> + <SqlMethod name="getIsReversedInvoice" type="preparedStatement" return="multiple"> + <SqlMethodComment></SqlMethodComment> + <Sql> + <![CDATA[ + SELECT C_INVOICE_ID + FROM C_INVOICE_REVERSE + WHERE C_INVOICE_ID=? + ]]> + </Sql> + <Parameter name="id"/> </SqlMethod> <SqlMethod name="selectDebtPayments" type="preparedStatement" return="multiple"> <SqlMethodComment></SqlMethodComment> ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits