details:   https://code.openbravo.com/erp/stable/2.50/rev/191125bd2a2e
changeset: 9789:191125bd2a2e
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Mon Jan 16 17:29:37 2012 -0500
summary:   Apply 2.50 preferences format: DocFINPayment, DocFINFinAccTransaction

details:   https://code.openbravo.com/erp/stable/2.50/rev/ff7391351bf5
changeset: 9790:ff7391351bf5
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Mon Jan 16 18:42:49 2012 -0500
summary:   Fixes issue 19075: Enable user1/user2 acct dimensions in 
Payment/Transaction/Reconciliation

details:   https://code.openbravo.com/erp/stable/2.50/rev/f56fd5d2be0c
changeset: 9791:f56fd5d2be0c
user:      Javier Etxarri <javier.echarri <at> openbravo.com>
date:      Wed Jan 25 10:05:17 2012 +0100
summary:   Fixes issue 19279: Error with parcial "Goods Shipments" and Invoices.
Now the shipments don't appear until the order has been delivered completely.

diffstat:

 src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql |    
8 +-
 src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java        |  
163 +++++----
 src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction_data.xsql   |   
32 +
 src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java                  |   
33 +-
 src/org/openbravo/erpCommon/ad_forms/DocFINPayment_data.xsql             |   
32 +
 src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java           |   
48 ++-
 6 files changed, 228 insertions(+), 88 deletions(-)

diffs (truncated from 580 to 300 lines):

diff -r 0994cecd23eb -r f56fd5d2be0c 
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql  
Mon Jan 23 13:18:01 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql  
Wed Jan 25 10:05:17 2012 +0100
@@ -372,7 +372,13 @@
         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 ic.term = 'N')
+        AND EXISTS (SELECT 1
+        FROM C_ORDER o , C_ORDERLINE ol
+        WHERE o.C_ORDER_ID = s.C_ORDER_ID
+        AND o.C_ORDER_ID = ol.C_ORDER_ID
+        GROUP BY o.INVOICERULE
+        HAVING o.INVOICERULE <> 'O' OR (SUM(ol.qtyordered) = 
SUM(ol.qtydelivered)))
         ORDER BY NAME
       ]]>
     </Sql>
diff -r 0994cecd23eb -r f56fd5d2be0c 
src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Mon Jan 
23 13:18:01 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Wed Jan 
25 10:05:17 2012 +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) 2010 Openbravo SLU
+ * All portions are Copyright (C) 2010-2012 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -51,6 +51,7 @@
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod;
 import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
+import org.openbravo.service.db.DalConnectionProvider;
 
 public class DocFINFinAccTransaction extends AcctServer {
   /** Transaction type - Financial Account */
@@ -81,8 +82,8 @@
         : new BigDecimal(data[0].getField("PaymentAmount"));
     BigDecimal depositAmount = "".equals(data[0].getField("DepositAmount")) ? 
ZERO
         : new BigDecimal(data[0].getField("DepositAmount"));
-    usedCredit = "".equals(data[0].getField("UsedCredit")) ? ZERO : new 
BigDecimal(
-        data[0].getField("UsedCredit"));
+    usedCredit = "".equals(data[0].getField("UsedCredit")) ? ZERO : new 
BigDecimal(data[0]
+        .getField("UsedCredit"));
     generatedCredit = "".equals(data[0].getField("GeneratedCredit")) ? ZERO : 
new BigDecimal(
         data[0].getField("GeneratedCredit"));
     Amounts[AMTTYPE_Gross] = depositAmount.subtract(paymentAmount).toString();
@@ -153,9 +154,7 @@
         FieldProviderFactory.setField(data[i], "Refund", 
paymentDetails.get(i).isRefund() ? "Y"
             : "N");
         FieldProviderFactory.setField(data[i], "adOrgId", 
transaction.getOrganization().getId());
-        FieldProviderFactory.setField(
-            data[i],
-            "cGlItemId",
+        FieldProviderFactory.setField(data[i], "cGlItemId",
             transaction.getGLItem() != null ? transaction.getGLItem().getId() 
: data[i]
                 .getField("cGlItemId"));
         FieldProviderFactory.setField(data[i], "description", 
transaction.getDescription());
@@ -213,6 +212,18 @@
             .getFINPaymentScheduleDetailList().get(0).getSalesRegion() != null 
? paymentDetails
             
.get(i).getFINPaymentScheduleDetailList().get(0).getSalesRegion().getId() : "");
         FieldProviderFactory.setField(data[i], "lineno", 
transaction.getLineNo().toString());
+
+        try { // Get User1_ID and User2_ID using xsql
+          ConnectionProvider conn = new DalConnectionProvider();
+          DocFINFinAccTransactionData[] trxInfo = 
DocFINFinAccTransactionData.select(conn,
+              transaction.getId());
+          if (trxInfo.length > 0) {
+            FieldProviderFactory.setField(data[i], "user1Id", 
trxInfo[0].user1Id);
+            FieldProviderFactory.setField(data[i], "user2Id", 
trxInfo[0].user2Id);
+          }
+        } catch (Exception e) {
+          log4j.error("Error while retreiving user1 and user2 - ", e);
+        }
       }
     } finally {
       OBContext.restorePreviousMode();
@@ -248,6 +259,19 @@
         FieldProviderFactory.setField(data[0], "cCampaignId", 
transaction.getSalesCampaign()
             .getId());
       FieldProviderFactory.setField(data[0], "lineno", 
transaction.getLineNo().toString());
+
+      try { // Get User1_ID and User2_ID using xsql
+        ConnectionProvider conn = new DalConnectionProvider();
+        DocFINFinAccTransactionData[] trxInfo = 
DocFINFinAccTransactionData.select(conn,
+            transaction.getId());
+        if (trxInfo.length > 0) {
+          FieldProviderFactory.setField(data[0], "user1Id", 
trxInfo[0].user1Id);
+          FieldProviderFactory.setField(data[0], "user2Id", 
trxInfo[0].user2Id);
+        }
+      } catch (Exception e) {
+        log4j.error("Error while retreiving user1 and user2 - ", e);
+      }
+
     } finally {
       OBContext.restorePreviousMode();
     }
@@ -369,8 +393,8 @@
     String Fact_Acct_Group_ID = SequenceIdData.getUUID();
     for (int i = 0; p_lines != null && i < p_lines.length; i++) {
       DocLine_FINFinAccTransaction line = (DocLine_FINFinAccTransaction) 
p_lines[i];
-      fact.createLine(line, getAccountFee(as, transaction.getAccount(), conn), 
C_Currency_ID,
-          line.getPaymentAmount(), line.getDepositAmount(), 
Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+      fact.createLine(line, getAccountFee(as, transaction.getAccount(), conn), 
C_Currency_ID, line
+          .getPaymentAmount(), line.getDepositAmount(), Fact_Acct_Group_ID, 
nextSeqNo(SeqNo),
           DocumentType, conn);
       fact.createLine(line, getWithdrawalAccount(as, null, 
transaction.getAccount(), conn),
           C_Currency_ID, line.getDepositAmount(), line.getPaymentAmount(), 
Fact_Acct_Group_ID,
@@ -416,12 +440,10 @@
         }
         // Bug critical: Before GL Item was not taken into account
         if (!"".equals(line.cGlItemId)) {
-          fact.createLine(
-              line,
-              getAccountGLItem(OBDal.getInstance().get(GLItem.class, 
line.getCGlItemId()), as,
-                  isReceipt, conn), C_Currency_ID, isReceipt ? "" : 
line.getAmount(),
-              isReceipt ? line.getAmount() : "", Fact_Acct_Group_ID, 
nextSeqNo(SeqNo),
-              DocumentType, conn);
+          fact.createLine(line, 
getAccountGLItem(OBDal.getInstance().get(GLItem.class,
+              line.getCGlItemId()), as, isReceipt, conn), C_Currency_ID, 
isReceipt ? "" : line
+              .getAmount(), isReceipt ? line.getAmount() : "", 
Fact_Acct_Group_ID,
+              nextSeqNo(SeqNo), DocumentType, conn);
         } else {
           String bpAmountConverted = bpamount.toString();
           Invoice invoice = line.getInvoice();
@@ -435,26 +457,25 @@
                 as.m_C_Currency_ID, line, as, fact, Fact_Acct_Group_ID, conn);
             strcCurrencyId = as.m_C_Currency_ID;
           }
-          fact.createLine(
-              line,
-              getAccountBPartner(
-                  (line.m_C_BPartner_ID == null || 
line.m_C_BPartner_ID.equals("")) ? this.C_BPartner_ID
-                      : line.m_C_BPartner_ID, as, isReceipt, isPrepayment, 
conn), strcCurrencyId,
-              !isReceipt ? bpAmountConverted : "", isReceipt ? 
bpAmountConverted : "",
-              Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
+          fact
+              .createLine(line,
+                  getAccountBPartner((line.m_C_BPartner_ID == null || 
line.m_C_BPartner_ID
+                      .equals("")) ? this.C_BPartner_ID : 
line.m_C_BPartner_ID, as, isReceipt,
+                      isPrepayment, conn), strcCurrencyId, !isReceipt ? 
bpAmountConverted : "",
+                  isReceipt ? bpAmountConverted : "", Fact_Acct_Group_ID, 
nextSeqNo(SeqNo),
+                  DocumentType, conn);
         }
       }
       // Pre-payment is consumed when Used Credit Amount not equals Zero. When 
consuming Credit no
       // credit is generated
       if (transaction.getFinPayment().getUsedCredit().compareTo(ZERO) != 0
           && transaction.getFinPayment().getGeneratedCredit().compareTo(ZERO) 
== 0) {
-        fact.createLine(
-            null,
-            getAccountBPartner(C_BPartner_ID, as, 
transaction.getFinPayment().isReceipt(), true,
-                conn), C_Currency_ID, (transaction.getFinPayment().isReceipt() 
? transaction
-                .getFinPayment().getUsedCredit().toString() : ""), 
(transaction.getFinPayment()
-                .isReceipt() ? "" : 
transaction.getFinPayment().getUsedCredit().toString()),
-            Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
+        fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, 
transaction.getFinPayment()
+            .isReceipt(), true, conn), C_Currency_ID,
+            (transaction.getFinPayment().isReceipt() ? 
transaction.getFinPayment().getUsedCredit()
+                .toString() : ""), (transaction.getFinPayment().isReceipt() ? 
"" : transaction
+                .getFinPayment().getUsedCredit().toString()), 
Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+            DocumentType, conn);
       }
     } else {
       FIN_Payment payment = transaction.getFinPayment();
@@ -469,16 +490,13 @@
             as.m_C_Currency_ID, null, as, fact, Fact_Acct_Group_ID, conn);
         strcCurrencyId = as.m_C_Currency_ID;
       }
-      fact.createLine(
-          null,
-          getAccountPayment(conn, 
transaction.getFinPayment().getPaymentMethod(), transaction
-              .getFinPayment().getAccount(), as, 
transaction.getFinPayment().isReceipt()),
+      fact.createLine(null, getAccountPayment(conn, 
transaction.getFinPayment().getPaymentMethod(),
+          transaction.getFinPayment().getAccount(), as, 
transaction.getFinPayment().isReceipt()),
           strcCurrencyId, !transaction.getFinPayment().isReceipt() ? 
bpAmountConverted : "",
           transaction.getFinPayment().isReceipt() ? bpAmountConverted : "", 
Fact_Acct_Group_ID,
           nextSeqNo(SeqNo), DocumentType, conn);
     }
-    fact.createLine(
-        null,
+    fact.createLine(null,
         getAccountUponDepositWithdrawal(conn, 
transaction.getFinPayment().getPaymentMethod(),
             transaction.getAccount(), as, 
transaction.getFinPayment().isReceipt()), C_Currency_ID,
         transaction.getDepositAmount().toString(), 
transaction.getPaymentAmount().toString(),
@@ -506,19 +524,16 @@
       boolean isReceipt = paymentAmount.compareTo(depositAmount) < 0;
       String Fact_Acct_Group_ID = SequenceIdData.getUUID();
       if (!"".equals(line.getCGlItemId()))
-        fact.createLine(
-            line,
-            getAccountGLItem(OBDal.getInstance().get(GLItem.class, 
line.getCGlItemId()), as,
-                isReceipt, conn), C_Currency_ID, line.getPaymentAmount(), 
line.getDepositAmount(),
-            Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
+        fact.createLine(line, 
getAccountGLItem(OBDal.getInstance().get(GLItem.class,
+            line.getCGlItemId()), as, isReceipt, conn), C_Currency_ID, 
line.getPaymentAmount(),
+            line.getDepositAmount(), Fact_Acct_Group_ID, nextSeqNo(SeqNo), 
DocumentType, conn);
       FIN_FinaccTransaction transaction = 
OBDal.getInstance().get(FIN_FinaccTransaction.class,
           Record_ID);
-      fact.createLine(
-          line,
-          getAccountUponDepositWithdrawal(conn, transaction.getFinPayment() != 
null ? transaction
-              .getFinPayment().getPaymentMethod() : null, 
transaction.getAccount(), as, isReceipt),
-          C_Currency_ID, line.getDepositAmount(), line.getPaymentAmount(), 
Fact_Acct_Group_ID,
-          "999999", DocumentType, conn);
+      fact.createLine(line, getAccountUponDepositWithdrawal(conn,
+          transaction.getFinPayment() != null ? 
transaction.getFinPayment().getPaymentMethod()
+              : null, transaction.getAccount(), as, isReceipt), C_Currency_ID, 
line
+          .getDepositAmount(), line.getPaymentAmount(), Fact_Acct_Group_ID, 
"999999", DocumentType,
+          conn);
     }
     SeqNo = "0";
     return fact;
@@ -589,8 +604,8 @@
       OBCriteria<FinAccPaymentMethod> obCriteria = 
OBDal.getInstance().createCriteria(
           FinAccPaymentMethod.class);
       obCriteria.add(Expression.eq(FinAccPaymentMethod.PROPERTY_ACCOUNT, 
payment.getAccount()));
-      obCriteria.add(Expression.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD,
-          payment.getPaymentMethod()));
+      obCriteria.add(Expression.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD, 
payment
+          .getPaymentMethod()));
       obCriteria.setFilterOnReadableClients(false);
       obCriteria.setFilterOnReadableOrganization(false);
       List<FinAccPaymentMethod> lines = obCriteria.list();
@@ -638,8 +653,8 @@
       OBCriteria<FinAccPaymentMethod> obCriteria = 
OBDal.getInstance().createCriteria(
           FinAccPaymentMethod.class);
       obCriteria.add(Expression.eq(FinAccPaymentMethod.PROPERTY_ACCOUNT, 
payment.getAccount()));
-      obCriteria.add(Expression.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD,
-          payment.getPaymentMethod()));
+      obCriteria.add(Expression.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD, 
payment
+          .getPaymentMethod()));
       obCriteria.setFilterOnReadableClients(false);
       obCriteria.setFilterOnReadableOrganization(false);
       List<FinAccPaymentMethod> lines = obCriteria.list();
@@ -695,8 +710,8 @@
         OBCriteria<FinAccPaymentMethod> obCriteria = 
OBDal.getInstance().createCriteria(
             FinAccPaymentMethod.class);
         obCriteria.add(Expression.eq(FinAccPaymentMethod.PROPERTY_ACCOUNT, 
payment.getAccount()));
-        
obCriteria.add(Expression.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD,
-            payment.getPaymentMethod()));
+        
obCriteria.add(Expression.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD, payment
+            .getPaymentMethod()));
         obCriteria.setFilterOnReadableClients(false);
         obCriteria.setFilterOnReadableOrganization(false);
         List<FinAccPaymentMethod> lines = obCriteria.list();
@@ -760,10 +775,8 @@
       OBCriteria<FIN_FinancialAccountAccounting> accounts = 
OBDal.getInstance().createCriteria(
           FIN_FinancialAccountAccounting.class);
       
accounts.add(Expression.eq(FIN_FinancialAccountAccounting.PROPERTY_ACCOUNT, 
finAccount));
-      accounts.add(Expression.eq(
-          FIN_FinancialAccountAccounting.PROPERTY_ACCOUNTINGSCHEMA,
-          OBDal.getInstance().get(
-              
org.openbravo.model.financialmgmt.accounting.coa.AcctSchema.class,
+      
accounts.add(Expression.eq(FIN_FinancialAccountAccounting.PROPERTY_ACCOUNTINGSCHEMA,
 OBDal
+          
.getInstance().get(org.openbravo.model.financialmgmt.accounting.coa.AcctSchema.class,
               as.m_C_AcctSchema_ID)));
       
accounts.add(Expression.eq(FIN_FinancialAccountAccounting.PROPERTY_ACTIVE, 
true));
       accounts.setFilterOnReadableClients(false);
@@ -830,9 +843,13 @@
       FieldProviderFactory.setField(data[0], "C_SalesRegion_ID",
           transaction.getSalesRegion() != null ? 
transaction.getSalesRegion().getId() : "");
       FieldProviderFactory.setField(data[0], "lineno", 
transaction.getLineNo().toString());
-      // This lines can be uncommented when User1 and User2 are implemented
-      // FieldProviderFactory.setField(data[0], "User1_ID", 
transaction.getNdDimension().getId());
-      // FieldProviderFactory.setField(data[0], "User2_ID", 
transaction.getNdDimension().getId());
+      // User1_ID and User2_ID
+      DocFINFinAccTransactionData[] trxInfo = 
DocFINFinAccTransactionData.select(conn, transaction
+          .getId());
+      if (trxInfo.length > 0) {
+        FieldProviderFactory.setField(data[0], "User1_ID", trxInfo[0].user1Id);
+        FieldProviderFactory.setField(data[0], "User2_ID", trxInfo[0].user2Id);
+      }
       FieldProviderFactory.setField(data[0], "FIN_Payment_ID",
           transaction.getFinPayment() != null ? 
transaction.getFinPayment().getId() : "");
       final String cBPartnerId;
@@ -851,13 +868,13 @@
       FieldProviderFactory.setField(data[0], "GeneratedCredit",
           transaction.getFinPayment() != null ? 
transaction.getFinPayment().getGeneratedCredit()
               .toString() : "");
-      String dateFormat = 
OBPropertiesProvider.getInstance().getOpenbravoProperties()
-          .getProperty("dateFormat.java");
+      String dateFormat = 
OBPropertiesProvider.getInstance().getOpenbravoProperties().getProperty(
+          "dateFormat.java");
       SimpleDateFormat outputFormat = new SimpleDateFormat(dateFormat);
-      FieldProviderFactory.setField(data[0], "DateAcct",
-          outputFormat.format(transaction.getDateAcct()));
-      FieldProviderFactory.setField(data[0], "trxdate",
-          outputFormat.format(transaction.getTransactionDate()));
+      FieldProviderFactory.setField(data[0], "DateAcct", 
outputFormat.format(transaction
+          .getDateAcct()));
+      FieldProviderFactory.setField(data[0], "trxdate", 
outputFormat.format(transaction
+          .getTransactionDate()));
       FieldProviderFactory.setField(data[0], "Posted", 
transaction.getPosted());
       FieldProviderFactory.setField(data[0], "Processed", 
transaction.isProcessed() ? "Y" : "N");
       FieldProviderFactory.setField(data[0], "Processing", 
transaction.isProcessNow() ? "Y" : "N");
@@ -886,10 +903,8 @@
       OBCriteria<FIN_FinancialAccountAccounting> accounts = 
OBDal.getInstance().createCriteria(

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to