Esempio n. 1
0
        public ProcessingResult CheckUnreleasedAndUnpostedDocumentsDoNotExist(int?branchID, TaxPeriod taxPeriod)
        {
            var lastFinPeriod = _gafRepository.FindFinPeriodWithEndDate(taxPeriod.EndDate);

            var result = new ProcessingResult();
            var modulesWithUnreleasedDocuments = new List <string>();

            if (!_gafRepository.CheckDoNotExistUnreleasedAPRegistersWithAPTransWithBranchWithFinPeriodLessOrEqual(branchID, lastFinPeriod.FinPeriodID))
            {
                modulesWithUnreleasedDocuments.Add(BatchModule.AP);
            }
            if (!_gafRepository.CheckDoNotExistUnreleasedARRegistersWithARTransWithBranchWithFinPeriodLessOrEqual(branchID, lastFinPeriod.FinPeriodID))
            {
                modulesWithUnreleasedDocuments.Add(BatchModule.AR);
            }
            if (!_gafRepository.CheckDoNotExistUnreleasedCAAdjsWithCASplitsWithBranchWithFinPeriodLessOrEqual(branchID, lastFinPeriod.FinPeriodID))
            {
                modulesWithUnreleasedDocuments.Add(BatchModule.CA);
            }

            if (modulesWithUnreleasedDocuments.Any())
            {
                result.AddMessage(PXErrorLevel.Warning, Messages.ThereAreUnreleasedDocumentsInModules,
                                  modulesWithUnreleasedDocuments.JoinIntoStringForMessage(edgingSymbol: null));
            }

            if (!_gafRepository.CheckDoNotExistUnreleasedOrUnpostedGLTransWithBranchWithFinPeriodLessOrEqual(branchID, lastFinPeriod.FinPeriodID))
            {
                result.AddMessage(PXErrorLevel.Warning, Messages.ThereAreUnpostedTransactions);
            }

            return(result);
        }
Esempio n. 2
0
        public ProcessingResult FinPeriodsForMasterExist(string masterFinPeriodID, int?[] organizationIDs)
        {
            List <FinPeriod> finPeriods =
                PXSelect <FinPeriod,
                          Where <FinPeriod.masterFinPeriodID, Equal <Required <FinPeriod.masterFinPeriodID> >,
                                 And <FinPeriod.organizationID, In <Required <FinPeriod.organizationID> > > > >
                .Select(Graph, masterFinPeriodID, organizationIDs)
                .RowCast <FinPeriod>()
                .ToList();

            ProcessingResult validationResult = new ProcessingResult();

            if (finPeriods.Count != organizationIDs.Length)
            {
                IEnumerable <int?> unexistingForOrganizationIDs =
                    organizationIDs.Except(finPeriods.Select(period => period.OrganizationID));

                validationResult.AddMessage(
                    PXErrorLevel.Error,
                    Messages.RelatedFinPeriodsForMasterDoesNotExistForCompanies,
                    FinPeriodIDFormattingAttribute.FormatForError(masterFinPeriodID),
                    unexistingForOrganizationIDs.Select(PXAccess.GetOrganizationCD).OrderBy(v => v).ToArray().JoinIntoStringForMessageNoQuotes(20));
            }

            return(validationResult);
        }