Exemplo n.º 1
0
        public virtual IEnumerable ViewDocument(PXAdapter adapter)
        {
            if (Orders.Current != null)
            {
                if (Orders.Current.ShipmentType == INDocType.DropShip)
                {
                    PO.POReceiptEntry docgraph = PXGraph.CreateInstance <PO.POReceiptEntry>();
                    docgraph.Document.Current = docgraph.Document.Search <POReceipt.receiptNbr>(Orders.Current.ShipmentNbr);

                    throw new PXRedirectRequiredException(docgraph, true, PO.Messages.POReceipt)
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
                else
                {
                    SOShipmentEntry docgraph = PXGraph.CreateInstance <SOShipmentEntry>();
                    docgraph.Document.Current = docgraph.Document.Search <SOShipment.shipmentNbr>(Orders.Current.ShipmentNbr);

                    throw new PXRedirectRequiredException(docgraph, true, Messages.SOShipment)
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
            }
            return(adapter.Get());
        }
        public virtual IEnumerable viewShipment(PXAdapter adapter)
        {
            if (SubmitFeedList.Current != null)
            {
                SOShipmentEntry graph    = PXGraph.CreateInstance <SOShipmentEntry>();
                SOShipment      shipment = PXSelect <SOShipment, Where <SOShipment.shipmentNbr, Equal <Required <SOShipment.shipmentNbr> > > > .Select(graph, SubmitFeedList.Current.ShipmentNbr);

                graph.Document.Current = shipment;
                PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
            }
            return(adapter.Get());
        }
Exemplo n.º 3
0
 public virtual IEnumerable ViewDocument(PXAdapter adapter)
 {
     if (Orders.Current != null)
     {
         SOShipmentEntry docgraph = PXGraph.CreateInstance <SOShipmentEntry>();
         docgraph.Document.Current = docgraph.Document.Search <SOShipment.shipmentNbr>(Orders.Current.ShipmentNbr);
         throw new PXRedirectRequiredException(docgraph, true, "Shipment")
               {
                   Mode = PXBaseRedirectException.WindowMode.NewWindow
               };
     }
     return(adapter.Get());
 }
Exemplo n.º 4
0
        private static SOShipmentPlan FindSalesOrderLine(SOShipmentEntry shipmentEntry, Func <PXResult <SOShipmentPlan>, bool> lineCriteria)
        {
            SOShipmentPlan item;

            try
            {
                item = shipmentEntry.soshipmentplan.Select().First(lineCriteria);
            }
            catch (InvalidOperationException ex)
            {
                throw new InvalidOperationException(SO.Messages.CannotSelectSpecificSOLine, ex);
            }

            return(item);
        }
    /// <summary>
    /// Adds all lines of a given order to the shipment.
    /// </summary>
    protected void Action_AddOrder(PXGraph graph, ActionImpl action)
    {
        SOShipmentEntry shipmentEntry = (SOShipmentEntry)graph;

        shipmentEntry.addsofilter.Current.OrderType = ((EntityValueField)action.Fields.Single(f => f.Name == "OrderType")).Value;
        shipmentEntry.addsofilter.Current.OrderNbr  = ((EntityValueField)action.Fields.Single(f => f.Name == "OrderNbr")).Value;
        shipmentEntry.addsofilter.Update(shipmentEntry.addsofilter.Current);

        foreach (SOShipmentPlan line in shipmentEntry.soshipmentplan.Select())
        {
            line.Selected = true;
            shipmentEntry.soshipmentplan.Update(line);
        }

        shipmentEntry.addSO.Press();
    }
Exemplo n.º 6
0
        public static void CreateShipment(System.Collections.Generic.List <SOShipmentPlan> list)
        {
            int num1 = 0;

            try
            {
                SOShipmentEntry instance = PXGraph.CreateInstance <SOShipmentEntry>();
                DocumentList <PX.Objects.SO.SOShipment> list1 = new DocumentList <PX.Objects.SO.SOShipment>((PXGraph)instance);
                Dictionary <long, PXResult <SOShipmentPlan, PX.Objects.SO.SOOrder> > dictionary = new Dictionary <long, PXResult <SOShipmentPlan, PX.Objects.SO.SOOrder> >();
                SOShipmentPlan        soShipmentPlan1 = new SOShipmentPlan();
                PX.Objects.SO.SOOrder soOrder         = new PX.Objects.SO.SOOrder();
                for (int index = 0; index < list.Count; ++index)
                {
                    SOShipmentPlan        i0 = list[index];
                    PX.Objects.SO.SOOrder i1 = SelectFrom <PX.Objects.SO.SOOrder> .Where <PX.Objects.SO.SOOrder.orderType.IsEqual <P.AsString>
                                                                                          .And <PX.Objects.SO.SOOrder.orderNbr.IsEqual <P.AsString> > > .View.Select((PXGraph)instance, (object)i0.OrderType, (object)i0.OrderNbr);

                    int?nullable1;
                    int?customerLocationId;
                    int?nullable2;
                    int num2;
                    if (num1 != 0)
                    {
                        int num3 = num1;
                        nullable1          = i1.CustomerID;
                        customerLocationId = i1.CustomerLocationID;
                        nullable2          = nullable1.HasValue & customerLocationId.HasValue ? new int?(nullable1.GetValueOrDefault() + customerLocationId.GetValueOrDefault()) : new int?();
                        int valueOrDefault = nullable2.GetValueOrDefault();
                        num2 = num3 == valueOrDefault & nullable2.HasValue ? 1 : 0;
                    }
                    else
                    {
                        num2 = 1;
                    }
                    if (num2 == 0)
                    {
                        throw new PXException("Please Only Select The Same Customer ID & Location For One Shipment");
                    }
                    nullable2          = i1.CustomerID;
                    customerLocationId = i1.CustomerLocationID;
                    int?nullable3;
                    if (!(nullable2.HasValue & customerLocationId.HasValue))
                    {
                        nullable1 = new int?();
                        nullable3 = nullable1;
                    }
                    else
                    {
                        nullable3 = new int?(nullable2.GetValueOrDefault() + customerLocationId.GetValueOrDefault());
                    }
                    nullable1 = nullable3;
                    num1      = nullable1.Value;
                    dictionary.Add(i0.PlanID.Value, new PXResult <SOShipmentPlan, PX.Objects.SO.SOOrder>(i0, i1));
                }
                PX.Objects.SO.SOOrder order = new PX.Objects.SO.SOOrder();
                foreach (PXResult <SOShipmentPlan, PX.Objects.SO.SOOrder> pxResult in dictionary.Values)
                {
                    SOShipmentPlan soShipmentPlan2 = (SOShipmentPlan)pxResult;
                    if (order.OrderNbr != pxResult.GetItem <PX.Objects.SO.SOOrder>().OrderNbr)
                    {
                        order = (PX.Objects.SO.SOOrder)pxResult;
                        instance.GetExtension <SOShipmentEntry_Extension>().CreateShipment2(order, soShipmentPlan2.SiteID, soShipmentPlan2.PlanDate, new bool?(false), "I", list1, list);
                    }
                }
                throw new PXPopupRedirectException((PXGraph)instance, "Shipment <*> is created", true);
            }
            catch (Exception ex)
            {
                if (ex.Message.Equals("Shipment <*> is created"))
                {
                    PXProcessing.SetProcessed();
                }
                else
                {
                    PXProcessing.SetError(ex);
                }
                throw;
            }
        }
Exemplo n.º 7
0
 public INRegisterEntryFactory(SOShipmentEntry shipGraph)
 {
     _shipGraph = shipGraph;
 }
Exemplo n.º 8
0
 private void SelectLine(SOShipmentEntry shipmentEntry, SOShipmentPlan item)
 {
     item.Selected = true;
     shipmentEntry.soshipmentplan.Cache.Update(item);
     AssertNoErrors(shipmentEntry.soshipmentplan.Cache, item);
 }
        public virtual IEnumerable Action(
            PXAdapter adapter,
            [PXInt]
            [PXIntList(new int[] { 1, 2, 3, 4, 5 }, new string[] { "Create Shipment", "Apply Assignment Rules", "Create Invoice", "Post Invoice to IN", "Create Purchase Order" })]
            int?actionID,
            [PXDate]
            DateTime?shipDate,
            [PXSelector(typeof(INSite.siteCD))]
            string siteCD,
            [SOOperation.List]
            string operation,
            [PXString()]
            string ActionName,
            Func <PXAdapter, int?, DateTime?, string, string, string, IEnumerable> baseMtd)
        {
            switch (actionID)
            {
            case 1:
            {
                if (!string.IsNullOrEmpty(ActionName))
                {
                    PXAction action = Base.Actions[ActionName];

                    if (action != null)
                    {
                        Base.Save.Press();
                        List <object> result = new List <object>();
                        foreach (object data in action.Press(adapter))
                        {
                            result.Add(data);
                        }
                        return(result);
                    }
                }

                List <SOOrder> list = new List <SOOrder>();
                foreach (SOOrder order in adapter.Get <SOOrder>())
                {
                    list.Add(order);
                }

                if (shipDate != null)
                {
                    Base.soparamfilter.Current.ShipDate = shipDate;
                }

                if (Base.soparamfilter.Current.ShipDate == null)
                {
                    Base.soparamfilter.Current.ShipDate = Base.Accessinfo.BusinessDate;
                }

                if (siteCD != null)
                {
                    Base.soparamfilter.Cache.SetValueExt <SOParamFilter.siteID>(Base.soparamfilter.Current, siteCD);
                }

                if (!adapter.MassProcess)
                {
                    if (Base.soparamfilter.Current.SiteID == null)
                    {
                        Base.soparamfilter.Current.SiteID = GetPreferedSiteID();
                    }
                    if (adapter.ExternalCall)
                    {
                        Base.soparamfilter.AskExt(true);
                    }
                }
                if (Base.soparamfilter.Current.SiteID != null || adapter.MassProcess)
                {
                    try
                    {
                        Base.RecalculateExternalTaxesSync = true;
                        Base.Save.Press();
                    }
                    finally
                    {
                        Base.RecalculateExternalTaxesSync = false;
                    }
                    PXAutomation.RemovePersisted(Base, typeof(SOOrder), new List <object>(list));

                    SOParamFilter filter = Base.soparamfilter.Current;
                    PXLongOperation.StartOperation(Base, delegate()
                        {
                            bool anyfailed                    = false;
                            SOShipmentEntry docgraph          = PXGraph.CreateInstance <SOShipmentEntry>();
                            SOOrderEntry ordgraph             = PXGraph.CreateInstance <SOOrderEntry>();
                            DocumentList <SOShipment> created = new DocumentList <SOShipment>(docgraph);

                            //address AC-92776
                            for (int i = 0; i < list.Count; i++)
                            {
                                SOOrder order = list[i];
                                if (adapter.MassProcess)
                                {
                                    PXProcessing <SOOrder> .SetCurrentItem(order);
                                }

                                SOOrder ordercopy = (SOOrder)Base.Caches[typeof(SOOrder)].CreateCopy(order);
                                try
                                {
                                    if (operation == SOOperation.Issue)
                                    {
                                        ReviewWarehouseAvailability(ordgraph, order);
                                    }
                                }
                                catch (SOShipmentException ex)
                                {
                                    Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy);
                                    if (!adapter.MassProcess)
                                    {
                                        throw;
                                    }

                                    order.LastShipDate = filter.ShipDate;
                                    order.Status       = SOOrderStatus.Shipping; //Automation will set the order to back order since no shipments were created

                                    docgraph.Clear();

                                    var ordergraph = PXGraph.CreateInstance <SOOrderEntry>();
                                    ordergraph.Clear();

                                    ordergraph.Document.Cache.MarkUpdated(order);
                                    PXAutomation.CompleteSimple(ordergraph.Document.View);
                                    try
                                    {
                                        ordergraph.Save.Press();
                                        PXAutomation.RemovePersisted(ordergraph, order);

                                        PXTrace.WriteInformation(ex);
                                        PXProcessing <SOOrder> .SetWarning(ex);
                                    }
                                    catch (Exception inner)
                                    {
                                        Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy);
                                        PXProcessing <SOOrder> .SetError(inner);
                                        anyfailed = true;
                                    }
                                    continue;     //Stop there for this order
                                }
                                catch (Exception ex)
                                {
                                    if (!adapter.MassProcess)
                                    {
                                        throw;
                                    }
                                    PXProcessing <SOOrder> .SetError(ex);
                                    anyfailed = true;
                                    continue;
                                }

                                List <int?> sites = new List <int?>();

                                if (filter.SiteID != null)
                                {
                                    sites.Add(filter.SiteID);
                                }
                                else
                                {
                                    foreach (SOShipmentPlan plan in PXSelectGroupBy <SOShipmentPlan, Where <SOShipmentPlan.orderType, Equal <Current <SOOrder.orderType> >, And <SOShipmentPlan.orderNbr, Equal <Current <SOOrder.orderNbr> > > >, Aggregate <GroupBy <SOShipmentPlan.siteID> >, OrderBy <Asc <SOShipmentPlan.siteID> > > .SelectMultiBound(docgraph, new object[] { order }))
                                    {
                                        sites.Add(plan.SiteID);
                                    }
                                }

                                foreach (int?SiteID in sites)
                                {
                                    ordercopy = (SOOrder)Base.Caches[typeof(SOOrder)].CreateCopy(order);
                                    try
                                    {
                                        using (var ts = new PXTransactionScope())
                                        {
                                            PXTimeStampScope.SetRecordComesFirst(typeof(SOOrder), true);
                                            docgraph.CreateShipment(order, SiteID, filter.ShipDate, adapter.MassProcess, operation, created, adapter.QuickProcessFlow);
                                            ts.Complete();
                                        }

                                        if (adapter.MassProcess)
                                        {
                                            PXProcessing <SOOrder> .SetProcessed();
                                        }
                                    }
                                    catch (SOShipmentException ex)
                                    {
                                        Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy);
                                        if (!adapter.MassProcess)
                                        {
                                            throw;
                                        }
                                        order.LastSiteID   = SiteID;
                                        order.LastShipDate = filter.ShipDate;
                                        order.Status       = SOOrderStatus.Shipping;

                                        docgraph.Clear();

                                        var ordergraph = PXGraph.CreateInstance <SOOrderEntry>();
                                        ordergraph.Clear();

                                        ordergraph.Document.Cache.MarkUpdated(order);
                                        PXAutomation.CompleteSimple(ordergraph.Document.View);
                                        try
                                        {
                                            ordergraph.Save.Press();
                                            PXAutomation.RemovePersisted(ordergraph, order);

                                            PXTrace.WriteInformation(ex);
                                            PXProcessing <SOOrder> .SetWarning(ex);
                                        }
                                        catch (Exception inner)
                                        {
                                            Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy);
                                            PXProcessing <SOOrder> .SetError(inner);
                                            anyfailed = true;
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy);
                                        docgraph.Clear();

                                        if (!adapter.MassProcess)
                                        {
                                            throw;
                                        }
                                        PXProcessing <SOOrder> .SetError(ex);
                                        anyfailed = true;
                                    }
                                }
                            }

                            if (adapter.AllowRedirect && !adapter.MassProcess && created.Count > 0)
                            {
                                using (new PXTimeStampScope(null))
                                {
                                    docgraph.Clear();
                                    docgraph.Document.Current = docgraph.Document.Search <SOShipment.shipmentNbr>(created[0].ShipmentNbr);
                                    throw new PXRedirectRequiredException(docgraph, "Shipment");
                                }
                            }

                            if (anyfailed)
                            {
                                throw new PXOperationCompletedWithErrorException(ErrorMessages.SeveralItemsFailed);
                            }
                        });
                }
                return(list);
            }

            default:
                return(baseMtd(adapter, actionID, shipDate, siteCD, operation, ActionName));
            }
        }