Exemplo 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);
        }