public LienWaiverGenerationDataProviderBase(PXGraph graph)
 {
     Graph                  = (APPaymentEntry)graph;
     LienWaiverSetup        = graph.GetExtension <ApPaymentEntryLienWaiverExtension>().LienWaiverSetup.Current;
     LienWaiverDataProvider = graph.GetService <ILienWaiverDataProvider>();
     TransactionRetriever   = graph.GetService <ILienWaiverTransactionRetriever>();
 }
Ejemplo n.º 2
0
        public virtual OrganizationFinPeriod GetNearestOpenOrganizationMappedFABookPeriodInSubledger <TClosedInSubledgerField>(int?bookID, int?sourceBranchID, string sourcefinPeriodID, int?targetBranchID)
            where TClosedInSubledgerField : IBqlField
        {
            if (!FABookPeriodRepositoryHelper.IsPostingFABook(bookID))
            {
                return(null);
            }

            IFinPeriodUtils         finPeriodUtils         = Graph.GetService <IFinPeriodUtils>();
            IFinPeriodRepository    finPeriodRepository    = Graph.GetService <IFinPeriodRepository>();
            IFABookPeriodRepository faBookPeriodRepository = Graph.GetService <IFABookPeriodRepository>();

            int?sourceOrganizationID = PXAccess.GetParentOrganizationID(sourceBranchID);
            int?targetOrganizationID = PXAccess.GetParentOrganizationID(targetBranchID);

            // Mapped book period - first way:
            // FABookPeriod of sourceBranchID -> master book Period -> FABookPeriod of targetBranchID
            //
            ProcessingResult <FABookPeriod> targetFABookPeriod = faBookPeriodRepository.FindMappedFABookPeriod(
                bookID,
                sourceOrganizationID,
                sourcefinPeriodID,
                targetOrganizationID);

            // Mapped book period - second way:
            // finPeriodID of sourceBranchID -> masterFinPeriod -> FinPeriodID of targetBranchID -> FABookPeriod of targetBranchID
            //
            if (targetFABookPeriod.Result == null)
            {
                ProcessingResult <FABookPeriod> targetFABookPeriodSecondWay = faBookPeriodRepository.FindMappedFABookPeriodUsingFinPeriod(
                    bookID,
                    sourceOrganizationID,
                    sourcefinPeriodID,
                    targetOrganizationID);

                targetFABookPeriodSecondWay.RaiseIfHasError();

                targetFABookPeriod = targetFABookPeriodSecondWay;
            }

            OrganizationFinPeriod period = finPeriodUtils.GetNearestOpenOrganizationFinPeriodInSubledger <TClosedInSubledgerField>(targetFABookPeriod.ThisOrRaiseIfHasError().Result);

            return(period);
        }
Ejemplo n.º 3
0
        public object GetBucketNumberForAgedReport(
            DateTime?reportDate,
            DateTime?dateToAge,
            int?dayBucketBoundary0,
            int?dayBucketBoundary1,
            int?dayBucketBoundary2,
            int?dayBucketBoundary3,
            bool?isByFinancialPeriod,
            bool?isForwardAging,
            int organizationID)
        {
            if (reportDate == null ||
                dayBucketBoundary0 == null ||
                dayBucketBoundary1 == null ||
                dayBucketBoundary2 == null ||
                dayBucketBoundary3 == null)
            {
                return(null);
            }

            AgingDirection agingDirection = isForwardAging == true
                                ? AgingDirection.Forward
                                : AgingDirection.Backwards;

            PXGraph graph = new PXGraph();

            return(isByFinancialPeriod == true
                                ? AgingEngine.AgeByPeriods(
                       reportDate.Value,
                       dateToAge.Value,
                       graph.GetService <IFinPeriodRepository>(),
                       agingDirection,
                       NUMBER_OF_AGING_BUCKETS,
                       organizationID)
                                : AgingEngine.AgeByDays(
                       reportDate.Value,
                       dateToAge.Value,
                       agingDirection,
                       dayBucketBoundary0 ?? 0,
                       dayBucketBoundary1 ?? 0,
                       dayBucketBoundary2 ?? 0,
                       dayBucketBoundary3 ?? 0));
        }
Ejemplo n.º 4
0
        /// <param name="roundingFunction">
        /// An optional parameter specifying a function that would be used to round
        /// the calculated transaction amounts. If <c>null</c>, the generator will use
        /// <see cref="PXDBCurrencyAttribute.BaseRound(PXGraph, decimal)"/> by default.
        /// </param>
        /// <param name="financialPeriodProvider">
        /// An optional parameter specifying an object that would be used to manipulate
        /// financial periods, e.g. extract a start date or an end date for a given period ID.
        /// If <c>null</c>, the generator will use <see cref="FinancialPeriodProvider.Default"/>.
        /// </param>
        public TransactionsGenerator(
            PXGraph graph,
            DRDeferredCode code,
            IFinPeriodRepository finPeriodRepository = null,
            Func <decimal, decimal> roundingFunction = null)
        {
            if (graph == null)
            {
                throw new ArgumentNullException(nameof(graph));
            }
            if (code == null)
            {
                throw new ArgumentNullException(nameof(code));
            }

            _graph               = graph;
            _code                = code;
            _roundingFunction    = roundingFunction ?? (rawAmount => PXDBCurrencyAttribute.BaseRound(_graph, rawAmount));
            _finPeriodRepository = finPeriodRepository ?? _graph.GetService <IFinPeriodRepository>();
        }
        /// <summary>
        /// Retrieves the first financial period of the year corresponding
        /// to the financial period specified.
        /// If no such period exists, returns <c>null</c>.
        /// </summary>
        public string GetFirstPeriodOfYear(string financialPeriodID)
        {
            if (financialPeriodID == null)
            {
                return(null);
            }

            PXGraph graph = PXGraph.CreateInstance <MasterFinPeriodMaint>();

            string firstPeriodOfYear = FinPeriodUtils.GetFirstFinPeriodIDOfYear(financialPeriodID);

            IFinPeriodRepository finPeriodRepository = graph.GetService <IFinPeriodRepository>();

            if (!finPeriodRepository.PeriodExists(financialPeriodID, FinPeriod.organizationID.MasterValue))
            {
                return(null);
            }

            return(FinPeriodIDFormattingAttribute.FormatForDisplay(firstPeriodOfYear));
        }
        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);
        }
        /// <summary>
        /// Retrieves the financial period with the same <see cref="MasterFinPeriod.PeriodNbr"/>
        /// as the one specified, but residing in the previous financial year.
        /// If no such period exists, returns <c>null</c>.
        /// </summary>
        public string GetSamePeriodInPreviousYear(string financialPeriodID)
        {
            if (financialPeriodID == null)
            {
                return(null);
            }

            PXGraph graph = PXGraph.CreateInstance <MasterFinPeriodMaint>();

            try
            {
                IFinPeriodRepository finPeriodRepository = graph.GetService <IFinPeriodRepository>();

                string resultingPeriodID = finPeriodRepository.GetSamePeriodInPreviousYear(financialPeriodID, FinPeriod.organizationID.MasterValue);

                return(FinPeriodIDFormattingAttribute.FormatForDisplay(resultingPeriodID));
            }
            catch (PXFinPeriodException)
            {
                return(null);
            }
        }
Ejemplo n.º 8
0
 public FABookPeriodUtils(PXGraph graph)
 {
     Graph = graph;
     FABookPeriodRepositoryHelper = Graph.GetService <IFABookPeriodRepository>();
 }
        public string GetBucketDescriptionForAgedReport(
            DateTime?reportDate,
            int?dayBucketBoundary0,
            int?dayBucketBoundary1,
            int?dayBucketBoundary2,
            int?dayBucketBoundary3,
            bool?isByFinancialPeriod,
            bool?isForwardAging,
            int?bucketIndex)
        {
            if (reportDate == null ||
                dayBucketBoundary0 == null ||
                dayBucketBoundary1 == null ||
                dayBucketBoundary2 == null ||
                dayBucketBoundary3 == null ||
                bucketIndex == null)
            {
                return(null);
            }

            AgingDirection agingDirection = isForwardAging == true
                                ? AgingDirection.Forward
                                : AgingDirection.Backwards;

            if (isByFinancialPeriod == true)
            {
                try
                {
                    PXGraph graph = new PXGraph();
                    IEnumerable <string> bucketDescriptions = AgingEngine.GetPeriodAgingBucketDescriptions(
                        graph.GetService <IFinPeriodRepository>(),
                        reportDate.Value,
                        agingDirection,
                        NUMBER_OF_AGING_BUCKETS);

                    return(bucketDescriptions.ElementAtOrDefault(bucketIndex.Value));
                }
                catch (PXFinPeriodException)
                {
                    throw new PXFinPeriodException(
                              isForwardAging == true
                                                        ? AR.Messages.UnableToCalculateBucketNamesPeriodsAfterwardsNotDefined
                                                        : AR.Messages.UnableToCalculateBucketNamesPeriodsPrecedingNotDefined);
                }
            }
            else
            {
                IEnumerable <string> bucketDescriptions = AgingEngine.GetDayAgingBucketDescriptions(
                    agingDirection,
                    new int[]
                {
                    dayBucketBoundary0 ?? 0,
                    dayBucketBoundary1 ?? 0,
                    dayBucketBoundary2 ?? 0,
                    dayBucketBoundary3 ?? 0
                },
                    true);

                return(bucketDescriptions.ElementAtOrDefault(bucketIndex.Value));
            }
        }
Ejemplo n.º 10
0
 public EmailLienWaiverService(PXGraph graph)
     : base(graph)
 {
     RecipientEmailDataProvider = graph.GetService <IRecipientEmailDataProvider>();
 }
Ejemplo n.º 11
0
 public Scheduler(PXGraph graph, IFinPeriodRepository finPeriodRepository = null)
 {
     _graph = graph;
     _finPeriodRepository = finPeriodRepository ?? _graph.GetService <IFinPeriodRepository>();
 }