예제 #1
0
            private int?GetAcct(PXGraph graph,
                                IFSSODetBase fsSODetBase,
                                FSAppointmentDet fsAppointmentInventoryItem,
                                FSServiceOrder fsServiceOrderRow,
                                FSSrvOrdType fsSrvOrdTypeRow)
            {
                int?acctID = null;

                if (fsSODetBase != null)
                {
                    if (fsSODetBase.AcctID != null)
                    {
                        acctID = fsSODetBase.AcctID;
                    }
                    else
                    {
                        acctID = ServiceOrderCore.Get_TranAcctID_DefaultValue(graph,
                                                                              fsSrvOrdTypeRow.SalesAcctSource,
                                                                              fsSODetBase.InventoryID,
                                                                              fsSODetBase.SiteID,
                                                                              fsServiceOrderRow);
                    }
                }
                else if (fsAppointmentInventoryItem != null)
                {
                    acctID = ServiceOrderCore.Get_TranAcctID_DefaultValue(graph,
                                                                          fsSrvOrdTypeRow.SalesAcctSource,
                                                                          fsAppointmentInventoryItem.InventoryID,
                                                                          fsAppointmentInventoryItem.SiteID,
                                                                          fsServiceOrderRow);
                }

                return(acctID);
            }
        public static void X_UOM_FieldDefaulting <DAC>(PXCache cache, PXFieldDefaultingEventArgs e)
            where DAC : class, IBqlTable, IFSSODetBase, new()
        {
            if (e.Row == null)
            {
                return;
            }

            IFSSODetBase fsSODetBaseRow = (IFSSODetBase)e.Row;
            string       returnUOM      = ((CommonSetup)PXSelect <CommonSetup> .Select(cache.Graph))?.WeightUOM;

            if (fsSODetBaseRow.InventoryID != null)
            {
                returnUOM = ((InventoryItem)
                             PXSelect <InventoryItem,
                                       Where <InventoryItem.inventoryID, Equal <Required <FSSODet.inventoryID> > > >
                             .Select(cache.Graph, fsSODetBaseRow.InventoryID))?.SalesUnit;
            }

            e.NewValue = returnUOM;
        }
        protected virtual void VerifyIsAlreadyPosted <Field>(PXCache cache, FSAppointmentDet fsAppointmentDetRow, FSAppointmentInventoryItem fsAppointmentInventoryItemRow, FSBillingCycle billingCycleRow)
            where Field : class, IBqlField
        {
            if ((fsAppointmentDetRow == null && fsAppointmentInventoryItemRow == null) || ServiceOrderRelated.Current == null || billingCycleRow == null)
            {
                return;
            }

            IFSSODetBase row   = null;
            int?         pivot = -1;

            if (fsAppointmentDetRow != null)
            {
                row   = fsAppointmentDetRow;
                pivot = fsAppointmentDetRow.SODetID;
            }
            else if (fsAppointmentInventoryItemRow != null)
            {
                row   = fsAppointmentInventoryItemRow;
                pivot = fsAppointmentInventoryItemRow.AppDetID > 0 ? fsAppointmentInventoryItemRow.AppDetID : null;
            }

            PXEntryStatus status            = ServiceOrderRelated.Cache.GetStatus(ServiceOrderRelated.Current);
            bool          needsVerify       = status == PXEntryStatus.Updated || status == PXEntryStatus.Notchanged;
            bool          isSOAlreadyPosted = ServiceOrderPostedIn.Select().Count > 0;

            if (needsVerify == true &&
                pivot == null &&
                IsInstructionOrComment(row) == false &&
                billingCycleRow.BillingBy == ID.Billing_By.SERVICE_ORDER &&
                isSOAlreadyPosted == true)
            {
                cache.RaiseExceptionHandling <Field>(row,
                                                     row.InventoryID,
                                                     new PXSetPropertyException(
                                                         PXMessages.LocalizeFormat(TX.Error.CANNOT_ADD_INVENTORY_TYPE_LINES_BECAUSE_SO_POSTED, GetLineType(row.LineType)),
                                                         PXErrorLevel.RowError));
            }
        }
예제 #4
0
        public static bool CheckReplaceComponentLines <TPartLine, TComponentLineRef>(PXCache cache, PXResultset <TPartLine> rows, IFSSODetBase currentRow)
            where TPartLine : class, IBqlTable, IFSSODetBase, new()
            where TComponentLineRef : IBqlField
        {
            if (currentRow == null)
            {
                return(true);
            }

            if (currentRow.EquipmentAction != ID.Equipment_Action.REPLACING_COMPONENT ||
                currentRow.SMEquipmentID == null ||
                currentRow.EquipmentLineRef == null)
            {
                return(true);
            }

            bool noErrors = true;

            foreach (TPartLine row in rows.RowCast <TPartLine>().Where(x => x.IsInventoryItem == true))
            {
                if (row.LineID != currentRow.LineID &&
                    row.EquipmentAction == currentRow.EquipmentAction &&
                    row.SMEquipmentID == currentRow.SMEquipmentID &&
                    row.EquipmentLineRef == currentRow.EquipmentLineRef)
                {
                    string componentLineRef = (string)PXSelectorAttribute.GetField(cache,
                                                                                   currentRow,
                                                                                   typeof(TComponentLineRef).Name,
                                                                                   currentRow.EquipmentLineRef,
                                                                                   typeof(FSEquipmentComponent.lineRef).Name);

                    cache.RaiseExceptionHandling <TComponentLineRef>(currentRow,
                                                                     componentLineRef,
                                                                     new PXSetPropertyException(TX.Error.SELECTED_COMPONENT_HAS_ALREADY_BEEN_CHOSEN_FOR_REPLACEMENT, PXErrorLevel.Error));

                    noErrors = false;
                }
            }

            return(noErrors);
        }