Exemple #1
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);
                    }
                }
            }
        }
        protected virtual void RQRequisition_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            RQRequisition    row    = (RQRequisition)e.Row;
            RQRequisitionExt rowExt = row.GetExtension <RQRequisitionExt>();

            if (row == null)
            {
                return;
            }

            bool splitable = row.Splittable == true;

            PXUIFieldAttribute.SetVisible <RQRequisition.curyID>(sender, null, PXAccess.FeatureInstalled <FeaturesSet.multicurrency>());
            PXUIFieldAttribute.SetVisible <RQRequisitionLine.biddingQty>(Base.Lines.Cache, null, splitable);
            PXUIFieldAttribute.SetVisible <RQBidding.orderQty>(Base.Bidding.Cache, null, splitable);

            PXUIFieldAttribute.SetEnabled <RQBidding.selected>(Base.Bidding.Cache, null, splitable);
            PXUIFieldAttribute.SetEnabled <RQRequisition.reqNbr>(sender, null, !(Base.State.Current.SingleMode == true));
            PXUIFieldAttribute.SetEnabled <RQRequisition.vendorID>(sender, row, false);
            PXUIFieldAttribute.SetEnabled <RQRequisition.vendorLocationID>(sender, row, false);

            if (row.Status == RQRequisitionStatus.Bidding)
            {
                PXUIFieldAttribute.SetEnabled <RQRequisition.vendorRefNbr>(sender, row, true);
                PXUIFieldAttribute.SetEnabled <RQRequisition.splittable>(sender, row, true);
            }
            else
            {
                PXUIFieldAttribute.SetEnabled(sender, row, false);
                PXUIFieldAttribute.SetEnabled <RQRequisition.reqNbr>(sender, row, true);
            }

            Base.Process.SetEnabled(row.Status == RQRequisitionStatus.Bidding);
            Base.ChooseVendor.SetEnabled(row.Status == RQRequisitionStatus.Bidding);
            Base.UpdateResult.SetEnabled(row.Status == RQRequisitionStatus.Bidding);
            Base.ClearResult.SetEnabled(row.Status == RQRequisitionStatus.Bidding);

            Base.Document.Cache.AllowInsert     =
                Base.Document.Cache.AllowDelete = false;
            Base.Document.Cache.AllowUpdate     = true;

            Base.Bidding.Cache.AllowInsert         =
                Base.Bidding.Cache.AllowUpdate     =
                    Base.Bidding.Cache.AllowDelete =

                        Base.Vendors.Cache.AllowInsert         =
                            Base.Vendors.Cache.AllowUpdate     =
                                Base.Vendors.Cache.AllowDelete =
                                    row.Status == RQRequisitionStatus.Bidding;

            bool rHold     = row.Hold == true;
            bool custOrder = row.CustomerID != null;
            bool gaRequest = (row.CustomerID == null && rowExt.UsrPurchMethod == 2) || row.CustomerID != null;
        }
        protected virtual void EnsurePattern(RQRequisition row)
        {
            foreach (RQRequisitionLine line in Base.Lines.Select())
            {
                RQRequisitionLineExt lineext = Base.Lines.Cache.GetExtension <RQRequisitionLineExt>(line);

                EnsureLine(row, line, lineext);
                Base.Lines.Cache.Update(line);

                lineext.PreventUpdate = true;
            }
        }
Exemple #4
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;
            }
        }
        protected virtual void EnsureLine(RQRequisition row, RQRequisitionLine line, RQRequisitionLineExt lineext)
        {
            if (row.VendorID == null || row.VendorLocationID == null)
            {
                lineext.UsrPatternCost        = 0;
                lineext.UsrCuryPatternCost    = 0;
                lineext.UsrInitialCost        = 0;
                lineext.UsrCuryInitialCost    = 0;
                lineext.UsrCuryInitialExtCost = 0;
                lineext.UsrInitialExtCost     = 0;
            }
            else
            {
                PXCache   cache   = Base.Bidding.Cache;
                RQBidding bidding = PXSelect <RQBidding,
                                              Where <RQBidding.reqNbr, Equal <Required <RQBidding.reqNbr> >,
                                                     And <RQBidding.lineNbr, Equal <Required <RQBidding.lineNbr> >,
                                                          And <RQBidding.vendorID, Equal <Required <RQBidding.vendorID> >,
                                                               And <RQBidding.vendorLocationID, Equal <Required <RQBidding.vendorLocationID> > > > > > > .Select(Base, line.ReqNbr, line.LineNbr, row.VendorID, row.VendorLocationID);

                if (bidding != null)
                {
                    RQBiddingExt biddingext = bidding.GetExtension <RQBiddingExt>();

                    //Pattern
                    lineext.UsrCuryPatternCost = Tools.ConvertCurrency <RQRequisitionLine.curyInfoID>(Base.Lines.Cache, line, biddingext.UsrPatternCost ?? 0);
                    //Unit Cost
                    line.CuryEstUnitCost = Tools.ConvertCurrency <RQRequisitionLine.curyInfoID>(Base.Lines.Cache, line, bidding.QuoteUnitCost ?? 0);
                    //Ext Cost
                    line.CuryEstExtCost = Tools.ConvertCurrency <RQRequisitionLine.curyInfoID>(Base.Lines.Cache, line, bidding.QuoteExtCost ?? 0);
                    //Initial Cost
                    lineext.UsrCuryInitialCost = Tools.ConvertCurrency <RQRequisitionLine.curyInfoID>(Base.Lines.Cache, line, biddingext.UsrInitialCost ?? 0);
                    //Initial Ext Cost
                    lineext.UsrCuryInitialCost = Tools.ConvertCurrency <RQRequisitionLine.curyInfoID>(Base.Lines.Cache, line, biddingext.UsrInitialExtCost ?? 0);
                }
            }
        }
Exemple #6
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);
        }
Exemple #7
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));
            }
        }
        protected virtual void RQRequisition_VendorLocationID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            RQRequisition upd = e.Row as RQRequisition;

            EnsurePattern(e.Row as RQRequisition);
        }