details:   /erp/devel/pi/rev/5291494cf8d4
changeset: 9210:5291494cf8d4
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Thu Dec 16 15:59:09 2010 +0100
summary:   [APRM] Transplant changeset 744:bf3700fc9b36.
Fixes bug 0015351: Payment plan created when processing a proposal or quotation

details:   /erp/devel/pi/rev/ef9626f80a61
changeset: 9211:ef9626f80a61
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Thu Dec 16 16:00:18 2010 +0100
summary:   [APRM] Transplant changeset 745:45d628293f43.
Improve manual reconciliation.
If a open reconciliation does not exist a new one will be created when the user
opens the Manual Reconciliation popup. This way is not possible to clear a 
transaction
without linking to a reconciliation

diffstat:

 
modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_ORD.xml
     |  14 +-
 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java
 |  65 +++------
 2 files changed, 37 insertions(+), 42 deletions(-)

diffs (196 lines):

diff -r b037e6cfeb18 -r ef9626f80a61 
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 Dec 16 13:56:46 2010 +0100
+++ 
b/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_ORD.xml
     Thu Dec 16 16:00:18 2010 +0100
@@ -32,9 +32,11 @@
 v_OrderDate DATE;
 v_Currency_ID VARCHAR2(32);
 v_Org_ID VARCHAR2(32);
+v_C_Doctype_ID VARCHAR2(32);
 v_client_ID VARCHAR2(32);
 v_paymentmethod_id c_order.fin_paymentmethod_id%TYPE;
 v_bpartner_id c_order.c_bpartner_id%TYPE;
+v_docSubType c_doctype.docsubtypeso%TYPE;
 
 TYPE RECORD IS REF CURSOR;
 Cur_Params RECORD;
@@ -63,13 +65,20 @@
   v_ResultStr:='ReadingOrder';
   SELECT ad_client_id, ad_org_id, 
          grandtotal, dateordered, c_currency_id,
-         fin_paymentmethod_id, c_bpartner_id
+         fin_paymentmethod_id, c_bpartner_id, c_doctype_id
     INTO v_client_id, v_org_id,
          v_grandtotal, v_orderdate, v_currency_id,
-         v_paymentmethod_id, v_bpartner_id
+         v_paymentmethod_id, v_bpartner_id, v_C_Doctype_ID
   FROM c_order
   WHERE c_order_id = p_record_id;
 
+  SELECT docsubtypeso
+  INTO v_docSubType
+  FROM c_doctype
+  WHERE c_doctype_id = v_C_Doctype_ID;
+  
+
+  IF(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
@@ -205,6 +214,7 @@
       END IF;
     END;
   END IF;
+  END IF;
 EXCEPTION
 WHEN OTHERS THEN
   DBMS_OUTPUT.PUT_LINE('APRM_GENERATE_PAYMENT_SCHEDULE exception: '|| 
v_ResultStr);
diff -r b037e6cfeb18 -r ef9626f80a61 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java
 Thu Dec 16 13:56:46 2010 +0100
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java
 Thu Dec 16 16:00:18 2010 +0100
@@ -24,6 +24,7 @@
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -146,7 +147,7 @@
       FIN_FinancialAccount account = 
OBDal.getInstance().get(FIN_FinancialAccount.class,
           strFinancialAccountId);
 
-      FIN_Reconciliation reconciliation = 
TransactionsDao.getLastReconciliation(account, null);
+      FIN_Reconciliation reconciliation = 
TransactionsDao.getLastReconciliation(account, "N");
 
       FIN_Reconciliation lastProcessedReconciliation = 
TransactionsDao.getLastReconciliation(
           account, "Y");
@@ -187,8 +188,6 @@
           msg.setMessage(Utility.parseTranslation(this, vars, 
vars.getLanguage(), strMessage));
           vars.setMessage(strTabId, msg);
           msg = null;
-          // printPage(response, vars, "", strWindowId, strTabId, 
strFinancialAccountId,
-          // strStatementDate, strEndBalance);
           printPageClosePopUpAndRefreshParent(response, vars);
           return;
         }
@@ -196,7 +195,6 @@
       }
 
       DocumentType docType = 
FIN_Utility.getDocumentType(account.getOrganization(), "REC");
-
       if (docType == null) {
         String strMessage = "@APRM_DocumentTypeNotFound@";
         msg.setType("Error");
@@ -204,36 +202,13 @@
         msg.setMessage(Utility.parseTranslation(this, vars, 
vars.getLanguage(), strMessage));
         vars.setMessage(strTabId, msg);
         msg = null;
-        // printPage(response, vars, "", strWindowId, strTabId, 
strFinancialAccountId,
-        // strStatementDate, strEndBalance);
         printPageClosePopUpAndRefreshParent(response, vars);
         return;
       }
 
-      if (reconciliation == null) {
-        String docNumber = 
FIN_Utility.getDocumentNo(account.getOrganization(), "REC",
-            "DocumentNo_FIN_Reconciliation");
-
-        reconciliation = dao.getNewReconciliation(account.getOrganization(), 
account, docNumber,
-            docType, FIN_Utility.getDateTime(strStatementDate), FIN_Utility
-                .getDateTime(strStatementDate), new 
BigDecimal(strBeginBalance), new BigDecimal(
-                strEndBalance), process ? "CO" : "DR");
-      } else {
-        if (reconciliation.isProcessed()) {
-          String docNumber = 
FIN_Utility.getDocumentNo(account.getOrganization(), "REC",
-              "DocumentNo_FIN_Reconciliation");
-
-          reconciliation = dao.getNewReconciliation(account.getOrganization(), 
account, docNumber,
-              docType, FIN_Utility.getDateTime(strStatementDate), FIN_Utility
-                  .getDateTime(strStatementDate), new 
BigDecimal(strBeginBalance), new BigDecimal(
-                  strEndBalance), process ? "CO" : "DR");
-        } else {
-          reconciliation.setEndingBalance(new BigDecimal(strEndBalance));
-          
reconciliation.setTransactionDate(FIN_Utility.getDateTime(strStatementDate));
-          
reconciliation.setEndingDate(FIN_Utility.getDateTime(strStatementDate));
-        }
-      }
-
+      reconciliation.setEndingBalance(new BigDecimal(strEndBalance));
+      
reconciliation.setTransactionDate(FIN_Utility.getDateTime(strStatementDate));
+      reconciliation.setEndingDate(FIN_Utility.getDateTime(strStatementDate));
       reconciliation.setDocumentStatus(process ? "CO" : "DR");
       reconciliation.setProcessed(process);
       OBDal.getInstance().save(reconciliation);
@@ -311,18 +286,20 @@
 
     log4j.debug("Output: Reconcile button pressed on Financial Account || 
Transaction tab");
 
+    dao = new AdvPaymentMngtDao();
     String dateFormat = 
OBPropertiesProvider.getInstance().getOpenbravoProperties().getProperty(
         "dateFormat.java");
     SimpleDateFormat dateFormater = new SimpleDateFormat(dateFormat);
+
+    FIN_Reconciliation currentReconciliation = null;
     OBContext.setAdminMode();
     try {
-
       FIN_FinancialAccount account = 
OBDal.getInstance().get(FIN_FinancialAccount.class,
           strFinancialAccountId);
 
-      FIN_Reconciliation reconciliation = 
TransactionsDao.getLastReconciliation(account, "Y");
-      FIN_Reconciliation currentReconciliation = TransactionsDao
-          .getLastReconciliation(account, "N");
+      FIN_Reconciliation lastProcessedReconciliation = 
TransactionsDao.getLastReconciliation(
+          account, "Y");
+      currentReconciliation = TransactionsDao.getLastReconciliation(account, 
"N");
       if (isAutomaticReconciliation(currentReconciliation)) {
         OBDal.getInstance().rollbackAndClose();
         OBError message = Utility.translateError(this, vars, 
vars.getLanguage(), Utility
@@ -331,6 +308,7 @@
         printPageClosePopUp(response, vars, Utility.getTabURL(this, strTabId, 
"R"));
         return;
       }
+
       XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
           
"org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation").createXmlDocument();
 
@@ -353,19 +331,17 @@
 
       } else {
         String currentStatementDate = DateTimeData.today(this);
-        if (currentReconciliation != null && 
!currentReconciliation.isProcessed()) {
+        if (currentReconciliation != null) {
           currentStatementDate = 
dateFormater.format(currentReconciliation.getTransactionDate());
+          currentEndBalance = currentReconciliation.getEndingBalance();
         }
         xmlDocument.setParameter("statementDate", currentStatementDate);
-        if (currentReconciliation != null && 
!currentReconciliation.isProcessed()) {
-          currentEndBalance = currentReconciliation.getEndingBalance();
-        }
         xmlDocument.setParameter("endBalance", currentEndBalance.toString());
         xmlDocument.setParameter("calcEndingBalance", 
currentEndBalance.toString());
       }
 
-      BigDecimal beginBalance = (reconciliation == null) ? 
account.getInitialBalance()
-          : reconciliation.getEndingBalance();
+      BigDecimal beginBalance = (lastProcessedReconciliation == null) ? 
account.getInitialBalance()
+          : lastProcessedReconciliation.getEndingBalance();
 
       xmlDocument.setParameter("account", account.getName());
       xmlDocument.setParameter("beginBalance", beginBalance.toString());
@@ -384,6 +360,15 @@
       try {
         xmlDocument.setParameter("precision", 
account.getCurrency().getStandardPrecision()
             .toString());
+
+        if (currentReconciliation == null) {
+          DocumentType docType = 
FIN_Utility.getDocumentType(account.getOrganization(), "REC");
+          String docNumber = 
FIN_Utility.getDocumentNo(account.getOrganization(), "REC",
+              "DocumentNo_FIN_Reconciliation");
+
+          dao.getNewReconciliation(account.getOrganization(), account, 
docNumber, docType,
+              new Date(), new Date(), beginBalance, BigDecimal.ZERO, "DR");
+        }
       } finally {
         OBContext.restorePreviousMode();
       }

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to