details:   https://code.openbravo.com/erp/devel/pi/rev/7ddaaea7ae8f
changeset: 24327:7ddaaea7ae8f
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Tue Aug 26 00:50:27 2014 +0530
summary:   Fixes Issue 26641:Complete a G/L journal when using open items is 
not working
if the role does not have access to document sequence

diffstat:

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

diffs (83 lines):

diff -r c020b50ce0fe -r 7ddaaea7ae8f 
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 Aug 25 16:24:51 2014 +0530
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java
  Tue Aug 26 00:50:27 2014 +0530
@@ -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):  ______________________________________.
  *************************************************************************
@@ -54,7 +54,7 @@
     String strMessageType = "";
     StringBuilder strMessageResult = new StringBuilder();
     String strTitle = "";
-
+    OBContext.setAdminMode(true);
     try {
 
       // retrieve the parameters from the bundle
@@ -67,8 +67,8 @@
       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);
@@ -111,18 +111,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,10 +144,8 @@
         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());
@@ -170,6 +168,8 @@
       msg.setMessage(e.getMessage());
       msg.setTitle("@Error@");
       bundle.setResult(msg);
+    } finally {
+      OBContext.restorePreviousMode();
     }
 
   }

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to