예제 #1
0
        protected virtual void RQBiddingVendor_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            RQBiddingVendor row = (RQBiddingVendor)e.Row;

            if (row == null)
            {
                return;
            }

            if (row.EntryDate == null)
            {
                row.EntryDate = sender.Graph.Accessinfo.BusinessDate;
            }

            if (BVendor.Current != null && BVendor.Current.AllowOverrideCury == true)
            {
                RQBidding bidding = (RQBidding)this.Bidding.View.SelectSingleBound(new object[] { e.Row });
                PXUIFieldAttribute.SetEnabled <RQBiddingVendor.curyID>(sender, e.Row, bidding == null);
            }
            else
            {
                PXUIFieldAttribute.SetEnabled <RQBiddingVendor.curyID>(sender, e.Row, false);
            }

            PXUIFieldAttribute.SetEnabled <RQBiddingVendor.curyTotalQuoteExtCost>(sender, e.Row, false);
            PXUIFieldAttribute.SetEnabled <RQBiddingVendor.totalQuoteExtCost>(sender, e.Row, false);
            PXUIFieldAttribute.SetEnabled <RQBiddingVendor.totalQuoteQty>(sender, e.Row, false);

            PORemitAddress remitAddress            = this.Remit_Address.Select();
            bool           enableAddressValidation = (remitAddress != null && remitAddress.IsDefaultAddress == false && remitAddress.IsValidated == false);

            this.validateAddresses.SetEnabled(enableAddressValidation);
        }
예제 #2
0
        public virtual void ValidateLeadTime(PXCache sender, PXRowSelectedEventArgs e)
        {
            RQBiddingVendor row = (RQBiddingVendor)e.Row;

            if (row == null)
            {
                return;
            }

            RQBiddingVendorExt rowExt = row.GetExtension <RQBiddingVendorExt>();

            bool isErr = false;

            if (row.CuryTotalQuoteExtCost > Decimal.Zero)
            {
                if (rowExt.UsrLeadTime != null && rowExt.UsrLeadTime == 0)
                {
                    sender.RaiseExceptionHandling <RQBiddingVendorExt.usrLeadTime>(e.Row, rowExt.UsrLeadTime, new PXSetPropertyException("Lead Time Must Be Greater Than Zero"));
                    isErr = true;
                }

                if (!isErr)
                {
                    sender.RaiseExceptionHandling <RQBiddingVendorExt.usrLeadTime>(e.Row, null, null);
                }
            }
        }
예제 #3
0
        protected virtual void RQBiddingVendor_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            RQBiddingVendor row = (RQBiddingVendor)e.Row;

            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete)
            {
                return;
            }
            RQBiddingVendorExt rowExt = row.GetExtension <RQBiddingVendorExt>();

            RQRequisition req = PXSelect <RQRequisition,
                                          Where <RQRequisition.reqNbr, Equal <Required <RQRequisition.reqNbr> > > > .Select(Base, row.ReqNbr);

            RQRequisitionExt reqExt = req.GetExtension <RQRequisitionExt>();

            if (reqExt.UsrPurchMethod == 2)
            {
                return;
            }

            if (row.CuryTotalQuoteExtCost > Decimal.Zero)
            {
                if (rowExt.UsrLeadTime == Decimal.Zero)
                {
                    if (sender.RaiseExceptionHandling <RQBiddingVendorExt.usrLeadTime>(e.Row, rowExt.UsrLeadTime, new PXSetPropertyException(LeadTimeCannotBeZero, typeof(RQBiddingVendorExt.usrLeadTime).Name)))
                    {
                        throw new PXRowPersistingException(typeof(RQBiddingVendorExt.usrLeadTime).Name, null, LeadTimeCannotBeZero, typeof(RQBiddingVendorExt.usrLeadTime).Name);
                    }
                }

                if (string.IsNullOrEmpty(rowExt.UsrIncoterm))
                {
                    if (sender.RaiseExceptionHandling <RQBiddingVendorExt.usrIncoterm>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(RQBiddingVendorExt.usrIncoterm).Name)))
                    {
                        throw new PXRowPersistingException(typeof(RQBiddingVendorExt.usrIncoterm).Name, null, ErrorMessages.FieldIsEmpty, typeof(RQBiddingVendorExt.usrIncoterm).Name);
                    }
                }

                if (rowExt.UsrRefDueDate == null)
                {
                    if (sender.RaiseExceptionHandling <RQBiddingVendorExt.usrRefDueDate>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(RQBiddingVendorExt.usrRefDueDate).Name)))
                    {
                        throw new PXRowPersistingException(typeof(RQBiddingVendorExt.usrRefDueDate).Name, null, ErrorMessages.FieldIsEmpty, typeof(RQBiddingVendorExt.usrRefDueDate).Name);
                    }
                }

                if (rowExt.UsrLeadFrom == null)
                {
                    if (sender.RaiseExceptionHandling <RQBiddingVendorExt.usrLeadFrom>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(RQBiddingVendorExt.usrLeadFrom).Name)))
                    {
                        throw new PXRowPersistingException(typeof(RQBiddingVendorExt.usrLeadFrom).Name, null, ErrorMessages.FieldIsEmpty, typeof(RQBiddingVendorExt.usrLeadFrom).Name);
                    }
                }
            }
        }
예제 #4
0
        protected virtual void RQBiddingVendor_RowInserting(PXCache sender, PXRowInsertingEventArgs e)
        {
            RQBiddingVendor row = (RQBiddingVendor)e.Row;

            if (row != null)
            {
                PORemitAddressAttribute.DefaultRecord <RQBiddingVendor.remitAddressID>(sender, e.Row);
                PORemitContactAttribute.DefaultRecord <RQBiddingVendor.remitContactID>(sender, e.Row);
            }
            BVendor.Current = (Vendor)BVendor.View.SelectSingleBound(new object[] { e.Row });
        }
예제 #5
0
        protected virtual void RQBiddingVendor_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            RQBiddingVendor row = (RQBiddingVendor)e.Row;

            if (row != null)
            {
                if (PXAccess.FeatureInstalled <FeaturesSet.multicurrency>() && row.ReqNbr != null && row.VendorID != null)
                {
                    BVendor.Current = (Vendor)BVendor.View.SelectSingleBound(new object[] { e.Row });
                    CurrencyInfo info = CurrencyInfoAttribute.SetDefaults <RQBiddingVendor.curyInfoID>(sender, e.Row);
                    sender.SetDefaultExt <RQBiddingVendor.curyID>(e.Row);
                }
            }
        }
예제 #6
0
        protected virtual void RQBiddingVendor_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            RQBiddingVendor row = (RQBiddingVendor)e.Row;

            if (row != null)
            {
                if ((bool)cmsetup.Current.MCActivated && row.ReqNbr != null && row.VendorID != null)
                {
                    BVendor.Current = (Vendor)BVendor.View.SelectSingleBound(new object[] { e.Row });
                    CurrencyInfo info = CurrencyInfoAttribute.SetDefaults <RQBiddingVendor.curyInfoID>(sender, e.Row);
                    sender.SetDefaultExt <RQBiddingVendor.curyID>(e.Row);
                }
            }
        }
예제 #7
0
        protected virtual void RQBiddingVendor_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
        {
            RQBiddingVendor    row    = (RQBiddingVendor)e.Row;
            RQBiddingVendorExt rowExt = row.GetExtension <RQBiddingVendorExt>();

            RQRequisition req = PXSelect <RQRequisition,
                                          Where <RQRequisition.reqNbr, Equal <Required <RQRequisition.reqNbr> > > > .Select(Base, row.ReqNbr);

            RQRequisitionExt reqExt = req.GetExtension <RQRequisitionExt>();

            if (req.CustomerID == null)
            {
                rowExt.UsrLeadTime = 30;
            }
        }
예제 #8
0
            protected override IEnumerable Handler(PXAdapter adapter)
            {
                List <object> items = new List <object>();

                foreach (object item in base.Handler(adapter))
                {
                    RQBiddingVendor b = item is PXResult ? (RQBiddingVendor)((PXResult)item)[0] : (RQBiddingVendor)item;
                    b.VendorID         = null;
                    b.VendorLocationID = null;
                    items.Add(item);
                    foreach (Type type in _Graph.Caches.Keys)
                    {
                        _Graph.Caches[type].IsDirty = false;
                    }
                }
                return(items);
            }
예제 #9
0
        protected virtual void RQBiddingVendor_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            RQBiddingVendor row = (RQBiddingVendor)e.Row;

            if (row == null)
            {
                return;
            }

            RQBiddingVendorExt rowExt = row.GetExtension <RQBiddingVendorExt>();

            bool bidExists = row.CuryTotalQuoteExtCost > Decimal.Zero == true;

            RQRequisition req = PXSelect <RQRequisition,
                                          Where <RQRequisition.reqNbr, Equal <Required <RQRequisition.reqNbr> > > > .Select(Base, row.ReqNbr);

            RQRequisitionExt reqExt = req.GetExtension <RQRequisitionExt>();


            if (bidExists)
            {
                if (req.CustomerID != null || reqExt.UsrPurchMethod != 2)
                {
                    if (req.CustomerID != null)
                    {
                        PXDefaultAttribute.SetPersistingCheck <RQBiddingVendorExt.usrIncoterm>(sender, row, bidExists ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
                    }

                    PXDefaultAttribute.SetPersistingCheck <RQBiddingVendorExt.usrLeadFrom>(sender, row, bidExists ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
                    PXDefaultAttribute.SetPersistingCheck <RQBiddingVendorExt.usrLeadTime>(sender, row, bidExists ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
                    PXDefaultAttribute.SetPersistingCheck <RQBiddingVendorExt.usrRefDueDate>(sender, row, bidExists ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
                }
            }

            //ValidateLeadTime(sender, e);
        }
예제 #10
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));
            }
        }