📄 orderview.bsh
字号:
/* * Copyright (c) 2003-2005 The Open For Business Project - www.ofbiz.org * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * *@author Andy Zeneski (jaz@ofbiz.org) *@version $Rev: 7352 $ *@since 2.2 */import java.util.*;import java.sql.Timestamp;import org.ofbiz.entity.*;import org.ofbiz.entity.condition.*;import org.ofbiz.entity.util.*;import org.ofbiz.base.util.*;import org.ofbiz.base.util.collections.*;import org.ofbiz.order.order.*;import org.ofbiz.party.contact.*;orderId = parameters.get("orderId");context.put("orderId", orderId);workEffortId = parameters.get("workEffortId");assignPartyId = parameters.get("partyId");assignRoleTypeId = parameters.get("roleTypeId");fromDate = parameters.get("fromDate");delegate = parameters.get("delegate");if (delegate != null && parameters.get("toFromDate") != null) { fromDate = parameters.get("toFromDate");}context.put("workEffortId", workEffortId);context.put("assignPartyId", assignPartyId);context.put("assignRoleTypeId", assignRoleTypeId);context.put("fromDate", fromDate);context.put("delegate", delegate);context.put("toDayDate", (new java.sql.Date(System.currentTimeMillis())).toString());orderHeader = null;if (orderId != null && orderId.length() > 0) { orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));}if (orderHeader != null) { // note these are overridden in the orderviewwebsecure.bsh script if run context.put("hasPermission", true); context.put("canViewInternalDetails", true); orderReadHelper = new OrderReadHelper(orderHeader); orderItems = orderReadHelper.getValidOrderItems(); orderAdjustments = orderReadHelper.getAdjustments(); orderHeaderAdjustments = orderReadHelper.getOrderHeaderAdjustments(); orderSubTotal = orderReadHelper.getOrderItemsSubTotal(); orderTerms = orderHeader.getRelated("OrderTerm"); context.put("orderHeader", orderHeader); context.put("orderReadHelper", orderReadHelper); context.put("orderItems", orderItems); context.put("orderAdjustments", orderAdjustments); context.put("orderHeaderAdjustments", orderHeaderAdjustments); context.put("orderSubTotal", orderSubTotal); context.put("currencyUomId", orderReadHelper.getCurrency()); context.put("orderTerms",orderTerms); // get the order type orderType = orderHeader.getString("orderTypeId"); context.put("orderType", orderType); // get the display party displayParty = null; if ("PURCHASE_ORDER".equals(orderType)) { displayParty = orderReadHelper.getSupplierAgent(); } else { displayParty = orderReadHelper.getPlacingParty(); } if (displayParty != null) { partyId = displayParty.getString("partyId"); context.put("displayParty", displayParty); context.put("partyId", partyId); } otherAdjAmount = OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, true, false, false); context.put("otherAdjAmount", otherAdjAmount); shippingAmount = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, false, true); shippingAmount += OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, false, true); context.put("shippingAmount", shippingAmount); taxAmount = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, true, false); taxAmount += OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, true, false); context.put("taxAmount", taxAmount); grandTotal = OrderReadHelper.getOrderGrandTotal(orderItems, orderAdjustments); context.put("grandTotal", grandTotal); orderItemList = orderReadHelper.getOrderItems(); context.put("orderItemList", orderItemList); shippingAddress = orderReadHelper.getShippingAddress(); context.put("shippingAddress", shippingAddress); billingAddress = orderReadHelper.getBillingAddress(); context.put("billingAddress", billingAddress); distributorId = orderReadHelper.getDistributorId(); context.put("distributorId", distributorId); affiliateId = orderReadHelper.getAffiliateId(); context.put("affiliateId", affiliateId); billingAccount = orderHeader.getRelatedOne("BillingAccount"); context.put("billingAccount", billingAccount); // get a list of all shipments, and a list of ItemIssuances per order item allShipmentsMap = new HashMap(); primaryShipments = orderHeader.getRelated("PrimaryShipment"); primaryShipmentIter = primaryShipments.iterator(); while (primaryShipmentIter.hasNext()) { primaryShipment = primaryShipmentIter.next(); allShipmentsMap.put(primaryShipment.get("shipmentId"), primaryShipment); } itemIssuancesPerItem = new HashMap(); itemIssuances = orderHeader.getRelated("ItemIssuance", null, UtilMisc.toList("shipmentId", "shipmentItemSeqId")); itemIssuanceIter = itemIssuances.iterator(); while (itemIssuanceIter.hasNext()) { itemIssuance = itemIssuanceIter.next(); if (!allShipmentsMap.containsKey(itemIssuance.get("shipmentId"))) { iiShipment = itemIssuance.getRelatedOne("Shipment"); if (iiShipment != null) { allShipmentsMap.put(iiShipment.get("shipmentId"), iiShipment); } } perItemList = itemIssuancesPerItem.get(itemIssuance.get("orderItemSeqId")); if (perItemList == null) { perItemList = new LinkedList(); itemIssuancesPerItem.put(itemIssuance.get("orderItemSeqId"), perItemList); } perItemList.add(itemIssuance); } context.put("allShipments", allShipmentsMap.values()); context.put("itemIssuancesPerItem", itemIssuancesPerItem); // get a list of all invoices allInvoices = new OrderedSet(); orderBilling = delegator.findByAnd("OrderItemBilling", UtilMisc.toMap("orderId", orderId), UtilMisc.toList("invoiceId")); obIter = orderBilling.iterator(); while (obIter.hasNext()) { billingGv = obIter.next(); allInvoices.add(billingGv.getString("invoiceId")); } context.put("invoices", allInvoices); oppFields = UtilMisc.toList(new EntityExpr("orderId", EntityOperator.EQUALS, orderId), new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "PAYMENT_CANCELLED")); orderPaymentPreferences = delegator.findByAnd("OrderPaymentPreference", oppFields); context.put("orderPaymentPreferences", orderPaymentPreferences); // ship groups shipGroups = delegator.findByAnd("OrderItemShipGroup", UtilMisc.toMap("orderId", orderId), UtilMisc.toList("shipGroupSeqId")); context.put("shipGroups", shipGroups); // get Shipment tracking info osisCond = new EntityFieldMap(UtilMisc.toMap("orderId", orderId), EntityOperator.AND); osisOrder = UtilMisc.toList("shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId"); osisFields = UtilMisc.toList("shipGroupSeqId", "shipmentId", "shipmentRouteSegmentId", "carrierPartyId", "shipmentMethodTypeId"); osisFields.add("shipmentPackageSeqId"); osisFields.add("trackingCode"); osisFields.add("boxNumber"); osisFindOptions = new EntityFindOptions(); osisFindOptions.setDistinct(true); orderShipmentInfoSummaryList = delegator.findByCondition("OrderShipmentInfoSummary", osisCond, null, osisFields, osisOrder, osisFindOptions); context.put("orderShipmentInfoSummaryList", orderShipmentInfoSummaryList); customerPoNumber = null; orderItemPOIter = UtilMisc.toIterator(orderItemList); if (orderItemPOIter != null && orderItemPOIter.hasNext()) { customerPoNumber = ((GenericValue)orderItemPOIter.next()).getString("correspondingPoId"); } context.put("customerPoNumber", customerPoNumber); statusChange = delegator.findByAnd("StatusValidChange",UtilMisc.toMap("statusId",orderHeader.getString("statusId")));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -