details:   /erp/devel/pi/rev/dbe46effa795
changeset: 9787:dbe46effa795
user:      Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date:      Wed Jan 12 17:21:44 2011 +0100
summary:   Fixes processing of orders. It was not working properly due to 
previous commit

details:   /erp/devel/pi/rev/702c6abdb8a7
changeset: 9788:702c6abdb8a7
user:      Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date:      Thu Jan 13 11:29:23 2011 +0100
summary:   Adds some more logic to identify BP when importing a bank statement

details:   /erp/devel/pi/rev/466defb80182
changeset: 9789:466defb80182
user:      Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date:      Thu Jan 13 12:52:05 2011 +0100
summary:   Fixes bug 0015442: 3.0RC3: Execute Payment doesn't appear in the 
Payment Proposal

details:   /erp/devel/pi/rev/9ef686946a14
changeset: 9790:9ef686946a14
user:      Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date:      Thu Jan 13 21:46:15 2011 +0100
summary:   Fixes 0015645: Impossible to reconciliate

diffstat:

 
modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_ORD.xml
         |   6 +-
 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
         |  15 +++++
 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProposalProcess.java
 |  18 ++++-
 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_BankStatementImport.java
    |  29 +++++++++-
 src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java                 
                               |   8 ++-
 5 files changed, 65 insertions(+), 11 deletions(-)

diffs (166 lines):

diff -r 8b633bd01c5e -r 9ef686946a14 
modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_ORD.xml
--- 
a/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_ORD.xml
     Thu Jan 13 18:26:53 2011 +0100
+++ 
b/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_ORD.xml
     Thu Jan 13 21:46:15 2011 +0100
@@ -77,9 +77,8 @@
   FROM c_doctype
   WHERE c_doctype_id = v_C_Doctype_ID;
   
-
-  IF(v_docSubType not in ('OB', 'ON')) THEN
-  IF (p_docaction = 'CO') THEN
+  IF(v_docSubType is null or v_docSubType not in ('OB', 'ON')) THEN
+    IF (p_docaction = 'CO') THEN
     -- Checking Payment Method ID is available
     IF(v_paymentmethod_id IS NULL) THEN
       RAISE_APPLICATION_ERROR(-20000, '@APRM_PAYMENTMETHOD_MISSING@');
@@ -98,7 +97,6 @@
       IF (v_count > 0) THEN
         RAISE_APPLICATION_ERROR(-20000, '@APRM_ORDER_MAN_PAYMENTS@');
       END IF;
-
       v_payment_schedule_order := get_uuid();
       INSERT INTO fin_payment_schedule
       (
diff -r 8b633bd01c5e -r 9ef686946a14 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
     Thu Jan 13 18:26:53 2011 +0100
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
     Thu Jan 13 21:46:15 2011 +0100
@@ -27,11 +27,14 @@
 import org.openbravo.advpaymentmngt.exception.NoExecutionProcessFoundException;
 import org.openbravo.advpaymentmngt.utility.FIN_PaymentExecutionProcess;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
+import org.openbravo.advpaymentmngt.utility.Value;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
 import org.openbravo.model.financialmgmt.payment.FIN_Payment;
+import org.openbravo.model.financialmgmt.payment.FIN_PaymentPropDetailV;
+import org.openbravo.model.financialmgmt.payment.FIN_PaymentProposal;
 import org.openbravo.model.financialmgmt.payment.PaymentExecutionProcess;
 import 
org.openbravo.model.financialmgmt.payment.PaymentExecutionProcessParameter;
 import org.openbravo.model.financialmgmt.payment.PaymentRun;
@@ -110,6 +113,12 @@
               paymentStatus = paymentRunPayment.getPayment().isReceipt() ? 
"RPR" : "PPM";
               paymentRunPayment.getPayment().setStatus(paymentStatus);
             }
+            if ("PPW".equals(paymentRun.getSourceOfTheExecution())) {
+              FIN_PaymentProposal pp = 
getPaymentProposalFromPayment(paymentRunPayment.getPayment());
+              pp.setStatus("PPM");
+              OBDal.getInstance().save(pp);
+              OBDal.getInstance().flush();
+            }
             paymentRunPayment.getPayment().setPosted("N");
             if (("RPR".equals(paymentStatus) || "PPM".equals(paymentStatus))
                 && 
FIN_Utility.isAutomaticDepositWithdrawn(paymentRunPayment.getPayment())
@@ -135,6 +144,12 @@
     }
   }
 
+  FIN_PaymentProposal getPaymentProposalFromPayment(FIN_Payment payment) {
+    FIN_PaymentPropDetailV ppv = 
FIN_Utility.getOneInstance(FIN_PaymentPropDetailV.class,
+        new Value(FIN_PaymentPropDetailV.PROPERTY_PAYMENT, payment));
+    return ppv.getPaymentProposal();
+  }
+
   private void setDefaultParameters() {
     final List<PaymentExecutionProcessParameter> allParameters = 
executionProcess
         .getFinancialMgmtPaymentExecutionProcessParameterList();
diff -r 8b633bd01c5e -r 9ef686946a14 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProposalProcess.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProposalProcess.java
     Thu Jan 13 18:26:53 2011 +0100
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProposalProcess.java
     Thu Jan 13 21:46:15 2011 +0100
@@ -172,6 +172,11 @@
           paymentProposal.setStatus(isReceipt ? "RPR" : "PPM");
           // process payment
           message = FIN_AddPayment.processPayment(vars, conProvider, "P", 
payment);
+          if ("RPAE".equals(payment.getStatus())) {
+            paymentProposal.setStatus("RPAE");
+            OBDal.getInstance().save(paymentProposal);
+            OBDal.getInstance().flush();
+          }
           if (message.getType().equals("Error")) {
             String exceptionMessage = payment.getBusinessPartner().getName();
             exceptionMessage += ": " + message.getMessage();
@@ -189,11 +194,14 @@
           OBDal.getInstance().flush();
           OBContext.restorePreviousMode();
         }
-        // If Automatic step is enabled get proposal status
-        if (FIN_Utility.isAutomaticDepositWithdrawn(paymentProposal))
-          paymentProposal.setStatus(isReceipt ? "RDNC" : "PWNC");
-        else
-          paymentProposal.setStatus(isReceipt ? "RPR" : "PPM");
+        // If Automatic step is enabled and not awaiting execution get 
proposal status
+        if (!"RPAE".equals(paymentProposal.getStatus())) {
+          if (FIN_Utility.isAutomaticDepositWithdrawn(paymentProposal)) {
+            paymentProposal.setStatus(isReceipt ? "RDNC" : "PWNC");
+          } else {
+            paymentProposal.setStatus(isReceipt ? "RPR" : "PPM");
+          }
+        }
         paymentProposal.setProcessed(true);
         paymentProposal.setAPRMProcessProposal("RE");
         OBDal.getInstance().save(paymentProposal);
diff -r 8b633bd01c5e -r 9ef686946a14 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_BankStatementImport.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_BankStatementImport.java
        Thu Jan 13 18:26:53 2011 +0100
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_BankStatementImport.java
        Thu Jan 13 21:46:15 2011 +0100
@@ -268,7 +268,11 @@
 
   BusinessPartner matchBusinessPartner(String partnername) {
     // TODO extend with other matching methods. It will make it easier to 
later reconcile
-    return matchBusinessPartnerByName(partnername);
+    BusinessPartner bp = matchBusinessPartnerByName(partnername);
+    if (bp == null) {
+      bp = finBPByName(partnername);
+    }
+    return bp;
   }
 
   BusinessPartner matchBusinessPartnerByName(String partnername) {
@@ -296,6 +300,29 @@
     }
   }
 
+  BusinessPartner finBPByName(String partnername) {
+    final StringBuilder whereClause = new StringBuilder();
+
+    OBContext.setAdminMode();
+    try {
+
+      whereClause.append(" as bp ");
+      whereClause.append(" where bp." + BusinessPartner.PROPERTY_NAME + " = '" 
+ partnername + "'");
+      whereClause.append(" and bp." + BusinessPartner.PROPERTY_CLIENT + " = "
+          + OBContext.getOBContext().getCurrentClient());
+      final OBQuery<BusinessPartner> bp = 
OBDal.getInstance().createQuery(BusinessPartner.class,
+          whereClause.toString());
+      List<BusinessPartner> matchedBP = bp.list();
+      if (matchedBP.size() == 0)
+        return null;
+      else
+        return matchedBP.get(0);
+
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
   public abstract List<FIN_BankStatementLine> loadFile(InputStream in,
       FIN_BankStatement targetBankStatement);
 
diff -r 8b633bd01c5e -r 9ef686946a14 
src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java    Thu Jan 
13 18:26:53 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java    Thu Jan 
13 21:46:15 2011 +0100
@@ -769,7 +769,13 @@
             } else if ("BPW".equals(transaction.getTransactionType())
                 && account.getClearedPaymentAccountOUT() != null) {
               confirmation = true;
-            } else if ("BF".equals(transaction.getTransactionType())
+            }
+          }
+        } else {
+          for (FIN_FinancialAccountAccounting account : accounts) {
+            if (confirmation)
+              return confirmation;
+            if ("BF".equals(transaction.getTransactionType())
                 && account.getClearedPaymentAccountOUT() != null) {
               confirmation = true;
             }

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to