protected virtual void FABookSettings_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            FABookSettings set = (FABookSettings)e.Row;

            if (set == null)
            {
                return;
            }

            PXUIFieldAttribute.SetEnabled <FABookSettings.bookID>(sender, set, set.BookID == null);

            IYearSetup           yearSetup = FABookPeriodIDAttribute.GetBookCalendar(this, set.BookID);
            FADepreciationMethod method    = PXSelect <FADepreciationMethod, Where <FADepreciationMethod.methodID, Equal <Current <FABookSettings.depreciationMethodID> > > > .SelectSingleBound(this, new object[] { set });

            List <KeyValuePair <object, Dictionary <object, string[]> > > parsList = new List <KeyValuePair <object, Dictionary <object, string[]> > >();

            if (method != null)
            {
                parsList.Add(method.IsTableMethod == true
                                        ? new KeyValuePair <object, Dictionary <object, string[]> >(method.RecordType, FAAveragingConvention.RecordTypeDisabledValues)
                                        : new KeyValuePair <object, Dictionary <object, string[]> >(method.DepreciationMethod, FAAveragingConvention.DeprMethodDisabledValues));
            }
            if (yearSetup != null)
            {
                parsList.Add(new KeyValuePair <object, Dictionary <object, string[]> >(yearSetup.IsFixedLengthPeriod, FAAveragingConvention.FixedLengthPeriodDisabledValues));
            }

            FAAveragingConvention.SetAveragingConventionsList <FADepreciationMethod.averagingConvention>(sender, set, parsList.ToArray());
        }
Ejemplo n.º 2
0
        protected virtual void FABookSettings_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            FABookSettings set = (FABookSettings)e.Row;

            if (set == null)
            {
                return;
            }

            bool depreciate = (set.Depreciate == true);

            PXUIFieldAttribute.SetEnabled <FABookSettings.bookID>(sender, set, set.BookID == null);
            PXUIFieldAttribute.SetEnabled <FABookSettings.averagingConvention>(sender, set, depreciate);
            PXUIFieldAttribute.SetEnabled <FABookSettings.depreciationMethodID>(sender, set, depreciate);
            PXUIFieldAttribute.SetEnabled <FABookSettings.recoveryPeriod>(sender, set, depreciate);
            PXUIFieldAttribute.SetEnabled <FABookSettings.bonus>(sender, set, depreciate);
            PXUIFieldAttribute.SetEnabled <FABookSettings.sect179>(sender, set, depreciate);

            bool midMonthEnable = (set.AveragingConvention == FAAveragingConvention.HalfPeriod ||
                                   set.AveragingConvention == FAAveragingConvention.ModifiedPeriod ||
                                   set.AveragingConvention == FAAveragingConvention.ModifiedPeriod2);

            PXUIFieldAttribute.SetEnabled <FABookSettings.midMonthDay>(sender, set, midMonthEnable);
            PXUIFieldAttribute.SetEnabled <FABookSettings.midMonthType>(sender, set, midMonthEnable);
        }
Ejemplo n.º 3
0
		protected virtual void FABookSettings_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
		{
			FixedAsset header = AssetClass.Current;
			FABookSettings set = (FABookSettings)e.Row;
			if (set == null || header == null) return;

			if (set.Depreciate == true)
			{
				if (set.AveragingConvention == null || string.IsNullOrEmpty(set.AveragingConvention.Trim()))
					sender.RaiseExceptionHandling<FABookSettings.averagingConvention>(set, set.AveragingConvention, new PXSetPropertyException(Messages.ValueCanNotBeEmpty));
				if (set.DepreciationMethodID == null)
					sender.RaiseExceptionHandling<FABookSettings.depreciationMethodID>(set, set.DepreciationMethodID, new PXSetPropertyException(Messages.ValueCanNotBeEmpty));
			}
		}
Ejemplo n.º 4
0
        protected virtual void FixedAsset_UsefulLife_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            FixedAsset header = (FixedAsset)e.Row;

            if (header == null)
            {
                return;
            }

            foreach (FABookSettings set in PXSelect <FABookSettings, Where <FABookSettings.assetID, Equal <Required <FABookSettings.assetID> > > > .Select(this, header.AssetID))
            {
                FABookSettings newSettings = (FABookSettings)DepreciationSettings.Cache.CreateCopy(set);
                newSettings.UsefulLife = header.UsefulLife;
                DepreciationSettings.Update(newSettings);
            }
        }
Ejemplo n.º 5
0
        protected virtual void FADepreciationMethod_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            FADepreciationMethod meth = (FADepreciationMethod)e.Row;

            if (meth == null)
            {
                return;
            }

            FABookSettings sett = PXSelect <FABookSettings, Where <FABookSettings.depreciationMethodID, Equal <Required <FADepreciationMethod.methodID> > > > .Select(this, meth.MethodID);

            FABookBalance bal = PXSelect <FABookBalance, Where <FABookBalance.depreciationMethodID, Equal <Required <FADepreciationMethod.methodID> > > > .Select(this, meth.MethodID);

            if (sett != null || bal != null)
            {
                throw new PXSetPropertyException(Messages.FADeprMethodUsedInAssets);
            }
        }
Ejemplo n.º 6
0
        protected virtual void FixedAsset_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            FixedAsset assetClass = (FixedAsset)e.Row;

            if (assetClass == null)
            {
                return;
            }

            if (assetClass.AssetCD != null)
            {
                foreach (FABook book in PXSelect <FABook> .Select(this))
                {
                    FABookSettings settings = new FABookSettings {
                        BookID = book.BookID
                    };
                    DepreciationSettings.Insert(settings);
                }

                DepreciationSettings.Cache.IsDirty = false;
            }
        }
Ejemplo n.º 7
0
		protected virtual void FABookSettings_DepreciationMethodID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
		{
			FABookSettings bookSettings = (FABookSettings)e.Row;
			if (bookSettings == null) return;

			if (bookSettings.BookID != null)
			{
				IYearSetup yearSetup = FABookPeriodRepository.FindFABookYearSetup(bookSettings.BookID);
				FADepreciationMethod deprMethod = PXSelectorAttribute.Select<FABookSettings.depreciationMethodID>(DepreciationSettings.Cache, bookSettings, e.NewValue) as FADepreciationMethod;

				if ((yearSetup.PeriodType == FinPeriodType.Week
						|| yearSetup.PeriodType == FinPeriodType.BiWeek
						|| yearSetup.PeriodType == FinPeriodType.FourWeek)
					&& (deprMethod?.IsNewZealandMethod == true))
				{
					e.NewValue = deprMethod?.MethodCD;
					
					string errorMessage = PXMessages.LocalizeFormat(Messages.WeeklyBooksDisabledForCalcMethod,
														PXStringListAttribute.GetLocalizedLabel<FADepreciationMethod.depreciationMethod>(Caches[typeof(FADepreciationMethod)], deprMethod));
					throw new PXSetPropertyException(errorMessage);
				}
			}
		}