details:   https://code.openbravo.com/erp/devel/pi/rev/de43b28a3df5
changeset: 30641:de43b28a3df5
user:      Mark <markmm82 <at> gmail.com>
date:      Sat Nov 12 18:18:08 2016 -0500
summary:   Fixes issue 26499: Removed @FIN_NoMultiAccountingAllowed@ 
restriction for G/L

When the Simple GL Journal window was implemented it included to be able to
"create G/L Item payments from journal" for organization with several General
Ledgers. As this feature is available, only pending point was to remove
@FIN_NoMultiAccountingAllowed@ restriction (FIN_AddPaymentFromJournalLine.java)
when processing a document defined as "Multi-General Ledger", and it is done by
this patch.

diffstat:

 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java
 |  60 +++++----
 1 files changed, 32 insertions(+), 28 deletions(-)

diffs (97 lines):

diff -r 9da6043d9017 -r de43b28a3df5 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java
  Mon Nov 14 17:44:46 2016 +0100
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java
  Sat Nov 12 18:18:08 2016 -0500
@@ -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-2014 Openbravo SLU
+ * All portions are Copyright (C) 2013-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -67,25 +67,27 @@
       BusinessPartner bPartner = journalLine.getBusinessPartner();
       GLItem glItem = journalLine.getGLItem();
       Date date = journalLine.getPaymentDate();
-      boolean isReceipt = 
journalLine.getDebit().subtract(journalLine.getCredit()).compareTo(
-          BigDecimal.ZERO) > 0;
+      boolean isReceipt = 
journalLine.getDebit().subtract(journalLine.getCredit())
+          .compareTo(BigDecimal.ZERO) > 0;
 
       // Check restrictions
       OBContext.setAdminMode(false);
-      try {
-        final StringBuilder hsqlScript = new StringBuilder();
-        hsqlScript.append("select distinct(o.generalLedger) ");
-        hsqlScript.append("from Organization o ");
-        hsqlScript.append("where ad_isorgincluded('" + 
journalLine.getOrganization().getId()
-            + "', o.id, o.client) <> -1 ");
-        hsqlScript.append("and o.generalLedger is not null ");
-        final Session session = OBDal.getInstance().getSession();
-        final Query query = session.createQuery(hsqlScript.toString());
-        if (query.list().size() != 1) {
-          throw new OBException("@FIN_NoMultiAccountingAllowed@");
+      if (!journalLine.getJournalEntry().isMultigeneralLedger()) {
+        try {
+          final StringBuilder hsqlScript = new StringBuilder();
+          hsqlScript.append("select distinct(o.generalLedger) ");
+          hsqlScript.append("from Organization o ");
+          hsqlScript.append("where ad_isorgincluded('" + 
journalLine.getOrganization().getId()
+              + "', o.id, o.client) <> -1 ");
+          hsqlScript.append("and o.generalLedger is not null ");
+          final Session session = OBDal.getInstance().getSession();
+          final Query query = session.createQuery(hsqlScript.toString());
+          if (query.list().size() != 1) {
+            throw new OBException("@FIN_NoMultiAccountingAllowed@");
+          }
+        } finally {
+          OBContext.restorePreviousMode();
         }
-      } finally {
-        OBContext.restorePreviousMode();
       }
 
       if (!journalLine.getCurrency().equals(financialAccount.getCurrency())) {
@@ -111,18 +113,18 @@
           (isReceipt) ? "ARR" : "APP", (isReceipt) ? "AR Receipt" : "AP 
Payment");
 
       // Generate Payment
-      FIN_Payment payment = dao.getNewPayment(isReceipt, 
journalLine.getOrganization(), dao
-          .getObject(DocumentType.class, strDocTypeId), strPaymentDocumentNo, 
bPartner,
-          paymentMethod, financialAccount, 
journalLine.getForeignCurrencyDebit().subtract(
-              journalLine.getForeignCurrencyCredit()).abs().toString(), date, 
null, journalLine
-              .getCurrency(), null, null);
+      FIN_Payment payment = dao.getNewPayment(isReceipt, 
journalLine.getOrganization(),
+          dao.getObject(DocumentType.class, strDocTypeId), 
strPaymentDocumentNo, bPartner,
+          paymentMethod, financialAccount,
+          
journalLine.getForeignCurrencyDebit().subtract(journalLine.getForeignCurrencyCredit())
+              .abs().toString(), date, null, journalLine.getCurrency(), null, 
null);
 
       // Add Payment Details
-      FIN_AddPayment.saveGLItem(payment, 
journalLine.getForeignCurrencyDebit().subtract(
-          journalLine.getForeignCurrencyCredit()).abs(), glItem, bPartner,
-          journalLine.getProduct(), journalLine.getProject(), 
journalLine.getSalesCampaign(),
-          journalLine.getActivity(), journalLine.getSalesRegion(), 
journalLine.getCostCenter(),
-          journalLine.getStDimension(), journalLine.getNdDimension());
+      FIN_AddPayment.saveGLItem(payment,
+          
journalLine.getForeignCurrencyDebit().subtract(journalLine.getForeignCurrencyCredit())
+              .abs(), glItem, bPartner, journalLine.getProduct(), 
journalLine.getProject(),
+          journalLine.getSalesCampaign(), journalLine.getActivity(), 
journalLine.getSalesRegion(),
+          journalLine.getCostCenter(), journalLine.getStDimension(), 
journalLine.getNdDimension());
 
       OBDal.getInstance().flush();
 
@@ -144,8 +146,10 @@
         strMessageType = "Success";
       }
       strMessageResult.append("@Payment@ ").append(payment.getDocumentNo());
-      strMessageResult.append(" (").append(
-          payment.getBusinessPartner() != null ? 
payment.getBusinessPartner().getName() : "")
+      strMessageResult
+          .append(" (")
+          .append(
+              payment.getBusinessPartner() != null ? 
payment.getBusinessPartner().getName() : "")
           .append(")");
       if (!"".equals(message.getMessage()))
         strMessageResult.append(": ").append(message.getMessage());

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to