[resetdocno]Modify java classes to use new API.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Mon, 20 Oct 2014 16:16:57 +0200
changeset 24072 34173eb858f9
parent 24071 c5a7eec2a316
child 24129 f20634951622
[resetdocno]Modify java classes to use new API.
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java
src/org/openbravo/erpCommon/ad_actionButton/CreateWorkEffort.java
src/org/openbravo/erpCommon/ad_process/CopyFromGLJournal.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java	Mon Oct 20 16:15:52 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java	Mon Oct 20 16:16:57 2014 +0200
@@ -53,6 +53,7 @@
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.ad_forms.AcctServer;
 import org.openbravo.erpCommon.utility.DateTimeData;
+import org.openbravo.erpCommon.utility.DocumentTypeUtils;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.common.enterprise.DocumentType;
@@ -436,7 +437,8 @@
             .toString());
 
         if (currentReconciliation == null) {
-          DocumentType docType = FIN_Utility.getDocumentType(account.getOrganization(), "REC");
+          DocumentType docType = DocumentTypeUtils
+              .getDocumentType(account.getOrganization(), "REC");
           if (docType == null) {
             OBError msg = new OBError();
             String strMessage = "@APRM_DocumentTypeNotFound@";
@@ -448,8 +450,8 @@
             printPageClosePopUpAndRefreshParent(response, vars);
             return;
           }
-          String docNumber = FIN_Utility.getDocumentNo(account.getOrganization(), "REC",
-              "DocumentNo_FIN_Reconciliation");
+          String docNumber = DocumentTypeUtils.getNextNumber(docType, "FIN_Reconciliation",
+              new Date(), new Date(), true);
 
           dao.getNewReconciliation(account.getOrganization(), account, docNumber, docType,
               new Date(), new Date(), beginBalance, BigDecimal.ZERO, "DR");
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java	Mon Oct 20 16:15:52 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java	Mon Oct 20 16:16:57 2014 +0200
@@ -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) 2013 Openbravo SLU
+ * All portions are Copyright (C) 2013-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -20,17 +20,15 @@
 package org.openbravo.advpaymentmngt.process;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.List;
 
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
-import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.base.exception.OBException;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.DocumentTypeUtils;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
 import org.openbravo.model.common.enterprise.DocumentType;
@@ -40,7 +38,6 @@
 import org.openbravo.model.financialmgmt.payment.FIN_Payment;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod;
 import org.openbravo.scheduling.ProcessBundle;
-import org.openbravo.service.db.CallStoredProcedure;
 import org.openbravo.service.db.DalBaseProcess;
 
 public class FIN_AddPaymentFromJournalLine extends DalBaseProcess {
@@ -101,20 +98,16 @@
       }
 
       // Retrieve additional variables
-      final List<Object> parameters = new ArrayList<Object>();
-      parameters.add(journalLine.getClient().getId());
-      parameters.add(journalLine.getOrganization().getId());
-      parameters.add(isReceipt ? "ARR" : "APP");
-      String strDocTypeId = (String) CallStoredProcedure.getInstance().call("AD_GET_DOCTYPE",
-          parameters, null);
-      String strPaymentDocumentNo = FIN_Utility.getDocumentNo(journalLine.getOrganization(),
-          (isReceipt) ? "ARR" : "APP", (isReceipt) ? "AR Receipt" : "AP Payment");
+      DocumentType docType = DocumentTypeUtils.getDocumentType(journalLine.getOrganization(),
+          isReceipt ? "ARR" : "APP");
+      String strPaymentDocumentNo = DocumentTypeUtils.getNextNumber(docType, "FIN_Payment", date,
+          date, true);
 
       // Generate Payment
-      FIN_Payment payment = dao.getNewPayment(isReceipt, journalLine.getOrganization(),
-          dao.getObject(DocumentType.class, strDocTypeId), strPaymentDocumentNo, bPartner,
-          paymentMethod, financialAccount, journalLine.getDebit().subtract(journalLine.getCredit())
-              .abs().toString(), date, null, journalLine.getCurrency(), null, null);
+      FIN_Payment payment = dao.getNewPayment(isReceipt, journalLine.getOrganization(), docType,
+          strPaymentDocumentNo, bPartner, paymentMethod, financialAccount, journalLine.getDebit()
+              .subtract(journalLine.getCredit()).abs().toString(), date, null,
+          journalLine.getCurrency(), null, null);
 
       // Add Payment Details
       FIN_AddPayment.saveGLItem(payment, journalLine.getDebit().subtract(journalLine.getCredit())
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateWorkEffort.java	Mon Oct 20 16:15:52 2014 +0200
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateWorkEffort.java	Mon Oct 20 16:16:57 2014 +0200
@@ -34,6 +34,7 @@
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.database.ConnectionProvider;
+import org.openbravo.erpCommon.utility.DocumentTypeUtils;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.manufacturing.cost.CostcenterVersion;
@@ -114,7 +115,7 @@
           productionTransaction.setMovementDate(date);
           productionTransaction.setStartingTime(starttime);
           productionTransaction.setEndingTime(endtime);
-          String documentNo = Utility.getDocumentNo(conn, wrOp.getClient().getId(), "M_Production",
+          String documentNo = DocumentTypeUtils.getNextNumber(null, "M_Production", date, date,
               true);
           productionTransaction.setDocumentNo(documentNo);
 
--- a/src/org/openbravo/erpCommon/ad_process/CopyFromGLJournal.java	Mon Oct 20 16:15:52 2014 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/CopyFromGLJournal.java	Mon Oct 20 16:16:57 2014 +0200
@@ -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) 2001-2013 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -22,6 +22,7 @@
 import java.io.PrintWriter;
 import java.sql.Connection;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
@@ -30,9 +31,13 @@
 
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.DocumentTypeUtils;
+import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.common.enterprise.DocumentType;
 import org.openbravo.xmlEngine.XmlDocument;
 
 public class CopyFromGLJournal extends HttpSecureAppServlet {
@@ -101,8 +106,11 @@
       CopyFromGLJournalData[] data = CopyFromGLJournalData.select(this, strKey, strGLJournalBatch);
       for (int i = 0; data != null && i < data.length; i++) {
         String strSequence = SequenceIdData.getUUID();
-        String strDocumentNo = Utility.getDocumentNo(this, vars, windowId, "GL_Journal", "",
-            data[i].cDoctypeId, false, true);
+        DocumentType docType = OBDal.getInstance().get(DocumentType.class, data[i].cDoctypeId);
+        Date dateDoc = OBDateUtils.getDate(data[i].datedoc);
+        Date dateAcct = OBDateUtils.getDate(data[i].dateacct);
+        String strDocumentNo = DocumentTypeUtils.getNextNumber(docType, "GL_Journal", dateAcct,
+            dateDoc, true);
         try {
           if (CopyFromGLJournalData.insertGLJournal(conn, this, strSequence, vars.getClient(),
               data[i].adOrgId, vars.getUser(), data[i].cAcctschemaId, data[i].cDoctypeId, "DR",