protected virtual void FABonusDetails_EndDate_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            FABonusDetails det = (FABonusDetails)e.Row;

            if (det == null)
            {
                return;
            }

            DateTime?start = det.StartDate;

            if (start != null && (DateTime?)e.NewValue < start)
            {
                throw new PXSetPropertyException(CS.Messages.Entry_GE, start);
            }

            FABonusDetails next = PXSelect <FABonusDetails, Where <FABonusDetails.lineNbr, Greater <Current <FABonusDetails.lineNbr> >, And <FABonusDetails.bonusID, Equal <Current <FABonusDetails.bonusID> > > >, OrderBy <Desc <FABonusDetails.endDate> > > .SelectSingleBound(this, new object[] { det });

            DateTime?nextStart = next == null ? null : next.StartDate;

            if (nextStart != null && (DateTime?)e.NewValue >= nextStart)
            {
                throw new PXSetPropertyException(CS.Messages.Entry_LT, nextStart);
            }

            FABonusDetails prev = PXSelect <FABonusDetails, Where <FABonusDetails.lineNbr, Less <Current <FABonusDetails.lineNbr> >, And <FABonusDetails.bonusID, Equal <Current <FABonusDetails.bonusID> > > >, OrderBy <Desc <FABonusDetails.endDate> > > .SelectSingleBound(this, new object[] { det });

            DateTime?prevEnd = prev == null ? null : prev.EndDate;

            if (prevEnd != null && (DateTime?)e.NewValue <= prevEnd)
            {
                throw new PXSetPropertyException(CS.Messages.Entry_GT, prevEnd);
            }
        }
Example #2
0
        public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars)
        {
            DateTime?date    = (DateTime?)pars[typeof(Date)];
            int?     bonusID = (int?)pars[typeof(BonusID)];

            if (bonusID == null || date == null)
            {
                return(0m);
            }

            FABonusDetails det = PXSelect <FABonusDetails, Where <FABonusDetails.bonusID, Equal <Required <FABonus.bonusID> >,
                                                                  And <FABonusDetails.startDate, LessEqual <Required <FABookBalance.deprFromDate> >,
                                                                       And <FABonusDetails.endDate, GreaterEqual <Required <FABookBalance.deprFromDate> > > > > > .Select(cache.Graph, bonusID, date, date);

            return(det == null ? 0m : det.BonusPercent);
        }
Example #3
0
        public override void Verify(PXCache cache, object item, List <object> pars, ref bool?result, ref object value)
        {
            DateTime?date    = (DateTime?)Calculate <Date>(cache, item);
            int?     bonusID = (int?)Calculate <BonusID>(cache, item);

            if (bonusID == null || date == null)
            {
                value = 0m;
                return;
            }

            FABonusDetails det = PXSelect <FABonusDetails, Where <FABonusDetails.bonusID, Equal <Required <FABonus.bonusID> >,
                                                                  And <FABonusDetails.startDate, LessEqual <Required <FABookBalance.deprFromDate> >,
                                                                       And <FABonusDetails.endDate, GreaterEqual <Required <FABookBalance.deprFromDate> > > > > > .Select(cache.Graph, bonusID, date, date);

            if (det == null)
            {
                value = 0m;
                return;
            }

            value = det.BonusPercent;
        }