protected virtual void AddCommonFilters(SOOrderFilter filter, PXSelectBase <SOOrder> cmd)
        {
            if (filter.EndDate != null)
            {
                switch (filter.DateSel)
                {
                case "S":
                    cmd.WhereAnd <Where <SOOrder.shipDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                    break;

                case "C":
                    cmd.WhereAnd <Where <SOOrder.cancelDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                    break;

                case "O":
                    cmd.WhereAnd <Where <SOOrder.orderDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                    break;
                }
            }

            if (filter.StartDate != null)
            {
                switch (filter.DateSel)
                {
                case "S":
                    cmd.WhereAnd <Where <SOOrder.shipDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    break;

                case "C":
                    cmd.WhereAnd <Where <SOOrder.cancelDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    break;

                case "O":
                    cmd.WhereAnd <Where <SOOrder.orderDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    break;
                }
            }

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

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

            if (filter.CustomerID != null)
            {
                cmd.WhereAnd <Where <SOOrder.customerID, Equal <Current <SOOrderFilter.customerID> > > >();
            }
        }
        protected virtual PXSelectBase <SOOrder> BuildCommandCreateShipment(SOOrderFilter filter)
        {
            PXSelectBase <SOOrder> cmd = new PXSelectJoinGroupBy <SOOrder,
                                                                  InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                                             LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> >,
                                                                                       InnerJoin <SOShipmentPlan,
                                                                                                  On <SOOrder.orderType, Equal <SOShipmentPlan.orderType>,
                                                                                                      And <SOOrder.orderNbr, Equal <SOShipmentPlan.orderNbr> > >,
                                                                                                  InnerJoin <INSite, On <INSite.siteID, Equal <SOShipmentPlan.siteID> >,
                                                                                                             LeftJoin <SOOrderShipment,
                                                                                                                       On <SOOrderShipment.orderType, Equal <SOShipmentPlan.orderType>,
                                                                                                                           And <SOOrderShipment.orderNbr, Equal <SOShipmentPlan.orderNbr>,
                                                                                                                                And <SOOrderShipment.siteID, Equal <SOShipmentPlan.siteID>,
                                                                                                                                     And <SOOrderShipment.confirmed, Equal <boolFalse> > > > >,
                                                                                                                       LeftJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> > > > > > > >,
                                                                  Where <SOShipmentPlan.inclQtySOBackOrdered, Equal <short0>, And <SOOrderShipment.shipmentNbr, IsNull,
                                                                                                                                   And2 <Where <Customer.bAccountID, IsNull, Or <Match <Customer, Current <AccessInfo.userName> > > >,
                                                                                                                                         And <Match <INSite, Current <AccessInfo.userName> > > > > >,
                                                                  Aggregate <
                                                                      GroupBy <SOOrder.orderType,
                                                                               GroupBy <SOOrder.orderNbr,
                                                                                        GroupBy <SOOrder.approved> > > > >(this);

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

            if (filter.DateSel == "S")
            {
                if (filter.EndDate != null)
                {
                    cmd.WhereAnd <Where <SOShipmentPlan.planDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                }

                if (filter.StartDate != null)
                {
                    cmd.WhereAnd <Where <SOShipmentPlan.planDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                }

                filter.DateSel = string.Empty;
            }

            return(cmd);
        }
        public virtual void SOOrderFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            SOOrderFilter filter = e.Row as SOOrderFilter;

            if (filter == null)
            {
                return;
            }
            string actionID = (string)Orders.GetTargetFill(null, null, null, filter.Action, "@actionID");

            PXUIFieldAttribute.SetVisible <SOOrderFilter.shipmentDate>(sender, null, actionID == "1");
            PXUIFieldAttribute.SetVisible <SOOrderFilter.siteID>(sender, null, actionID == "1");
            if (!String.IsNullOrEmpty(filter.Action))
            {
                string siteCD = Filter.GetValueExt <SOOrderFilter.siteID>(filter) as string;
                Orders.SetProcessTarget(null, null, null, filter.Action, null, actionID == "1" ? filter.ShipmentDate : filter.EndDate, siteCD);
            }
        }
Beispiel #4
0
        public virtual void AddCommonFilters(SOOrderFilter filter, PXSelectBase <SOOrder> cmd, AddCommonFiltersDelegate baseMethod)
        {
            baseMethod.Invoke(filter, cmd);
            switch (filter.Action)
            {
            case "SO301000$createDCLShipment":
                cmd.WhereAnd <Where <SOOrder.status, Equal <SOOrderStatus.open> > >();
                cmd.WhereAnd <Where <SOOrderExt.usrDCLShipmentCreated, Equal <False>,
                                     Or <SOOrderExt.usrDCLShipmentCreated, IsNull> > >();
                break;

            case "SO301000$lumCallDCLShipemnt":
                cmd.WhereAnd <Where <SOOrder.status, Equal <SOOrderStatus.open> > >();
                cmd.WhereAnd <Where <SOOrderExt.usrDCLShipmentCreated, Equal <True> > >();
                break;

            case "SO301000$lumGenerate3PLUKFile":
                cmd.Join <InnerJoin <vSOSiteMapping, On <SOOrder.orderType, Equal <vSOSiteMapping.orderType>, And <SOOrder.orderNbr, Equal <vSOSiteMapping.orderNbr> > > > >();
                cmd.Join <InnerJoin <INSite, On <vSOSiteMapping.siteid, Equal <INSite.siteID> > > >();
                cmd.WhereAnd <Where <SOOrder.status, Equal <SOOrderStatus.open> > >();
                cmd.WhereAnd <Where <INSite.siteCD.IsEqual <P3PLAttr> > >();
                cmd.WhereAnd <Where <SOOrderExt.usrSendToMiddleware, Equal <False>,
                                     Or <SOOrderExt.usrSendToMiddleware, IsNull> > >();
                break;

            case "SO301000$lumGenerateYUSENCAFile":
                cmd.Join <InnerJoin <vSOSiteMapping, On <SOOrder.orderType, Equal <vSOSiteMapping.orderType>, And <SOOrder.orderNbr, Equal <vSOSiteMapping.orderNbr> > > > >();
                cmd.Join <InnerJoin <INSite, On <vSOSiteMapping.siteid, Equal <INSite.siteID> > > >();
                cmd.WhereAnd <Where <SOOrder.status, Equal <SOOrderStatus.open> > >();
                cmd.WhereAnd <Where <INSite.siteCD.IsEqual <YusenAttr> > >();
                cmd.WhereAnd <Where <SOOrderExt.usrSendToMiddleware, Equal <False>,
                                     Or <SOOrderExt.usrSendToMiddleware, IsNull> > >();
                break;

            case "SO301000$lumGererateYUSENNLFile":
                cmd.Join <InnerJoin <vSOSiteMapping, On <SOOrder.orderType, Equal <vSOSiteMapping.orderType>, And <SOOrder.orderNbr, Equal <vSOSiteMapping.orderNbr> > > > >();
                cmd.Join <InnerJoin <INSite, On <vSOSiteMapping.siteid, Equal <INSite.siteID> > > >();
                cmd.WhereAnd <Where <SOOrder.status, Equal <SOOrderStatus.open> > >();
                cmd.WhereAnd <Where <INSite.siteCD.IsEqual <YusenAttr> > >();
                cmd.WhereAnd <Where <SOOrderExt.usrSendToMiddleware, Equal <False>,
                                     Or <SOOrderExt.usrSendToMiddleware, IsNull> > >();
                break;
            }
        }
        public virtual IEnumerable orders()
        {
            PXUIFieldAttribute.SetDisplayName <SOOrder.customerID>(Caches[typeof(SOOrder)], Messages.CustomerID);

            List <SOOrder> ret = new List <SOOrder>();

            SOOrderFilter filter = PXCache <SOOrderFilter> .CreateCopy(Filter.Current);

            if (filter.Action == "<SELECT>")
            {
                return(ret);
            }

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

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

            foreach (SOOrder order in Orders.Cache.Updated)
            {
                ret.Add(order);
            }

            PXSelectBase <SOOrder> cmd;

            switch (actionID)
            {
            case "1":
                cmd = new PXSelectJoinGroupBy <SOOrder,
                                               InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                          LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> >,
                                                                    InnerJoin <SOShipmentPlan, On <SOOrder.orderType, Equal <SOShipmentPlan.orderType>, And <SOOrder.orderNbr, Equal <SOShipmentPlan.orderNbr> > >,
                                                                               LeftJoin <SOOrderShipment, On <SOOrderShipment.orderType, Equal <SOShipmentPlan.orderType>, And <SOOrderShipment.orderNbr, Equal <SOShipmentPlan.orderNbr>, And <SOOrderShipment.siteID, Equal <SOShipmentPlan.siteID>, And <SOOrderShipment.confirmed, Equal <boolFalse> > > > > > > > >,
                                               Where <SOShipmentPlan.inclQtySOBackOrdered, Equal <short0>, And <SOOrderShipment.shipmentNbr, IsNull> >,
                                               Aggregate <
                                                   GroupBy <SOOrder.orderType,
                                                            GroupBy <SOOrder.orderNbr> > > >(this);

                if (filter.DateSel == "S")
                {
                    cmd.WhereAnd <Where <SOShipmentPlan.planDate, LessEqual <Current <SOOrderFilter.endDate> > > >();

                    if (filter.StartDate != null)
                    {
                        cmd.WhereAnd <Where <SOShipmentPlan.planDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    }

                    filter.DateSel = string.Empty;
                }
                break;

            case "3":
                cmd = new PXSelectJoinGroupBy <SOOrder,
                                               InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                          LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> >,
                                                                    LeftJoin <SOOrderShipment, On <SOOrderShipment.orderType, Equal <SOOrder.orderType>, And <SOOrderShipment.orderNbr, Equal <SOOrder.orderNbr> > >,
                                                                              LeftJoin <ARInvoice, On <ARInvoice.docType, Equal <SOOrderShipment.invoiceType>, And <ARInvoice.refNbr, Equal <SOOrderShipment.invoiceNbr> > > > > > >,
                                               Where <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                      And2 <Where <SOOrderType.requireShipping, Equal <boolFalse>, Or <SOOrder.shipmentCntr, Equal <short0>, And <SOOrder.openLineCntr, Equal <short0> > > >,
                                                            And <ARInvoice.refNbr, IsNull> > >,
                                               Aggregate <
                                                   GroupBy <SOOrder.orderType,
                                                            GroupBy <SOOrder.orderNbr> > > >(this);
                break;

            case "3.5":
                cmd = new PXSelectJoinGroupBy <SOOrder,
                                               InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                          LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> >,
                                                                    InnerJoin <SOOrderShipment, On <SOOrderShipment.orderType, Equal <SOOrder.orderType>, And <SOOrderShipment.orderNbr, Equal <SOOrder.orderNbr> > >,
                                                                               LeftJoin <ARInvoice, On <ARInvoice.docType, Equal <SOOrderShipment.invoiceType>, And <ARInvoice.refNbr, Equal <SOOrderShipment.invoiceNbr> > > > > > >,
                                               Where <SOOrderShipment.confirmed, Equal <boolTrue>,
                                                      And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                           And <ARInvoice.refNbr, IsNull> > >,
                                               Aggregate <
                                                   GroupBy <SOOrder.orderType,
                                                            GroupBy <SOOrder.orderNbr> > > >(this);
                break;

            default:
                if (!string.IsNullOrEmpty(filter.Action) && filter.Action.StartsWith("PrepareInvoice", StringComparison.OrdinalIgnoreCase))
                {
                    cmd = new PXSelectJoinGroupBy <SOOrder,
                                                   InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType>, And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate> > >,
                                                              LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> >,
                                                                        LeftJoin <SOOrderShipment, On <SOOrderShipment.orderType, Equal <SOOrder.orderType>, And <SOOrderShipment.orderNbr, Equal <SOOrder.orderNbr> > >,
                                                                                  LeftJoin <ARInvoice, On <ARInvoice.docType, Equal <SOOrderShipment.invoiceType>, And <ARInvoice.refNbr, Equal <SOOrderShipment.invoiceNbr> > > > > > >,
                                                   Where <SOOrder.hold, Equal <boolFalse>, And <SOOrder.cancelled, Equal <boolFalse>,
                                                                                                And <Where <Sub <Sub <Sub <SOOrder.shipmentCntr,
                                                                                                                           SOOrder.openShipmentCntr>,
                                                                                                                      SOOrder.billedCntr>,
                                                                                                                 SOOrder.releasedCntr>, Greater <short0>,
                                                                                                            Or2 <Where <SOOrder.orderQty, Equal <decimal0>,
                                                                                                                        And <SOOrder.curyUnbilledMiscTot, Greater <decimal0> > >,
                                                                                                                 Or <Where <SOOrderType.requireShipping, Equal <boolFalse>, And <ARInvoice.refNbr, IsNull> > > > > > > >,
                                                   Aggregate <
                                                       GroupBy <SOOrder.orderType,
                                                                GroupBy <SOOrder.orderNbr> > > >(this);
                }
                else
                {
                    cmd = new PXSelectJoin <SOOrder, InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                                LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> > > > >(this);
                }
                break;
            }

            switch (filter.DateSel)
            {
            case "S":
                cmd.WhereAnd <Where <SOOrder.shipDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                break;

            case "C":
                cmd.WhereAnd <Where <SOOrder.cancelDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                break;

            case "O":
                cmd.WhereAnd <Where <SOOrder.orderDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                break;
            }

            if (filter.StartDate != null)
            {
                switch (filter.DateSel)
                {
                case "S":
                    cmd.WhereAnd <Where <SOOrder.shipDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    break;

                case "C":
                    cmd.WhereAnd <Where <SOOrder.cancelDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    break;

                case "O":
                    cmd.WhereAnd <Where <SOOrder.orderDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    break;
                }
            }

            if (filter.SiteID != null)
            {
                switch (actionID)
                {
                case "1":
                    cmd.WhereAnd <Where <SOShipmentPlan.siteID, Equal <Current <SOOrderFilter.siteID> > > >();
                    break;
                }
            }

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

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

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

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

            List <PXFilterRow> newFilters = new List <PXFilterRow>();

            foreach (PXFilterRow f in PXView.Filters)
            {
                if (f.DataField.ToLower() == "behavior")
                {
                    f.DataField = "SOOrderType__Behavior";
                }
                newFilters.Add(f);
            }

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

                order.Behavior         = ((SOOrderType)res).Behavior;
                order.ARDocType        = ((SOOrderType)res).ARDocType;
                order.DefaultOperation = ((SOOrderType)res).DefaultOperation;

                if ((cached = (SOOrder)Orders.Cache.Locate(order)) == null || Orders.Cache.GetStatus(cached) == PXEntryStatus.Notchanged)
                {
                    ret.Add(order);
                }
            }

            PXView.StartRow = 0;

            Orders.Cache.IsDirty = false;

            return(ret);
        }
        public virtual IEnumerable orders()
        {
            PXUIFieldAttribute.SetDisplayName <SOOrder.customerID>(Caches[typeof(SOOrder)], Messages.CustomerID);

            SOOrderFilter filter = PXCache <SOOrderFilter> .CreateCopy(Filter.Current);

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

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

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

            PXSelectBase <SOOrder> cmd;

            const string ActionIdCreateShipment = "1";

            switch (actionID)
            {
            case ActionIdCreateShipment:
                cmd = BuildCommandCreateShipment(filter);
                break;

            case var action when !string.IsNullOrEmpty(filter.Action) && filter.Action.StartsWith("PrepareInvoice", StringComparison.OrdinalIgnoreCase):
                cmd = BuildCommandPrepareInvoice();
                break;

            default:
                cmd = BuildCommandDefault();
                break;
            }

            AddCommonFilters(filter, cmd);

            PXFilterRow[] newFilters = AlterFilters();

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

            foreach (PXResult <SOOrder, SOOrderType> res in cmd.View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters, ref startRow, PXView.MaximumRows, ref totalRows))
            {
                SOOrder order = res;
                SOOrder cached;

                order.Behavior         = ((SOOrderType)res).Behavior;
                order.ARDocType        = ((SOOrderType)res).ARDocType;
                order.DefaultOperation = ((SOOrderType)res).DefaultOperation;

                if ((cached = (SOOrder)Orders.Cache.Locate(order)) != null)
                {
                    order.Selected = cached.Selected;
                }

                yield return(order);
            }

            PXView.StartRow = 0;

            Orders.Cache.IsDirty = false;
        }