public FABookPeriod FindMappedPeriod(FABookPeriod.Key fromPeriodKey, FABookPeriod.Key toPeriodKey) { if (fromPeriodKey.BookID != toPeriodKey.BookID) { return(null); } if (!IsPostingFABook(fromPeriodKey.BookID)) { return(null); } FABookPeriod oldPeriod = FindByKey(fromPeriodKey.BookID, fromPeriodKey.OrganizationID, fromPeriodKey.PeriodID); return(FindPeriodByMasterPeriodID(toPeriodKey.BookID, toPeriodKey.OrganizationID, oldPeriod?.MasterFinPeriodID)); }
protected override void ValidatePeriodAndSourcesImpl(PXCache cache, object oldRow, object newRow, bool externalCall) { PeriodKeyProviderBase.KeyWithSourceValuesCollection < FABookPeriodKeyProvider.FAKeyWithSourceValues, FABookPeriodKeyProvider.FASourceSpecificationItem, FABookPeriod.Key> newKeyWithSourceValues = FABookPeriodKeyProvider.GetKeys(cache.Graph, cache, newRow); PeriodKeyProviderBase.KeyWithSourceValuesCollection < FABookPeriodKeyProvider.FAKeyWithSourceValues, FABookPeriodKeyProvider.FASourceSpecificationItem, FABookPeriod.Key> oldKeyWithSourceValues = FABookPeriodKeyProvider.GetKeys(cache.Graph, cache, oldRow); FABookPeriod.Key newPeriodKey = newKeyWithSourceValues.ConsolidatedKey; newPeriodKey.PeriodID = (string)cache.GetValue(newRow, _FieldName); if (!newPeriodKey.Defined) { return; } IFABookPeriodRepository periodRepository = cache.Graph.GetService <IFABookPeriodRepository>(); FABookPeriod period = periodRepository.FindByKey(newPeriodKey.BookID, newPeriodKey.OrganizationID, newPeriodKey.PeriodID); if (period == null) { PXSetPropertyException exception = null; FABook book = BookMaint.FindByID(cache.Graph, newPeriodKey.BookID); if (book.UpdateGL == true) { exception = new PXSetPropertyException(PXMessages.LocalizeFormatNoPrefix( Messages.PeriodDoesNotExistForBookAndCompany, FormatForError(newPeriodKey.PeriodID), book.BookCode, PXAccess.GetOrganizationCD(newPeriodKey.OrganizationID))); if (FAMainSpecificationItem.OrganizationSourceType != null && newKeyWithSourceValues.MainItem.SourceOrganizationIDs.First() != null && newKeyWithSourceValues.MainItem.SourceOrganizationIDs.First() != oldKeyWithSourceValues.MainItem.SourceOrganizationIDs.First()) { SetErrorAndResetToOldForField( cache, oldRow, newRow, FAMainSpecificationItem.OrganizationSourceType.Name, exception, externalCall); } if (FAMainSpecificationItem.BranchSourceType != null && newKeyWithSourceValues.MainItem.SourceBranchIDs.First() != null && newKeyWithSourceValues.MainItem.SourceBranchIDs.First() != oldKeyWithSourceValues.MainItem.SourceBranchIDs.First()) { SetErrorAndResetToOldForField( cache, oldRow, newRow, FAMainSpecificationItem.BranchSourceType.Name, exception, externalCall); } if (FAMainSpecificationItem.AssetSourceType != null && newKeyWithSourceValues.MainItem.SourceAssetIDs.First() != null && newKeyWithSourceValues.MainItem.SourceAssetIDs.First() != oldKeyWithSourceValues.MainItem.SourceAssetIDs.First()) { SetErrorAndResetToOldForField( cache, oldRow, newRow, FAMainSpecificationItem.AssetSourceType.Name, exception, externalCall); } } else { exception = new PXSetPropertyException(PXMessages.LocalizeFormatNoPrefix( Messages.PeriodDoesNotExistForBook, FormatForError(newPeriodKey.PeriodID))); } cache.RaiseExceptionHandling( _FieldName, newRow, FormatForDisplay(newPeriodKey.PeriodID), exception); cache.SetValue( newRow, _FieldName, cache.GetValue(oldRow, _FieldName)); if (FAMainSpecificationItem.BookSourceType != null && newKeyWithSourceValues.MainItem.SourceBookIDs.First() != null && newKeyWithSourceValues.MainItem.SourceBookIDs.First() != oldKeyWithSourceValues.MainItem.SourceBookIDs.First()) { SetErrorAndResetToOldForField( cache, oldRow, newRow, FAMainSpecificationItem.BookSourceType.Name, exception, externalCall); } } }