details:   https://code.openbravo.com/erp/devel/pi/rev/a775ba12f12c
changeset: 13778:a775ba12f12c
user:      Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date:      Thu Sep 15 17:29:48 2011 +0200
summary:   Files formats

diffstat:

 src/org/openbravo/erpCommon/ad_forms/AcctServer.java |   17 +-
 src/org/openbravo/erpCommon/ad_forms/Fact.java       |  225 ++++++++----------
 src/org/openbravo/erpCommon/ad_forms/FactLine.java   |    6 +-
 3 files changed, 109 insertions(+), 139 deletions(-)

diffs (truncated from 351 to 300 lines):

diff -r dcf84616ed83 -r a775ba12f12c 
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Thu Sep 15 
12:57:56 2011 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Thu Sep 15 
17:29:48 2011 +0200
@@ -933,7 +933,7 @@
         AcctServerData[] data = 
AcctServerData.selectDocType(connectionProvider, C_DocType_ID);
         DocumentType = data[0].docbasetype;
         GL_Category_ID = data[0].glCategoryId;
-       IsReversal = data[0].isreversal;
+        IsReversal = data[0].isreversal;
       }
       // We have a document Type, but no GL info - search for DocType
       if (GL_Category_ID != null && GL_Category_ID.equals("")) {
@@ -941,7 +941,7 @@
             DocumentType);
         if (data != null && data.length != 0)
           GL_Category_ID = data[0].glCategoryId;
-         IsReversal = data[0].isreversal;
+        IsReversal = data[0].isreversal;
       }
       if (DocumentType != null && DocumentType.equals(""))
         log4j.warn("AcctServer - loadDocumentType - No DocType for GL Info");
@@ -1242,15 +1242,16 @@
             .get(Invoice.class, recordId)));
         if (!reversedCriteria.list().isEmpty()) {
           String strDateFormat;
-          strDateFormat = 
OBPropertiesProvider.getInstance().getOpenbravoProperties().getProperty(
-              "dateFormat.java");
+          strDateFormat = 
OBPropertiesProvider.getInstance().getOpenbravoProperties()
+              .getProperty("dateFormat.java");
           final SimpleDateFormat dateFormat = new 
SimpleDateFormat(strDateFormat);
           ConvDate = 
dateFormat.format(reversedCriteria.list().get(0).getReversedInvoice()
               .getAccountingDate());
           data = AcctServerData.currencyConvert(conn, Amt, CurFrom_ID, 
CurTo_ID, ConvDate,
               RateType, client, org);
-          
docRateCriteria.add(Restrictions.eq(ConversionRateDoc.PROPERTY_INVOICE, OBDal
-              .getInstance().get(Invoice.class,
+          docRateCriteria.add(Restrictions.eq(
+              ConversionRateDoc.PROPERTY_INVOICE,
+              OBDal.getInstance().get(Invoice.class,
                   
reversedCriteria.list().get(0).getReversedInvoice().getId())));
 
         } else {
@@ -1275,8 +1276,8 @@
             .get(APRM_FinaccTransactionV.class, recordId);
         if (a.getForeignCurrency() != null) { // && 
!a.getForeignCurrency().getId().equals(CurTo_ID)
           String strDateFormat;
-          strDateFormat = 
OBPropertiesProvider.getInstance().getOpenbravoProperties().getProperty(
-              "dateFormat.java");
+          strDateFormat = 
OBPropertiesProvider.getInstance().getOpenbravoProperties()
+              .getProperty("dateFormat.java");
           final SimpleDateFormat dateFormat = new 
SimpleDateFormat(strDateFormat);
           Amt = a.getForeignAmount().toString();
           data = AcctServerData.currencyConvert(conn, Amt, 
a.getForeignCurrency().getId(),
diff -r dcf84616ed83 -r a775ba12f12c 
src/org/openbravo/erpCommon/ad_forms/Fact.java
--- a/src/org/openbravo/erpCommon/ad_forms/Fact.java    Thu Sep 15 12:57:56 
2011 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/Fact.java    Thu Sep 15 17:29:48 
2011 +0200
@@ -21,15 +21,12 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 
 import javax.servlet.ServletException;
 
 import org.apache.log4j.Logger;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.database.ConnectionProvider;
-import org.openbravo.model.common.invoice.Invoice;
-import org.openbravo.model.financialmgmt.payment.FIN_Payment;
 
 public class Fact {
   static Logger log4jFact = Logger.getLogger(Fact.class);
@@ -51,8 +48,8 @@
   public static final String POST_Budget = "B";
   /** Encumbrance Posting */
   public static final String POST_Commitment = "C";
-  
-  /** Document Types for document level conversion rates*/
+
+  /** 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";
@@ -142,12 +139,14 @@
     return createLine(docLine, account, C_Currency_ID, debitAmt, creditAmt, 
Fact_Acct_Group_ID,
         SeqNo, DocBaseType, conversionDate, null, conn);
   }
+
   public FactLine createLine(DocLine docLine, Account account, String 
C_Currency_ID,
-             String debitAmt, String creditAmt, String Fact_Acct_Group_ID, 
String SeqNo,
-             String DocBaseType, String conversionDate, BigDecimal 
conversionRate, ConnectionProvider conn) {
-         return createLine(docLine, account, C_Currency_ID, debitAmt, 
creditAmt, Fact_Acct_Group_ID,
-                       SeqNo, DocBaseType, conversionDate, null, "", null, 
conn);
+      String debitAmt, String creditAmt, String Fact_Acct_Group_ID, String 
SeqNo,
+      String DocBaseType, String conversionDate, BigDecimal conversionRate, 
ConnectionProvider conn) {
+    return createLine(docLine, account, C_Currency_ID, debitAmt, creditAmt, 
Fact_Acct_Group_ID,
+        SeqNo, DocBaseType, conversionDate, null, "", null, conn);
   }
+
   /**
    * Create and convert Fact Line using a specified conversion date. Used to 
create a DR and/or CR
    * entry
@@ -174,9 +173,82 @@
    *          The rate to use to convert from source amount to account amount. 
May be null
    * @return Fact Line
    */
-  /*public FactLine createLine(DocLine docLine, Account account, String 
C_Currency_ID,
+  /*
+   * public FactLine createLine(DocLine docLine, Account account, String 
C_Currency_ID, String
+   * debitAmt, String creditAmt, String Fact_Acct_Group_ID, String SeqNo, 
String DocBaseType, String
+   * conversionDate, BigDecimal conversionRate, ConnectionProvider conn) {
+   * 
+   * String strNegate = ""; try { strNegate = AcctServerData.selectNegate(conn,
+   * m_acctSchema.m_C_AcctSchema_ID, DocBaseType); if (strNegate.equals("")) 
strNegate =
+   * AcctServerData.selectDefaultNegate(conn, m_acctSchema.m_C_AcctSchema_ID); 
} catch
+   * (ServletException e) { } if (strNegate.equals("")) strNegate = "Y"; 
BigDecimal DebitAmt = new
+   * BigDecimal(debitAmt.equals("") ? "0.00" : debitAmt); BigDecimal CreditAmt 
= new
+   * BigDecimal(creditAmt.equals("") ? "0.00" : creditAmt); if 
(DebitAmt.compareTo(BigDecimal.ZERO)
+   * == 0 && CreditAmt.compareTo(BigDecimal.ZERO) == 0) { return null; } if 
(strNegate.equals("N")
+   * && (DebitAmt.compareTo(ZERO) < 0 || CreditAmt.compareTo(ZERO) < 0)) { 
return
+   * createLine(docLine, account, C_Currency_ID, CreditAmt.abs().toString(), 
DebitAmt.abs()
+   * .toString(), Fact_Acct_Group_ID, SeqNo, DocBaseType, conn); }
+   * 
+   * log4jFact.debug("createLine - " + account + " - Dr=" + debitAmt + ", Cr=" 
+ creditAmt);
+   * log4jFact.debug("Starting createline"); // Data Check if (account == 
null) {
+   * log4jFact.debug("end of create line"); 
m_doc.setStatus(AcctServer.STATUS_InvalidAccount);
+   * return null; } // log4jFact.debug("createLine - Fact_Acct_Group_ID = " + 
Fact_Acct_Group_ID);
+   * FactLine line = new FactLine(m_doc.AD_Table_ID, m_doc.Record_ID, docLine 
== null ? "" :
+   * docLine.m_TrxLine_ID, Fact_Acct_Group_ID, SeqNo, DocBaseType);
+   * log4jFact.debug("createLine - line.m_Fact_Acct_Group_ID = " + 
line.m_Fact_Acct_Group_ID);
+   * log4jFact.debug("Object created"); line.setDocumentInfo(m_doc, docLine);
+   * line.setAD_Org_ID(m_doc.AD_Org_ID); // if (docLine!=null)
+   * line.setAD_Org_ID(docLine.m_AD_Org_ID); log4jFact.debug("document info 
set");
+   * line.setAccount(m_acctSchema, account); log4jFact.debug("account set");
+   * 
+   * log4jFact.debug("C_Currency_ID: " + C_Currency_ID + " - debitAmt: " + 
debitAmt +
+   * " - creditAmt: " + creditAmt); // Amounts - one needs to be both not zero 
if
+   * (!line.setAmtSource(C_Currency_ID, debitAmt, creditAmt)) return null; if 
(conversionDate ==
+   * null || conversionDate.isEmpty()) { conversionDate = m_doc.DateAcct; }
+   * log4jFact.debug("C_Currency_ID: " + m_acctSchema.getC_Currency_ID() + " - 
ConversionDate: " +
+   * conversionDate + " - CurrencyRateType: " + 
m_acctSchema.getCurrencyRateType()); // Convert if
+   * (conversionRate != null) { 
line.convertByRate(m_acctSchema.getC_Currency_ID(), conversionRate);
+   * } else { line.convert(m_acctSchema.getC_Currency_ID(), conversionDate,
+   * m_acctSchema.getCurrencyRateType(), conn); } // Optionally overwrite Acct 
Amount if (docLine !=
+   * null && !docLine.m_AmtAcctDr.equals("") && 
!docLine.m_AmtAcctCr.equals(""))
+   * line.setAmtAcct(docLine.m_AmtAcctDr, docLine.m_AmtAcctCr); // Info
+   * line.setJournalInfo(m_doc.GL_Category_ID); 
line.setPostingType(m_postingType); // Set Info
+   * line.setDocumentInfo(m_doc, docLine); // log4jFact.debug("createLine - " 
+ m_doc.DocumentNo);
+   * log4jFact.debug("********************* Fact - createLine - DocumentNo - " 
+ m_doc.DocumentNo +
+   * " -  m_lines.size() - " + m_lines.size()); m_lines.add(line); return 
line; } // createLine
+   */
+  /**
+   * Create and convert Fact Line using a specified conversion date. Used to 
create a DR and/or CR
+   * entry
+   * 
+   * @param docLine
+   *          the document line or null
+   * @param account
+   *          if null, line is not created
+   * @param C_Currency_ID
+   *          the currency
+   * @param debitAmt
+   *          debit amount, can be null
+   * @param creditAmt
+   *          credit amount, can be null
+   * @param Fact_Acct_Group_ID
+   * 
+   * @param SeqNo
+   * 
+   * @param DocBaseType
+   * 
+   * @param conversionDate
+   *          Date to convert currencies if required
+   * @param conversionRate
+   *          The rate to use to convert from source amount to account amount. 
May be null
+   * @param AD_Table_ID
+   *          The document to get the date or conversion rate
+   * @return Fact Line
+   */
+  public FactLine createLine(DocLine docLine, Account account, String 
C_Currency_ID,
       String debitAmt, String creditAmt, String Fact_Acct_Group_ID, String 
SeqNo,
-      String DocBaseType, String conversionDate, BigDecimal conversionRate, 
ConnectionProvider conn) {
+      String DocBaseType, String conversionDate, BigDecimal conversionRate, 
String AD_Table_ID,
+      String recordId, ConnectionProvider conn) {
 
     String strNegate = "";
     try {
@@ -228,126 +300,23 @@
     }
     log4jFact.debug("C_Currency_ID: " + m_acctSchema.getC_Currency_ID() + " - 
ConversionDate: "
         + conversionDate + " - CurrencyRateType: " + 
m_acctSchema.getCurrencyRateType());
-    // Convert
-    if (conversionRate != null) {
-      line.convertByRate(m_acctSchema.getC_Currency_ID(), conversionRate);
+
+    // Overwrite conversion
+    if (AD_Table_ID.equals(EXCHANGE_DOCTYPE_Invoice)
+        || AD_Table_ID.equals(EXCHANGE_DOCTYPE_Payment)
+        || AD_Table_ID.equals(EXCHANGE_DOCTYPE_Transaction)) {
+      line.convertByDocumentData(m_acctSchema.getC_Currency_ID(),
+          m_acctSchema.getCurrencyRateType(), recordId, AD_Table_ID, conn);
     } else {
-      line.convert(m_acctSchema.getC_Currency_ID(), conversionDate,
-          m_acctSchema.getCurrencyRateType(), conn);
-    }
-    // Optionally overwrite Acct Amount
-    if (docLine != null && !docLine.m_AmtAcctDr.equals("") && 
!docLine.m_AmtAcctCr.equals(""))
-      line.setAmtAcct(docLine.m_AmtAcctDr, docLine.m_AmtAcctCr);
-    // Info
-    line.setJournalInfo(m_doc.GL_Category_ID);
-    line.setPostingType(m_postingType);
-    // Set Info
-    line.setDocumentInfo(m_doc, docLine);
-    //
-    log4jFact.debug("createLine - " + m_doc.DocumentNo);
-    log4jFact.debug("********************* Fact - createLine - DocumentNo - " 
+ m_doc.DocumentNo
-        + " -  m_lines.size() - " + m_lines.size());
-    m_lines.add(line);
-    return line;
-  } // createLine
-  */
-  /**
-   * Create and convert Fact Line using a specified conversion date. Used to 
create a DR and/or CR
-   * entry
-   * 
-   * @param docLine
-   *          the document line or null
-   * @param account
-   *          if null, line is not created
-   * @param C_Currency_ID
-   *          the currency
-   * @param debitAmt
-   *          debit amount, can be null
-   * @param creditAmt
-   *          credit amount, can be null
-   * @param Fact_Acct_Group_ID
-   * 
-   * @param SeqNo
-   * 
-   * @param DocBaseType
-   * 
-   * @param conversionDate
-   *          Date to convert currencies if required
-   * @param conversionRate
-   *          The rate to use to convert from source amount to account amount. 
May be null
-   * @param AD_Table_ID
-   *          The document to get the date or conversion rate
-   * @return Fact Line
-   */
-  public FactLine createLine(DocLine docLine, Account account, String 
C_Currency_ID,
-      String debitAmt, String creditAmt, String Fact_Acct_Group_ID, String 
SeqNo,
-      String DocBaseType, String conversionDate, BigDecimal conversionRate, 
String AD_Table_ID, String recordId ,ConnectionProvider conn) {
-
-    String strNegate = "";
-    try {
-      strNegate = AcctServerData.selectNegate(conn, 
m_acctSchema.m_C_AcctSchema_ID, DocBaseType);
-      if (strNegate.equals(""))
-        strNegate = AcctServerData.selectDefaultNegate(conn, 
m_acctSchema.m_C_AcctSchema_ID);
-    } catch (ServletException e) {
-    }
-    if (strNegate.equals(""))
-      strNegate = "Y";
-    BigDecimal DebitAmt = new BigDecimal(debitAmt.equals("") ? "0.00" : 
debitAmt);
-    BigDecimal CreditAmt = new BigDecimal(creditAmt.equals("") ? "0.00" : 
creditAmt);
-    if (DebitAmt.compareTo(BigDecimal.ZERO) == 0 && 
CreditAmt.compareTo(BigDecimal.ZERO) == 0) {
-      return null;
-    }
-    if (strNegate.equals("N") && (DebitAmt.compareTo(ZERO) < 0 || 
CreditAmt.compareTo(ZERO) < 0)) {
-      return createLine(docLine, account, C_Currency_ID, 
CreditAmt.abs().toString(), DebitAmt.abs()
-          .toString(), Fact_Acct_Group_ID, SeqNo, DocBaseType, conn);
+      // Standard Conversion
+      if (conversionRate != null) {
+        line.convertByRate(m_acctSchema.getC_Currency_ID(), conversionRate);
+      } else {
+        line.convert(m_acctSchema.getC_Currency_ID(), conversionDate,
+            m_acctSchema.getCurrencyRateType(), conn);
+      }
     }
 
-    log4jFact.debug("createLine - " + account + " - Dr=" + debitAmt + ", Cr=" 
+ creditAmt);
-    log4jFact.debug("Starting createline");
-    // Data Check
-    if (account == null) {
-      log4jFact.debug("end of create line");
-      m_doc.setStatus(AcctServer.STATUS_InvalidAccount);
-      return null;
-    }
-    //
-    log4jFact.debug("createLine - Fact_Acct_Group_ID = " + Fact_Acct_Group_ID);
-    FactLine line = new FactLine(m_doc.AD_Table_ID, m_doc.Record_ID, docLine 
== null ? ""
-        : docLine.m_TrxLine_ID, Fact_Acct_Group_ID, SeqNo, DocBaseType);
-    log4jFact.debug("createLine - line.m_Fact_Acct_Group_ID = " + 
line.m_Fact_Acct_Group_ID);
-    log4jFact.debug("Object created");
-    line.setDocumentInfo(m_doc, docLine);
-    line.setAD_Org_ID(m_doc.AD_Org_ID);
-    // if (docLine!=null) line.setAD_Org_ID(docLine.m_AD_Org_ID);
-    log4jFact.debug("document info set");
-    line.setAccount(m_acctSchema, account);
-    log4jFact.debug("account set");
-

------------------------------------------------------------------------------
Doing More with Less: The Next Generation Virtual Desktop 
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops?   How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to