public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars)
        {
            string         classID = (string)pars[typeof(ClassID)];
            CRContactClass cls     = PXSelect <CRContactClass, Where <CRContactClass.classID, Equal <Required <CRContactClass.classID> > > > .Select(cache.Graph, classID);

            if (cls == null)
            {
                return(null);
            }

            PXSelectBase <EPCompanyTreeMember> cmd = new PXSelectJoin <EPCompanyTreeMember,
                                                                       InnerJoin <EPCompanyTreeH, On <EPCompanyTreeMember.workGroupID, Equal <EPCompanyTreeH.workGroupID> > >,
                                                                       Where <EPCompanyTreeMember.userID, Equal <Required <EPCompanyTreeMember.userID> > > >(cache.Graph);

            if (cls.DefaultWorkgroupID != null && cls.OwnerIsCreatedUser != true)
            {
                return(cls.DefaultWorkgroupID);
            }
            else if (cls.DefaultWorkgroupID != null && cls.OwnerIsCreatedUser == true)
            {
                cmd.WhereAnd <Where <EPCompanyTreeH.parentWGID, Equal <Required <EPCompanyTreeH.parentWGID> > > >();
                EPCompanyTreeMember m = cmd.SelectSingle(cache.Graph.Accessinfo.UserID, cls.DefaultWorkgroupID);
                return(m.With(_ => _.WorkGroupID));
            }
            else if (cls.DefaultWorkgroupID == null && cls.OwnerIsCreatedUser == true && cls.DefaultOwnerWorkgroup == true)
            {
                EPCompanyTreeMember m = cmd.SelectSingle(cache.Graph.Accessinfo.UserID);
                return(m.With(_ => _.WorkGroupID));
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public override void Verify(PXCache cache, object item, List <object> pars, ref bool?result, ref object value)
        {
            string         classID = (string)Calculate <ClassID>(cache, item);
            CRContactClass cls     = PXSelect <CRContactClass, Where <CRContactClass.classID, Equal <Required <CRContactClass.classID> > > > .Select(cache.Graph, classID);

            if (cls == null)
            {
                return;
            }

            PXSelectBase <EPCompanyTreeMember> cmd = new PXSelectJoin <EPCompanyTreeMember,
                                                                       InnerJoin <EPCompanyTreeH, On <EPCompanyTreeMember.workGroupID, Equal <EPCompanyTreeH.workGroupID> > >,
                                                                       Where <EPCompanyTreeMember.userID, Equal <Required <EPCompanyTreeMember.userID> > > >(cache.Graph);

            if (cls.DefaultWorkgroupID != null && cls.OwnerIsCreatedUser != true)
            {
                value = cls.DefaultWorkgroupID;
            }
            else if (cls.DefaultWorkgroupID != null && cls.OwnerIsCreatedUser == true)
            {
                cmd.WhereAnd <Where <EPCompanyTreeH.parentWGID, Equal <Required <EPCompanyTreeH.parentWGID> > > >();
                EPCompanyTreeMember m = cmd.SelectSingle(cache.Graph.Accessinfo.UserID, cls.DefaultWorkgroupID);
                value = m.With(_ => _.WorkGroupID);
            }
            else if (cls.DefaultWorkgroupID == null && cls.OwnerIsCreatedUser == true && cls.DefaultOwnerWorkgroup == true)
            {
                EPCompanyTreeMember m = cmd.SelectSingle(cache.Graph.Accessinfo.UserID);
                value = m.With(_ => _.WorkGroupID);
            }
            else
            {
                value = null;
            }
        }
Beispiel #3
0
        private string GetSubcontractProjectName(POOrder subcontract)
        {
            var query = new PXSelectJoin <Contract,
                                          LeftJoin <POLine, On <POLine.projectID, Equal <Contract.contractID> > >,
                                          Where <POLine.orderNbr, Equal <Required <POLine.orderNbr> >,
                                                 And <POLine.orderType, Equal <POOrderType.regularSubcontract> > >,
                                          OrderBy <Asc <POLine.lineNbr> > >(Base);

            return(query.SelectSingle(subcontract.OrderNbr)?.ContractCD);
        }
Beispiel #4
0
        private static bool ValidatePrice(PXGraph graph, int InventoryID, ContractItem item)
        {
            PXSelectBase <ARSalesPrice> s = new PXSelectJoin <ARSalesPrice, InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <ARSalesPrice.inventoryID> > >, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> >, And <ARSalesPrice.curyID, Equal <Required <ARSalesPrice.curyID> >, And <ARSalesPrice.custPriceClassID, Equal <AR.ARPriceClass.emptyPriceClass> > > > >(graph);
            ARSalesPrice aRPrice          = s.SelectSingle(InventoryID, item.CuryID);

            if (aRPrice == null)
            {
                return(false);
            }
            return(true);
        }
Beispiel #5
0
    public void SOOrder_OrderType_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
    {
        var query = new PXSelectJoin <SOOrderType,
                                      InnerJoin <PX.SM.UsersInRoles,
                                                 On <PX.SM.UsersInRoles.rolename,
                                                     Equal <SOOrderTypeExt.usrUserRole> > >,
                                      Where <PX.SM.UsersInRoles.username,
                                             Equal <Current <AccessInfo.userName> > > >(Base);
        var orderType = query.SelectSingle();

        if (orderType != null)
        {
            e.NewValue = orderType.OrderType;
            e.Cancel   = true;
        }
    }
        public bool CheckDoNotExistUnreleasedCAAdjsWithCASplitsWithBranchWithFinPeriodLessOrEqual(int?branchID, string finPeriod)
        {
            var childBranchIds = PXAccess.GetChildBranchIDs(GetBranchByID(branchID).BranchCD);

            var query = new PXSelectJoin <CAAdj,
                                          LeftJoin <CASplit,
                                                    On <CAAdj.adjTranType, Equal <CASplit.adjTranType>,
                                                        And <CAAdj.adjRefNbr, Equal <CASplit.adjRefNbr> > > >,
                                          Where <CAAdj.released, Equal <False>,
                                                 And <CAAdj.finPeriodID, LessEqual <Required <CAAdj.finPeriodID> >,
                                                      And <Where <CAAdj.branchID, In <Required <CAAdj.branchID> >,
                                                                  Or <CASplit.branchID, In <Required <CASplit.branchID> > > > > > > >(_graph);

            var caAdj = query.SelectSingle(finPeriod, childBranchIds, childBranchIds);

            return(caAdj == null);
        }
        public bool CheckDoNotExistUnreleasedARRegistersWithARTransWithBranchWithFinPeriodLessOrEqual(int?branchID, string finPeriod)
        {
            var childBranchIds = PXAccess.GetChildBranchIDs(GetBranchByID(branchID).BranchCD);

            var query = new PXSelectJoin <ARRegister,
                                          LeftJoin <ARTran,
                                                    On <ARRegister.docType, Equal <ARTran.tranType>,
                                                        And <ARRegister.refNbr, Equal <ARTran.refNbr> > > >,
                                          Where <ARRegister.released, Equal <False>,
                                                 And <ARRegister.finPeriodID, LessEqual <Required <ARRegister.finPeriodID> >,
                                                      And <Where <ARRegister.branchID, In <Required <ARRegister.branchID> >,
                                                                  Or <ARTran.branchID, In <Required <ARTran.branchID> > > > > > > >(_graph);

            var arRegister = query.SelectSingle(finPeriod, childBranchIds, childBranchIds);

            return(arRegister == null);
        }
Beispiel #8
0
        protected virtual void _(Events.RowSelected <APPayment> eventArgs)
        {
            if (eventArgs.Row == null)
            {
                return;
            }

            bool allowUpdate = eventArgs.Row.DocType == APDocType.Prepayment &&
                               eventArgs.Row.Status.IsIn(APDocStatus.Hold, APDocStatus.Reserved) &&
                               eventArgs.Row.IsMigratedRecord != true &&
                               IsPrepaymentCheck(Base.Document.Current);

            POAdjustments.Cache.AllowDelete = allowUpdate;
            POAdjustments.Cache.AllowInsert = allowUpdate;
            POAdjustments.Cache.AllowUpdate = allowUpdate;
            loadPOOrders.SetEnabled(allowUpdate);

            POAdjustments.Cache.AllowSelect = eventArgs.Row.DocType.IsIn(APPaymentType.Prepayment, APPaymentType.VoidCheck);

            if (eventArgs.Row.Hold != true &&
                eventArgs.Row.CuryPOFullApplAmt > eventArgs.Row.CuryOrigDocAmt &&
                eventArgs.Row.DocType == APPaymentType.Prepayment)
            {
                eventArgs.Cache.RaiseExceptionHandling <APPayment.curyPOApplAmt>(
                    eventArgs.Row, eventArgs.Row.CuryPOFullApplAmt,
                    new PXSetPropertyException <APPayment.curyPOApplAmt>(
                        Messages.TotalPrepaymentAmountGreaterDocumentAmount, PXErrorLevel.RowError));
            }
            else
            {
                eventArgs.Cache.RaiseExceptionHandling <APPayment.curyPOApplAmt>(
                    eventArgs.Row, eventArgs.Row.CuryPOFullApplAmt, null);
            }

            PXUIFieldAttribute.SetVisible <APPayment.curyPOApplAmt>(eventArgs.Cache, eventArgs.Row, eventArgs.Row.DocType == APDocType.Prepayment);

            if (eventArgs.Row.DocType == APDocType.Prepayment && eventArgs.Row.VendorID != null)
            {
                if (POAdjustments.SelectSingle() != null)
                {
                    PXUIFieldAttribute.SetEnabled <APPayment.vendorID>(eventArgs.Cache, eventArgs.Row, false);
                }
            }
        }
Beispiel #9
0
        private ARTran SearchProjectTransaction(ARInvoiceExt doc)
        {
            ARRetainageFilter filter     = Filter.Current;
            List <object>     parameters = new List <object>();

            var selectProjectTransaction = new PXSelectJoin <ARTran,
                                                             LeftJoin <Account, On <Account.accountID, Equal <ARTran.accountID> > >,
                                                             Where <ARTran.tranType, Equal <Required <ARTran.tranType> >,
                                                                    And <ARTran.refNbr, Equal <Required <ARTran.refNbr> > > > >(this);

            parameters.Add(doc.DocType);
            parameters.Add(doc.RefNbr);

            if (filter.ProjectTaskID != null)
            {
                selectProjectTransaction.WhereAnd <Where <ARTran.taskID, Equal <Required <ARTran.taskID> > > >();
                parameters.Add(filter.ProjectTaskID);
            }

            if (filter.AccountGroupID != null)
            {
                selectProjectTransaction.WhereAnd <Where <Account.accountGroupID, Equal <Required <Account.accountGroupID> > > >();
                parameters.Add(filter.AccountGroupID);
            }

            if (filter.CostCodeID != null)
            {
                selectProjectTransaction.WhereAnd <Where <ARTran.costCodeID, Equal <Required <ARTran.costCodeID> > > >();
                parameters.Add(filter.CostCodeID);
            }

            if (filter.InventoryID != null)
            {
                selectProjectTransaction.WhereAnd <Where <ARTran.inventoryID, Equal <Required <ARTran.inventoryID> > > >();
                parameters.Add(filter.InventoryID);
            }

            return(selectProjectTransaction.SelectSingle(parameters.ToArray()));
        }
Beispiel #10
0
        public static bool CheckForUnprocessedPPD(PXGraph graph, string statementCycleID, DateTime?nextStmtDate, int?customerID)
        {
            PXSelectBase <ARInvoice> select = new PXSelectJoin <ARInvoice,
                                                                InnerJoin <Customer, On <Customer.bAccountID, Equal <ARInvoice.customerID> >,
                                                                           InnerJoin <ARAdjust, On <ARAdjust.adjdDocType, Equal <ARInvoice.docType>,
                                                                                                    And <ARAdjust.adjdRefNbr, Equal <ARInvoice.refNbr>,
                                                                                                         And <ARAdjust.released, Equal <True>,
                                                                                                              And <ARAdjust.voided, NotEqual <True>,
                                                                                                                   And <ARAdjust.pendingPPD, Equal <True>,
                                                                                                                        And <ARAdjust.adjgDocDate, LessEqual <Required <ARAdjust.adjgDocDate> > > > > > > > > >,
                                                                Where <ARInvoice.pendingPPD, Equal <True>,
                                                                       And <ARInvoice.released, Equal <True>,
                                                                            And <ARInvoice.openDoc, Equal <True>,
                                                                                 And <Customer.statementCycleId, Equal <Required <Customer.statementCycleId> > > > > > >(graph);

            if (customerID != null)
            {
                select.WhereAnd <Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > >();
            }

            return(select.SelectSingle(nextStmtDate, statementCycleID, customerID) != null);
        }
Beispiel #11
0
        protected virtual void _(Events.FieldUpdated <UserPreferences, FSxUserPreferences.trackLocation> e)
        {
            if (e.Row == null)
            {
                return;
            }

            UserPreferences    userPreferencesRow    = e.Row as UserPreferences;
            FSxUserPreferences fsxUserPreferencesRow = e.Cache.GetExtension <FSxUserPreferences>(userPreferencesRow);

            if (fsxUserPreferencesRow != null &&
                fsxUserPreferencesRow.TrackLocation != (bool)e.OldValue)
            {
                if (fsxUserPreferencesRow.TrackLocation == true && LocationTracking.Select().Count == 0)
                {
                    List <FSGPSTrackingLocation> trackingLocations = new List <FSGPSTrackingLocation>();
                    CSCalendar csCalendarRow = UserCalendar.SelectSingle();

                    if (csCalendarRow?.SunWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay1 = true,
                            WeekDay      = 0,
                            StartTime    = csCalendarRow.SunStartTime,
                            EndTime      = csCalendarRow.SunEndTime
                        });
                    }

                    if (csCalendarRow?.MonWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay2 = true,
                            WeekDay      = 1,
                            StartTime    = csCalendarRow.MonStartTime,
                            EndTime      = csCalendarRow.MonEndTime
                        });
                    }

                    if (csCalendarRow?.TueWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay3 = true,
                            WeekDay      = 2,
                            StartTime    = csCalendarRow.TueStartTime,
                            EndTime      = csCalendarRow.TueEndTime
                        });
                    }

                    if (csCalendarRow?.WedWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay4 = true,
                            WeekDay      = 3,
                            StartTime    = csCalendarRow.WedStartTime,
                            EndTime      = csCalendarRow.WedEndTime
                        });
                    }

                    if (csCalendarRow?.ThuWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay5 = true,
                            WeekDay      = 4,
                            StartTime    = csCalendarRow.ThuStartTime,
                            EndTime      = csCalendarRow.ThuEndTime
                        });
                    }

                    if (csCalendarRow?.FriWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay6 = true,
                            WeekDay      = 5,
                            StartTime    = csCalendarRow.FriStartTime,
                            EndTime      = csCalendarRow.FriEndTime
                        });
                    }

                    if (csCalendarRow?.SatWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay7 = true,
                            WeekDay      = 6,
                            StartTime    = csCalendarRow.SatStartTime,
                            EndTime      = csCalendarRow.SatEndTime
                        });
                    }

                    foreach (FSGPSTrackingLocation fsGPSTrackingLocationRow in trackingLocations)
                    {
                        fsGPSTrackingLocationRow.StartDate = Base.Accessinfo.BusinessDate;
                        fsGPSTrackingLocationRow.EndDate   = fsGPSTrackingLocationRow.StartDate.Value.AddYears(1000);
                        fsGPSTrackingLocationRow.Interval  = fsxUserPreferencesRow.Interval;
                        fsGPSTrackingLocationRow.Distance  = fsxUserPreferencesRow.Distance;
                        LocationTracking.Insert(fsGPSTrackingLocationRow);
                    }
                }
                else
                {
                    foreach (FSGPSTrackingLocation fsGPSTrackingLocationRow in LocationTracking.Select())
                    {
                        fsGPSTrackingLocationRow.IsActive = fsxUserPreferencesRow.TrackLocation;
                        LocationTracking.Cache.Update(fsGPSTrackingLocationRow);
                    }
                }

                PXPersistingCheck persistingCheck = fsxUserPreferencesRow.TrackLocation == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing;
                PXDefaultAttribute.SetPersistingCheck <UserPreferences.timeZone>(e.Cache, userPreferencesRow, persistingCheck);
            }
        }
        protected virtual IEnumerable Cancel(PXAdapter a)
        {
            string organizationCD;
            string yearNumber;

            if (NewCalendarParams.View.Answer == WebDialogResult.None)             // First outer call
            {
                FinYearKey storedYearKey = new FinYearKey
                {
                    OrganizationID = OrgFinYear.Current?.OrganizationID,
                    Year           = OrgFinYear.Current?.Year
                };

                #region Deliberate Technomagic. Copy-pasted fron base PXCancel instead invocation
                Clear();
                SelectTimeStamp();
                #endregion

                StoredYearKey.Cache.Clear();
                StoredYearKey.Insert(storedYearKey);
                StoredYearKey.Cache.IsDirty = false;

                organizationCD = (string)a.Searches.GetSearchValueByPosition(0);
                if (organizationCD == null)
                {
                    yield break;
                }
                yearNumber = (string)a.Searches.GetSearchValueByPosition(1);
            }
            else             // Second call after SmartPanel closing
            {
                object       extValue = NewCalendarParams.Cache.GetValueExt <NewOrganizationCalendarParameters.organizationID>(NewCalendarParams.Current);
                PXFieldState state    = extValue as PXFieldState;
                organizationCD = state != null ? (string)state.Value : (string)extValue;
                yearNumber     = NewCalendarParams.Current.StartYear;
            }

            OrganizationFinYear targetYear = PXSelectJoin <
                OrganizationFinYear,
                InnerJoin <Organization,
                           On <OrganizationFinYear.organizationID, Equal <Organization.organizationID> > >,
                Where <Organization.organizationCD, Equal <Required <Organization.organizationCD> >,
                       And <OrganizationFinYear.year, Equal <Required <OrganizationFinYear.year> > > > >
                                             .SelectSingleBound(this, new object[] { }, organizationCD, yearNumber);

            OrganizationFinYear returnYear = null;
            if (targetYear == null)
            {
                OrganizationFinYear lastYear = LastOrganizationYear.SelectSingle(organizationCD);

                if (lastYear == null)
                {
                    if (NewCalendarParams.AskExtFullyValid((graph, viewName) =>
                    {
                        NewCalendarParams.Current.OrganizationID = PXAccess.GetOrganizationID(organizationCD);
                    },
                                                           DialogAnswerType.Positive))
                    {
                        OrganizationFinYear generatedFinYear;
                        using (PXTransactionScope ts = new PXTransactionScope())
                        {
                            generatedFinYear = GenerateSingleOrganizationFinYear(
                                (int)NewCalendarParams.Current.OrganizationID,
                                NewCalendarParams.Current.StartYear,
                                NewCalendarParams.Current.StartMasterFinPeriodID);
                            Actions.PressSave();
                            ts.Complete();
                        }
                        returnYear = generatedFinYear;
                    }
                    else
                    {
                        OrganizationFinYear storedYear = FinPeriodRepository.FindOrganizationFinYearByID(StoredYearKey.Current?.OrganizationID, StoredYearKey.Current?.Year);
                        returnYear = storedYear;
                    }
                }
                else
                {
                    returnYear = lastYear;
                }
            }
            else
            {
                returnYear = targetYear;
            }

            if (returnYear != null)
            {
                yield return(returnYear);
            }
            yield break;
        }