[resetdocno]Remove client id from api.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Mon, 20 Oct 2014 16:15:52 +0200
changeset 24071 c5a7eec2a316
parent 24070 1bbe398e359c
child 24072 34173eb858f9
[resetdocno]Remove client id from api.
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/DoubtFulDebtPickEditLines.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromTransaction.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProposalProcess.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/event/SetDocumentNoHandler.java
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
src/org/openbravo/erpCommon/ad_callouts/DocumentNoCalloutUtils.java
src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java
src/org/openbravo/erpCommon/utility/DocumentTypeUtils.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java	Mon Oct 20 16:15:52 2014 +0200
@@ -249,8 +249,8 @@
     String strPaymentAmount = "0";
     if (strPaymentDocumentNo.startsWith("<")) {
       // get DocumentNo
-      strPaymentDocumentNo = DocumentTypeUtils.getNextNumber(documentType, "FIN_Payment", org
-          .getClient().getId(), paymentDate, paymentDate, true);
+      strPaymentDocumentNo = DocumentTypeUtils.getNextNumber(documentType, "FIN_Payment",
+          paymentDate, paymentDate, true);
     }
 
     FIN_Payment payment = (new AdvPaymentMngtDao()).getNewPayment(isReceipt, org, documentType,
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/DoubtFulDebtPickEditLines.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/DoubtFulDebtPickEditLines.java	Mon Oct 20 16:15:52 2014 +0200
@@ -139,8 +139,7 @@
           newDoubtfulDebt.setDescription(doubtfulDebtRun.getDescription());
           newDoubtfulDebt.setDocumentNo(DocumentTypeUtils.getNextNumber(documentType,
               documentType.getTable() != null ? documentType.getTable().getDBTableName() : null,
-              doubtfulDebtRun.getClient().getId(), doubtfulDebtRun.getAccountingDate(),
-              doubtfulDebtRun.getAccountingDate(), true));
+              doubtfulDebtRun.getAccountingDate(), doubtfulDebtRun.getAccountingDate(), true));
           newDoubtfulDebt.setCurrency(currency);
           newDoubtfulDebt.setFINDoubtfulDebtRun(doubtfulDebtRun);
           newDoubtfulDebt.setDocumentType(documentType);
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromTransaction.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromTransaction.java	Mon Oct 20 16:15:52 2014 +0200
@@ -280,8 +280,8 @@
 
         if (strPaymentDocumentNo.startsWith("<")) {
           // get DocumentNo
-          strPaymentDocumentNo = DocumentTypeUtils.getNextNumber(docType, "FIN_Payment", OBContext
-              .getOBContext().getCurrentClient().getId(), paymentDate, paymentDate, true);
+          strPaymentDocumentNo = DocumentTypeUtils.getNextNumber(docType, "FIN_Payment",
+              paymentDate, paymentDate, true);
         }
         FIN_Payment payment = dao.getNewPayment(isReceipt, finAcc.getOrganization(), docType,
             strPaymentDocumentNo, paymentBusinessPartner,
@@ -482,8 +482,8 @@
     if (StringUtils.isNotBlank(strTransactionDate)) {
       paymentDate = FIN_Utility.getDate(strTransactionDate);
     }
-    String strDocNo = DocumentTypeUtils.getNextNumber(docType, "FIN_Payment", vars.getClient(),
-        paymentDate, paymentDate, false);
+    String strDocNo = DocumentTypeUtils.getNextNumber(docType, "FIN_Payment", paymentDate,
+        paymentDate, false);
     xmlDocument.setParameter("documentNumber", "<" + strDocNo + ">");
     xmlDocument.setParameter("documentType", dao.getObject(DocumentType.class, strDocTypeId)
         .getName());
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java	Mon Oct 20 16:15:52 2014 +0200
@@ -393,10 +393,9 @@
           final boolean isSalesTransaction = invoice.isSalesTransaction();
           final DocumentType docType = FIN_Utility.getDocumentType(invoice.getOrganization(),
               isSalesTransaction ? AcctServer.DOCTYPE_ARReceipt : AcctServer.DOCTYPE_APPayment);
-          final String strPaymentDocumentNo = DocumentTypeUtils.getNextNumber(docType, docType
-              .getTable() != null ? docType.getTable().getDBTableName() : "", invoice.getClient()
-              .getId(), FIN_Utility.getDate(strPaymentDate), FIN_Utility.getDate(strPaymentDate),
-              true);
+          final String strPaymentDocumentNo = DocumentTypeUtils.getNextNumber(docType,
+              docType.getTable() != null ? docType.getTable().getDBTableName() : "",
+              FIN_Utility.getDate(strPaymentDate), FIN_Utility.getDate(strPaymentDate), true);
 
           final FIN_FinancialAccount bpFinAccount = isSalesTransaction ? invoice
               .getBusinessPartner().getAccount() : invoice.getBusinessPartner()
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java	Mon Oct 20 16:15:52 2014 +0200
@@ -118,10 +118,10 @@
     Organization org = OBDal.getInstance().get(Organization.class, context.get("inpadOrgId"));
     boolean isReceipt = "Y".equals(getDefaultIsSOTrx(requestMap));
 
-    String strDocNo = DocumentTypeUtils.getNextNumber(DocumentTypeUtils.getDocumentType(org,
-        isReceipt ? "ARR" : "APP"), "FIN_Payment", org.getClient().getId(), FIN_Utility
-        .getDate(getDefaultPaymentDate(requestMap)), FIN_Utility
-        .getDate(getDefaultPaymentDate(requestMap)), true);
+    String strDocNo = DocumentTypeUtils.getNextNumber(
+        DocumentTypeUtils.getDocumentType(org, isReceipt ? "ARR" : "APP"), "FIN_Payment",
+        FIN_Utility.getDate(getDefaultPaymentDate(requestMap)),
+        FIN_Utility.getDate(getDefaultPaymentDate(requestMap)), true);
 
     return "<" + strDocNo + ">";
   }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java	Mon Oct 20 16:15:52 2014 +0200
@@ -430,8 +430,8 @@
       refundPayment.setGeneratedCredit(BigDecimal.ZERO);
       final String strDocumentNo = DocumentTypeUtils.getNextNumber(DocumentTypeUtils
           .getDocumentType(payment.getOrganization(), payment.getDocumentType()
-              .getDocumentCategory()), "DocumentNo_FIN_Payment", payment.getClient().getId(),
-          payment.getPaymentDate(), payment.getPaymentDate(), true);
+              .getDocumentCategory()), "DocumentNo_FIN_Payment", payment.getPaymentDate(), payment
+          .getPaymentDate(), true);
       refundPayment.setDocumentNo(strDocumentNo);
     }
     refundPayment.setProcessed(false);
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Mon Oct 20 16:15:52 2014 +0200
@@ -518,9 +518,8 @@
             reversedPayment.setGeneratedCredit(BigDecimal.ZERO);
           }
           reversedPayment.setDocumentNo("*R*"
-              + DocumentTypeUtils.getNextNumber(payment.getDocumentType(), "FIN_Payment", payment
-                  .getClient().getId(), FIN_Utility.getDate(paymentDate), FIN_Utility
-                  .getDate(paymentDate), true));
+              + DocumentTypeUtils.getNextNumber(payment.getDocumentType(), "FIN_Payment",
+                  FIN_Utility.getDate(paymentDate), FIN_Utility.getDate(paymentDate), true));
           reversedPayment.setPaymentDate(FIN_Utility.getDate(paymentDate));
           reversedPayment.setDescription("");
           reversedPayment.setProcessed(false);
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProposalProcess.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProposalProcess.java	Mon Oct 20 16:15:52 2014 +0200
@@ -128,8 +128,7 @@
 
               String strPaymentDocumentNo = DocumentTypeUtils.getNextNumber(
                   DocumentTypeUtils.getDocumentType(orgId, (isReceipt) ? "ARR" : "APP"),
-                  "DocumentNo_FIN_Payment_Proposal", orgId.getClient().getId(), paymentDate,
-                  paymentDate, true);
+                  "DocumentNo_FIN_Payment_Proposal", paymentDate, paymentDate, true);
 
               BigDecimal finAccTxnAmount = paymentTotal.multiply(exchangeRate);
               long faPrecision = financialAccountCurrency.getStandardPrecision();
@@ -172,8 +171,7 @@
 
           String strPaymentDocumentNo = DocumentTypeUtils.getNextNumber(
               DocumentTypeUtils.getDocumentType(orgId, (isReceipt) ? "ARR" : "APP"),
-              "DocumentNo_FIN_Payment_Proposal", orgId.getClient().getId(), paymentDate,
-              paymentDate, true);
+              "DocumentNo_FIN_Payment_Proposal", paymentDate, paymentDate, true);
 
           BigDecimal finAccTxnAmount = paymentTotal.multiply(exchangeRate);
           long faPrecision = financialAccountCurrency.getStandardPrecision();
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/SetDocumentNoHandler.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/SetDocumentNoHandler.java	Mon Oct 20 16:15:52 2014 +0200
@@ -35,7 +35,6 @@
 import org.openbravo.client.kernel.event.EntityUpdateEvent;
 import org.openbravo.erpCommon.utility.DocumentTypeUtils;
 import org.openbravo.erpCommon.utility.Utility;
-import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.common.enterprise.DocumentType;
 import org.openbravo.model.common.order.Order;
 
@@ -100,8 +99,6 @@
         docType = (documentTypeProperty == null ? null : (DocumentType) event
             .getCurrentState(documentTypeProperty));
       }
-      Property client = entity.getProperty("client");
-      String strClientId = ((Client) event.getCurrentState(client)).getId();
       Date dateDoc = null;
       if (docDateProperty != null) {
         dateDoc = (Date) event.getCurrentState(docDateProperty);
@@ -112,8 +109,8 @@
       }
 
       // recompute it
-      documentNo = DocumentTypeUtils.getNextNumber(docType, entity.getTableName(), strClientId,
-          dateAcct, dateDoc, true);
+      documentNo = DocumentTypeUtils.getNextNumber(docType, entity.getTableName(), dateAcct,
+          dateDoc, true);
       event.setCurrentState(documentNoProperty, documentNo);
     }
   }
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java	Mon Oct 20 16:15:52 2014 +0200
@@ -186,7 +186,7 @@
         // the document type and sequence to use. This callout will overwrite this default value in
         // case the default dates are different than now.
         String strDocNo = DocumentTypeUtils.getNextNumber(docType, field.getColumn().getTable()
-            .getDBTableName(), strClientId, new Date(), new Date(), false);
+            .getDBTableName(), new Date(), new Date(), false);
         columnValue = "<" + strDocNo + ">";
       } else {
         String defaultS = field.getColumn().getDefaultValue();
--- a/src/org/openbravo/erpCommon/ad_callouts/DocumentNoCalloutUtils.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/DocumentNoCalloutUtils.java	Mon Oct 20 16:15:52 2014 +0200
@@ -59,7 +59,6 @@
     try {
       // Get values from request
       String strTableId = info.getStringParameter("inpTableId", IsIDFilter.instance);
-      String strClientId = info.getStringParameter("inpadClientId", IsIDFilter.instance);
       String strDocDateColumn = null;
       String strAcctDateColumn = null;
       String strDateDoc = null;
@@ -117,8 +116,8 @@
         return;
       }
 
-      strDocumentNo = DocumentTypeUtils.getNextNumber(docType, entity.getTableName(), strClientId,
-          dateAcct, dateDoc, false);
+      strDocumentNo = DocumentTypeUtils.getNextNumber(docType, entity.getTableName(), dateAcct,
+          dateDoc, false);
     } catch (OBException e) {
       log.error("Error getting document number for invoice", e);
       String msg = OBMessageUtils.parseTranslation(e.getMessage());
--- a/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java	Mon Oct 20 16:15:52 2014 +0200
@@ -348,8 +348,8 @@
             strDocTypeId = MaterialReceiptPendingData.cDoctypeTarget(this, vars.getClient(),
                 data[0].adOrgId);
             DocumentType docType = OBDal.getInstance().get(DocumentType.class, strDocTypeId);
-            strDocumentno = DocumentTypeUtils.getNextNumber(docType, "M_InOut", vars.getClient(),
-                receiptDate, receiptDate, true);
+            strDocumentno = DocumentTypeUtils.getNextNumber(docType, "M_InOut", receiptDate,
+                receiptDate, true);
 
             try {
               MaterialReceiptPendingData.insert(conn, this, strmInoutId, vars.getClient(),
--- a/src/org/openbravo/erpCommon/utility/DocumentTypeUtils.java	Mon Oct 20 13:38:19 2014 +0200
+++ b/src/org/openbravo/erpCommon/utility/DocumentTypeUtils.java	Mon Oct 20 16:15:52 2014 +0200
@@ -99,16 +99,15 @@
   /**
    * 
    * @param docType
-   * @param strTableName
-   * @param strClientId
+   * @param strTableNam
    * @param dateAcct
    * @param dateDoc
    * @param updateNext
    * @return
    * @throws OBException
    */
-  public static String getNextNumber(DocumentType docType, String strTableName, String strClientId,
-      Date dateAcct, Date dateDoc, boolean updateNext) throws OBException {
+  public static String getNextNumber(DocumentType docType, String strTableName, Date dateAcct,
+      Date dateDoc, boolean updateNext) throws OBException {
     OBContext.setAdminMode(false);
     try {
       Sequence seq = null;
@@ -118,9 +117,8 @@
           seq = null;
         }
       }
-      if (seq == null && StringUtils.isNotBlank(strTableName)
-          && StringUtils.isNotBlank(strClientId)) {
-        seq = getTableSequence(strClientId, strTableName);
+      if (seq == null && StringUtils.isNotBlank(strTableName)) {
+        seq = getTableSequence(strTableName);
       }
       if (seq == null) {
         if (docType != null) {
@@ -216,13 +214,10 @@
     return (DocumentType) critDoc.uniqueResult();
   }
 
-  private static Sequence getTableSequence(String strClientId, String strTableName) {
+  private static Sequence getTableSequence(String strTableName) {
     OBCriteria<Sequence> critSeq = OBDal.getInstance().createCriteria(Sequence.class);
     critSeq.setFilterOnReadableOrganization(false);
-    critSeq.setFilterOnReadableClients(false);
     critSeq.add(Restrictions.eq(Sequence.PROPERTY_NAME, "DocumentNo_" + strTableName));
-    critSeq.add(Restrictions.eq(Sequence.PROPERTY_CLIENT,
-        (Client) OBDal.getInstance().getProxy(Client.ENTITY_NAME, strClientId)));
 
     Sequence seq = (Sequence) critSeq.uniqueResult();
     if (seq == null) {