예제 #1
0
        protected virtual void Batch_RowInserted(PXCache sender, PXRowInsertedEventArgs e, PXRowInserted bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }

            if (Base.IsWithinContext)
            {
                string vb   = Base.GetContextValue <GLVoucherBatch.voucherBatchNbr>();
                string wbID = Base.GetContextValue <GLVoucherBatch.workBookID>();
                this.VoucherBatch.Current = this.VoucherBatch.Select(wbID, vb);
                GLWorkBook wb = PXSelect <GLWorkBook,
                                          Where <GLWorkBook.workBookID, Equal <Required <GLVoucherBatch.workBookID> > > > .Select(this.Base, Base.GetContextValue <GLVoucherBatch.workBookID>());

                if (!String.IsNullOrEmpty(vb))
                {
                    Guid?noteID = PXNoteAttribute.GetNoteID <Batch.noteID>(sender, e.Row);
                    this.Voucher.Insert(new GLVoucher());
                    this.Voucher.Cache.IsDirty        = false;
                    Base.Caches[typeof(Note)].IsDirty = false;
                }
                if (wb.DefaultDescription != null && (e.Row as Batch)?.Description == null)
                {
                    sender.SetValueExt <Batch.description>(e.Row, wb.DefaultDescription);
                }
            }
        }
예제 #2
0
        protected virtual void Filter_WorkBookID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            var        page  = HttpContext.Current.CurrentHandler as Page;
            string     value = page.Request.QueryString["WorkBookID"];
            GLWorkBook wb    = PXSelect <GLWorkBook, Where <GLWorkBook.workBookID, Equal <Required <GLWorkBook.workBookID> > > > .Select(this, value);

            if (wb != null)
            {
                e.NewValue = wb.WorkBookID;
                e.Cancel   = true;
            }
        }
예제 #3
0
        protected virtual void Filter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            PXLongRunStatus status = GetLongOperationStatus();

            bool haveRecords  = VoucherBatches.Select().Any <object>();
            bool noProcessing = status == PXLongRunStatus.NotExists;

            GLWorkBook workBook = WorkBook.Select((e.Row as Filter).WorkBookID);

            bool active = workBook?.Status == WorkBookStatus.Active;

            Insert.SetEnabled(noProcessing && active);
            Delete.SetEnabled(noProcessing && haveRecords && active);
            Release.SetEnabled(noProcessing && haveRecords && active);
            ViewDocument.SetEnabled(haveRecords);
            VoucherBatches.Cache.AllowUpdate = noProcessing && active;
        }
예제 #4
0
        protected virtual void GLVoucherBatch_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            GLVoucherBatch row = (GLVoucherBatch)e.Row;

            if (row == null)
            {
                return;
            }

            Dictionary <string, Dictionary <Guid, CAMessage> > listMessages = PXLongOperation.GetCustomInfo(this.UID) as Dictionary <string, Dictionary <Guid, CAMessage> >;
            PXLongRunStatus status = GetLongOperationStatus();

            if ((status == PXLongRunStatus.Aborted || status == PXLongRunStatus.Completed) && listMessages != null)
            {
                string key = row.VoucherBatchNbr;
                if (listMessages.ContainsKey(key))
                {
                    VouchersInBatch.View.AllowSelect = true;
                    CAMessage message;
                    if (listMessages[key].TryGetValue(Guid.Empty, out message))
                    {
                        sender.RaiseExceptionHandling <GLVoucherBatch.voucherBatchNbr>(row, row.VoucherBatchNbr, new PXSetPropertyException <GLVoucherBatch.voucherBatchNbr>(message.Message, message.ErrorLevel));
                    }
                    else
                    {
                        sender.RaiseExceptionHandling <GLVoucherBatch.voucherBatchNbr>(row, row.VoucherBatchNbr, new PXSetPropertyException <GLVoucherBatch.voucherBatchNbr>("Processed", PXErrorLevel.RowInfo));
                    }
                }
                else
                {
                    VouchersInBatch.View.AllowSelect = false;
                }
            }
            else
            {
                VouchersInBatch.View.AllowSelect = false;
            }

            GLWorkBook workBook = WorkBook.Select(filter.Current.WorkBookID);

            bool active = workBook.Status == WorkBookStatus.Active;

            PXUIFieldAttribute.SetEnabled <GLVoucherBatch.selected>(sender, row, row.Released == false && active);
            PXUIFieldAttribute.SetEnabled <GLVoucherBatch.descr>(sender, row, row.Released == false && active);
        }
예제 #5
0
        protected virtual IEnumerable insert(PXAdapter adapter)
        {
            GLWorkBook wb = WorkBook.Select();

            if (wb.SingleOpenVoucherBatch == true)
            {
                int unreleasedCount = PXSelect <GLVoucherBatch,
                                                Where <GLVoucherBatch.workBookID, Equal <Required <GLWorkBook.workBookID> >,
                                                       And <GLVoucherBatch.released, Equal <False> > > > .Select(this, wb.WorkBookID).Count;

                if (unreleasedCount > 0)
                {
                    throw new PXException(Messages.OnlyOneUnreleasedBatchAllowed);
                }
            }
            if (BatchCreation.View.Answer == WebDialogResult.None)
            {
                BatchCreation.Cache.Clear();
            }
            if (BatchCreation.AskExt() == WebDialogResult.OK)
            {
                if (VoucherBatches.Current != null)
                {
                    VoucherBatches.Cache.RaiseExceptionHandling <GLVoucherBatch.voucherBatchNbr>(VoucherBatches.Current,
                                                                                                 VoucherBatches.Current.VoucherBatchNbr, null);
                }
                GLVoucherBatch batch = new GLVoucherBatch();
                batch.Descr = BatchCreation.Current.BatchDescription;
                Numbering numbering        = Numbering.Select();
                bool      isManualNumberig = numbering != null && numbering.UserNumbering == true;
                if (isManualNumberig)
                {
                    batch.VoucherBatchNbr = BatchCreation.Current.VoucherBatchNbr;
                }

                batch = VoucherBatches.Insert(batch);
                this.VoucherBatches.Current = batch;
                Save.Press();
                editRecord.Press();
            }

            return(adapter.Get());
        }
예제 #6
0
        private void RedirectToBatch(GLVoucherBatch batch, GLVoucher voucher = null)
        {
            if (batch != null)
            {
                GLWorkBook wb = PXSelect <GLWorkBook, Where <GLWorkBook.workBookID, Equal <Required <GLWorkBook.workBookID> > > > .Select(this, batch.WorkBookID);

                if (wb == null || wb.VoucherEditScreen == null)
                {
                    throw new PXException(Messages.GLWorkBookIsInvalidOrVoucherEditScreenIsNotConfiguredForIt, batch.WorkBookID);
                }

                PXGraph       target = null;
                PXSiteMapNode sm     = PXSiteMap.Provider.FindSiteMapNodeFromKey((Guid)wb.VoucherEditScreen);
                if (sm == null)
                {
                    throw new PXException(Messages.CannotFindSitemapNode);
                }
                Type graphType       = System.Web.Compilation.BuildManager.GetType(sm.GraphType, true);
                Type parentGraphType = GLWorkBookMaint.GetGraphByDocType(batch.Module, wb.DocType);
                if (parentGraphType != null && parentGraphType.IsAssignableFrom(graphType))
                {
                    target = PXGraph.CreateInstance(graphType);
                }
                else
                {
                    throw new PXException(Messages.GLVoucherEditGraphMayNotBeAssignedToTheBasedDocumentGraph, graphType, parentGraphType);
                }
                if (voucher == null)
                {
                    voucher = PXSelect <GLVoucher, Where <GLVoucher.workBookID, Equal <Required <GLVoucher.workBookID> >,
                                                          And <GLVoucher.voucherBatchNbr, Equal <Required <GLVoucher.voucherBatchNbr> > > >, OrderBy <Desc <GLVoucher.refNbr> > > .Select(this, batch.WorkBookID, batch.VoucherBatchNbr);
                }
                else
                {
                    voucher = PXSelect <GLVoucher, Where <GLVoucher.workBookID, Equal <Required <GLVoucher.workBookID> >,
                                                          And <GLVoucher.voucherBatchNbr, Equal <Required <GLVoucher.voucherBatchNbr> >, And <GLVoucher.refNbr, Equal <Required <GLVoucher.refNbr> > > > >, OrderBy <Desc <GLVoucher.refNbr> > > .Select(this, batch.WorkBookID, batch.VoucherBatchNbr, voucher.RefNbr);
                }
                SetVoucherAsCurrent(target, voucher);
                throw new PXRedirectWithinContextException(this, target, Messages.VoucherEdit, typeof(GLVoucherBatch.workBookID), typeof(GLVoucherBatch.voucherBatchNbr));
            }
        }
예제 #7
0
        public static void ReverseGLVoucher(PXGraph graph, PXAction actionSave, Action baseReverse, PXCache voucherBatchView)
        {
            GLWorkBook wb = PXSelect <GLWorkBook, Where <GLWorkBook.workBookID, Equal <Required <GLVoucherBatch.workBookID> > > > .Select(graph, graph.GetContextValue <GLVoucherBatch.workBookID>());

            if (wb?.ReversingWorkBookID == null)
            {
                throw new PXException(Messages.ReversingWorkbookIDisnotDefined);
            }
            GLWorkBook reversingWB = PXSelect <GLWorkBook,
                                               Where <GLWorkBook.workBookID, Equal <Required <GLVoucherBatch.workBookID> >,
                                                      And <GLWorkBook.status, Equal <WorkBookStatus.active> > > > .Select(graph, wb.ReversingWorkBookID);

            if (reversingWB == null)
            {
                throw new PXException(Messages.ReversingWorkbookIDisnotFound);
            }

            GLVoucherBatch vb = PXSelect <GLVoucherBatch, Where <GLVoucherBatch.workBookID, Equal <Required <GLWorkBook.workBookID> >, And <GLVoucherBatch.released, Equal <False> > >,
                                          OrderBy <Asc <GLVoucherBatch.voucherBatchNbr> > > .Select(graph, reversingWB.WorkBookID);

            if (vb == null)
            {
                var batch = new GLVoucherBatch
                {
                    WorkBookID = reversingWB.WorkBookID,
                    Descr      = Messages.ReversingVoucherBatchDesc
                };

                vb = (GLVoucherBatch)voucherBatchView.Insert(batch);
                voucherBatchView.Current = batch;
                actionSave.Press();
            }

            graph.contextValues[typeof(GLVoucherBatch.workBookID).FullName]      = reversingWB.WorkBookID;
            graph.contextValues[typeof(GLVoucherBatch.voucherBatchNbr).FullName] = vb.VoucherBatchNbr;

            baseReverse.Invoke();
            throw new PXRedirectWithinContextException(graph, graph, Messages.VoucherEdit, typeof(GLVoucherBatch.workBookID), typeof(GLVoucherBatch.voucherBatchNbr));
        }