private static List <ScheduledTran> GetValidatedItems(List <ScheduledTran> items, ScheduleMaint scheduleMaint)
        {
            List <ScheduledTran> validatedItems = new List <ScheduledTran>();

            foreach (ScheduledTran item in items)
            {
                PXProcessing <ScheduledTran> .SetCurrentItem(item);

                try
                {
                    FinPeriod finPeriod = scheduleMaint.GetService <IFinPeriodRepository>().FindByID(PXAccess.GetParentOrganizationID(item.BranchID), item.FinPeriodID);
                    scheduleMaint.GetService <IFinPeriodUtils>().CanPostToPeriod(finPeriod).RaiseIfHasError();

                    validatedItems.Add(item);
                }
                catch (Exception ex)
                {
                    PXProcessing <ScheduledTran> .SetError(ex.Message);
                }
            }

            return(validatedItems);
        }
Beispiel #2
0
        public static void ReleaseCustomSchedule(DRScheduleDetail item)
        {
            ScheduleMaint maint = PXGraph.CreateInstance <ScheduleMaint>();

            var details = PXSelect <
                DRScheduleDetail,
                Where <DRScheduleDetail.scheduleID, Equal <Required <DRSchedule.scheduleID> >,
                       And <DRScheduleDetail.isResidual, Equal <False> > > >
                          .Select(maint, item.ScheduleID)
                          .RowCast <DRScheduleDetail>();

            maint.GetService <IFinPeriodUtils>().ValidateFinPeriod <DRScheduleDetail>(details, m => item.FinPeriodID, m => m.BranchID.SingleToArray());

            maint.Clear();
            maint.Document.Current = PXSelect <DR.DRScheduleDetail,
                                               Where <DR.DRScheduleDetail.scheduleID, Equal <Required <DR.DRScheduleDetail.scheduleID> >,
                                                      And <DR.DRScheduleDetail.componentID, Equal <Required <DR.DRScheduleDetail.componentID> > > > > .Select(maint, item.ScheduleID, item.ComponentID);

            maint.ReleaseCustomScheduleDetail();
        }