public static void ReleaseCustomSchedule(DRScheduleDetail item)
        {
            ScheduleMaint maint = PXGraph.CreateInstance <ScheduleMaint>();

            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.ReleaseCustomSchedule();
        }
示例#2
0
        private void ReleaseCustomSchedule()
        {
            foreach (DRScheduleDetail detail in Components.Select())
            {
                ScheduleMaint maint = PXGraph.CreateInstance <ScheduleMaint>();
                maint.Clear();
                maint.Document.Current = detail;

                maint.ReleaseCustomSchedule();
            }
        }
示例#3
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();
        }
        public static void RunRecognition(List <ScheduledTran> trans, DateTime?filterDate)
        {
            ScheduleMaint scheduleMaint = PXGraph.CreateInstance <ScheduleMaint>();

            scheduleMaint.Clear();

            bool failed = false;

            List <ScheduledTran> items = GetValidatedItems(trans, scheduleMaint);

            failed = items.Count() < trans.Count();

            // Save virtual records:
            // -
            foreach (ScheduledTran tr in items)
            {
                PXProcessing <ScheduledTran> .SetCurrentItem(tr);

                if (tr.IsVirtual == true)
                {
                    try
                    {
                        scheduleMaint.Document.Current = PXSelect <DRScheduleDetail,
                                                                   Where <DRScheduleDetail.scheduleID, Equal <Required <DRScheduleDetail.scheduleID> >,
                                                                          And <DRScheduleDetail.componentID, Equal <Required <DRScheduleDetail.componentID> > > > >
                                                         .Select(scheduleMaint, tr.ScheduleID, tr.ComponentID ?? DRScheduleDetail.EmptyComponentID);

                        DRScheduleTran tran = new DRScheduleTran();
                        tran.BranchID    = tr.BranchID;
                        tran.AccountID   = tr.AccountID;
                        tran.SubID       = tr.SubID;
                        tran.AdjgDocType = tr.AdjgDocType;
                        tran.AdjgRefNbr  = tr.AdjgRefNbr;
                        tran.AdjNbr      = tr.AdjNbr;
                        tran.Amount      = tr.Amount;
                        tran.ComponentID = tr.ComponentID ?? DRScheduleDetail.EmptyComponentID;
                        tran.FinPeriodID = tr.FinPeriodID;
                        tran.ScheduleID  = tr.ScheduleID;
                        tran.RecDate     = tr.RecDate;
                        tran.Status      = DRScheduleTranStatus.Open;

                        tran       = scheduleMaint.OpenTransactions.Insert(tran);
                        tr.LineNbr = tran.LineNbr;

                        scheduleMaint.RebuildProjections();

                        scheduleMaint.Save.Press();
                        byte[] ts = scheduleMaint.TimeStamp;
                        scheduleMaint.Clear();
                        scheduleMaint.TimeStamp = ts;
                        PXProcessing <ScheduledTran> .SetProcessed();
                    }

                    catch (Exception ex)
                    {
                        failed = true;
                        PXProcessing <ScheduledTran> .SetError(ex.Message);
                    }
                }
                else
                {
                    PXProcessing <ScheduledTran> .SetProcessed();
                }
            }

            PXProcessing <ScheduledTran> .SetCurrentItem(null);

            List <DRBatch> list = SplitByFinPeriod(items);

            DRProcess process = CreateInstance <DRProcess>();

            process.Clear();
            process.TimeStamp = scheduleMaint.TimeStamp;
            List <Batch> batchlist = process.RunRecognition(list, filterDate);

            PostGraph pg = PXGraph.CreateInstance <PostGraph>();
            //Post Batches if AutoPost

            bool postFailed = false;

            if (pg.AutoPost)
            {
                foreach (Batch batch in batchlist)
                {
                    try
                    {
                        pg.Clear();
                        pg.TimeStamp = batch.tstamp;
                        pg.PostBatchProc(batch);
                    }
                    catch (Exception)
                    {
                        postFailed = true;
                    }
                }
                if (postFailed)
                {
                    throw new PXException(Messages.AutoPostFailed);
                }
            }

            if (failed)
            {
                throw new PXException(GL.Messages.DocumentsNotReleased);
            }
        }