Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java?rev=757093&r1=757092&r2=757093&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java Sat Mar 21 23:44:59 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -59,20 +59,20 @@ * WorldPay Select Pro Response Servlet */ public class SelectRespServlet extends SelectServlet implements SelectDefs { - + public static final String module = SelectRespServlet.class.getName(); protected JPublishWrapper jp = null; protected void doRequest(SelectServletRequest request, SelectServletResponse response) throws ServletException, IOException { Debug.logInfo("Response received from worldpay..", module); - + String localLocaleStr = request.getParameter("M_localLocale"); String webSiteId = request.getParameter("M_webSiteId"); String delegatorName = request.getParameter("M_delegatorName"); String dispatchName = request.getParameter("M_dispatchName"); String userLoginId = request.getParameter("M_userLoginId"); String confirmTemplate = request.getParameter("M_confirmTemplate"); - + // get the ServletContext ServletContext context = (ServletContext) request.getAttribute("servletContext"); if (this.jp == null) { @@ -80,30 +80,30 @@ if (this.jp == null) { this.jp = new JPublishWrapper(context); } - } - + } + // get the delegator GenericDelegator delegator = GenericDelegator.getGenericDelegator(delegatorName); - + // get the dispatcher ServiceDispatcher serviceDisp = ServiceDispatcher.getInstance(dispatchName, delegator); DispatchContext dctx = serviceDisp.getLocalContext(dispatchName); - LocalDispatcher dispatcher = dctx.getDispatcher(); - + LocalDispatcher dispatcher = dctx.getDispatcher(); + // get the userLogin - GenericValue userLogin = null; + GenericValue userLogin = null; try { - userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", userLoginId)); + userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", userLoginId)); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get admin UserLogin entity", module); callError(request); } - + // get the client locale List localeSplit = StringUtil.split(localLocaleStr, "_"); Locale localLocale = new Locale((String) localeSplit.get(0), (String) localeSplit.get(1)); - - // get the properties file + + // get the properties file String configString = null; try { GenericValue webSitePayment = delegator.findByPrimaryKey("WebSitePaymentSetting", UtilMisc.toMap("webSiteId", webSiteId, "paymentMethodTypeId", "EXT_WORLDPAY")); @@ -113,13 +113,13 @@ Debug.logWarning(e, "Cannot find webSitePayment Settings", module); } if (configString == null) - configString = "payment.properties"; - Debug.logInfo("Got the payment configuration", module); - + configString = "payment.properties"; + Debug.logInfo("Got the payment configuration", module); + String orderId = request.getParameter(SelectDefs.SEL_cartId); String authAmount = request.getParameter(SelectDefs.SEL_authAmount); String transStatus = request.getParameter(SelectDefs.SEL_transStatus); - + // get the order header GenericValue orderHeader = null; try { @@ -128,7 +128,7 @@ Debug.logError(e, "Cannot get the order header for the returned orderId", module); callError(request); } - + // the order total MUST match the auth amount or we do not process BigDecimal wpTotal = new BigDecimal(authAmount); BigDecimal orderTotal = orderHeader.getBigDecimal("grandTotal"); @@ -136,45 +136,45 @@ if (orderTotal.compareTo(wpTotal) != 0) { Debug.logError("AuthAmount (" + wpTotal + ") does not match OrderTotal (" + orderTotal + ")", module); callError(request); - } + } } - + // store some stuff for calling existing events HttpSession session = request.getSession(true); session.setAttribute("userLogin", userLogin); - + request.setAttribute("delegator", delegator); request.setAttribute("dispatcher", dispatcher); request.setAttribute("orderId", orderId); request.setAttribute("notifyEmail", request.getParameter("M_notifyEmail")); - request.setAttribute("confirmEmail", request.getParameter("M_confirmEmail")); + request.setAttribute("confirmEmail", request.getParameter("M_confirmEmail")); request.setAttribute("_CONTROL_PATH_", request.getParameter("M_controlPath")); - + // attempt to start a transaction boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); } catch (GenericTransactionException gte) { Debug.logError(gte, "Unable to begin transaction", module); - } - + } + boolean okay = false; if (transStatus.equalsIgnoreCase("Y")) { // order was approved Debug.logInfo("Order #" + orderId + " approved", module); - okay = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId); + okay = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId); } else { // order was cancelled Debug.logInfo("Order #" + orderId + " cancelled", module); okay = OrderChangeHelper.cancelOrder(dispatcher, userLogin, orderId); } - - if (okay) { + + if (okay) { // set the payment preference okay = setPaymentPreferences(delegator, userLogin, orderId, request); } - - if (okay) { + + if (okay) { try { TransactionUtil.commit(beganTransaction); } catch (GenericTransactionException gte) { @@ -187,34 +187,34 @@ Debug.logError(gte, "Unable to rollback transaction", module); } } - + // attempt to release the offline hold on the order (workflow) - OrderChangeHelper.releaseInitialOrderHold(dispatcher, orderId); - + OrderChangeHelper.releaseInitialOrderHold(dispatcher, orderId); + // call the email confirm service Map emailContext = UtilMisc.toMap("orderId", orderId); try { Map emailResult = dispatcher.runSync("sendOrderConfirmation", emailContext); } catch (GenericServiceException e) { Debug.logError(e, "Problems sending email confirmation", module); - } - + } + // set up the output stream for the response response.setContentType("text/html"); - ServletOutputStream out = response.getOutputStream(); + ServletOutputStream out = response.getOutputStream(); String content = "Error getting confirm content"; - if (confirmTemplate != null) { - // render the thank-you / confirm page + if (confirmTemplate != null) { + // render the thank-you / confirm page try { content = jp.render(confirmTemplate, request, response); - } catch (GeneralException e) { + } catch (GeneralException e) { Debug.logError(e, "Trouble rendering confirm page", module); - } + } } out.println(content); - out.flush(); + out.flush(); } - + private boolean setPaymentPreferences(GenericDelegator delegator, GenericValue userLogin, String orderId, ServletRequest request) { List paymentPrefs = null; boolean okay = true; @@ -225,7 +225,7 @@ Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module); } if (UtilValidate.isNotEmpty(paymentPrefs)) { - Iterator i = paymentPrefs.iterator(); + Iterator i = paymentPrefs.iterator(); while (okay && i.hasNext()) { GenericValue pref = (GenericValue) i.next(); okay = setPaymentPreference(pref, userLogin, request); @@ -233,19 +233,19 @@ } return okay; } - + private boolean setPaymentPreference(GenericValue paymentPreference, GenericValue userLogin, ServletRequest request) { - String transId = request.getParameter(SelectDefs.SEL_transId); + String transId = request.getParameter(SelectDefs.SEL_transId); String transTime = request.getParameter(SelectDefs.SEL_transTime); String transStatus = request.getParameter(SelectDefs.SEL_transStatus); String avsCode = request.getParameter("AVS"); // why is this not in SelectDefs?? String authCode = request.getParameter(SelectDefs.SEL_authCode); - String authAmount = request.getParameter(SelectDefs.SEL_authAmount); + String authAmount = request.getParameter(SelectDefs.SEL_authAmount); String rawAuthMessage = request.getParameter(SelectDefs.SEL_rawAuthMessage); - + // Need these for create payment service LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - + if (transStatus.equalsIgnoreCase("Y")) { paymentPreference.set("authCode", authCode); paymentPreference.set("statusId", "PAYMENT_RECEIVED"); @@ -254,18 +254,18 @@ } Long transTimeLong = new Long(transTime); java.sql.Timestamp authDate = new java.sql.Timestamp(transTimeLong.longValue()); - + paymentPreference.set("avsCode", avsCode); paymentPreference.set("authRefNum", transId); paymentPreference.set("authDate", authDate); paymentPreference.set("authFlag", transStatus); paymentPreference.set("authMessage", rawAuthMessage); paymentPreference.set("maxAmount", new BigDecimal(authAmount)); - + // create a payment record too -- this method does not store the object so we must here Map results = null; try { - results = dispatcher.runSync("createPaymentFromPreference", UtilMisc.toMap("userLogin", userLogin, + results = dispatcher.runSync("createPaymentFromPreference", UtilMisc.toMap("userLogin", userLogin, "orderPaymentPreferenceId", paymentPreference.get("orderPaymentPreferenceId"), "comments", "Payment received via WorldPay")); } catch (GenericServiceException e) { Debug.logError(e, "Failed to execute service createPaymentFromPreference", module); @@ -278,24 +278,24 @@ request.setAttribute("_ERROR_MESSAGE_", (String) results.get(ModelService.ERROR_MESSAGE)); return false; } - + try { paymentPreference.store(); paymentPreference.getDelegator().create(paymentPreference); } catch (GenericEntityException e) { Debug.logError(e, "Cannot set payment preference/payment info", module); return false; - } - return true; - } - + } + return true; + } + private void callError(ServletRequest request) throws ServletException { Enumeration e = request.getParameterNames(); Debug.logError("###### SelectRespServlet Error:", module); while (e.hasMoreElements()) { String name = (String) e.nextElement(); String value = request.getParameter(name); - Debug.logError("### Parameter: " + name + " => " + value, module); + Debug.logError("### Parameter: " + name + " => " + value, module); } Debug.logError("###### The order was not processed!", module); throw new ServletException("Order Error"); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java?rev=757093&r1=757092&r2=757093&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java Sat Mar 21 23:44:59 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -53,27 +53,27 @@ * WorldPay Select Pro Events/Services */ public class WorldPayEvents { - + public static final String module = WorldPayEvents.class.getName(); - + public static String worldPayRequest(HttpServletRequest request, HttpServletResponse response) { ServletContext application = ((ServletContext) request.getAttribute("servletContext")); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); - + // we need the websiteId for the correct properties file String webSiteId = CatalogWorker.getWebSiteId(request); - + // get the orderId from the request, stored by previous event(s) String orderId = (String) request.getAttribute("orderId"); - + if (orderId == null) { Debug.logError("Problems getting orderId, was not found in request", module); request.setAttribute("_ERROR_MESSAGE_", "<li>OrderID not found, please contact customer service."); return "error"; } - + // get the order header for total and other information GenericValue orderHeader = null; try { @@ -83,29 +83,29 @@ request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting order information, please contact customer service."); return "error"; } - + // get the contact address to pass over GenericValue contactAddress = null; try { List addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "BILLING_LOCATION")); if (addresses.size() == 0) addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "SHIPPING_LOCATION")); - GenericValue contactMech = EntityUtil.getFirst(addresses); - contactAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", contactMech.getString("contactMechId"))); + GenericValue contactMech = EntityUtil.getFirst(addresses); + contactAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", contactMech.getString("contactMechId"))); } catch (GenericEntityException e) { Debug.logWarning(e, "Problems getting order contact information", module); } - + // get the country geoID GenericValue countryGeo = null; if (contactAddress != null) { try { countryGeo = contactAddress.getRelatedOne("CountryGeo"); } catch (GenericEntityException e) { - Debug.logWarning(e, "Problems getting country geo entity", module); + Debug.logWarning(e, "Problems getting country geo entity", module); } } - + // string of customer's name String name = null; if (contactAddress != null) { @@ -114,72 +114,72 @@ else if (contactAddress.get("toName") != null && contactAddress.getString("toName").length() > 0) name = contactAddress.getString("toName"); } - + // build an address string StringBuffer address = null; if (contactAddress != null) { address = new StringBuffer(); - if (contactAddress.get("address1") != null) { + if (contactAddress.get("address1") != null) { address.append(contactAddress.getString("address1").trim()); } if (contactAddress.get("address2") != null) { if (address.length() > 0) address.append(" "); - address.append(contactAddress.getString("address2").trim()); + address.append(contactAddress.getString("address2").trim()); } if (contactAddress.get("city") != null) { if (address.length() > 0) address.append(" "); - address.append(contactAddress.getString("city").trim()); + address.append(contactAddress.getString("city").trim()); } if (contactAddress.get("stateProvinceGeoId") != null) { if (contactAddress.get("city") != null) address.append(", "); address.append(contactAddress.getString("stateProvinceGeoId").trim()); - } + } } - + // get the telephone number to pass over String phoneNumber = null; - GenericValue phoneContact = null; - + GenericValue phoneContact = null; + // get the email address to pass over String emailAddress = null; GenericValue emailContact = null; try { List emails = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "ORDER_EMAIL")); GenericValue firstEmail = EntityUtil.getFirst(emails); - emailContact = delegator.findByPrimaryKey("ContactMech", UtilMisc.toMap("contactMechId", firstEmail.getString("contactMechId"))); + emailContact = delegator.findByPrimaryKey("ContactMech", UtilMisc.toMap("contactMechId", firstEmail.getString("contactMechId"))); emailAddress = emailContact.getString("infoString"); } catch (GenericEntityException e) { Debug.logWarning(e, "Problems getting order email address", module); } - + // get the product store GenericValue productStore = null; try { productStore = orderHeader.getRelatedOne("ProductStore"); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductStore from OrderHeader", module); - + } if (productStore == null) { Debug.logError("ProductStore is null", module); request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting merchant configuration, please contact customer service."); return "error"; } - - // get the payment properties file + + // get the payment properties file GenericValue paymentConfig = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStore.getString("productStoreId"), "EXT_WORLDPAY", null, true); String configString = null; if (paymentConfig != null) { - configString = paymentConfig.getString("paymentPropertiesPath"); + configString = paymentConfig.getString("paymentPropertiesPath"); } - + if (configString == null) { configString = "payment.properties"; } - + String instId = UtilProperties.getPropertyValue(configString, "payment.worldpay.instId", "NONE"); String authMode = UtilProperties.getPropertyValue(configString, "payment.worldpay.authMode", "A"); String testMode = UtilProperties.getPropertyValue(configString, "payment.worldpay.testMode", "100"); @@ -188,20 +188,20 @@ String confirmTemplate = UtilProperties.getPropertyValue(configString, "payment.worldpay.confirmTemplate", ""); String timeout = UtilProperties.getPropertyValue(configString, "payment.worldpay.timeout", "0"); String company = UtilFormatOut.checkEmpty(productStore.getString("companyName"), ""); - String defCur = UtilFormatOut.checkEmpty(productStore.getString("defaultCurrencyUomId"), "USD"); - + String defCur = UtilFormatOut.checkEmpty(productStore.getString("defaultCurrencyUomId"), "USD"); + // order description String description = "Order #" + orderId; if (company != null && company.length() > 0) description = description + " from " + company; - + // check the instId - very important if (instId == null || instId.equals("NONE")) { Debug.logError("Worldpay InstId not found, cannot continue", module); request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting merchant configuration, please contact customer service."); return "error"; - } - + } + int instIdInt = 0; try { instIdInt = Integer.parseInt(instId); @@ -210,7 +210,7 @@ request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting merchant configuration, please contact customer service."); return "error"; } - + // check the testMode int testModeInt = -1; if (testMode != null) { @@ -219,9 +219,9 @@ } catch (NumberFormatException nfe) { Debug.logWarning(nfe, "Problems getting the testMode value, setting to 0", module); testModeInt = 0; - } + } } - + // create the purchase link String purchaseURL = null; HTTPURL link = null; @@ -238,11 +238,11 @@ Debug.logError(e, "Problems creating HTTPURL link", module); request.setAttribute("_ERROR_MESSAGE_", "<li>Problem creating link to WorldPay, please contact customer service."); return "error"; - } - + } + // create the currency amount double orderTotal = orderHeader.getDouble("grandTotal").doubleValue(); - CurrencyAmount currencyAmount = null; + CurrencyAmount currencyAmount = null; try { Currency currency = SelectCurrency.getInstanceByISOCode(defCur); currencyAmount = new CurrencyAmount(orderTotal, currency); @@ -251,29 +251,29 @@ request.setAttribute("_ERROR_MESSAGE_", "<li>Merchant Configuration Error, please contact customer service."); return "error"; } - + // create a purchase token - PurchaseToken token = null; + PurchaseToken token = null; try { token = new PurchaseToken(instIdInt, currencyAmount, orderId); } catch (SelectException e) { Debug.logError(e, "Cannot create purchase token", module); } catch (ArgumentException e) { Debug.logError(e, "Cannot create purchase token", module); - } + } if (token == null) { request.setAttribute("_ERROR_MESSAGE_", "<li>Problems creating a purchase token, please contact customer service."); - return "error"; + return "error"; } - - // set the auth/test modes + + // set the auth/test modes try { token.setAuthorisationMode(authMode); } catch (SelectException e) { Debug.logWarning(e, "Problems setting the authorization mode", module); } token.setTestMode(testModeInt); - + // set the token to the purchase link try { linkParms.setValue(SelectDefs.SEL_purchase, token.produce()); @@ -282,16 +282,16 @@ request.setAttribute("_ERROR_MESSAGE_", "<li>Problems producing purchase token, please contact customer service."); return "error"; } - + // set the customer data in the link linkParms.setValue(SelectDefs.SEL_desc, description); linkParms.setValue(SelectDefs.SEL_name, name != null ? name : ""); linkParms.setValue(SelectDefs.SEL_address, address != null ? address.toString() : ""); linkParms.setValue(SelectDefs.SEL_postcode, contactAddress != null ? contactAddress.getString("postalCode") : ""); linkParms.setValue(SelectDefs.SEL_country, countryGeo.getString("geoCode")); - linkParms.setValue(SelectDefs.SEL_tel, phoneNumber != null ? phoneNumber : ""); + linkParms.setValue(SelectDefs.SEL_tel, phoneNumber != null ? phoneNumber : ""); linkParms.setValue(SelectDefs.SEL_email, emailAddress != null ? emailAddress : ""); - + // set some optional data if (fixContact != null && fixContact.toUpperCase().startsWith("Y")) { linkParms.setValue(SelectDefs.SEL_fixContact, "Y"); @@ -299,16 +299,16 @@ if (hideContact != null && hideContact.toUpperCase().startsWith("Y")) { linkParms.setValue("hideContact", "Y"); // why is this not in SelectDefs?? } - + // now set some send-back parameters linkParms.setValue("M_controlPath", (String)request.getAttribute("_CONTROL_PATH_")); - linkParms.setValue("M_userLoginId", userLogin.getString("userLoginId")); + linkParms.setValue("M_userLoginId", userLogin.getString("userLoginId")); linkParms.setValue("M_dispatchName", dispatcher.getName()); - linkParms.setValue("M_delegatorName", delegator.getDelegatorName()); - linkParms.setValue("M_webSiteId", webSiteId); - linkParms.setValue("M_localLocale", UtilHttp.getLocale(request).toString()); + linkParms.setValue("M_delegatorName", delegator.getDelegatorName()); + linkParms.setValue("M_webSiteId", webSiteId); + linkParms.setValue("M_localLocale", UtilHttp.getLocale(request).toString()); linkParms.setValue("M_confirmTemplate", confirmTemplate != null ? confirmTemplate : ""); - + // redirect to worldpay try { response.sendRedirect(link.produce()); @@ -317,7 +317,7 @@ request.setAttribute("_ERROR_MESSAGE_", "<li>Problems connecting with WorldPay, please contact customer service."); return "error"; } - + return "success"; } Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java?rev=757093&r1=757092&r2=757093&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java Sat Mar 21 23:44:59 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -49,14 +49,14 @@ * @return The account ID (glAccountId) found * @throws AccountingException When the no accounts found or an entity exception occurs */ - public static String getProductOrgGlAccountId(String productId, - String glAccountTypeId, String organizationPartyId, GenericDelegator delegator) + public static String getProductOrgGlAccountId(String productId, + String glAccountTypeId, String organizationPartyId, GenericDelegator delegator) throws AccountingException { GenericValue account = null; try { // first try to find the account in ProductGlAccount - account = delegator.findByPrimaryKeyCache("ProductGlAccount", + account = delegator.findByPrimaryKeyCache("ProductGlAccount", UtilMisc.toMap("productId", productId, "glAccountTypeId", glAccountTypeId, "organizationPartyId", organizationPartyId)); } catch (GenericEntityException e) { throw new AccountingException("Failed to find a ProductGLAccount for productId [" + productId + "], organization [" + organizationPartyId + "], and productGlAccountTypeId [" + glAccountTypeId + "].", e); @@ -80,9 +80,9 @@ return account.getString("glAccountId"); } - /** - * As above, but explicitly looking for default account for given type and organization - * + /** + * As above, but explicitly looking for default account for given type and organization + * * @param glAccountTypeId The type of account * @param organizationPartyId The organization of the account * @return The default account ID (glAccountId) for this type @@ -96,7 +96,7 @@ * Little method to figure out the net or ending balance of a GlAccountHistory or GlAccountAndHistory value, based on what kind * of account (DEBIT or CREDIT) it is * @param account - GlAccountHistory or GlAccountAndHistory value - * @return balance - a BigDecimal + * @return balance - a BigDecimal */ public static BigDecimal getNetBalance(GenericValue account, String debugModule) { try { @@ -114,7 +114,7 @@ } else if (isCreditAccount(glAccount)) { balance = account.getBigDecimal("postedCredits").subtract(account.getBigDecimal("postedDebits")); } - return balance; + return balance; } public static List getDescendantGlAccountClassIds(GenericValue glAccountClass) throws GenericEntityException { @@ -153,11 +153,11 @@ /** * Checks if a payment is of a specified PaymentType.paymentTypeId. Return false if payment is null. It's better to use the - * more specific calls like isTaxPayment(). + * more specific calls like isTaxPayment(). */ public static boolean isPaymentType(GenericValue payment, String inputTypeId) throws GenericEntityException { - if (payment == null) { - return false; + if (payment == null) { + return false; } GenericValue paymentType = payment.getRelatedOneCache("PaymentType"); |
Free forum by Nabble | Edit this page |