Beispiel #1
0
        public IEnumerable detailsView()
        {
            //var lastFinPeriod = DateTime.Now.AddMonths(-1).ToString("yyyyMM");

            var filter = MasterViewFilter.Current?.FinPeriodID;

            if (filter == null)
            {
                filter = ((DateTime)Accessinfo.BusinessDate).AddMonths(-1).ToString("yyyyMM");
            }

            PXSelectBase <LCMValuation> command = new SelectFrom <LCMValuation> .View.ReadOnly(this);

            var result = new PXDelegateResult();

            foreach (PXResult <LCMValuation> row in command.Select())
            {
                if (((LCMValuation)row).FinPeriodID == filter)
                {
                    result.Add(row);
                }
            }

            return(result);
        }
Beispiel #2
0
        protected void _(Events.RowPersisting <APInvoice> e, PXRowPersisting baseHandler)
        {
            baseHandler?.Invoke(e.Cache, e.Args);

            if (ManualAPBill.Select().Count == 0 && Base.Taxes.Select().Count > 0)
            {
                throw new PXException(TWMessages.NoGUIWithTax);
            }

            //if (activateGUI.Equals(false) || e.Row.Status.Equals(APDocStatus.Open)) { return; }

            //APRegisterExt regisExt = PXCache<APRegister>.GetExtension<APRegisterExt>(e.Row);

            //TWNGUIValidation tWNGUIValidation = new TWNGUIValidation();

            //if (regisExt.UsrVATInCode == TWGUIFormatCode.vATInCode21 ||
            //    regisExt.UsrVATInCode == TWGUIFormatCode.vATInCode22 ||
            //    regisExt.UsrVATInCode == TWGUIFormatCode.vATInCode25)
            //{
            //    tWNGUIValidation.CheckGUINbrExisted(Base, regisExt.UsrGUINbr, regisExt.UsrVATInCode);
            //}
            //else
            //{
            //    tWNGUIValidation.CheckCorrespondingInv(Base, regisExt.UsrGUINbr, regisExt.UsrVATInCode);

            //    if (tWNGUIValidation.errorOccurred.Equals(true))
            //    {
            //        e.Cache.RaiseExceptionHandling<APRegisterExt.usrGUINbr>(e.Row, regisExt.UsrGUINbr, new PXSetPropertyException(tWNGUIValidation.errorMessage, PXErrorLevel.Error));
            //    }
            //}
        }
Beispiel #3
0
        //Copy repair items and labor items from the Services and Prices form.
        protected virtual void _(Events.RowUpdated <RSSVWorkOrder> e)
        {
            if (WorkOrders.Cache.GetStatus(e.Row) == PXEntryStatus.Inserted &&
                !e.Cache.ObjectsEqual <RSSVWorkOrder.serviceID, RSSVWorkOrder.deviceID>(e.Row, e.OldRow))
            {
                if (e.Row.ServiceID != null && e.Row.DeviceID != null &&
                    !IsCopyPasteContext && RepairItems.Select().Count == 0 &&
                    Labor.Select().Count == 0)
                {
                    //Retrieve the default repair items
                    var repairItems = SelectFrom <RSSVRepairItem> .
                                      Where <RSSVRepairItem.serviceID.IsEqual <RSSVWorkOrder.serviceID.FromCurrent> .
                                             And <RSSVRepairItem.deviceID.IsEqual <RSSVWorkOrder.deviceID.FromCurrent> > >
                                      .View.Select(this);

                    //Insert default repair items
                    foreach (RSSVRepairItem item in repairItems)
                    {
                        RSSVWorkOrderItem orderItem = RepairItems.Insert();
                        orderItem.RepairItemType = item.RepairItemType;
                        orderItem.InventoryID    = item.InventoryID;
                        orderItem.BasePrice      = item.BasePrice;
                        RepairItems.Update(orderItem);
                    }

                    //Retrieve the default labor items
                    var laborItems = SelectFrom <RSSVLabor> .
                                     Where <RSSVLabor.serviceID.IsEqual <RSSVWorkOrder.serviceID.FromCurrent> .
                                            And <RSSVLabor.deviceID.IsEqual <RSSVWorkOrder.deviceID.FromCurrent> > >
                                     .View.Select(this);

                    //Insert the default labor items
                    foreach (RSSVLabor item in laborItems)
                    {
                        RSSVWorkOrderLabor orderItem = new RSSVWorkOrderLabor();
                        orderItem.InventoryID  = item.InventoryID;
                        orderItem              = Labor.Insert(orderItem);
                        orderItem.DefaultPrice = item.DefaultPrice;
                        orderItem.Quantity     = item.Quantity;
                        orderItem.ExtPrice     = item.ExtPrice;
                        Labor.Update(orderItem);
                    }
                }
            }
        }
        public IEnumerable CalculatePlanCost(PXAdapter adapter)
        {
            Base.CalculatePlanCost(adapter);
            var       BomCostData = amBomCost.Select(this);
            AMBomCost model       = new AMBomCost();

            if (amBomCost.Select(this).Count == 0)
            {
                model.BOMID                   = Base.ProdItemSelected.Current.BOMID;
                model.InventoryID             = Base.ProdMaintRecords.Current.InventoryID;
                model.RevisionID              = Base.ProdItemSelected.Current.BOMRevisionID;
                model.UserID                  = Base.Accessinfo.UserID;
                model.SiteID                  = Base.ProdItemSelected.Current.SiteID;
                model.MachCost                = Base.ProdTotalRecs.Current.PlanMachine;
                model.ToolCost                = Base.ProdTotalRecs.Current.PlanTool;
                model.FOvdCost                = Base.ProdTotalRecs.Current.PlanFixedOverhead;
                model.VOvdCost                = Base.ProdTotalRecs.Current.PlanVariableOverhead;
                model.SubcontractMaterialCost = Base.ProdTotalRecs.Current.PlanSubcontract;
                model.TotalCost               = Base.ProdTotalRecs.Current.PlanTotal;
                model.UnitCost                = Base.ProdTotalRecs.Current.PlanUnitCost;
                this.amBomCost.Cache.Insert(model);
            }
            else
            {
                model          = BomCostData.TopFirst;
                model.SiteID   = Base.ProdItemSelected.Current.SiteID;
                model.MachCost = Base.ProdTotalRecs.Current.PlanMachine;
                model.ToolCost = Base.ProdTotalRecs.Current.PlanTool;
                model.FOvdCost = Base.ProdTotalRecs.Current.PlanFixedOverhead;
                model.VOvdCost = Base.ProdTotalRecs.Current.PlanVariableOverhead;
                model.SubcontractMaterialCost = Base.ProdTotalRecs.Current.PlanSubcontract;
                model.TotalCost = Base.ProdTotalRecs.Current.PlanTotal;
                model.UnitCost  = Base.ProdTotalRecs.Current.PlanUnitCost;
                this.amBomCost.Cache.Update(model);
            }
            Base.Persist();
            return(adapter.Get());
        }
Beispiel #5
0
        protected IEnumerable updateMaterial(PXAdapter adapter)
        {
            var data = Bom.Select();

            data.Where(x => ((AMBomMatl)x).BOMID == "210293").ToList()
            .ForEach(x =>
            {
                var row = x.GetItem <AMBomMatl>();
                Bom.SetValueExt <AMBomMatl.qtyReq>(row, (decimal?)0.006666);
                Bom.Update(row);
            });
            this.Actions.PressSave();
            return(adapter.Get());
        }
Beispiel #6
0
        /// <summary> Get Config </summary>
        public FTP_Config GetConfig()
        {
            var        configP3PL = P3PLSetup.Select().RowCast <LUM3PLUKSetup>().FirstOrDefault();
            FTP_Config config     = new FTP_Config()
            {
                FtpHost = configP3PL.FtpHost,
                FtpUser = configP3PL.FtpUser,
                FtpPass = configP3PL.FtpPass,
                FtpPort = configP3PL.FtpPort,
                FtpPath = configP3PL.FtpOutPath
            };

            return(config);
        }
Beispiel #7
0
        public virtual IEnumerable addUsers(PXAdapter adapter)
        {
            var users = UsersForAddition.Select().Where(a => a.GetItem <Contact>().Selected == true).ToList();

            foreach (var user in users)
            {
                var surveyUser = new SurveyUser();
                surveyUser.Active    = true;
                surveyUser.SurveyID  = SurveyCurrent.Current.SurveyID;
                surveyUser.ContactID = user.GetItem <Contact>().ContactID;
                surveyUser           = SurveyUsers.Insert(surveyUser);
            }

            return(adapter.Get());
        }
        protected virtual IEnumerable innerLabel(PXAdapter adapter)
        {
            var _reportID   = "lm601002";
            var _CurrentRow = Base.GetCacheCurrent <AMProdItem>().Current;

            PXResultset <InventoryItem> data =
                SelectFrom <InventoryItem>
                .LeftJoin <INItemXRef> .On <INItemXRef.inventoryID.IsEqual <InventoryItem.inventoryID> >
                .LeftJoin <CSAnswers> .On <InventoryItem.noteID.IsEqual <CSAnswers.refNoteID> >
                .Where <InventoryItem.inventoryID.IsEqual <P.AsInt> > .View.Select(Base, _CurrentRow.InventoryID);

            SOOrder soData = soOrderData.Select(
                _CurrentRow.GetExtension <AMProdItemExt>().UsrSOOrderNbr,
                _CurrentRow.GetExtension <AMProdItemExt>().UsrSOOrderType);

            SOLine soLineData =
                SelectFrom <SOLine>
                .Where <SOLine.orderNbr.IsEqual <P.AsString>
                        .And <SOLine.orderType.IsEqual <P.AsString> >
                        .And <SOLine.lineNbr.IsEqual <P.AsInt> > >
                .View.Select(Base,
                             _CurrentRow.GetExtension <AMProdItemExt>().UsrSOOrderNbr,
                             _CurrentRow.GetExtension <AMProdItemExt>().UsrSOOrderType,
                             _CurrentRow.GetExtension <AMProdItemExt>().UsrSOLineNbr);

            var _customer = (soOrderData.Cache.GetValueExt(soData, PX.Objects.CS.Messages.Attribute + "ENDC") as PXFieldState).Value.ToString();
            var ENDCDescr = new PXGraph().Select <CSAttributeDetail>().Where(x => x.ValueID == _customer).FirstOrDefault()?.Description;

            ENDCDescr = ENDCDescr ?? _customer;

            Dictionary <string, string> parameters = new Dictionary <string, string>
            {
                ["OrderType"]      = _CurrentRow.OrderType,
                ["ProdOrdID"]      = _CurrentRow.ProdOrdID,
                ["Customer"]       = ENDCDescr,
                ["CustomerPartNo"] = soLineData?.AlternateID,
                ["Description"]    = data.FirstOrDefault().GetItem <InventoryItem>().Descr,
                ["Resistor"]       = data.RowCast <CSAnswers>().Where(x => x.AttributeID == "RESISTOR").FirstOrDefault()?.Value,
                ["DATE"]           = null
            };

            throw new PXReportRequiredException(parameters, _reportID, string.Format("Report {0}", _reportID));
        }
        protected virtual void MarkAs(PXCache cache, CRActivity row, Guid UserID, int status)
        {
            if (IsImport || row.NoteID == null)
            {
                return;
            }

            var epviewSelect = new SelectFrom <EPView>
                               .Where <EPView.noteID.IsEqual <@P.AsGuid>
                                       .And <EPView.userID.IsEqual <@P.AsGuid> > >
                               .View(this);

            EPView epview = epviewSelect
                            .Select(row.NoteID, UserID)
                            .FirstOrDefault();

            bool dirty = EPViews.Cache.IsDirty;

            if (epview == null)
            {
                var epView = EPViews.Cache.Insert(
                    new EPView
                {
                    NoteID = row.NoteID,
                    UserID = UserID,
                    Status = status,
                }
                    );

                EPViews.Cache.PersistInserted(epView);
                epviewSelect.View.Clear();
                EPViews.Cache.SetStatus(epView, PXEntryStatus.Notchanged);
            }
            else if (status != epview.Status)
            {
                epview.Status = status;
                EPViews.Cache.PersistUpdated(epview);
            }
            EPViews.Cache.IsDirty = dirty;
        }
Beispiel #10
0
        public virtual IEnumerable checkForDuplicates(PXAdapter adapter)
        {
            DuplicateDocument duplicateDocument = DuplicateDocuments.Current ?? DuplicateDocuments.Select();

            if (duplicateDocument == null)
            {
                return(adapter.Get());
            }

            var prevStatus  = duplicateDocument.DuplicateStatus;
            var prevIsDirty = Base.Caches[DuplicateDocuments.Cache.GetMain(duplicateDocument).GetType()].IsDirty;

            if (CheckIsActive())
            {
                duplicateDocument.DuplicateFound = true;
                duplicateDocument = DuplicateDocuments.Update(duplicateDocument);

                Duplicates.View.Clear();
                var result = Duplicates.Select().ToList();

                bool anyFound = result != null && result.Count > 0;
                duplicateDocument.DuplicateFound  = anyFound;
                duplicateDocument.DuplicateStatus = anyFound
                                        ? DuplicateStatusAttribute.PossibleDuplicated
                                        : DuplicateStatusAttribute.Validated;

                duplicateDocument = DuplicateDocuments.Update(duplicateDocument);

                if (duplicateDocument.ContactType?.IsIn(ContactTypesAttribute.Lead, ContactTypesAttribute.Person) == true &&
                    Setup.Current?.ContactEmailUnique == true &&
                    !String.IsNullOrWhiteSpace(duplicateDocument.Email))
                {
                    try
                    {
                        var parsedEmail = EmailParser.ParseAddresses(duplicateDocument.Email).FirstOrDefault();

                        if (result
                            .Select(item => item.GetItem <DuplicateContact>())
                            .Where(item => !String.IsNullOrWhiteSpace(item.EMail) && item.ContactType.IsIn(ContactTypesAttribute.Lead, ContactTypesAttribute.Person))
                            .Any(item => item.EMail.Contains(parsedEmail.Address)))
                        {
                            DuplicateDocuments.Cache.RaiseExceptionHandling <DuplicateDocument.email>(
                                duplicateDocument,
                                duplicateDocument.Email,
                                new PXSetPropertyException(Messages.ContactEmailNotUnique, PXErrorLevel.Warning));
                        }
                    }
                    catch (Exception) { }
                }
            }

            if (duplicateDocument.DuplicateStatus != prevStatus)
            {
                Base.Actions.PressSave();
            }
            else
            {
                Base.Caches[DuplicateDocuments.Cache.GetMain(duplicateDocument).GetType()].IsDirty = prevIsDirty;
            }

            if (duplicateDocument.DuplicateStatus == DuplicateStatusAttribute.PossibleDuplicated || duplicateDocument.DuplicateFound == true)
            {
                DuplicateDocuments.Cache.RaiseExceptionHandling <DuplicateDocument.duplicateStatus>(duplicateDocument,
                                                                                                    duplicateDocument.DuplicateStatus,
                                                                                                    new PXSetPropertyException(WarningMessage, PXErrorLevel.Warning));
            }
            else
            {
                DuplicateDocuments.Cache.RaiseExceptionHandling <DuplicateDocument.duplicateStatus>(duplicateDocument,
                                                                                                    duplicateDocument.DuplicateStatus,
                                                                                                    null);
            }

            return(adapter.Get());
        }