Exemple #1
0
        public virtual ProcessingResult <FinPeriod> GetFinPeriodByMasterPeriodID(int?organizationID, string masterFinPeriodID)
        {
            FinPeriod period = PXSelect <FinPeriod,
                                         Where <FinPeriod.organizationID, Equal <Required <FinPeriod.organizationID> >,
                                                And <FinPeriod.masterFinPeriodID, Equal <Required <FinPeriod.masterFinPeriodID> > > > >
                               .Select(Graph, organizationID, masterFinPeriodID);

            var result = ProcessingResult <FinPeriod> .CreateSuccess(period);

            if (period == null)
            {
                string errorMessage = PXMessages.LocalizeFormatNoPrefix(
                    Messages.RelatedFinPeriodsForMasterDoesNotExistForCompany,
                    PeriodIDAttribute.FormatForError(masterFinPeriodID),
                    PXAccess.GetOrganizationCD(organizationID));

                result.AddErrorMessage(errorMessage);
            }

            return(result);
        }
        public virtual ProcessingResult <FABookPeriod> FindMappedFABookPeriodUsingFinPeriod(int?bookID, int?sourceOrganizationID, string sourcefinPeriodID, int?targetOrganizationID)
        {
            IFinPeriodRepository finPeriodRepository = Graph.GetService <IFinPeriodRepository>();

            string       targetFinPeriodID  = finPeriodRepository.GetMappedPeriod(sourceOrganizationID, sourcefinPeriodID, targetOrganizationID)?.FinPeriodID;
            FABookPeriod targetFABookPeriod = FindByKey(bookID, targetOrganizationID, targetFinPeriodID);

            ProcessingResult <FABookPeriod> result = ProcessingResult <FABookPeriod> .CreateSuccess(targetFABookPeriod);

            if (targetFABookPeriod == null)
            {
                string errorMessage = PXMessages.LocalizeFormat(
                    Messages.PeriodDoesNotExistForBookAndCompany,
                    PeriodIDAttribute.FormatForError(sourcefinPeriodID),
                    FindFABook(bookID).BookCode,
                    PXAccess.GetOrganizationCD(sourceOrganizationID));

                result.AddErrorMessage(errorMessage);
            }

            return(result);
        }
        public virtual ProcessingResult <FABookPeriod> FindMappedFABookPeriod(int?bookID, int?sourceOrganizationID, string sourcefinPeriodID, int?targetOrganizationID)
        {
            FABookPeriod sourceFABookPeriod = FindByKey(bookID, sourceOrganizationID, sourcefinPeriodID);

            ProcessingResult <FABookPeriod> result = ProcessingResult <FABookPeriod> .CreateSuccess(sourceFABookPeriod);

            if (sourceFABookPeriod == null)
            {
                string errorMessage = PXMessages.LocalizeFormat(
                    Messages.PeriodDoesNotExistForBookAndCompany,
                    PeriodIDAttribute.FormatForError(sourcefinPeriodID),
                    FindFABook(bookID).BookCode,
                    PXAccess.GetOrganizationCD(sourceOrganizationID));

                result.AddErrorMessage(errorMessage);
            }
            else if (IsPostingFABook(bookID) && sourceOrganizationID != targetOrganizationID)
            {
                result = GetFABookPeriodByMasterPeriodID(bookID, targetOrganizationID, sourceFABookPeriod?.MasterFinPeriodID);
            }

            return(result);
        }
        public virtual ProcessingResult <FABookPeriod> GetFABookPeriodByMasterPeriodID(int?bookID, int?organizationID, string masterFinPeriodID)
        {
            FABookPeriod period = SelectFrom <FABookPeriod>
                                  .Where <FABookPeriod.bookID.IsEqual <@P.AsInt>
                                          .And <FABookPeriod.organizationID.IsEqual <@P.AsInt> >
                                          .And <FABookPeriod.masterFinPeriodID.IsEqual <@P.AsString> > >
                                  .View
                                  .ReadOnly
                                  .Select(Graph, bookID, organizationID, masterFinPeriodID);

            ProcessingResult <FABookPeriod> result = ProcessingResult <FABookPeriod> .CreateSuccess(period);

            if (period == null)
            {
                string errorMessage = PXMessages.LocalizeFormatNoPrefix(
                    GL.Messages.RelatedFinPeriodsForMasterDoesNotExistForCompany,
                    PeriodIDAttribute.FormatForError(masterFinPeriodID),
                    PXAccess.GetOrganizationCD(organizationID));

                result.AddErrorMessage(errorMessage);
            }

            return(result);
        }