Esempio n. 1
0
        protected virtual void CABatchDetail_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            CABatchDetail row        = (CABatchDetail)e.Row;
            bool          isReleased = false;
            bool          isVoided   = false;

            if (row.OrigModule == GL.BatchModule.AP)
            {
                APRegister apDocument = PXSelect <APRegister, Where <APRegister.docType, Equal <Required <APRegister.docType> >,
                                                                     And <APRegister.refNbr, Equal <Required <APRegister.refNbr> > > > > .Select(this, row.OrigDocType, row.OrigRefNbr);

                isReleased = (bool)apDocument.Released;
                isVoided   = (bool)apDocument.Voided;
            }

            if (row.OrigModule == GL.BatchModule.AR)
            {
                ARRegister arDocument = PXSelect <ARRegister, Where <ARRegister.docType, Equal <Required <ARRegister.docType> >,
                                                                     And <ARRegister.refNbr, Equal <Required <ARRegister.refNbr> > > > > .Select(this, row.OrigDocType, row.OrigRefNbr);

                isReleased = (bool)arDocument.Released;
                isVoided   = (bool)arDocument.Voided;
            }

            if (isReleased && !isVoided)
            {
                throw new PXException(Messages.ReleasedDocumentMayNotBeDeletedFromCABatch);
            }
        }
        protected virtual void CABatchDetail_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            CABatchDetail row = (CABatchDetail)e.Row;

            if (!this._isMassDelete)
            {
                UpdateDocAmount(row, true);
            }
        }
Esempio n. 3
0
        private CABatch UpdateDocAmount(CABatchDetail row, bool negative)
        {
            CABatch document = this.Document.Current;

            if (row.OrigDocType != null && row.OrigRefNbr != null)
            {
                decimal?curyAmount = null, amount = null;
                if (row.OrigModule == GL.BatchModule.AP)
                {
                    APPayment payment = PXSelect <APPayment,
                                                  Where <APPayment.docType, Equal <Required <APPayment.docType> >,
                                                         And <APPayment.refNbr, Equal <Required <APPayment.refNbr> > > > > .Select(this, row.OrigDocType, row.OrigRefNbr);

                    if (payment != null)
                    {
                        curyAmount = payment.CuryOrigDocAmt;
                        amount     = payment.OrigDocAmt;
                    }
                }
                else
                {
                    ARPayment payment = PXSelect <ARPayment,
                                                  Where <ARPayment.docType, Equal <Required <ARPayment.docType> >,
                                                         And <ARPayment.refNbr, Equal <Required <ARPayment.refNbr> > > > > .Select(this, row.OrigDocType, row.OrigRefNbr);

                    if (payment != null)
                    {
                        curyAmount = payment.CuryOrigDocAmt;
                        amount     = payment.OrigDocAmt;
                    }
                }

                CABatch copy = (CABatch)this.Document.Cache.CreateCopy(document);

                if (curyAmount.HasValue)
                {
                    document.CuryDetailTotal += negative ? -curyAmount : curyAmount;
                }

                if (amount.HasValue)
                {
                    document.DetailTotal += negative ? -amount : amount;
                }

                document = this.Document.Update(document);
            }
            return(document);
        }
Esempio n. 4
0
        public virtual IEnumerable viewAPDocument(PXAdapter adapter)
        {
            CABatchDetail detail = this.BatchPayments.Current;

            if (detail == null)
            {
                return(adapter.Get());
            }

            APRegister apDocument = PXSelect <APRegister,
                                              Where <APRegister.docType, Equal <Required <APRegister.docType> >,
                                                     And <APRegister.refNbr, Equal <Required <APRegister.refNbr> > > > > .Select(this, detail.OrigDocType, detail.OrigRefNbr);

            if (apDocument == null)
            {
                return(adapter.Get());
            }

            if (apDocument.DocType == APDocType.Check)
            {
                APPaymentEntry apGraph = PXGraph.CreateInstance <APPaymentEntry>();
                apGraph.Document.Current = apGraph.Document.Search <APRegister.refNbr>(apDocument.RefNbr, apDocument.DocType);
                if (apGraph.Document.Current != null)
                {
                    throw new PXRedirectRequiredException(apGraph, true, "")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
            }
            else if (apDocument.DocType == APDocType.QuickCheck)
            {
                APQuickCheckEntry apGraph = PXGraph.CreateInstance <APQuickCheckEntry>();
                apGraph.Document.Current = apGraph.Document.Search <APRegister.refNbr>(apDocument.RefNbr, apDocument.DocType);
                if (apGraph.Document.Current != null)
                {
                    throw new PXRedirectRequiredException(apGraph, true, "")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
            }

            return(adapter.Get());
        }
Esempio n. 5
0
        public virtual CABatchDetail AddPayment(ARPayment aPayment, bool skipCheck)
        {
            if (!skipCheck)
            {
                foreach (CABatchDetail iDel in this.BatchPayments.Select())
                {
                    if (IsKeyEqual(aPayment, iDel))
                    {
                        return(iDel);
                    }
                }
            }
            CABatchDetail detail = new CABatchDetail();

            detail.Copy(aPayment);
            detail = this.BatchPayments.Insert(detail);
            return(detail);
        }
Esempio n. 6
0
        protected virtual void CABatchDetail_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            CABatchDetail row = (CABatchDetail)e.Row;

            if (!this._isMassDelete)
            {
                UpdateDocAmount(row, true);
            }
            #region Update APPayment.status
            var       cache   = this.Caches <APPayment>();
            APPayment payment = PXSelect <APPayment,
                                          Where <APPayment.docType, Equal <Required <APPayment.docType> >,
                                                 And <APPayment.refNbr, Equal <Required <APPayment.refNbr> > > > >
                                .Select(this, row.OrigDocType, row.OrigRefNbr);

            cache.SetValueExt <APPayment.printed>(payment, false);
            cache.SetValueExt <APPayment.hold>(payment, false);
            cache.SetValueExt <APPayment.extRefNbr>(payment, null);
            cache.MarkUpdated(payment);
            #endregion
        }
Esempio n. 7
0
 public static bool IsKeyEqual(AR.ARPayment payment, CABatchDetail detail)
 {
     return(detail.OrigModule == BatchModule.AR && payment.DocType == detail.OrigDocType && payment.RefNbr == detail.OrigRefNbr);
 }
Esempio n. 8
0
        protected virtual void CABatchDetail_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            CABatchDetail row = (CABatchDetail)e.Row;

            UpdateDocAmount(row, false);
        }
Esempio n. 9
0
 public static bool IsKeyEqual(AR.ARPayment op1, CABatchDetail op2)
 {
     return(op2.OrigModule == BatchModule.AR && op1.DocType == op2.OrigDocType && op1.RefNbr == op2.OrigRefNbr);
 }