示例#1
0
        protected virtual void ProcessPayments(List <ARPayment> list, ProcessPaymentFilter filter, PaymentMethod paymenttype)
        {
            if (list.Count == 0)
            {
                return;
            }

            CABatch batch = CreateBatchPayment(list, filter);

            if (batch != null)
            {
                bool failed          = false;
                ARPaymentEntryExt pe = PXGraph.CreateInstance <ARPaymentEntryExt>();

                string NextCheckNbr = filter.NextCheckNbr;
                for (int i = 0; i < list.Count; i++)
                {
                    try
                    {
                        AssignNumbers(pe, list[i], ref NextCheckNbr);
                        var docExt = PXCache <ARPayment> .GetExtension <ARPaymentExt>(list[i]);

                        if (docExt.Passed == true)
                        {
                            pe.TimeStamp = list[i].tstamp;
                        }
                        pe.Save.Press();
                        list[i].tstamp = pe.TimeStamp;
                        pe.Clear();
                    }
                    catch (Exception e)
                    {
                        PXProcessing <ARPayment> .SetError(i, e);

                        failed = true;
                    }
                }
                if (failed)
                {
                    throw new PXOperationCompletedWithErrorException(Messages.ARPaymentsAreAddedToTheBatchButWasNotUpdatedCorrectly, batch.BatchNbr);
                }
                RedirectToResultWithCreateBatch(batch);
            }
        }
示例#2
0
        public virtual void AssignNumbers(ARPaymentEntryExt pe, ARPayment doc, ref string NextCheckNbr)
        {
            pe.RowPersisting.RemoveHandler <ARAdjust>(pe.ARAdjust_RowPersisting);
            pe.Clear(PXClearOption.PreserveTimeStamp);
            doc = pe.Document.Current = pe.Document.Search <ARPayment.refNbr>(doc.RefNbr, doc.DocType);
            PaymentMethodAccount det = pe.cashaccountdetail.Select();

            var payExt = PXCache <ARPayment> .GetExtension <ARPaymentExt>(pe.Document.Current);

            if (!string.IsNullOrEmpty(NextCheckNbr))
            {
                if (String.IsNullOrEmpty(pe.Document.Current.ExtRefNbr))
                {
                    payExt.StubCntr = 1;
                    payExt.BillCntr = 0;
                    pe.Document.Current.ExtRefNbr = NextCheckNbr;
                    if (String.IsNullOrEmpty(NextCheckNbr))
                    {
                        throw new PXException(AP.Messages.NextCheckNumberIsRequiredForProcessing);
                    }

                    pe.cashaccountdetail.Update(det); // det.APLastRefNumber was modified in StoreStubNumber method

                    NextCheckNbr                         = AutoNumberAttribute.NextNumber(NextCheckNbr);
                    payExt.Printed                       = true;
                    pe.Document.Current.Hold             = false;
                    pe.Document.Current.UpdateNextNumber = true;
                    pe.Document.Update(pe.Document.Current);
                }
                else
                {
                    if (payExt.Printed != true || pe.Document.Current.Hold != false)
                    {
                        payExt.Printed           = true;
                        pe.Document.Current.Hold = false;
                        pe.Document.Update(pe.Document.Current);
                    }
                }
            }
        }