Пример #1
0
        public static CABatch CreateBatchPayment(List <ARPayment> list, ProcessPaymentFilter filter)
        {
            CABatch result = new CABatch();

            //var resultExt = PXCache<CABatch>.GetExtension<CABatchExt>(result);
            //resultExt.BatchModule = GL.BatchModule.AR;

            ARBatchEntry be = PXGraph.CreateInstance <ARBatchEntry>();

            result = be.Document.Insert(result);
            be.Document.Current = result;
            CABatch copy = (CABatch)be.Document.Cache.CreateCopy(result);

            copy.CashAccountID   = filter.PayAccountID;
            copy.PaymentMethodID = filter.PayTypeID;
            be.Document.SetValueExt <CABatchExt.batchModule>(copy, GL.BatchModule.AR);
            result = be.Document.Update(copy);
            foreach (ARPayment iPmt in list)
            {
                if (iPmt.CashAccountID != result.CashAccountID || iPmt.PaymentMethodID != iPmt.PaymentMethodID)
                {
                    throw new PXException(AP.Messages.APPaymentDoesNotMatchCABatchByAccountOrPaymentType);
                }
                if (String.IsNullOrEmpty(iPmt.ExtRefNbr) && string.IsNullOrEmpty(filter.NextCheckNbr))
                {
                    throw new PXException(Messages.NextCheckNumberIsRequiredForProcessing);
                }
                CABatchDetail detail = be.AddPayment(iPmt);
            }
            be.Save.Press();
            result = be.Document.Current;
            return(result);
        }
Пример #2
0
        protected virtual void RedirectToResultWithCreateBatch(CABatch batch)
        {
            ARBatchEntry be = PXGraph.CreateInstance <ARBatchEntry>();

            be.Document.Current = be.Document.Search <CABatch.batchNbr>(batch.BatchNbr);
            be.TimeStamp        = be.Document.Current.tstamp;
            throw new PXRedirectRequiredException(be, "Redirect");
        }