Ejemplo n.º 1
0
            private void ReqClassFieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
            {
                string oldClassId = (string)e.OldValue;
                string newClassId = (string)sender.GetValue(e.Row, reqClassID.Name);
                object value      = sender.GetValue(e.Row, _FieldName);

                if (oldClassId != newClassId)
                {
                    RQRequestClass newClass = (RQRequestClass)this.viewClass.SelectSingle(newClassId);
                    RQRequestClass oldClass = (RQRequestClass)this.viewClass.SelectSingle(oldClassId);

                    if (newClass != null && oldClass != null && newClass.CustomerRequest != oldClass.CustomerRequest)
                    {
                        sender.SetValue(e.Row, _FieldOrdinal, null);
                        sender.SetDefaultExt(e.Row, _FieldName);
                    }
                    else if (newClass != null && value != null)
                    {
                        BAccount account =
                            PXSelect <BAccount, Where <BAccount.bAccountID, Equal <Required <BAccount.bAccountID> > > > .Select(sender.Graph, value);

                        if (account == null)
                        {
                            return;
                        }

                        if ((account.Type != BAccountType.CustomerType && newClass.CustomerRequest == true) ||
                            (account.Type != BAccountType.EmployeeType && newClass.CustomerRequest != true))
                        {
                            sender.SetValue(e.Row, _FieldOrdinal, null);
                        }
                    }
                }
            }
Ejemplo n.º 2
0
        protected override PXView CreateIntView(PXGraph graph)
        {
            RQRequestClass curClass = graph.Caches[typeof(RQRequestClass)].Current as RQRequestClass;

            if (curClass != null && curClass.RestrictItemList == true)
            {
                return(CreateRestictedIntView(graph));
            }
            return(base.CreateIntView(graph));
        }
Ejemplo n.º 3
0
            protected virtual IEnumerable GetRecords()
            {
                RQRequestClass reqClass =
                    this.reqClassID != null ?
                    (RQRequestClass)this.viewClass.SelectSingle() :
                    null;

                PXView view;
                var    startRow  = PXView.StartRow;
                var    totalRows = 0;

                view = (reqClass != null && reqClass.CustomerRequest == true)
                                        ? this.viewCustomers
                                        : this.viewEmployees;

                var res = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);

                PXView.StartRow = 0;
                return(res);
            }
Ejemplo n.º 4
0
            protected virtual IEnumerable GetRecords()
            {
                RQRequestClass reqClass =
                    this.reqClassID != null ?
                    (RQRequestClass)this.viewClass.SelectSingle() :
                    null;

                if (reqClass == null || !(reqClass.CustomerRequest == true))
                {
                    foreach (object emp in this.viewEmployees.SelectMulti())
                    {
                        yield return(emp);
                    }
                }

                if (reqClass == null || reqClass.CustomerRequest == true)
                {
                    foreach (object cust in this.viewCustomers.SelectMulti())
                    {
                        yield return(cust);
                    }
                }
            }
Ejemplo n.º 5
0
        private static void GenerateRequisition(RQRequestSelection filter, List <RQRequestLineOwned> lines)
        {
            RQRequisitionEntry graph = PXGraph.CreateInstance <RQRequisitionEntry>();

            RQRequisition requisition = (RQRequisition)graph.Document.Cache.CreateInstance();

            graph.Document.Insert(requisition);
            requisition.ShipDestType = null;

            bool isCustomerSet = true;
            bool isVendorSet   = true;
            bool isShipToSet   = true;
            int? shipContactID = null;
            int? shipAddressID = null;
            var  vendors       = new HashSet <VendorRef>();

            foreach (RQRequestLine line in lines)
            {
                PXResult <RQRequest, RQRequestClass> e =
                    (PXResult <RQRequest, RQRequestClass>)
                    PXSelectJoin <RQRequest,
                                  InnerJoin <RQRequestClass,
                                             On <RQRequestClass.reqClassID, Equal <RQRequest.reqClassID> > >,
                                  Where <RQRequest.orderNbr, Equal <Required <RQRequest.orderNbr> > > >
                    .Select(graph, line.OrderNbr);

                RQRequest      req      = e;
                RQRequestClass reqclass = e;

                requisition = PXCache <RQRequisition> .CreateCopy(graph.Document.Current);

                if (reqclass.CustomerRequest == true && isCustomerSet)
                {
                    if (requisition.CustomerID == null)
                    {
                        requisition.CustomerID         = req.EmployeeID;
                        requisition.CustomerLocationID = req.LocationID;
                    }
                    else if (requisition.CustomerID != req.EmployeeID || requisition.CustomerLocationID != req.LocationID)
                    {
                        isCustomerSet = false;
                    }
                }
                else
                {
                    isCustomerSet = false;
                }

                if (isShipToSet)
                {
                    if (shipContactID == null && shipAddressID == null)
                    {
                        requisition.ShipDestType     = req.ShipDestType;
                        requisition.ShipToBAccountID = req.ShipToBAccountID;
                        requisition.ShipToLocationID = req.ShipToLocationID;
                        shipContactID = req.ShipContactID;
                        shipAddressID = req.ShipAddressID;
                    }
                    else if (requisition.ShipDestType != req.ShipDestType ||
                             requisition.ShipToBAccountID != req.ShipToBAccountID ||
                             requisition.ShipToLocationID != req.ShipToLocationID)
                    {
                        isShipToSet = false;
                    }
                }

                if (line.VendorID != null && line.VendorLocationID != null)
                {
                    VendorRef vendor = new VendorRef()
                    {
                        VendorID   = line.VendorID.Value,
                        LocationID = line.VendorLocationID.Value
                    };

                    vendors.Add(vendor);

                    if (isVendorSet)
                    {
                        if (requisition.VendorID == null)
                        {
                            requisition.VendorID         = line.VendorID;
                            requisition.VendorLocationID = line.VendorLocationID;
                        }
                        else if (requisition.VendorID != line.VendorID ||
                                 requisition.VendorLocationID != line.VendorLocationID)
                        {
                            isVendorSet = false;
                        }
                    }
                }
                else
                {
                    isVendorSet = false;
                }

                if (!isCustomerSet)
                {
                    requisition.CustomerID         = null;
                    requisition.CustomerLocationID = null;
                }

                if (!isVendorSet)
                {
                    requisition.VendorID         = null;
                    requisition.VendorLocationID = null;
                    requisition.RemitAddressID   = null;
                    requisition.RemitContactID   = null;
                }
                else if (requisition.VendorID == req.VendorID && requisition.VendorLocationID == req.VendorLocationID)
                {
                    requisition.RemitAddressID = req.RemitAddressID;
                    requisition.RemitContactID = req.RemitContactID;
                }

                if (!isShipToSet)
                {
                    requisition.ShipDestType = PX.Objects.PO.POShippingDestination.CompanyLocation;
                    graph.Document.Cache.SetDefaultExt <RQRequisition.shipToBAccountID>(requisition);
                }

                graph.Document.Update(requisition);

                if (line.OpenQty > 0)
                {
                    if (!graph.Lines.Cache.IsDirty && req.CuryID != requisition.CuryID)
                    {
                        requisition = PXCache <RQRequisition> .CreateCopy(graph.Document.Current);

                        requisition.CuryID = req.CuryID;
                        graph.Document.Update(requisition);
                    }

                    graph.InsertRequestLine(line, line.OpenQty.GetValueOrDefault(), filter.AddExists == true);
                }
            }

            if (isShipToSet)
            {
                foreach (PXResult <POAddress, POContact> res in
                         PXSelectJoin <POAddress,
                                       CrossJoin <POContact>,
                                       Where <POAddress.addressID, Equal <Required <RQRequisition.shipAddressID> >,
                                              And <POContact.contactID, Equal <Required <RQRequisition.shipContactID> > > > >
                         .Select(graph, shipAddressID, shipContactID))
                {
                    AddressAttribute.CopyRecord <RQRequisition.shipAddressID>(graph.Document.Cache, graph.Document.Current, (POAddress)res, true);
                    AddressAttribute.CopyRecord <RQRequisition.shipContactID>(graph.Document.Cache, graph.Document.Current, (POContact)res, true);
                }
            }

            if (requisition.VendorID == null && vendors.Count > 0)
            {
                foreach (var vendor in vendors)
                {
                    RQBiddingVendor bid = PXCache <RQBiddingVendor> .CreateCopy(graph.Vendors.Insert());

                    bid.VendorID         = vendor.VendorID;
                    bid.VendorLocationID = vendor.LocationID;
                    graph.Vendors.Update(bid);
                }
            }

            if (graph.Lines.Cache.IsDirty)
            {
                graph.Save.Press();
                throw new PXRedirectRequiredException(graph, string.Format(Messages.RequisitionCreated, graph.Document.Current.ReqNbr));
            }

            for (int i = 0; i < lines.Count; i++)
            {
                PXProcessing <RQRequestLine> .SetInfo(i, PXMessages.LocalizeFormatNoPrefixNLA(Messages.RequisitionCreated, graph.Document.Current.ReqNbr));
            }
        }