📄 orderreadhelper.java
字号:
return null; } } else { return this.getPartyFromRole("BILL_FROM_VENDOR"); } } /** * Returns party from OrderRole of SHIP_TO_CUSTOMER */ public GenericValue getShipToParty() { return this.getPartyFromRole("SHIP_TO_CUSTOMER"); } /** * Returns party from OrderRole of PLACING_CUSTOMER */ public GenericValue getPlacingParty() { return this.getPartyFromRole("PLACING_CUSTOMER"); } /** * Returns party from OrderRole of END_USER_CUSTOMER */ public GenericValue getEndUserParty() { return this.getPartyFromRole("END_USER_CUSTOMER"); } /** * Returns party from OrderRole of SUPPLIER_AGENT */ public GenericValue getSupplierAgent() { return this.getPartyFromRole("SUPPLIER_AGENT"); } public GenericValue getPartyFromRole(String roleTypeId) { GenericDelegator delegator = orderHeader.getDelegator(); GenericValue partyObject = null; try { GenericValue orderRole = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderRole", UtilMisc.toMap("roleTypeId", roleTypeId))); if (orderRole != null) { partyObject = delegator.findByPrimaryKey("Person", UtilMisc.toMap("partyId", orderRole.getString("partyId"))); if (partyObject == null) { partyObject = delegator.findByPrimaryKey("PartyGroup", UtilMisc.toMap("partyId", orderRole.getString("partyId"))); } } } catch (GenericEntityException e) { Debug.logError(e, module); } return partyObject; } public String getDistributorId() { try { GenericEntity distributorRole = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderRole", UtilMisc.toMap("roleTypeId", "DISTRIBUTOR"))); return distributorRole == null ? null : distributorRole.getString("partyId"); } catch (GenericEntityException e) { Debug.logWarning(e, module); } return null; } public String getAffiliateId() { try { GenericEntity distributorRole = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderRole", UtilMisc.toMap("roleTypeId", "AFFILIATE"))); return distributorRole == null ? null : distributorRole.getString("partyId"); } catch (GenericEntityException e) { Debug.logWarning(e, module); } return null; } public BigDecimal getShippingTotalBd() { return OrderReadHelper.calcOrderAdjustmentsBd(getOrderHeaderAdjustments(), getOrderItemsSubTotalBd(), false, false, true); } /** @deprecated Use getShippingTotalBd() instead */ public double getShippingTotal() { return getShippingTotalBd().doubleValue(); } public BigDecimal getHeaderTaxTotalBd() { return OrderReadHelper.calcOrderAdjustmentsBd(getOrderHeaderAdjustments(), getOrderItemsSubTotalBd(), false, true, false); } /** @deprecated Use getHeaderTaxTotalBd() instead */ public double getHeaderTaxTotal() { return getHeaderTaxTotalBd().doubleValue(); } public BigDecimal getTaxTotalBd() { return OrderReadHelper.calcOrderAdjustmentsBd(getAdjustments(), getOrderItemsSubTotalBd(), false, true, false); } /** @deprecated Use getTaxTotalBd() instead */ public double getTaxTotal() { return getTaxTotalBd().doubleValue(); } public Set getItemFeatureSet(GenericValue item) { Set featureSet = new ListOrderedSet(); List featureAppls = null; if (item.get("productId") != null) { try { featureAppls = item.getDelegator().findByAndCache("ProductFeatureAppl", UtilMisc.toMap("productId", item.getString("productId"))); List filterExprs = UtilMisc.toList(new EntityExpr("productFeatureApplTypeId", EntityOperator.EQUALS, "STANDARD_FEATURE")); filterExprs.add(new EntityExpr("productFeatureApplTypeId", EntityOperator.EQUALS, "REQUIRED_FEATURE")); featureAppls = EntityUtil.filterByOr(featureAppls, filterExprs); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductFeatureAppl for item : " + item, module); } if (featureAppls != null) { Iterator fai = featureAppls.iterator(); while (fai.hasNext()) { GenericValue appl = (GenericValue) fai.next(); featureSet.add(appl.getString("productFeatureId")); } } } // get the ADDITIONAL_FEATURE adjustments List additionalFeatures = null; try { additionalFeatures = item.getRelatedByAnd("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "ADDITIONAL_FEATURE")); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get OrderAdjustment from item : " + item, module); } if (additionalFeatures != null) { Iterator afi = additionalFeatures.iterator(); while (afi.hasNext()) { GenericValue adj = (GenericValue) afi.next(); String featureId = adj.getString("productFeatureId"); if (featureId != null) { featureSet.add(featureId); } } } return featureSet; } public Map getFeatureIdQtyMap(String shipGroupSeqId) { Map featureMap = new HashMap(); List validItems = getValidOrderItems(shipGroupSeqId); if (validItems != null) { Iterator i = validItems.iterator(); while (i.hasNext()) { GenericValue item = (GenericValue) i.next(); List featureAppls = null; if (item.get("productId") != null) { try { featureAppls = item.getDelegator().findByAndCache("ProductFeatureAppl", UtilMisc.toMap("productId", item.getString("productId"))); List filterExprs = UtilMisc.toList(new EntityExpr("productFeatureApplTypeId", EntityOperator.EQUALS, "STANDARD_FEATURE")); filterExprs.add(new EntityExpr("productFeatureApplTypeId", EntityOperator.EQUALS, "REQUIRED_FEATURE")); featureAppls = EntityUtil.filterByOr(featureAppls, filterExprs); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductFeatureAppl for item : " + item, module); } if (featureAppls != null) { Iterator fai = featureAppls.iterator(); while (fai.hasNext()) { GenericValue appl = (GenericValue) fai.next(); Double lastQuantity = (Double) featureMap.get(appl.getString("productFeatureId")); if (lastQuantity == null) { lastQuantity = new Double(0); } Double newQuantity = new Double(lastQuantity.doubleValue() + getOrderItemQuantity(item).doubleValue()); featureMap.put(appl.getString("productFeatureId"), newQuantity); } } } // get the ADDITIONAL_FEATURE adjustments List additionalFeatures = null; try { additionalFeatures = item.getRelatedByAnd("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "ADDITIONAL_FEATURE")); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get OrderAdjustment from item : " + item, module); } if (additionalFeatures != null) { Iterator afi = additionalFeatures.iterator(); while (afi.hasNext()) { GenericValue adj = (GenericValue) afi.next(); String featureId = adj.getString("productFeatureId"); if (featureId != null) { Double lastQuantity = (Double) featureMap.get(featureId); if (lastQuantity == null) { lastQuantity = new Double(0); } Double newQuantity = new Double(lastQuantity.doubleValue() + getOrderItemQuantity(item).doubleValue()); featureMap.put(featureId, newQuantity); } } } } } return featureMap; } public boolean shippingApplies() { boolean shippingApplies = false; List validItems = this.getValidOrderItems(); if (validItems != null) { Iterator i = validItems.iterator(); while (i.hasNext()) { GenericValue item = (GenericValue) i.next(); GenericValue product = null; try { product = item.getRelatedOne("Product"); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting Product from OrderItem; returning 0", module); } if (product != null) { if (ProductWorker.shippingApplies(product)) { shippingApplies = true; break; } } } } return shippingApplies; } public boolean taxApplies() { boolean taxApplies = false; List validItems = this.getValidOrderItems(); if (validItems != null) { Iterator i = validItems.iterator(); while (i.hasNext()) { GenericValue item = (GenericValue) i.next(); GenericValue product = null; try { product = item.getRelatedOne("Product"); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting Product from OrderItem; returning 0", module); } if (product != null) { if (ProductWorker.taxApplies(product)) { taxApplies = true; break; } } } } return taxApplies; } public BigDecimal getShippableTotalBd(String shipGroupSeqId) { BigDecimal shippableTotal = ZERO; List validItems = getValidOrderItems(shipGroupSeqId); if (validItems != null) { Iterator i = validItems.iterator(); while (i.hasNext()) { GenericValue item = (GenericValue) i.next(); GenericValue product = null; try { product = item.getRelatedOne("Product"); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting Product from OrderItem; returning 0", module); return ZERO; } if (product != null) { if (ProductWorker.shippingApplies(product)) { shippableTotal = shippableTotal.add(OrderReadHelper.getOrderItemSubTotalBd(item, getAdjustments(), false, true)).setScale(scale, rounding); } } } } return shippableTotal.setScale(scale, rounding); } /** @deprecated Use getShippableTotalBd() instead */ public double getShippableTotal(String shipGroupSeqId) { return getShippableTotalBd(shipGroupSeqId).doubleValue(); } public BigDecimal getShippableQuantityBd(String shipGroupSeqId) { BigDecimal shippableQuantity = ZERO; List validItems = getValidOrderItems(shipGroupSeqId); if (validItems != null) { Iterator i = validItems.iterator(); while (i.hasNext()) { GenericValue item = (GenericValue) i.next(); GenericValue product = null; try { product = item.getRelatedOne("Product"); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting Product from OrderItem; returning 0", module); return ZERO; } if (product != null) { if (ProductWorker.shippingApplies(product)) { shippableQuantity =shippableQuantity.add(getOrderItemQuantityBd(item)).setScale(scale, rounding); } } } } return shippableQuantity.setScale(scale, rounding); } /** @deprecated Use getShippableQuantityBd() instead */ public double getShippableQuantity(String shipGroupSeqId) { return getShippableQuantityBd(shipGroupSeqId).doubleValue(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -