Exemplo n.º 1
0
        public virtual IEnumerable orders()
        {
            PXUIFieldAttribute.SetDisplayName <SOShipment.shipVia_Carrier_description>(Caches[typeof(SOShipment)], Messages.CarrierDescr);
            PXUIFieldAttribute.SetDisplayName <SOShipment.siteID_INSite_descr>(Caches[typeof(SOShipment)], Messages.SiteDescr);
            PXUIFieldAttribute.SetDisplayName <SOShipment.customerID>(Caches[typeof(SOShipment)], Messages.CustomerID);

            SOShipmentFilter filter = Filter.Current;

            if (filter.Action == "<SELECT>")
            {
                yield break;
            }

            string actionID = (string)Orders.GetTargetFill(null, null, null, filter.Action, "@actionID");

            if (_ActionChanged)
            {
                Orders.Cache.Clear();
            }

            foreach (SOShipment order in Orders.Cache.Updated)
            {
                yield return(order);
            }

            PXSelectBase cmd;

            switch (actionID)
            {
            case "2":
                cmd = new PXSelectJoinGroupBy <SOShipment,
                                               LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                         InnerJoin <SOShipLine, On <SOShipLine.shipmentNbr, Equal <SOShipment.shipmentNbr> >,
                                                                    InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOShipLine.origOrderType>, And <SOOrder.orderNbr, Equal <SOShipLine.origOrderNbr> > >,
                                                                               InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOShipLine.origOrderType> >,
                                                                                          InnerJoin <SOOrderTypeOperation,
                                                                                                     On <SOOrderTypeOperation.orderType, Equal <SOShipLine.origOrderType>,
                                                                                                         And <SOOrderTypeOperation.operation, Equal <SOShipment.operation> > >,
                                                                                                     InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                                                                LeftJoin <ARTran, On <ARTran.sOShipmentNbr, Equal <SOShipLine.shipmentNbr>, And <ARTran.sOShipmentType, NotEqual <SOShipmentType.dropShip>, And <ARTran.sOShipmentLineNbr, Equal <SOShipLine.lineNbr> > > > > > > > > > >,
                                               Where <SOShipment.confirmed, Equal <boolTrue>,
                                                      And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                           And <ARTran.refNbr, IsNull,
                                                                And <Match <INSite, Current <AccessInfo.userName> > > > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.insurance,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;

            case "3":
                cmd = new PXSelectJoinGroupBy <SOShipment,
                                               LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                         InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                    InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >,
                                                                               InnerJoin <SOShipLine, On <SOShipLine.shipmentType, Equal <SOOrderShipment.shipmentType>, And <SOShipLine.shipmentNbr, Equal <SOOrderShipment.shipmentNbr>, And <SOShipLine.origOrderType, Equal <SOOrderShipment.orderType>, And <SOShipLine.origOrderNbr, Equal <SOOrderShipment.orderNbr> > > > >,
                                                                                          InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOShipLine.origOrderType>, And <SOOrder.orderNbr, Equal <SOShipLine.origOrderNbr> > >,
                                                                                                     InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> > > > > > > >,
                                               Where <SOShipment.confirmed, Equal <boolTrue>,
                                                      And <SOOrderShipment.invtRefNbr, IsNull,
                                                           And <SOShipLine.lineType, Equal <SOLineType.inventory>,
                                                                And <SOOrderType.iNDocType, NotEqual <INTranType.noUpdate>,
                                                                     And <Match <INSite, Current <AccessInfo.userName> > > > > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;

            case "6":
                cmd = new PXSelectJoinGroupBy <POReceipt,
                                               CrossJoin <SOOrder,
                                                          InnerJoin <POReceiptLine, On <POReceiptLine.receiptNbr, Equal <POReceipt.receiptNbr> >,
                                                                     InnerJoin <SOLine, On <SOLine.pOType, Equal <POReceiptLine.pOType>, And <SOLine.pONbr, Equal <POReceiptLine.pONbr>, And <SOLine.pOLineNbr, Equal <POReceiptLine.pOLineNbr>, And <SOLine.orderType, Equal <SOOrder.orderType>, And <SOLine.orderNbr, Equal <SOOrder.orderNbr> > > > > >,
                                                                                LeftJoin <ARTran, On <ARTran.sOShipmentNbr, Equal <POReceiptLine.receiptNbr>, And <ARTran.sOShipmentType, Equal <SOShipmentType.dropShip>, And <ARTran.sOShipmentLineNbr, Equal <POReceiptLine.lineNbr>, And <ARTran.sOOrderType, Equal <SOLine.orderType>, And <ARTran.sOOrderNbr, Equal <SOLine.orderNbr>, And <ARTran.sOOrderLineNbr, Equal <SOLine.lineNbr> > > > > > >,
                                                                                          InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOLine.orderType> >,
                                                                                                     InnerJoin <SOOrderTypeOperation,
                                                                                                                On <SOOrderTypeOperation.orderType, Equal <SOOrder.orderType>,
                                                                                                                    And <SOOrderTypeOperation.operation, Equal <SOLine.operation> > > > > > > > >,
                                               Where <POReceipt.released, Equal <boolTrue>,
                                                      And2 <Where <POReceiptLine.lineType, Equal <POLineType.goodsForDropShip>, Or <POReceiptLine.lineType, Equal <POLineType.nonStockForDropShip> > >,
                                                            And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                                 And <ARTran.refNbr, IsNull> > > >,
                                               Aggregate <GroupBy <POReceipt.receiptNbr,
                                                                   GroupBy <POReceipt.createdByID,
                                                                            GroupBy <POReceipt.lastModifiedByID,
                                                                                     GroupBy <POReceipt.released,
                                                                                              GroupBy <POReceipt.ownerID,
                                                                                                       GroupBy <POReceipt.hold> > > > > > > >(this);
                break;

            case "9":
                cmd = new PXSelectJoinGroupBy <SOShipment, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                      LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                                                InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >,
                                                                                           InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > > > > > >,
                                               Where <SOShipment.labelsPrinted, Equal <False>, And <Match <INSite, Current <AccessInfo.userName> > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;

            default:
                cmd = new PXSelectJoinGroupBy <SOShipment,
                                               LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                         InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                    InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >,
                                                                               InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > > > > > >,
                                               Where <Match <INSite, Current <AccessInfo.userName> > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;
            }

            if (typeof(PXSelectBase <SOShipment>).IsAssignableFrom(cmd.GetType()))
            {
                ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, LessEqual <Current <SOShipmentFilter.endDate> > > >();

                if (filter.SiteID != null)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.siteID, Equal <Current <SOShipmentFilter.siteID> > > >();
                }

                if (!string.IsNullOrEmpty(filter.CarrierPluginID))
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <Carrier.carrierPluginID, Equal <Current <SOShipmentFilter.carrierPluginID> > > >();
                }

                if (!string.IsNullOrEmpty(filter.ShipVia))
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipVia, Equal <Current <SOShipmentFilter.shipVia> > > >();
                }

                if (filter.StartDate != null)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >();
                }

                if (filter.CustomerID != null)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.customerID, Equal <Current <SOShipmentFilter.customerID> > > >();
                }

                if (actionID == "7" && filter.ShowPrinted == false)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.labelsPrinted, Equal <False> > >();
                }

                if (filter.PackagingType == SOShipmentFilter.Manual)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, Equal <True> > >();
                }
                else if (filter.PackagingType == SOShipmentFilter.Auto)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, NotEqual <True> > >();
                }


                int startRow  = PXView.StartRow;
                int totalRows = 0;

                foreach (object res in ((PXSelectBase <SOShipment>)cmd).View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows))
                {
                    SOShipment order = PXResult.Unwrap <SOShipment>(res);
                    SOOrder    so    = PXResult.Unwrap <SOOrder>(res);

                    if (order.BilledOrderCntr + order.UnbilledOrderCntr + order.ReleasedOrderCntr == 1)
                    {
                        order.CustomerOrderNbr = so.CustomerOrderNbr;
                    }

                    object item;
                    if ((item = (SOShipment)Orders.Cache.Locate(order)) == null || Orders.Cache.GetStatus(item) == PXEntryStatus.Notchanged)
                    {
                        yield return(order);
                    }
                }
                PXView.StartRow = 0;
            }

            if (typeof(PXSelectBase <POReceipt>).IsAssignableFrom(cmd.GetType()))
            {
                ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, LessEqual <Current <SOShipmentFilter.endDate> > > >();

                /*
                 * if (filter.SiteID != null)
                 * {
                 *      ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.siteID, Equal<Current<SOShipmentFilter.siteID>>>>();
                 * }
                 *
                 * if (!string.IsNullOrEmpty(filter.ShipVia))
                 * {
                 *      ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.shipVia, Equal<Current<SOShipmentFilter.shipVia>>>>();
                 * }
                 */

                if (filter.StartDate != null)
                {
                    ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >();
                }

                foreach (PXResult <POReceipt, SOOrder> res in ((PXSelectBase <POReceipt>)cmd).Select())
                {
                    SOShipment order = res;

                    if ((order = (SOShipment)Orders.Cache.Locate(order)) == null)
                    {
                        Orders.Cache.SetStatus(order = res, PXEntryStatus.Held);
                        yield return(order);
                    }
                    else if (Orders.Cache.GetStatus(order) == PXEntryStatus.Notchanged || Orders.Cache.GetStatus(order) == PXEntryStatus.Held)
                    {
                        yield return(order);
                    }
                }
            }
            Orders.Cache.IsDirty = false;
        }
        public virtual IEnumerable orders()
        {
            PXUIFieldAttribute.SetDisplayName <SOShipment.customerID>(Caches[typeof(SOShipment)], Messages.CustomerID);

            SOShipmentFilter filter = Filter.Current;
            int?action = GetActionIDByName(filter.Action);

            if (action == null)
            {
                yield break;
            }

            if (_ActionChanged)
            {
                Orders.Cache.Clear();
            }

            PXSelectBase cmd;

            switch (action)
            {
            case SOShipmentEntryActionsAttribute.CreateInvoice:
                cmd = new PXSelectJoinGroupBy <SOShipment,
                                               InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr>, And <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType> > >,
                                                          InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >,
                                                                     InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> >,
                                                                                InnerJoin <SOOrderTypeOperation,
                                                                                           On <SOOrderTypeOperation.orderType, Equal <SOOrderShipment.orderType>,
                                                                                               And <SOOrderTypeOperation.operation, Equal <SOOrderShipment.operation> > >,
                                                                                           InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                                                      InnerJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> >,
                                                                                                                            LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> > > > > > > > >,
                                               Where <SOShipment.confirmed, Equal <boolTrue>,
                                                      And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                           And <SOOrderShipment.invoiceNbr, IsNull,
                                                                And2 <Match <Customer, Current <AccessInfo.userName> >,
                                                                      And <Match <INSite, Current <AccessInfo.userName> > > > > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.insurance,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;

            case SOShipmentEntryActionsAttribute.PostInvoiceToIN:
                cmd = new PXSelectJoinGroupBy <SOShipment,
                                               LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                         InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                    InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >,
                                                                               InnerJoin <SOShipLine, On <SOShipLine.shipmentType, Equal <SOOrderShipment.shipmentType>, And <SOShipLine.shipmentNbr, Equal <SOOrderShipment.shipmentNbr>, And <SOShipLine.origOrderType, Equal <SOOrderShipment.orderType>, And <SOShipLine.origOrderNbr, Equal <SOOrderShipment.orderNbr> > > > >,
                                                                                          InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOShipLine.origOrderType>, And <SOOrder.orderNbr, Equal <SOShipLine.origOrderNbr> > >,
                                                                                                     LeftJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> >,
                                                                                                                          InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> > > > > > > > >,
                                               Where <SOShipment.confirmed, Equal <boolTrue>,
                                                      And <SOOrderShipment.invtRefNbr, IsNull,
                                                           And <SOShipLine.requireINUpdate, Equal <True>,
                                                                And <SOOrderType.iNDocType, NotEqual <INTranType.noUpdate>,
                                                                     And2 <Where <Customer.bAccountID, IsNull, Or <Match <Customer, Current <AccessInfo.userName> > > >,
                                                                           And <Match <INSite, Current <AccessInfo.userName> > > > > > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;

            case SOShipmentEntryActionsAttribute.CreateDropshipInvoice:
                cmd = new PXSelectJoinGroupBy <POReceipt,
                                               InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentNbr, Equal <POReceipt.receiptNbr>, And <SOOrderShipment.shipmentType, Equal <SOShipmentType.dropShip> > >,
                                                          InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >,
                                                                     InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> >,
                                                                                InnerJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> >,
                                                                                                      InnerJoin <SOOrderTypeOperation,
                                                                                                                 On <SOOrderTypeOperation.orderType, Equal <SOOrderShipment.orderType>,
                                                                                                                     And <SOOrderTypeOperation.operation, Equal <SOOrderShipment.operation> > > > > > > >,
                                               Where <POReceipt.released, Equal <boolTrue>,
                                                      //And2<Where<POReceiptLine.lineType, Equal<POLineType.goodsForDropShip>, Or<POReceiptLine.lineType, Equal<POLineType.nonStockForDropShip>>>,
                                                      And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                           And <SOOrderShipment.invoiceNbr, IsNull,
                                                                And <Match <Customer, Current <AccessInfo.userName> > > > > >,
                                               Aggregate <GroupBy <POReceipt.receiptNbr,
                                                                   GroupBy <POReceipt.createdByID,
                                                                            GroupBy <POReceipt.lastModifiedByID,
                                                                                     GroupBy <POReceipt.released,
                                                                                              GroupBy <POReceipt.ownerID,
                                                                                                       GroupBy <POReceipt.hold> > > > > > > >(this);
                break;

            case SOShipmentEntryActionsAttribute.CancelReturn:
                cmd = new PXSelectJoinGroupBy <SOShipment, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                      LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                                                InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >,
                                                                                           InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >,
                                                                                                      InnerJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> > > > > > >,
                                               Where <SOShipment.labelsPrinted, Equal <False>,
                                                      And2 <Match <Customer, Current <AccessInfo.userName> >,
                                                            And <Match <INSite, Current <AccessInfo.userName> > > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;

            default:
                cmd = new PXSelectJoinGroupBy <SOShipment,
                                               LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                         InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                    InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >,
                                                                               InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >,
                                                                                          LeftJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> > > > > > >,
                                               Where2 <Match <INSite, Current <AccessInfo.userName> >,
                                                       And <Where <Customer.bAccountID, IsNull, Or <Match <Customer, Current <AccessInfo.userName> > > > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;
            }

            if (typeof(PXSelectBase <SOShipment>).IsAssignableFrom(cmd.GetType()))
            {
                ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, LessEqual <Current <SOShipmentFilter.endDate> > > >();

                if (filter.SiteID != null)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.siteID, Equal <Current <SOShipmentFilter.siteID> > > >();
                }

                if (!string.IsNullOrEmpty(filter.CarrierPluginID))
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <Carrier.carrierPluginID, Equal <Current <SOShipmentFilter.carrierPluginID> > > >();
                }

                if (!string.IsNullOrEmpty(filter.ShipVia))
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipVia, Equal <Current <SOShipmentFilter.shipVia> > > >();
                }

                if (filter.StartDate != null)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >();
                }

                if (filter.CustomerID != null)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.customerID, Equal <Current <SOShipmentFilter.customerID> > > >();
                }

                if (action == SOShipmentEntryActionsAttribute.PrintLabels && filter.ShowPrinted == false)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.labelsPrinted, Equal <False> > >();
                }

                if (action == SOShipmentEntryActionsAttribute.PrintPickList && filter.ShowPrinted == false)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.pickListPrinted, Equal <False> > >();
                }

                if (filter.PackagingType == SOShipmentFilter.Manual)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, Equal <True> > >();
                }
                else if (filter.PackagingType == SOShipmentFilter.Auto)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, NotEqual <True> > >();
                }

                int startRow  = PXView.StartRow;
                int totalRows = 0;

                List <PXFilterRow> newFilters = new List <PXFilterRow>();
                foreach (PXFilterRow f in PXView.Filters)
                {
                    if (string.Compare(f.DataField, "CustomerOrderNbr", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        f.DataField = "SOOrder__CustomerOrderNbr";
                    }
                    newFilters.Add(f);
                }

                foreach (object res in ((PXSelectBase <SOShipment>)cmd).View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows))
                {
                    SOShipment order = PXResult.Unwrap <SOShipment>(res);
                    SOOrder    so    = PXResult.Unwrap <SOOrder>(res);

                    if (order.BilledOrderCntr + order.UnbilledOrderCntr + order.ReleasedOrderCntr == 1)
                    {
                        order.CustomerOrderNbr = so.CustomerOrderNbr;
                    }

                    SOShipment cached = (SOShipment)Orders.Cache.Locate(order);
                    if (cached != null)
                    {
                        order.Selected = cached.Selected;
                    }
                    yield return(order);
                }
                PXView.StartRow = 0;
            }

            if (typeof(PXSelectBase <POReceipt>).IsAssignableFrom(cmd.GetType()))
            {
                ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, LessEqual <Current <SOShipmentFilter.endDate> > > >();

                /*
                 * if (filter.SiteID != null)
                 * {
                 *      ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.siteID, Equal<Current<SOShipmentFilter.siteID>>>>();
                 * }
                 *
                 * if (!string.IsNullOrEmpty(filter.ShipVia))
                 * {
                 *      ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.shipVia, Equal<Current<SOShipmentFilter.shipVia>>>>();
                 * }
                 */

                if (filter.StartDate != null)
                {
                    ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >();
                }

                foreach (PXResult <POReceipt, SOOrderShipment, SOOrder> res in ((PXSelectBase <POReceipt>)cmd).Select())
                {
                    SOShipment order  = res;
                    SOShipment cached = (SOShipment)Orders.Cache.Locate(order);

                    if (cached == null)
                    {
                        Orders.Cache.SetStatus(order, PXEntryStatus.Held);
                    }
                    else
                    {
                        order.Selected = cached.Selected;
                    }
                    yield return(order);
                }
            }
            Orders.Cache.IsDirty = false;
        }