示例#1
0
		public override void Persist()
		{
			foreach (FABookSettings set in DepreciationSettings.Cache.Inserted.Cast<FABookSettings>().Concat<FABookSettings>(DepreciationSettings.Cache.Updated.Cast<FABookSettings>()))
			{
				FABook book = PXSelect<FABook, Where<FABook.bookID, Equal<Required<FABook.bookID>>>>.SelectWindowed(this, 0, 1, set.BookID);
				IYearSetup yearSetup = FABookPeriodRepository.FindFABookYearSetup(book);

				if (yearSetup == null || !yearSetup.IsFixedLengthPeriod)
				{
					FABookPeriodSetup period = PXSelect<FABookPeriodSetup, Where<FABookPeriodSetup.bookID, Equal<Required<FABookPeriodSetup.bookID>>>>.SelectWindowed(this, 0, 1, set.BookID);
					if (period == null && set.UpdateGL == false && book != null)
					{
						DepreciationSettings.Cache.RaiseExceptionHandling<FABookSettings.bookID>(set, book.BookCode,
							new PXSetPropertyException<FABookSettings.bookID>(Messages.NoCalendarDefined));
					}
				}

				FADepreciationMethod method = PXSelect<FADepreciationMethod, Where<FADepreciationMethod.methodID, Equal<Required<FABookSettings.depreciationMethodID>>>>.SelectWindowed(this, 0, 1, set.DepreciationMethodID);
				if (method != null && method.IsTableMethod == true && method.UsefulLife != set.UsefulLife)
				{
					DepreciationSettings.Cache.RaiseExceptionHandling<FABookSettings.usefulLife>(set, set.UsefulLife, new PXSetPropertyException<FABookSettings.usefulLife>(Messages.UsefulLifeNotMatchDeprMethod));
				}
			}
			base.Persist();
		}
示例#2
0
        public override void Persist()
        {
            foreach (FABookSettings set in this.DepreciationSettings.Cache.Inserted)
            {
                FABookPeriodSetup period = PXSelect <FABookPeriodSetup, Where <FABookPeriodSetup.bookID, Equal <Required <FABookPeriodSetup.bookID> > > > .SelectWindowed(this, 0, 1, set.BookID);

                if (period == null && set.UpdateGL == false)
                {
                    FABook book = PXSelect <FABook, Where <FABook.bookID, Equal <Required <FABook.bookID> > > > .SelectWindowed(this, 0, 1, set.BookID);

                    if (book != null)
                    {
                        this.DepreciationSettings.Cache.RaiseExceptionHandling <FABookSettings.bookID>(set, book.BookCode, new PXSetPropertyException <FABookSettings.bookID>(Messages.NoCalendarDefined));
                    }
                }
            }
            foreach (FABookSettings set in this.DepreciationSettings.Cache.Updated)
            {
                FABookPeriodSetup period = PXSelect <FABookPeriodSetup, Where <FABookPeriodSetup.bookID, Equal <Required <FABookPeriodSetup.bookID> > > > .SelectWindowed(this, 0, 1, set.BookID);

                if (period == null && set.UpdateGL == false)
                {
                    FABook book = PXSelect <FABook, Where <FABook.bookID, Equal <Required <FABook.bookID> > > > .SelectWindowed(this, 0, 1, set.BookID);

                    if (book != null)
                    {
                        this.DepreciationSettings.Cache.RaiseExceptionHandling <FABookSettings.bookID>(set, book.BookCode, new PXSetPropertyException <FABookSettings.bookID>(Messages.NoCalendarDefined));
                    }
                }
            }
            base.Persist();
        }