Beispiel #1
0
        public virtual void SOShipmentFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            SOShipmentFilter filter = e.Row as SOShipmentFilter;

            if (filter != null && !String.IsNullOrEmpty(filter.Action))
            {
                Dictionary <string, object> parameters = Filter.Cache.ToDictionary(filter);
                Orders.SetProcessTarget(null, null, null, filter.Action, parameters);
            }
            string actionID = (string)Orders.GetTargetFill(null, null, null, filter.Action, "@actionID");
            int    action   = 0;

            int.TryParse(actionID, out action);

            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.invoiceDate>(sender, filter, action == SOShipmentEntryActionsAttribute.CreateInvoice || action == SOShipmentEntryActionsAttribute.CreateDropshipInvoice);
            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.packagingType>(sender, filter, action != SOShipmentEntryActionsAttribute.CreateDropshipInvoice);
            PXUIFieldAttribute.SetVisible <SOShipmentFilter.showPrinted>(sender, filter, action == SOShipmentEntryActionsAttribute.PrintLabels || action == SOShipmentEntryActionsAttribute.PrintPickList);
            PXUIFieldAttribute.SetDisplayName <SOShipment.shipmentNbr>(Orders.Cache, action == SOShipmentEntryActionsAttribute.CreateDropshipInvoice ? Messages.GetLocal(POReceipt.receiptNbr.DisplayName) : Messages.GetLocal(SOShipment.shipmentNbr.DisplayName));
            PXUIFieldAttribute.SetDisplayName <SOShipment.shipDate>(Orders.Cache, action == SOShipmentEntryActionsAttribute.CreateDropshipInvoice ? Messages.GetLocal(POReceipt.receiptDate.DisplayName) : Messages.GetLocal(SOShipment.shipDate.DisplayName));


            if (sosetup.Current.UseShipDateForInvoiceDate == true)
            {
                sender.RaiseExceptionHandling <SOShipmentFilter.invoiceDate>(filter, null, new PXSetPropertyException(Messages.UseInvoiceDateFromShipmentDateWarning, PXErrorLevel.Warning));
                PXUIFieldAttribute.SetEnabled <SOShipmentFilter.invoiceDate>(sender, filter, false);
            }
        }
        public virtual void SOShipmentFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            SOShipmentFilter filter = e.Row as SOShipmentFilter;

            if (filter != null && !String.IsNullOrEmpty(filter.Action))
            {
                Dictionary <string, object> parameters = Filter.Cache.ToDictionary(filter);
                Orders.SetProcessTarget(null, null, null, filter.Action, parameters);
            }
            string actionID = (string)Orders.GetTargetFill(null, null, null, filter.Action, "@actionID");

            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.invoiceDate>(sender, filter, actionID == "2" || actionID == "6");
            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.packagingType>(sender, filter, actionID != "6");
            PXUIFieldAttribute.SetVisible <SOShipmentFilter.showPrinted>(sender, filter, actionID == "7");

            if (sosetup.Current.UseShipDateForInvoiceDate == true)
            {
                sender.RaiseExceptionHandling <SOShipmentFilter.invoiceDate>(filter, null, new PXSetPropertyException(Messages.UseInvoiceDateFromShipmentDateWarning, PXErrorLevel.Warning));
                PXUIFieldAttribute.SetEnabled <SOShipmentFilter.invoiceDate>(sender, filter, false);
            }
        }
Beispiel #3
0
        public virtual void SOShipmentFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            SOShipmentFilter filter = e.Row as SOShipmentFilter;

            if (filter != null && !String.IsNullOrEmpty(filter.Action))
            {
                Dictionary <string, object> parameters = Filter.Cache.ToDictionary(filter);
                Orders.SetProcessTarget(null, null, null, filter.Action, parameters);
            }
            int?action = GetActionIDByName(filter.Action);

            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.invoiceDate>(sender, filter, action == SOShipmentEntryActionsAttribute.CreateInvoice || action == SOShipmentEntryActionsAttribute.CreateDropshipInvoice);
            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.packagingType>(sender, filter, action != SOShipmentEntryActionsAttribute.CreateDropshipInvoice);
            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.siteID>(sender, filter, action != SOShipmentEntryActionsAttribute.CreateDropshipInvoice);
            PXUIFieldAttribute.SetVisible <SOShipmentFilter.showPrinted>(sender, filter, action == SOShipmentEntryActionsAttribute.PrintLabels || action == SOShipmentEntryActionsAttribute.PrintPickList);

            PXUIFieldAttribute.SetDisplayName <SOShipment.shipmentNbr>(Orders.Cache, action == SOShipmentEntryActionsAttribute.CreateDropshipInvoice ? Messages.ReceiptNbr : Messages.ShipmentNbr);
            PXUIFieldAttribute.SetDisplayName <SOShipment.shipDate>(Orders.Cache, action == SOShipmentEntryActionsAttribute.CreateDropshipInvoice ? Messages.ReceiptDate : Messages.ShipmentDate);

            if (sosetup.Current.UseShipDateForInvoiceDate == true)
            {
                sender.RaiseExceptionHandling <SOShipmentFilter.invoiceDate>(filter, null, new PXSetPropertyException(Messages.UseInvoiceDateFromShipmentDateWarning, PXErrorLevel.Warning));
                PXUIFieldAttribute.SetEnabled <SOShipmentFilter.invoiceDate>(sender, filter, false);
            }

            bool warnShipNotInvoiced = (action == SOShipmentEntryActionsAttribute.PostInvoiceToIN &&
                                        (string)Orders.GetTargetFill(null, null, null, filter.Action, nameof(SOShipment.status)) != SOShipmentStatus.Completed &&
                                        sosetup.Current.UseShippedNotInvoiced != true && sosetup.Current.UseShipDateForInvoiceDate != true);
            Exception warnShipNotInvoicedExc = warnShipNotInvoiced ? new PXSetPropertyException(Messages.ShipNotInvoicedWarning, PXErrorLevel.Warning) : null;

            sender.RaiseExceptionHandling <SOShipmentFilter.action>(filter, null, warnShipNotInvoicedExc);
            bool showPrintSettings = IsPrintingAllowed(filter);

            PXUIFieldAttribute.SetVisible <SOShipmentFilter.printWithDeviceHub>(sender, filter, showPrintSettings);
            PXUIFieldAttribute.SetVisible <SOShipmentFilter.definePrinterManually>(sender, filter, showPrintSettings);
            PXUIFieldAttribute.SetVisible <SOShipmentFilter.printerID>(sender, filter, showPrintSettings);
            PXUIFieldAttribute.SetVisible <SOShipmentFilter.numberOfCopies>(sender, filter, showPrintSettings);

            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.definePrinterManually>(sender, filter, filter.PrintWithDeviceHub == true);
            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.numberOfCopies>(sender, filter, filter.PrintWithDeviceHub == true);
            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.printerID>(sender, filter, filter.PrintWithDeviceHub == true && filter.DefinePrinterManually == true);

            if (filter.PrintWithDeviceHub != true || filter.DefinePrinterManually != true)
            {
                filter.PrinterID = null;
            }

            bool showInvoiceSeparately = action.IsIn(SOShipmentEntryActionsAttribute.CreateInvoice, SOShipmentEntryActionsAttribute.CreateDropshipInvoice);

            PXUIFieldAttribute.SetEnabled <SOShipment.billSeparately>(Orders.Cache, null, showInvoiceSeparately &&
                                                                      PXLongOperation.GetStatus(this.UID) == PXLongRunStatus.NotExists);
            PXUIFieldAttribute.SetVisible <SOShipment.billSeparately>(Orders.Cache, null, showInvoiceSeparately);
        }
Beispiel #4
0
        protected virtual bool IsPrintingAllowed(SOShipmentFilter filter)
        {
            int?action = GetActionIDByName(filter.Action);

            return(PXAccess.FeatureInstalled <FeaturesSet.deviceHub>() &&
                   (action == SOShipmentEntryActionsAttribute.PrintLabels ||
                    action == SOShipmentEntryActionsAttribute.PrintPickList ||
                    (filter != null && !String.IsNullOrEmpty(filter.Action) && SOReports.GetReportIDByName(Orders, filter.Action) == SOReports.PrintShipmentConfirmation)));
        }
Beispiel #5
0
        protected virtual void SOShipmentFilter_PrinterName_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            SOShipmentFilter row = (SOShipmentFilter)e.Row;

            if (row != null)
            {
                if (!IsPrintingAllowed(row))
                {
                    e.NewValue = null;
                }
            }
        }
Beispiel #6
0
        public virtual void SOShipmentFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            SOShipmentFilter filter = e.Row as SOShipmentFilter;

            string actionID = (string)Base.Orders.GetTargetFill(null, null, null, filter.Action, "@actionID");
            int    action   = 0;

            int.TryParse(actionID, out action);

            PXUIFieldAttribute.SetVisible <SOShipmentFilterExt.printQueue>(sender, filter, action == SOShipmentEntryActionsAttribute.PrintLabels || action == SOShipmentEntryActionsAttribute.PrintPickList);
        }
Beispiel #7
0
        public virtual void ApplyShipmentFilters(PXSelectBase <SOShipment> shCmd, SOShipmentFilter filter, ApplyShipmentFiltersDelegate baseMthod)
        {
            baseMthod?.Invoke(shCmd, filter);
            switch (filter.Action)
            {
            // Yusen NL
            case "SO302000$lumGererateYUSENNLFile":
                shCmd.WhereAnd <Where <INSite.siteCD.IsEqual <YusenAttr> > >();
                shCmd.WhereAnd <Where <SOShipment.status.IsEqual <SOShipmentStatus.open> > >();
                break;

            // Yusen CA
            case "SO302000$lumGenerateYUSENCAFile":
                shCmd.WhereAnd <Where <INSite.siteCD.IsEqual <YusenAttr> > >();
                shCmd.WhereAnd <Where <SOShipment.status.IsEqual <SOShipmentStatus.open> > >();
                break;

            // P3PL UK
            case "SO302000$lumGenerate3PLUKFile":
                shCmd.WhereAnd <Where <INSite.siteCD.IsEqual <P3PLAttr> > >();
                shCmd.WhereAnd <Where <SOShipment.status.IsEqual <SOShipmentStatus.open> > >();
                break;
            }
        }
        public virtual void SOShipmentFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            SOShipmentFilter filter = e.Row as SOShipmentFilter;

            if (filter != null && !String.IsNullOrEmpty(filter.Action))
            {
                Dictionary <string, object> parameters = Filter.Cache.ToDictionary(filter);
                Orders.SetProcessTarget(null, null, null, filter.Action, parameters);
            }
            int?action = GetActionIDByName(filter.Action);

            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.invoiceDate>(sender, filter, action == SOShipmentEntryActionsAttribute.CreateInvoice || action == SOShipmentEntryActionsAttribute.CreateDropshipInvoice);
            PXUIFieldAttribute.SetEnabled <SOShipmentFilter.packagingType>(sender, filter, action != SOShipmentEntryActionsAttribute.CreateDropshipInvoice);
            PXUIFieldAttribute.SetVisible <SOShipmentFilter.showPrinted>(sender, filter, action == SOShipmentEntryActionsAttribute.PrintLabels || action == SOShipmentEntryActionsAttribute.PrintPickList);

            PXUIFieldAttribute.SetDisplayName <SOShipment.shipmentNbr>(Orders.Cache, action == SOShipmentEntryActionsAttribute.CreateDropshipInvoice ? Messages.ReceiptNbr : Messages.ShipmentNbr);
            PXUIFieldAttribute.SetDisplayName <SOShipment.shipDate>(Orders.Cache, action == SOShipmentEntryActionsAttribute.CreateDropshipInvoice ? Messages.ReceiptDate : Messages.ShipmentDate);

            if (sosetup.Current.UseShipDateForInvoiceDate == true)
            {
                sender.RaiseExceptionHandling <SOShipmentFilter.invoiceDate>(filter, null, new PXSetPropertyException(Messages.UseInvoiceDateFromShipmentDateWarning, PXErrorLevel.Warning));
                PXUIFieldAttribute.SetEnabled <SOShipmentFilter.invoiceDate>(sender, filter, false);
            }

            bool warnShipNotInvoiced = (action == SOShipmentEntryActionsAttribute.PostInvoiceToIN &&
                                        (string)Orders.GetTargetFill(null, null, null, filter.Action, nameof(SOShipment.status)) != SOShipmentStatus.Completed &&
                                        sosetup.Current.UseShippedNotInvoiced != true && sosetup.Current.UseShipDateForInvoiceDate != true);
            Exception warnShipNotInvoicedExc = warnShipNotInvoiced ? new PXSetPropertyException(Messages.ShipNotInvoicedWarning, PXErrorLevel.Warning) : null;

            sender.RaiseExceptionHandling <SOShipmentFilter.action>(filter, null, warnShipNotInvoicedExc);
        }
        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;
        }
Beispiel #10
0
        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
                      PXSelectJoin <SOShipment,
                                    InnerJoin <INSite, On <SOShipment.FK.Site>,
                                               InnerJoinSingleTable <Customer, On <SOShipment.customerID, Equal <Customer.bAccountID> >,
                                                                     LeftJoin <Carrier, On <SOShipment.FK.Carrier> > > >,
                                    Where <SOShipment.confirmed, Equal <boolTrue>,
                                           And2 <Match <Customer, Current <AccessInfo.userName> >,
                                                 And2 <Match <INSite, Current <AccessInfo.userName> >,
                                                       And <Exists <
                                                                Select <SOOrderShipment,
                                                                        Where <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr>,
                                                                               And <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>,
                                                                                    And <SOOrderShipment.invoiceNbr, IsNull,
                                                                                         And <SOOrderShipment.createARDoc, Equal <True> > > > > > > > > > > >(this);
                break;

            case SOShipmentEntryActionsAttribute.PostInvoiceToIN:
                cmd = new
                      PXSelectJoin <SOShipment,
                                    InnerJoin <INSite, On <SOShipment.FK.Site>,
                                               LeftJoinSingleTable <Customer, On <SOShipment.customerID, Equal <Customer.bAccountID> >,
                                                                    LeftJoin <Carrier, On <SOShipment.FK.Carrier> > > >,
                                    Where <SOShipment.confirmed, Equal <boolTrue>,
                                           And2 <Where <Customer.bAccountID, IsNull, Or <Match <Customer, Current <AccessInfo.userName> > > >,
                                                 And2 <Match <INSite, Current <AccessInfo.userName> >,
                                                       And <Exists <
                                                                Select <SOOrderShipment,
                                                                        Where <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr>,
                                                                               And <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>,
                                                                                    And <SOOrderShipment.invtRefNbr, IsNull,
                                                                                         And <SOOrderShipment.createINDoc, Equal <True> > > > > > > > > > > >(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> > > > > >,
                                               Where <POReceipt.released, Equal <True>,
                                                      //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 <SOShipment.FK.Site>,
                                                          LeftJoin <Carrier, On <SOShipment.FK.Carrier>,
                                                                    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
                      PXSelectJoin <SOShipment,
                                    InnerJoin <INSite, On <SOShipment.FK.Site>,
                                               LeftJoinSingleTable <Customer, On <SOShipment.customerID, Equal <Customer.bAccountID> >,
                                                                    LeftJoin <Carrier, On <SOShipment.FK.Carrier> > > >,
                                    Where2 <Match <INSite, Current <AccessInfo.userName> >,
                                            And2 <Where <Customer.bAccountID, IsNull, Or <Match <Customer, Current <AccessInfo.userName> > > >,
                                                  And <Exists <
                                                           Select <SOOrderShipment,
                                                                   Where <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr>,
                                                                          And <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType> > > > > > > > >(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 == SOPackageType.ForFiltering.Manual)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.isManualPackage, Equal <True> > >();
                }
                else if (filter.PackagingType == SOPackageType.ForFiltering.Auto)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.isManualPackage, Equal <False> > >();
                }

                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 shipment = PXResult.Unwrap <SOShipment>(res);
                    SOShipment cached   = (SOShipment)Orders.Cache.Locate(shipment);
                    if (cached != null)
                    {
                        shipment.Selected       = cached.Selected;
                        shipment.BillSeparately = cached.BillSeparately;
                    }
                    yield return(shipment);
                }
                PXView.StartRow = 0;
            }

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

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

                if (filter.ShipVia != null)
                {
                    ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <SOOrder.shipVia, Equal <Current <SOShipmentFilter.shipVia> > > >();
                }

                if (filter.CarrierPluginID != null)
                {
                    ((PXSelectBase <POReceipt>)cmd).Join <InnerJoin <Carrier, On <Carrier.carrierID, Equal <SOOrder.shipVia> > > >();
                    ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <Carrier.carrierPluginID, Equal <Current <SOShipmentFilter.carrierPluginID> > > >();
                }

                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;
                        order.BillSeparately = cached.BillSeparately;
                    }
                    yield return(order);
                }
            }
            Orders.Cache.IsDirty = false;
        }
Beispiel #11
0
        public virtual IEnumerable orders()
        {
            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");
            int    action   = 0;

            int.TryParse(actionID, out action);

            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.lineType, Equal <SOLineType.inventory>,
                                                                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;
        }