diff --git a/applications/product/webapp/facility/WEB-INF/actions/shipment/PrintPickSheets.groovy b/applications/product/webapp/facility/WEB-INF/actions/shipment/PrintPickSheets.groovy new file mode 100644 index 0000000000..e44d00b5b1 --- /dev/null +++ b/applications/product/webapp/facility/WEB-INF/actions/shipment/PrintPickSheets.groovy @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * 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 + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.ofbiz.order.order.OrderReadHelper; +import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.util.EntityUtil; + +toPrintOrders = []; +maxNumberOfOrders = parameters.maxNumberOfOrdersToPrint; +int maxNumberOfOrders = maxNumberOfOrders.toInteger(); +int printListCounter = 0; +printGroupName = parameters.printGroupName; +if (printGroupName != null) { + pickMoveInfoList.each { pickMoveInfo -> + groupName = pickMoveInfo.groupName ; + if (groupName == printGroupName) { + toPrintOrders.add(pickMoveInfo.orderReadyToPickInfoList); + } + } +} +else { + pickMoveInfoList.each { pickMoveInfo -> + toPrintOrders.add(pickMoveInfo.orderReadyToPickInfoList); + } +} +if (toPrintOrders) { + orderList = []; + orderInfoList = []; + itemInfoList = []; + orderHeaderList = []; + orderChargeList =[]; + toPrintOrders.each { toPrintOrder -> + if(toPrintOrder) { + orderHeaders = toPrintOrder.orderHeader; + orderItemShipGroups = toPrintOrder.orderItemShipGroup; + orderItemShipGrpInvResList = toPrintOrder.orderItemShipGrpInvResList; + orderItemShipGrpInvResInfoList = toPrintOrder.orderItemShipGrpInvResInfoList; + orderHeaders.each { orderHeader -> + printListCounter = ++printListCounter; + if (printListCounter <= maxNumberOfOrders) { + orderMap = [:]; + orderId = orderHeader.orderId; + orderMap.orderId = orderId; + orderMap.orderDate = orderHeader.orderDate; + billingContactMechId = EntityUtil.getFirst(delegator.findByAnd("OrderContactMech", [orderId : orderId, contactMechPurposeTypeId : "BILLING_LOCATION"])).contactMechId; + billingAddress = delegator.findOne("PostalAddress", [contactMechId : billingContactMechId], false); + shippingContactMechId = EntityUtil.getFirst(delegator.findByAnd("OrderContactMech", [orderId : orderId, contactMechPurposeTypeId : "SHIPPING_LOCATION"])).contactMechId; + shippingAddress = delegator.findOne("PostalAddress", [contactMechId : shippingContactMechId], false); + orderItemShipGroups.each { orderItemShipGroup -> + if (orderItemShipGroup.orderId == orderId) { + orderMap.shipmentMethodTypeId = orderItemShipGroup.shipmentMethodTypeId; + orderMap.carrierPartyId = orderItemShipGroup.carrierPartyId; + orderMap.shipGroupSeqId = orderItemShipGroup.shipGroupSeqId; + orderMap.carrierPartyId = orderItemShipGroup.carrierPartyId; + } + orderMap.shippingAddress = shippingAddress; + orderMap.billingAddress = billingAddress; + orderInfoMap = [:]; + orderInfoMap.(orderHeader.orderId) = orderMap; + } + addInMap = "true"; + orderItemMap = [:]; + orderItemShipGrpInvResInfoList.each { orderItemShipGrpInvResInfos -> + orderItemShipGrpInvResInfos.each { orderItemShipGrpInvResInfo -> + if (orderItemShipGrpInvResInfo.orderItemShipGrpInvRes.orderId == orderId && addInMap == "true") { + orderItemMap.(orderHeader.orderId) = orderItemShipGrpInvResInfos; + addInMap = "false"; + } + } + } + orderChargeMap = [:]; + orderReadHelper = new OrderReadHelper(orderHeader); + orderItems = orderReadHelper.getOrderItems(); + orderAdjustments = orderReadHelper.getAdjustments(); + orderHeaderAdjustments = orderReadHelper.getOrderHeaderAdjustments(); + orderSubTotal = orderReadHelper.getOrderItemsSubTotal(); + otherAdjAmount = orderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, true, false, false); + shippingAmount = orderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, false, true); + shippingAmount = shippingAmount.add(orderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, false, true)); + taxAmount = orderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, true, false); + taxAmount = taxAmount.add(orderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, true, false)); + grandTotal = orderReadHelper.getOrderGrandTotal(orderItems, orderAdjustments); + orderChargeMap.orderSubTotal = orderSubTotal; + orderChargeMap.taxAmount = taxAmount; + orderChargeMap.shippingAmount = shippingAmount; + orderChargeMap.otherAdjAmount = otherAdjAmount; + orderChargeMap.grandTotal = grandTotal; + orderChargeMap.totalItem = orderItems.size(); + orderCharges = [:]; + orderCharges.(orderHeader.orderId) = orderChargeMap; + orderChargeList.add(orderCharges); + itemInfoList.add(orderItemMap); + orderInfoList.add(orderInfoMap); + orderList.add(orderHeader); + context.orderHeaderList = orderList; + context.orderInfoList = orderInfoList; + context.itemInfoList = itemInfoList; + context.orderChargeList = orderChargeList; + } + } + } + } +} \ No newline at end of file diff --git a/applications/product/webapp/facility/facility/PrintPickSheets.fo.ftl b/applications/product/webapp/facility/facility/PrintPickSheets.fo.ftl new file mode 100644 index 0000000000..582a2db6ad --- /dev/null +++ b/applications/product/webapp/facility/facility/PrintPickSheets.fo.ftl @@ -0,0 +1,233 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +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 +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<#escape x as x?xml> + + + + + + + + + + <#list orderHeaderList as order> + + + <#include "component://order/webapp/ordermgr/order/companyHeader.fo.ftl"/> + <#assign orderId = order.orderId> + <#assign orderDate = order.orderDate> + <#list orderInfoList as orderInfo> + <#if orderInfo.get("${orderId}")?exists> + <#assign orderDetail = orderInfo.get("${orderId}")> + <#assign orderDate = orderDetail.orderDate> + <#assign billAddress = orderDetail.billingAddress> + <#assign shipAddress = orderDetail.shippingAddress> + <#assign shipmentMethodTypeId = orderDetail.shipmentMethodTypeId> + <#assign carrierPartyId = orderDetail.carrierPartyId> + <#assign shipGroupSeqId = orderDetail.shipGroupSeqId> + + + + + + 8mm + + + + + + + + + + + + ${uiLabelMap.OrderOrderId}: ${orderId} (${shipGroupSeqId}) + ${uiLabelMap.OrderOrderDate}: ${orderDate} + + + + + + + + + ${uiLabelMap.OrderShipToParty}: + ${shipAddress.toName?if_exists} + ${shipAddress.address1?if_exists} + ${shipAddress.city?if_exists} + ${shipAddress.countryGeoId?if_exists} + ${shipAddress.postalCode?if_exists} + ${shipAddress.postalCodeGeoId?if_exists} + ${shipAddress.stateProvinceGeoId?if_exists} + + + + + + + + ${uiLabelMap.OrderOrderBillToParty}: + ${billAddress.toName?if_exists} + ${billAddress.address1?if_exists} + ${billAddress.city?if_exists} + ${billAddress.countryGeoId?if_exists} + ${billAddress.postalCode?if_exists} + ${billAddress.postalCodeGeoId?if_exists} + ${billAddress.stateProvinceGeoId?if_exists} + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${uiLabelMap.ProductShipmentMethod}: + + + ${carrierPartyId?if_exists}-${shipmentMethodTypeId?if_exists} + + + + + + + + + + + + + + + + + + + + + + ${uiLabelMap.ProductLocation} + ${uiLabelMap.ProductItemId} + ${uiLabelMap.ProductProductName} + ${uiLabelMap.FormFieldTitle_supplierProductId} + ${uiLabelMap.OrderQty} + ${uiLabelMap.OrderUnitPrice} + + <#assign totalQty = 0> + <#list itemInfoList as itemInfo> + <#if itemInfo.get("${orderId}")?exists > + <#assign infoItems = itemInfo.get("${orderId}")> + <#list infoItems as infoItem> + + <#assign orderItemShipGrpInvRes = infoItem.orderItemShipGrpInvRes> + <#assign orderProduct = orderItemShipGrpInvRes.getRelatedOne("OrderItem").getRelatedOne("Product")?if_exists> + <#assign supplierProduct = Static["org.ofbiz.entity.util.EntityUtil"].getFirst(orderProduct.getRelated("SupplierProduct"))?if_exists> + <#assign inventoryItem = infoItem.inventoryItem> + <#if infoItem.facilityLocation?has_content> + <#assign facilityLocation = infoItem.facilityLocation> + ${facilityLocation.locationSeqId?if_exists} + <#else> + + + ${orderProduct.productId} + ${orderProduct.internalName?if_exists} + <#if supplierProduct?has_content > + ${supplierProduct.supplierProductId?if_exists} + <#else> + + + <#assign quantity = Static["java.lang.Integer"].parseInt("${orderItemShipGrpInvRes.quantity}")/> + <#assign totalQty = totalQty + quantity> + ${orderItemShipGrpInvRes.quantity?if_exists} + ${inventoryItem.unitCost?if_exists} + + + + + + + + + + + + + + <#list orderChargeList as orderCharge> + <#if orderCharge.get("${orderId}")?exists > + <#assign charges = orderCharge.get("${orderId}")> + + ${uiLabelMap.OrderSubTotal}: + <@ofbizCurrency amount=charges.orderSubTotal isoCode=currencyUomId/> + + + ${uiLabelMap.OrderSalesTax}: + <@ofbizCurrency amount=charges.taxAmount isoCode=currencyUomId/> + + + ${uiLabelMap.OrderShippingAndHandling}: + <@ofbizCurrency amount=charges.shippingAmount isoCode=currencyUomId/> + + + ${uiLabelMap.OrderTotalOtherOrderAdjustments}: + <@ofbizCurrency amount=charges.otherAdjAmount isoCode=currencyUomId/> + + + ${uiLabelMap.OrderGrandTotal}: + <@ofbizCurrency amount=charges.grandTotal isoCode=currencyUomId/> + + + ${uiLabelMap.OrderPickedBy}: ______________ + + + ${uiLabelMap.OrderTotalNoOfItems}: ${totalQty} + + + + + + + + + + + \ No newline at end of file