Exemple #1
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, "Voucher Edit", typeof(GLVoucherBatch.workBookID), typeof(GLVoucherBatch.voucherBatchNbr));
            }
        }
Exemple #2
0
        protected virtual void Batch_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }
            Batch row = e.Row as Batch;

            if (row == null)
            {
                return;
            }
            bool           isWithinContext = Base.IsWithinContext;
            GLVoucher      voucher         = this.Voucher.Select();
            GLVoucherBatch voucherBatch    = this.VoucherBatch.Select();
            PXCache        voucherCache    = this.Voucher.Cache;
            bool           isDetached      = (voucher == null);

            PXUIFieldAttribute.SetEnabled <GLVoucher.refNbr>(voucherCache, voucher, false);
            PXUIFieldAttribute.SetVisible <GLVoucher.refNbr>(voucherCache, voucher, !isDetached);
            PXUIFieldAttribute.SetEnabled <Batch.batchNbr>(sender, e.Row, !isWithinContext);
            this.SaveAndAdd.SetVisible(!isDetached && isWithinContext);
            this.SaveAndAdd.SetEnabled(!isDetached && isWithinContext);
            if (isWithinContext)
            {
                Base.release.SetVisible(false);
                Base.release.SetEnabled(false);
            }
            if (!isDetached)
            {
                Base.createSchedule.SetVisible(false);
                Base.createSchedule.SetEnabled(false);
            }
            PXUIFieldAttribute.SetVisible <GLVoucher.voucherBatchNbr>(Voucher.Cache, null, !isDetached && !isWithinContext);
            PXUIFieldAttribute.SetVisible <GLVoucher.workBookID>(Voucher.Cache, null, !isDetached && !isWithinContext);
            if (isWithinContext && !isDetached)
            {
                sender.AllowInsert = !(voucherBatch != null && voucherBatch.Released == true);
            }
        }
Exemple #3
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());
        }
Exemple #4
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));
        }