details: https://code.openbravo.com/erp/devel/main/rev/8eef7ee8f876 changeset: 13696:8eef7ee8f876 user: Stefan Hühner <stefan.huehner <at> openbravo.com> date: Tue Sep 27 11:10:27 2011 +0200 summary: Transplant manually the changeset 700d50a15824 from tag 3.0MP2.3 This includes in the end the following chanegsets from pi:
changeset: 13780:79b0d2a02b4f user: Eduardo Argal Guibert <eduardo.ar...@openbravo.com> date: Fri Sep 16 13:05:55 2011 +0200 summary: Backout changeset a775ba12f12c (formatting only) as preparation of more backouts changeset: 13781:912178a2e9d8 user: Eduardo Argal Guibert <eduardo.ar...@openbravo.com> date: Fri Sep 16 13:07:10 2011 +0200 summary: Partial backout of cset 354aa0b865ad. changeset: 13782:99501c6c3f26 user: Eduardo Argal Guibert <eduardo.ar...@openbravo.com> date: Fri Sep 16 13:12:31 2011 +0200 summary: Partial backout of cset f5c1f04bb7ac (part1) changeset: 13783:1bb9b92ae229 user: Eduardo Argal Guibert <eduardo.ar...@openbravo.com> date: Fri Sep 16 13:30:07 2011 +0200 summary: Partial backout of cset f5c1f04bb7ac (part2) changeset: 13784:38ac082e328d user: Eduardo Argal Guibert <eduardo.ar...@openbravo.com> date: Thu Sep 22 15:00:12 2011 +0200 summary: Fixes issue 0018519, 18441 changeset: 13785:3093237e1219 tag: tip user: Eduardo Argal Guibert <eduardo.ar...@openbravo.com> date: Thu Sep 22 18:13:24 2011 +0200 summary: Fixes consistency try: Build #486 details: https://code.openbravo.com/erp/devel/main/rev/681c42b685dd changeset: 13697:681c42b685dd user: Stefan Hühner <stefan.huehner <at> openbravo.com> date: Tue Sep 27 11:15:47 2011 +0200 summary: Transplant manually f9d44f213f7b from pi to mp2.3 Fix 0018618: Currency balancing when acctschema is not enabled details: https://code.openbravo.com/erp/devel/main/rev/743aa5959962 changeset: 13698:743aa5959962 user: Stefan Hühner <stefan.huehner <at> openbravo.com> date: Tue Sep 27 11:42:17 2011 +0200 summary: Fix mistake in merge from cset: 8eef7ee8f876 diffstat: src-db/database/model/triggers/FIN_FINACC_TRANSACTION_TRG.xml | 78 + src-db/database/model/triggers/FIN_PAYMENT_TRG.xml | 81 + src/org/openbravo/erpCommon/ad_forms/AcctServer.java | 623 ++++++++- src/org/openbravo/erpCommon/ad_forms/AcctServer_data.xsql | 12 + src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java | 304 ++-- src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java | 206 +-- src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java | 207 +- src/org/openbravo/erpCommon/ad_forms/DocInvoice.java | 252 ++- src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql | 18 +- src/org/openbravo/erpCommon/ad_forms/DocLine_FINFinAccTransaction.java | 45 +- src/org/openbravo/erpCommon/ad_forms/DocLine_FINReconciliation.java | 15 +- src/org/openbravo/erpCommon/ad_forms/Fact.java | 159 +-- src/org/openbravo/erpCommon/ad_forms/FactLine.java | 143 +- 13 files changed, 1257 insertions(+), 886 deletions(-) diffs (truncated from 2908 to 300 lines): diff -r adb7ef6043dc -r 743aa5959962 src-db/database/model/triggers/FIN_FINACC_TRANSACTION_TRG.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src-db/database/model/triggers/FIN_FINACC_TRANSACTION_TRG.xml Tue Sep 27 11:42:17 2011 +0200 @@ -0,0 +1,78 @@ +<?xml version="1.0"?> + <database name="TRIGGER FIN_FINACC_TRANSACTION_TRG"> + <trigger name="FIN_FINACC_TRANSACTION_TRG" table="FIN_FINACC_TRANSACTION" fires="after" insert="true" update="true" delete="false" foreach="row"> + <body><![CDATA[ + +/************************************************************************ +* The contents of this file are subject to the Openbravo Public License +* Version 1.0 (the "License"), being the Mozilla Public License +* Version 1.1 with a permitted attribution clause; you may not use this +* file except in compliance with the License. You may obtain a copy of +* the License at http://www.openbravo.com/legal/license.html +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +* License for the specific language governing rights and limitations +* under the License. +* The Original Code is Openbravo ERP. +* The Initial Developer of the Original Code is Openbravo SLU +* All portions are Copyright (C) 2010-2011 Openbravo SLU +* All Rights Reserved. +* Contributor(s): ______________________________________. +*************************************************************************/ + +v_Count NUMBER:=0; + +BEGIN + + IF AD_isTriggerEnabled()='N' THEN RETURN; + END IF; + + IF (UPDATING) THEN + IF(:OLD.FOREIGN_CURRENCY_ID <> :NEW.FOREIGN_CURRENCY_ID + OR :OLD.FOREIGN_CONVERT_RATE <> :NEW.FOREIGN_CONVERT_RATE + OR :OLD.FOREIGN_AMOUNT <> :NEW.FOREIGN_AMOUNT) THEN + IF(:NEW.FOREIGN_CURRENCY_ID IS NULL) THEN + DELETE FROM C_CONVERSION_RATE_DOCUMENT WHERE APRM_FINACC_TRANSACTION_V_ID = :NEW.FIN_FINACC_TRANSACTION_ID; + ELSE + SELECT COUNT(*) INTO v_Count + FROM C_CONVERSION_RATE_DOCUMENT + WHERE C_CURRENCY_ID = :NEW.FOREIGN_CURRENCY_ID + AND C_CURRENCY_ID_TO = :NEW.C_CURRENCY_ID + AND APRM_FINACC_TRANSACTION_V_ID = :NEW.FIN_FINACC_TRANSACTION_ID; + + IF(V_Count = 0) THEN + INSERT INTO C_CONVERSION_RATE_DOCUMENT( + C_CONVERSION_RATE_DOCUMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, + CREATED, CREATEDBY, UPDATED, UPDATEDBY, C_CURRENCY_ID, C_CURRENCY_ID_TO, + C_INVOICE_ID, FIN_PAYMENT_ID, APRM_FINACC_TRANSACTION_V_ID, RATE, + FOREIGN_AMOUNT) + VALUES (get_uuid(), :NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID, :NEW.ISACTIVE, + now(), :NEW.UPDATEDBY, now(), :NEW.UPDATEDBY, :NEW.FOREIGN_CURRENCY_ID, :NEW.C_CURRENCY_ID, + NULL, NULL, :new.FIN_FINACC_TRANSACTION_ID, :NEW.FOREIGN_CONVERT_RATE, + :NEW.FOREIGN_AMOUNT); + ELSE + UPDATE C_CONVERSION_RATE_DOCUMENT SET RATE = :NEW.FOREIGN_CONVERT_RATE, FOREIGN_AMOUNT = :NEW.FOREIGN_AMOUNT + WHERE C_CURRENCY_ID = :NEW.C_CURRENCY_ID + AND C_CURRENCY_ID_TO = :NEW.FOREIGN_CURRENCY_ID + AND APRM_FINACC_TRANSACTION_V_ID = :NEW.FIN_FINACC_TRANSACTION_ID; + END IF; + END IF; + END IF; + END IF; + IF(INSERTING) THEN + IF(:NEW.FOREIGN_CONVERT_RATE <> 1) THEN + INSERT INTO c_conversion_rate_document( + c_conversion_rate_document_id, ad_client_id, ad_org_id, isactive, + created, createdby, updated, updatedby, c_currency_id, c_currency_id_to, + c_invoice_id, fin_payment_id, aprm_finacc_transaction_v_id, rate, + foreign_amount) + VALUES (get_uuid(), :NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID, :NEW.ISACTIVE, + now(), :NEW.UPDATEDBY, now(), :NEW.UPDATEDBY, :NEW.FOREIGN_CURRENCY_ID, :NEW.C_CURRENCY_ID, + NULL, NULL, :NEW.FIN_FINACC_TRANSACTION_ID, :NEW.FOREIGN_CONVERT_RATE, + :NEW.FOREIGN_AMOUNT); + END IF; + END IF; + END FIN_FINACC_TRANSACTION_TRG +]]></body> + </trigger> + </database> diff -r adb7ef6043dc -r 743aa5959962 src-db/database/model/triggers/FIN_PAYMENT_TRG.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src-db/database/model/triggers/FIN_PAYMENT_TRG.xml Tue Sep 27 11:42:17 2011 +0200 @@ -0,0 +1,81 @@ +<?xml version="1.0"?> + <database name="TRIGGER FIN_PAYMENT_TRG"> + <trigger name="FIN_PAYMENT_TRG" table="FIN_PAYMENT" fires="after" insert="true" update="true" delete="true" foreach="row"> + <body><![CDATA[ + +/************************************************************************ +* The contents of this file are subject to the Openbravo Public License +* Version 1.0 (the "License"), being the Mozilla Public License +* Version 1.1 with a permitted attribution clause; you may not use this +* file except in compliance with the License. You may obtain a copy of +* the License at http://www.openbravo.com/legal/license.html +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +* License for the specific language governing rights and limitations +* under the License. +* The Original Code is Openbravo ERP. +* The Initial Developer of the Original Code is Openbravo SLU +* All portions are Copyright (C) 2010-2011 Openbravo SLU +* All Rights Reserved. +* Contributor(s): ______________________________________. +*************************************************************************/ + +v_DateNull DATE := TO_DATE('01-01-1900','DD-MM-YYYY'); +v_C_CURRENCY_ID FIN_FINANCIAL_ACCOUNT.C_CURRENCY_ID%TYPE; +v_Count NUMBER:=0; + +BEGIN + + IF AD_isTriggerEnabled()='N' THEN RETURN; + END IF; + + IF (UPDATING OR INSERTING) THEN + SELECT C_CURRENCY_ID INTO v_C_CURRENCY_ID + FROM FIN_FINANCIAL_ACCOUNT + WHERE FIN_FINANCIAL_ACCOUNT_ID = :NEW.FIN_FINANCIAL_ACCOUNT_ID; + END IF; + + IF (UPDATING) THEN + IF(:OLD.FINACC_TXN_CONVERT_RATE <> :NEW.FINACC_TXN_CONVERT_RATE AND :OLD.AMOUNT <> :NEW.AMOUNT) THEN + + SELECT COUNT(*) INTO v_Count + FROM C_CONVERSION_RATE_DOCUMENT + WHERE C_CURRENCY_ID = :NEW.C_CURRENCY_ID + AND C_CURRENCY_ID_TO = v_C_CURRENCY_ID + AND FIN_PAYMENT_ID = :NEW.FIN_PAYMENT_ID; + + IF(V_Count = 0) THEN + INSERT INTO C_CONVERSION_RATE_DOCUMENT( + C_CONVERSION_RATE_DOCUMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, + CREATED, CREATEDBY, UPDATED, UPDATEDBY, C_CURRENCY_ID, C_CURRENCY_ID_TO, + C_INVOICE_ID, FIN_PAYMENT_ID, APRM_FINACC_TRANSACTION_V_ID, RATE, + FOREIGN_AMOUNT) + VALUES (get_uuid(), :NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID, :NEW.ISACTIVE, + now(), :NEW.UPDATEDBY, now(), :NEW.UPDATEDBY, :NEW.C_CURRENCY_ID, v_C_CURRENCY_ID, + NULL, :NEW.FIN_PAYMENT_ID, NULL, :NEW.FINACC_TXN_CONVERT_RATE, + :NEW.AMOUNT*:NEW.FINACC_TXN_CONVERT_RATE); + ELSE + UPDATE C_CONVERSION_RATE_DOCUMENT SET RATE = :NEW.FINACC_TXN_CONVERT_RATE, FOREIGN_AMOUNT = :NEW.AMOUNT*:NEW.FINACC_TXN_CONVERT_RATE + WHERE C_CURRENCY_ID = :NEW.C_CURRENCY_ID + AND C_CURRENCY_ID_TO = v_C_CURRENCY_ID + AND FIN_PAYMENT_ID = :NEW.FIN_PAYMENT_ID; + END IF; + END IF; + END IF; + IF(INSERTING) THEN + IF(:NEW.FINACC_TXN_CONVERT_RATE <> 1) THEN + INSERT INTO c_conversion_rate_document( + c_conversion_rate_document_id, ad_client_id, ad_org_id, isactive, + created, createdby, updated, updatedby, c_currency_id, c_currency_id_to, + c_invoice_id, fin_payment_id, aprm_finacc_transaction_v_id, rate, + foreign_amount) + VALUES (get_uuid(), :NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID, :NEW.ISACTIVE, + now(), :NEW.UPDATEDBY, now(), :NEW.UPDATEDBY, :NEW.C_CURRENCY_ID, v_C_CURRENCY_ID, + NULL, :NEW.FIN_PAYMENT_ID, NULL, :NEW.FINACC_TXN_CONVERT_RATE, + :NEW.AMOUNT*:NEW.FINACC_TXN_CONVERT_RATE); + END IF; + END IF; +END FIN_PAYMENT_TRG +]]></body> + </trigger> + </database> diff -r adb7ef6043dc -r 743aa5959962 src/org/openbravo/erpCommon/ad_forms/AcctServer.java --- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java Fri Sep 16 13:33:17 2011 +0200 +++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java Tue Sep 27 11:42:17 2011 +0200 @@ -18,6 +18,7 @@ import java.io.IOException; import java.math.BigDecimal; +import java.math.MathContext; import java.sql.Connection; import java.sql.SQLException; import java.text.SimpleDateFormat; @@ -56,6 +57,7 @@ import org.openbravo.model.financialmgmt.accounting.coa.AcctSchemaTable; import org.openbravo.model.financialmgmt.gl.GLItem; import org.openbravo.model.financialmgmt.gl.GLItemAccounts; +import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction; import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount; import org.openbravo.model.financialmgmt.payment.FIN_Payment; @@ -118,6 +120,9 @@ public String[] Amounts = new String[4]; + // Conversion Rate precision. defaulted to 6 as it is stated in Format.xml + int conversionRatePrecision = 6; + public DocLine[] p_lines = new DocLine[0]; public DocLine_Payment[] m_debt_payments = new DocLine_Payment[0]; @@ -164,6 +169,22 @@ /** Document Status */ public static final String STATUS_BackgroundDisabled = "d"; + /** Table IDs for document level conversion rates */ + public static final String TABLEID_Invoice = "318"; + public static final String TABLEID_Payment = "D1A97202E832470285C9B1EB026D54E2"; + public static final String TABLEID_Transaction = "4D8C3B3C31D1410DA046140C9F024D17"; + public static final String TABLEID_Reconciliation = "B1B7075C46934F0A9FD4C4D0F1457B42"; + + @Deprecated + // Use TABLEID_Invoice instead + public static final String EXCHANGE_DOCTYPE_Invoice = "318"; + @Deprecated + // Use TABLEID_Payment instead + public static final String EXCHANGE_DOCTYPE_Payment = "D1A97202E832470285C9B1EB026D54E2"; + @Deprecated + // Use TABLEID_Transaction instead + public static final String EXCHANGE_DOCTYPE_Transaction = "4D8C3B3C31D1410DA046140C9F024D17"; + OBError messageResult = null; String strMessage = null; @@ -276,11 +297,6 @@ /** GL Accounts */ public static final String ACCTTYPE_PPVOffset = "60"; - /** Document Types for document level conversion rates */ - public static final String EXCHANGE_DOCTYPE_Invoice = "318"; - public static final String EXCHANGE_DOCTYPE_Payment = "D1A97202E832470285C9B1EB026D54E2"; - public static final String EXCHANGE_DOCTYPE_Transaction = "4D8C3B3C31D1410DA046140C9F024D17"; - // Reference (to find SalesRegion from BPartner) public String BP_C_SalesRegion_ID = ""; // set in FactLine @@ -656,6 +672,8 @@ log4j.warn("AcctServer - post - Error loading document"); return false; } + // Set Currency precision + conversionRatePrecision = getConversionRatePrecision(vars); if (data == null || data.length == 0) return false; // if (log4j.isDebugEnabled()) @@ -1013,10 +1031,12 @@ return Status; Status = STATUS_PostPrepared; + // Distinguish multi-currency Documents + MultiCurrency = m_fact[index].isMulticurrencyDocument(); // if (log4j.isDebugEnabled()) // log4j.debug("AcctServer - Before balanceSource"); // balanceSource - if (!m_fact[index].isSourceBalanced() && !MultiCurrency) + if (!MultiCurrency && !m_fact[index].isSourceBalanced()) m_fact[index].balanceSource(conn); // if (log4j.isDebugEnabled()) // log4j.debug("AcctServer - After balanceSource"); @@ -1024,7 +1044,7 @@ // if (log4j.isDebugEnabled()) // log4j.debug("AcctServer - Before isSegmentBalanced"); // balanceSegments - if (!m_fact[index].isSegmentBalanced(conn) && !MultiCurrency) + if (!MultiCurrency && !m_fact[index].isSegmentBalanced(conn)) m_fact[index].balanceSegments(conn); // if (log4j.isDebugEnabled()) // log4j.debug("AcctServer - After isSegmentBalanced"); @@ -1080,7 +1100,7 @@ * * @param acctSchema * accounting schema - * @return true, if convertable to accounting currency + * @return true, if convertible to accounting currency */ public boolean isConvertible(AcctSchema acctSchema, ConnectionProvider conn) throws ServletException { @@ -1119,7 +1139,7 @@ // if (log4j.isDebugEnabled()) log4j.debug // ("AcctServer - get converted amount (init)"); String amt = getConvertedAmt("1", currency, acctSchema.m_C_Currency_ID, DateAcct, - acctSchema.m_CurrencyRateType, AD_Client_ID, AD_Org_ID, "", "", conn); + acctSchema.m_CurrencyRateType, AD_Client_ID, AD_Org_ID, conn); // if (log4j.isDebugEnabled()) log4j.debug // ("get converted amount (end)"); if (amt == null || amt.equals("")) { @@ -1176,36 +1196,11 @@ String ConvDate, String RateType, ConnectionProvider conn) { if (log4j.isDebugEnabled()) log4j.debug("AcctServer - getConvertedAmount no client nor org"); - return getConvertedAmt(Amt, CurFrom_ID, CurTo_ID, ConvDate, RateType, "", "", "", "", conn); - } - - /** - * Convert an amount - * - * @param CurFrom_ID - * The C_Currency_ID FROM - * @param CurTo_ID - * The C_Currency_ID TO - * @param ConvDate - * The Conversion date - if null - use current date - * @param RateType - * The Conversion rate type - if null/empty - use Spot - * @param Amt ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits