protected virtual void _(Events.FieldDefaulting <CROpportunityProducts, FSxCROpportunityProducts.estimatedDuration> e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (fsxCROpportunityProductsRow != null)
            {
                InventoryItem inventoryItemRow = SharedFunctions.GetInventoryItemRow(Base, crOpportunityProductsRow.InventoryID);

                if (inventoryItemRow != null)
                {
                    FSxService fsxServiceRow = PXCache <InventoryItem> .GetExtension <FSxService>(inventoryItemRow);

                    if (inventoryItemRow.ItemType == INItemTypes.ServiceItem ||
                        inventoryItemRow.ItemType == INItemTypes.NonStockItem)
                    {
                        e.NewValue = fsxServiceRow?.EstimatedDuration;
                        e.Cancel   = true;
                    }
                }
            }
        }
        protected virtual void _(Events.RowSelected <CROpportunityProducts> e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row;
            PXCache cache = e.Cache;

            FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (fsxCROpportunityProductsRow != null)
            {
                InventoryItem inventoryItemRow = SharedFunctions.GetInventoryItemRow(Base, crOpportunityProductsRow.InventoryID);

                if (inventoryItemRow != null)
                {
                    PXUIFieldAttribute.SetEnabled <FSxCROpportunityProducts.billingRule>(cache, crOpportunityProductsRow, inventoryItemRow.ItemType == INItemTypes.ServiceItem);
                    PXUIFieldAttribute.SetEnabled <FSxCROpportunityProducts.estimatedDuration>(cache, crOpportunityProductsRow, inventoryItemRow.ItemType == INItemTypes.ServiceItem || inventoryItemRow.ItemType == INItemTypes.NonStockItem);
                    PXUIFieldAttribute.SetEnabled <CROpportunityProducts.curyUnitCost>(cache, crOpportunityProductsRow, crOpportunityProductsRow.POCreate == true);
                    PXUIFieldAttribute.SetEnabled <FSxCROpportunityProducts.vendorLocationID>(cache, crOpportunityProductsRow, crOpportunityProductsRow.POCreate == true);
                    PXUIFieldAttribute.SetEnabled <CROpportunityProducts.quantity>(cache, crOpportunityProductsRow, fsxCROpportunityProductsRow.BillingRule != ID.BillingRule.TIME);
                }
            }
        }
        protected virtual void _(Events.FieldDefaulting <CROpportunityProducts, FSxCROpportunityProducts.billingRule> e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (crOpportunityProductsRow.InventoryID != null)
            {
                InventoryItem inventoryItemRow = SharedFunctions.GetInventoryItemRow(Base, crOpportunityProductsRow.InventoryID);

                if (inventoryItemRow.ItemType == INItemTypes.ServiceItem)
                {
                    FSxService fsxServiceRow = PXCache <InventoryItem> .GetExtension <FSxService>(inventoryItemRow);

                    e.NewValue = fsxServiceRow?.BillingRule;
                    e.Cancel   = true;
                }
                else
                {
                    e.NewValue = ID.BillingRule.FLAT_RATE;
                    e.Cancel   = true;
                }
            }
        }
Esempio n. 4
0
        protected virtual void CROpportunityProducts_CuryUnitCost_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (string.IsNullOrEmpty(crOpportunityProductsRow.UOM) == false && crOpportunityProductsRow.InventoryID != null && crOpportunityProductsRow.POCreate == true)
            {
                object unitcost;
                cache.RaiseFieldDefaulting <CROpportunityProducts.unitCost>(e.Row, out unitcost);

                if (unitcost != null && (decimal)unitcost != 0m)
                {
                    decimal newval = INUnitAttribute.ConvertToBase <CROpportunityProducts.inventoryID, CROpportunityProducts.uOM>(cache, crOpportunityProductsRow, (decimal)unitcost, INPrecision.NOROUND);

                    IPXCurrencyHelper currencyHelper = Base.FindImplementation <IPXCurrencyHelper>();

                    if (currencyHelper != null)
                    {
                        currencyHelper.CuryConvCury((decimal)unitcost, out newval);
                    }
                    else
                    {
                        CM.PXDBCurrencyAttribute.CuryConvCury(cache, crOpportunityProductsRow, newval, out newval, true);
                    }

                    e.NewValue = Math.Round(newval, CommonSetupDecPl.PrcCst, MidpointRounding.AwayFromZero);
                    e.Cancel   = true;
                }
            }
        }
Esempio n. 5
0
        public static void InsertFSSODetFromOpportunity(ServiceOrderEntry graphServiceOrder,
                                                        PXCache cacheOpportunityProducts,
                                                        CRSetup crSetupRow,
                                                        CROpportunityProducts crOpportunityProductRow,
                                                        FSxCROpportunityProducts fsxCROpportunityProductsRow,
                                                        InventoryItem inventoryItemRow)
        {
            if (graphServiceOrder == null ||
                crOpportunityProductRow == null ||
                fsxCROpportunityProductsRow == null ||
                inventoryItemRow == null)
            {
                return;
            }

            //Insert a new SODet line
            FSSODet fsSODetRow = new FSSODet();

            UpdateFSSODetFromOpportunity(graphServiceOrder.ServiceOrderDetails.Cache,
                                         fsSODetRow,
                                         crOpportunityProductRow,
                                         fsxCROpportunityProductsRow,
                                         SharedFunctions.GetLineTypeFromInventoryItem(inventoryItemRow));

            SharedFunctions.CopyNotesAndFiles(cacheOpportunityProducts,
                                              graphServiceOrder.ServiceOrderDetails.Cache,
                                              crOpportunityProductRow, graphServiceOrder.ServiceOrderDetails.Current,
                                              crSetupRow.CopyNotes,
                                              crSetupRow.CopyFiles);
        }
        public virtual void CreateServiceOrderDocument(OpportunityMaint graphOpportunityMaint, CROpportunity crOpportunityRow, FSCreateServiceOrderFilter fsCreateServiceOrderFilterRow)
        {
            if (graphOpportunityMaint == null ||
                crOpportunityRow == null ||
                fsCreateServiceOrderFilterRow == null)
            {
                return;
            }

            ServiceOrderEntry graphServiceOrderEntry = PXGraph.CreateInstance <ServiceOrderEntry>();

            FSServiceOrder newServiceOrderRow = CRExtensionHelper.InitNewServiceOrder(fsCreateServiceOrderFilterRow.SrvOrdType, ID.SourceType_ServiceOrder.OPPORTUNITY);

            CRSetup crSetupRow = GetCRSetup();

            graphServiceOrderEntry.ServiceOrderRecords.Current = graphServiceOrderEntry.ServiceOrderRecords.Insert(newServiceOrderRow);

            CRExtensionHelper.UpdateServiceOrderHeader(graphServiceOrderEntry,
                                                       Base.Opportunity.Cache,
                                                       crOpportunityRow,
                                                       fsCreateServiceOrderFilterRow,
                                                       graphServiceOrderEntry.ServiceOrderRecords.Current,
                                                       Base.Opportunity_Contact.Current,
                                                       Base.Opportunity_Address.Current,
                                                       true);

            SharedFunctions.CopyNotesAndFiles(Base.Opportunity.Cache,
                                              graphServiceOrderEntry.ServiceOrderRecords.Cache,
                                              crOpportunityRow, graphServiceOrderEntry.ServiceOrderRecords.Current,
                                              crSetupRow.CopyNotes,
                                              crSetupRow.CopyFiles);

            foreach (CROpportunityProducts crOpportunityProductsRow in graphOpportunityMaint.Products.Select())
            {
                if (crOpportunityProductsRow.InventoryID != null)
                {
                    InventoryItem inventoryItemRow = SharedFunctions.GetInventoryItemRow(graphServiceOrderEntry, crOpportunityProductsRow.InventoryID);

                    if (inventoryItemRow.StkItem == true &&
                        graphServiceOrderEntry.ServiceOrderTypeSelected.Current.PostTo == ID.SrvOrdType_PostTo.ACCOUNTS_RECEIVABLE_MODULE)
                    {
                        throw new PXException(TX.Error.STOCKITEM_NOT_HANDLED_BY_SRVORDTYPE, inventoryItemRow.InventoryCD);
                    }

                    FSxCROpportunityProducts fsxCROpportunityProductsRow = graphOpportunityMaint.Products.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);
                    CRExtensionHelper.InsertFSSODetFromOpportunity(graphServiceOrderEntry, graphOpportunityMaint.Products.Cache, crSetupRow, crOpportunityProductsRow, fsxCROpportunityProductsRow, inventoryItemRow);
                }
            }

            graphServiceOrderEntry.ServiceOrderRecords.Current.SourceRefNbr = crOpportunityRow.OpportunityID;

            if (!Base.IsContractBasedAPI)
            {
                throw new PXRedirectRequiredException(graphServiceOrderEntry, null);
            }
        }
Esempio n. 7
0
        public static void UpdateFSSODetFromOpportunity(PXCache soDetCache,
                                                        FSSODet fsSODetRow,
                                                        CROpportunityProducts crOpportunityProductRow,
                                                        FSxCROpportunityProducts fsxCROpportunityProductsRow,
                                                        string lineType)
        {
            if (crOpportunityProductRow == null || fsxCROpportunityProductsRow == null)
            {
                return;
            }

            fsSODetRow.SourceNoteID = crOpportunityProductRow.NoteID;
            soDetCache.Current      = fsSODetRow = (FSSODet)soDetCache.Insert(fsSODetRow);

            fsSODetRow.LineType    = lineType;
            fsSODetRow.InventoryID = crOpportunityProductRow.InventoryID;
            fsSODetRow.IsBillable  = crOpportunityProductRow.IsFree == false;

            soDetCache.Current = fsSODetRow = (FSSODet)soDetCache.Update(fsSODetRow);
            fsSODetRow         = (FSSODet)soDetCache.CreateCopy(fsSODetRow);

            fsSODetRow.BillingRule = fsxCROpportunityProductsRow.BillingRule;
            fsSODetRow.TranDesc    = crOpportunityProductRow.Descr;

            if (crOpportunityProductRow.SiteID != null)
            {
                fsSODetRow.SiteID = crOpportunityProductRow.SiteID;
            }

            fsSODetRow.EstimatedDuration = fsxCROpportunityProductsRow.EstimatedDuration;
            fsSODetRow.EstimatedQty      = crOpportunityProductRow.Qty;

            fsSODetRow.CuryUnitPrice = crOpportunityProductRow.CuryUnitPrice;
            fsSODetRow.ManualPrice   = crOpportunityProductRow.ManualPrice;

            fsSODetRow.ProjectID     = crOpportunityProductRow.ProjectID;
            fsSODetRow.ProjectTaskID = crOpportunityProductRow.TaskID;
            fsSODetRow.CostCodeID    = crOpportunityProductRow.CostCodeID;

            fsSODetRow.CuryUnitCost = crOpportunityProductRow.CuryUnitCost;
            fsSODetRow.ManualCost   = crOpportunityProductRow.POCreate;

            fsSODetRow.EnablePO           = crOpportunityProductRow.POCreate;
            fsSODetRow.POVendorID         = crOpportunityProductRow.VendorID;
            fsSODetRow.POVendorLocationID = fsxCROpportunityProductsRow.VendorLocationID;

            fsSODetRow.TaxCategoryID = crOpportunityProductRow.TaxCategoryID;

            fsSODetRow.DiscPct              = crOpportunityProductRow.DiscPct;
            fsSODetRow.CuryDiscAmt          = crOpportunityProductRow.CuryDiscAmt;
            fsSODetRow.CuryBillableExtPrice = crOpportunityProductRow.CuryExtPrice;

            soDetCache.Current = soDetCache.Update(fsSODetRow);
        }
        protected virtual void _(Events.FieldUpdated <CROpportunityProducts, FSxCROpportunityProducts.estimatedDuration> e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (fsxCROpportunityProductsRow.EstimatedDuration != null && fsxCROpportunityProductsRow.BillingRule == ID.BillingRule.TIME)
            {
                e.Cache.SetDefaultExt <CROpportunityProducts.quantity>(crOpportunityProductsRow);
            }
        }
        protected virtual void _(Events.FieldDefaulting <CROpportunityProducts, FSxCROpportunityProducts.vendorLocationID> e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (crOpportunityProductsRow.POCreate == false || crOpportunityProductsRow.InventoryID == null)
            {
                e.Cancel = true;
            }
        }
Esempio n. 10
0
        protected virtual void CROpportunityProducts_EstimatedDuration_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (fsxCROpportunityProductsRow.EstimatedDuration != null && fsxCROpportunityProductsRow.BillingRule == ID.BillingRule.TIME)
            {
                cache.SetDefaultExt <CROpportunityProducts.quantity>(crOpportunityProductsRow);
            }
        }
Esempio n. 11
0
        protected virtual void CROpportunityProducts_VendorLocationID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (crOpportunityProductsRow.POCreate == false || crOpportunityProductsRow.InventoryID == null)
            {
                e.Cancel = true;
            }
        }
Esempio n. 12
0
        protected virtual void CROpportunityProducts_SiteID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (fsxCROpportunityProductsRow != null)
            {
                cache.SetDefaultExt <CROpportunityProducts.curyUnitCost>(e.Row);
            }
        }
        protected virtual void _(Events.FieldUpdated <CROpportunityProducts, CROpportunityProducts.siteID> e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row;
            PXCache cache = e.Cache;

            FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (fsxCROpportunityProductsRow != null && Base.IsImportFromExcel == false)
            {
                cache.SetDefaultExt <CROpportunityProducts.curyUnitCost>(e.Row);
            }
        }
        protected virtual void _(Events.FieldDefaulting <CROpportunityProducts, CROpportunityProducts.quantity> e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (fsxCROpportunityProductsRow != null &&
                fsxCROpportunityProductsRow.BillingRule == ID.BillingRule.TIME &&
                fsxCROpportunityProductsRow.EstimatedDuration != null &&
                fsxCROpportunityProductsRow.EstimatedDuration > 0)
            {
                e.NewValue = fsxCROpportunityProductsRow.EstimatedDuration / 60m;
            }
            else
            {
                e.NewValue = 0m;
            }
        }
Esempio n. 15
0
        protected virtual void CROpportunityProducts_Quantity_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunityProducts    crOpportunityProductsRow    = (CROpportunityProducts)e.Row;
            FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow);

            if (fsxCROpportunityProductsRow != null &&
                fsxCROpportunityProductsRow.BillingRule == ID.BillingRule.TIME &&
                fsxCROpportunityProductsRow.EstimatedDuration != null &&
                fsxCROpportunityProductsRow.EstimatedDuration > 0)
            {
                e.NewValue = fsxCROpportunityProductsRow.EstimatedDuration / 60m;
            }
            else
            {
                e.NewValue = 0m;
            }
        }