Author: hansbak
Date: Wed Apr 7 03:55:50 2010 New Revision: 931423 URL: http://svn.apache.org/viewvc?rev=931423&view=rev Log: Ebaystore: Add field require inventory in export Product screen to update qty of product in ofbiz inventory system when user checked at this field. Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java?rev=931423&r1=931422&r2=931423&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java (original) +++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java Wed Apr 7 03:55:50 2010 @@ -18,6 +18,7 @@ */ package org.ofbiz.ebaystore; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -783,7 +784,33 @@ public class EbayEvents { storeFront.setStoreCategory2ID(new Long(requestParams.get("ebayStore2Category").toString())); attributeMapList.put("StoreCategory2ID", requestParams.get("ebayStore2Category").toString()); } - item.setStorefront(storeFront); + if (UtilValidate.isNotEmpty(requestParams.get("ebayStore1Category")) || UtilValidate.isNotEmpty(requestParams.get("ebayStore2Category"))) { + item.setStorefront(storeFront); + } + if (UtilValidate.isNotEmpty(requestParams.get("requireEbayInventory")) && "Y".equals(requestParams.get("requireEbayInventory").toString())) { + GenericValue ebayProductStore = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("EbayProductStoreInventory", UtilMisc.toMap("productStoreId", productStoreId, "productId", productId)))); + if (UtilValidate.isNotEmpty(ebayProductStore)) { + String facilityId = ebayProductStore.getString("facilityId"); + BigDecimal atp = ebayProductStore.getBigDecimal("availableToPromiseListing"); + int intAtp = atp.intValue(); + if ((facilityId != "") && (intAtp != 0)) { + int newAtp = intAtp - 1; + Map<String,Object> inMap = FastMap.newInstance(); + inMap.put("productStoreId", productStoreId); + inMap.put("facilityId", facilityId); + inMap.put("productId", productId); + inMap.put("availableToPromiseListing", new BigDecimal(newAtp)); + inMap.put("userLogin", userLogin); + try { + dispatcher.runSync("updateEbayProductStoreInventory", inMap); + } catch (GenericServiceException ex) { + Debug.logError(ex.getMessage(), module); + return "error"; + } + itemObj.put("requireEbayInventory", "Y"); + } + } + } addItemCall.setItem(item); // create/update EbayProductListing entity Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java?rev=931423&r1=931422&r2=931423&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java (original) +++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java Wed Apr 7 03:55:50 2010 @@ -20,6 +20,7 @@ package org.ofbiz.ebaystore; import java.io.IOException; +import java.math.BigDecimal; import java.sql.Timestamp; import java.util.Date; import java.util.List; @@ -40,10 +41,12 @@ import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; +import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.serialize.SerializeException; import org.ofbiz.entity.serialize.XmlSerializer; +import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -719,5 +722,22 @@ public class EbayStoreHelper { Debug.log("Error from create error log messages : "+ex.getMessage()); } } - } + } + + public static boolean isReserveInventory(GenericDelegator delegator, String productId, String productStoreId) { + boolean isReserve = false; + try { + GenericValue ebayProductStore = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("EbayProductStoreInventory", UtilMisc.toMap("productStoreId", productStoreId, "productId", productId)))); + if (UtilValidate.isNotEmpty(ebayProductStore)) { + BigDecimal atp = ebayProductStore.getBigDecimal("availableToPromiseListing"); + int intAtp = atp.intValue(); + if (intAtp > 0) { + isReserve = true; + } + } + } catch (Exception ex) { + Debug.log("Error from get eBay Inventory data : "+ ex.getMessage()); + } + return isReserve; + } } Modified: ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy?rev=931423&r1=931422&r2=931423&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy (original) +++ ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy Wed Apr 7 03:55:50 2010 @@ -27,6 +27,7 @@ import org.ofbiz.product.product.ProductWorker; import org.ofbiz.product.product.ProductContentWrapper; import org.ofbiz.product.catalog.*; + import org.ofbiz.ebaystore.EbayStoreHelper; import com.ebay.sdk.ApiContext; import com.ebay.sdk.call.AddItemCall; import com.ebay.soap.eBLBaseComponents.ItemType; @@ -73,6 +74,8 @@ request.setAttribute("productStoreId", productStoreId); categories = EbayEvents.getChildCategories(request); context.categories = categories; + + // point product tab id productId = null; if (request.getAttribute("isProductId") || parameters.isProductId) { @@ -87,6 +90,9 @@ if (productPrices) { context.productPrices = productPrices; } + //Is it reserve on eBayInventory + isReserve = EbayStoreHelper.isReserveInventory(delegator, productStoreId, productId); + context.isReserve = isReserve; // get category detail pkCateId = null; stCate1ID = null; Modified: ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl?rev=931423&r1=931422&r2=931423&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl (original) +++ ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl Wed Apr 7 03:55:50 2010 @@ -225,6 +225,7 @@ under the License. <#assign addItem = addItemObj.addItemCall?if_exists> <#assign isSaved = addItemObj.isSaved?if_exists> <#assign isAutoRelist = addItemObj.isAutoRelist?if_exists> + <#assign requireEbayInventory = addItemObj.requireEbayInventory?if_exists> <#assign item = addItem.getItem()?if_exists> <#assign primaryCate = item.getPrimaryCategory()?if_exists> <#if isProductId == item.getSKU()?if_exists> @@ -409,6 +410,12 @@ under the License. <td class="label"><b>Enable auto-relist item</b></td> <td><input type="checkbox" name="isAutoRelist" value="Y" <#if isAutoRelist == "Y">checked="checked"</#if>/></td> </tr> + <#if isReserve?exists && isReserve == true> + <tr> + <td class="label"><b>Require eBay Inventory</b></td> + <td><input type="checkbox" name="requireEbayInventory" value="Y" <#if requireEbayInventory == "Y">checked="checked"</#if>/></td> + </tr> + </#if> <tr> <td class="label"></td> <td><br /></td> |
Free forum by Nabble | Edit this page |