Ejemplo n.º 1
0
        protected virtual void ProcessPaymentFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            bool SuggestNextNumber   = false;
            ProcessPaymentFilter row = (ProcessPaymentFilter)e.Row;

            PXUIFieldAttribute.SetVisible <ProcessPaymentFilter.curyID>(sender, null, PXAccess.FeatureInstalled <FeaturesSet.multicurrency>());

            if (e.Row != null && cashaccountdetail.Current != null && (!Equals(cashaccountdetail.Current.CashAccountID, row.PayAccountID) || !Equals(cashaccountdetail.Current.PaymentMethodID, row.PayTypeID)))
            {
                cashaccountdetail.Current = null;
                SuggestNextNumber         = true;
            }

            if (e.Row != null && paymenttype.Current != null && (!Equals(paymenttype.Current.PaymentMethodID, row.PayTypeID)))
            {
                paymenttype.Current = null;
            }

            if (e.Row != null && string.IsNullOrEmpty(row.NextCheckNbr))
            {
                SuggestNextNumber = true;
            }

            PXUIFieldAttribute.SetVisible <ProcessPaymentFilter.nextCheckNbr>(sender, null, true);

            if (e.Row == null)
            {
                return;
            }

            if (cashaccountdetail.Current != null && true == cashaccountdetail.Current.ARAutoNextNbr && SuggestNextNumber)
            {
                row.NextCheckNbr = string.IsNullOrEmpty(cashaccountdetail.Current.ARLastRefNbr) == false?AutoNumberAttribute.NextNumber(cashaccountdetail.Current.ARLastRefNbr) : string.Empty;
            }

            sender.RaiseExceptionHandling <ProcessPaymentFilter.payTypeID>(e.Row, row.PayTypeID,
                                                                           paymenttype.Current != null && true != PXCache <PaymentMethod> .GetExtension <PaymentMethodExt>(paymenttype.Current).ARCreateBatchPayment
                ? new PXSetPropertyException(AP.Messages.PaymentTypeNoPrintCheck, PXErrorLevel.Warning)
                : null);

            sender.RaiseExceptionHandling <ProcessPaymentFilter.nextCheckNbr>(e.Row, row.NextCheckNbr,
                                                                              paymenttype.Current != null && paymenttype.Current.PrintOrExport == true && String.IsNullOrEmpty(row.NextCheckNbr)
                ? new PXSetPropertyException(AP.Messages.NextCheckNumberIsRequiredForProcessing, PXErrorLevel.Warning)
                : !string.IsNullOrEmpty(row.NextCheckNbr) && !AutoNumberAttribute.CanNextNumber(row.NextCheckNbr)
                    ? new PXSetPropertyException(AP.Messages.NextCheckNumberCanNotBeInc, PXErrorLevel.Warning)
                    : null);

            if (/*HttpContext.Current != null && */ Filter.Current.BranchID != PXAccess.GetBranchID())
            {
                Filter.Current.BranchID = PXAccess.GetBranchID();
            }

            ProcessPaymentFilter filter = Filter.Current;
            PaymentMethod        pt     = paymenttype.Current;

            ARPaymentList.SetProcessTooltip(Messages.Process);
            ARPaymentList.SetProcessAllTooltip(Messages.ProcessAll);
            ARPaymentList.SetProcessDelegate(
                delegate(List <ARPayment> list)
            {
                var graph = CreateInstance <ARProcessPayment>();
                graph.ProcessPayments(list, filter, pt);
            }
                );
        }
Ejemplo n.º 2
0
        protected virtual void PrintChecksFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            bool SuggestNextNumber   = false;
            PrintChecksFilter filter = (PrintChecksFilter)e.Row;

            PXUIFieldAttribute.SetVisible <PrintChecksFilter.curyID>(sender, null, PXAccess.FeatureInstalled <FeaturesSet.multicurrency>());

            if (e.Row != null &&
                cashaccountdetail.Current != null &&
                (!Equals(cashaccountdetail.Current.CashAccountID, filter.PayAccountID) ||
                 !Equals(cashaccountdetail.Current.PaymentMethodID, filter.PayTypeID)))
            {
                cashaccountdetail.Current = null;
                SuggestNextNumber         = true;
            }

            if (e.Row != null && paymenttype.Current != null && (!Equals(paymenttype.Current.PaymentMethodID, filter.PayTypeID)))
            {
                paymenttype.Current = null;
            }

            if (e.Row != null && string.IsNullOrEmpty(filter.NextCheckNbr))
            {
                SuggestNextNumber = true;
            }

            PXUIFieldAttribute.SetVisible <PrintChecksFilter.nextCheckNbr>(sender, null, true);

            if (e.Row == null)
            {
                return;
            }

            if (cashaccountdetail.Current != null && true == cashaccountdetail.Current.APAutoNextNbr && SuggestNextNumber)
            {
                filter.NextCheckNbr = PaymentRefAttribute.GetNextPaymentRef(
                    sender.Graph,
                    cashaccountdetail.Current.CashAccountID,
                    cashaccountdetail.Current.PaymentMethodID);
            }

            bool printOrExport = paymenttype.Current == null || paymenttype.Current.PrintOrExport == true;

            bool isNextNumberDuplicated = false;

            if (paymenttype.Current != null && paymenttype.Current.PrintOrExport == true && string.IsNullOrEmpty(filter.NextCheckNbr))
            {
                sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, filter.NextCheckNbr,
                                                                               new PXSetPropertyException(Messages.NextCheckNumberIsRequiredForProcessing, PXErrorLevel.Warning));
            }
            else if (!string.IsNullOrEmpty(filter.NextCheckNbr) && !AutoNumberAttribute.CanNextNumber(filter.NextCheckNbr))
            {
                sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, filter.NextCheckNbr,
                                                                               new PXSetPropertyException(Messages.NextCheckNumberCanNotBeInc, PXErrorLevel.Warning));
            }
            else if (paymenttype.Current != null && paymenttype.Current.APPrintChecks == true &&
                     (isNextNumberDuplicated = filter.IsNextNumberDuplicated(sender.Graph, filter.NextCheckNbr)))
            {
                sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, filter.NextCheckNbr,
                                                                               new PXSetPropertyException(Messages.ConflictWithExistingCheckNumber, filter.NextCheckNbr));
            }
            else
            {
                sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, filter.NextCheckNbr, null);
            }

            APPaymentList.SetProcessEnabled(!isNextNumberDuplicated && printOrExport && filter.PayTypeID != null);
            APPaymentList.SetProcessAllEnabled(!isNextNumberDuplicated && printOrExport && filter.PayTypeID != null);

            if (HttpContext.Current != null && Filter.Current.BranchID != PXAccess.GetBranchID())
            {
                Filter.Current.BranchID = PXAccess.GetBranchID();
            }

            PaymentMethod pt = paymenttype.Current;

            APPaymentList.SetProcessDelegate(
                delegate(List <APPayment> list)
            {
                APPrintChecks graph = CreateInstance <APPrintChecks>();
                graph.PrintPayments(list, filter, pt);
            }
                );
        }
Ejemplo n.º 3
0
        protected virtual void PrintChecksFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            bool SuggestNextNumber = false;
            PrintChecksFilter row  = (PrintChecksFilter)e.Row;

            PXUIFieldAttribute.SetVisible <PrintChecksFilter.curyID>(sender, null, (bool)CMSetup.Current.MCActivated);

            if (e.Row != null && cashaccountdetail.Current != null && (object.Equals(cashaccountdetail.Current.CashAccountID, row.PayAccountID) == false || object.Equals(cashaccountdetail.Current.PaymentMethodID, row.PayTypeID) == false))
            {
                cashaccountdetail.Current = null;
                SuggestNextNumber         = true;
            }

            if (e.Row != null && paymenttype.Current != null && (object.Equals(paymenttype.Current.PaymentMethodID, row.PayTypeID) == false))
            {
                paymenttype.Current = null;
            }

            if (e.Row != null && string.IsNullOrEmpty(row.NextCheckNbr))
            {
                SuggestNextNumber = true;
            }

            PXUIFieldAttribute.SetVisible <PrintChecksFilter.nextCheckNbr>(sender, null, true);

            if (e.Row == null)
            {
                return;
            }

            if (cashaccountdetail.Current != null && (bool)cashaccountdetail.Current.APAutoNextNbr == true)
            {
                //PXUIFieldAttribute.SetVisible<PrintChecksFilter.nextCheckNbr>(sender, null, true);
                if (SuggestNextNumber)
                {
                    if (string.IsNullOrEmpty(cashaccountdetail.Current.APLastRefNbr) == false)
                    {
                        row.NextCheckNbr = AutoNumberAttribute.NextNumber(cashaccountdetail.Current.APLastRefNbr);
                    }
                    else
                    {
                        row.NextCheckNbr = string.Empty;
                    }
                }
            }
            else
            {
                //PXUIFieldAttribute.SetVisible<PrintChecksFilter.nextCheckNbr>(sender, null, false);
                //row.NextCheckNbr = null;
            }

            if (paymenttype.Current != null && ((bool)paymenttype.Current.APPrintChecks == false && (bool)paymenttype.Current.APCreateBatchPayment == false))
            {
                sender.RaiseExceptionHandling <PrintChecksFilter.payTypeID>(e.Row, row.PayTypeID, new PXSetPropertyException(Messages.PaymentTypeNoPrintCheck, PXErrorLevel.Warning));
            }
            else
            {
                sender.RaiseExceptionHandling <PrintChecksFilter.payTypeID>(e.Row, row.PayTypeID, null);
            }

            if (paymenttype.Current != null && paymenttype.Current.PrintOrExport == true && String.IsNullOrEmpty(row.NextCheckNbr))
            {
                sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, row.NextCheckNbr, new PXSetPropertyException(Messages.NextCheckNumberIsRequiredForProcessing, PXErrorLevel.Warning));
            }
            else
            {
                if (!String.IsNullOrEmpty(row.NextCheckNbr) && !AutoNumberAttribute.CanNextNumber(row.NextCheckNbr))
                {
                    sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, row.NextCheckNbr, new PXSetPropertyException(Messages.NextCheckNumberCanNotBeInc, PXErrorLevel.Warning));
                }
                else
                {
                    sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, row.NextCheckNbr, null);
                }
            }


            PrintChecksFilter filter = Filter.Current;
            PaymentMethod     pt     = paymenttype.Current;

            APPaymentList.SetProcessTooltip(Messages.ProcessSelectedRecordsTooltip);
            APPaymentList.SetProcessAllTooltip(Messages.ProcessAllRecordsTooltip);
            APPaymentList.SetProcessDelegate(
                delegate(List <APPayment> list)
            {
                var graph = PXGraph.CreateInstance <APPrintChecks>();
                graph.PrintPayments(list, filter, pt);
                //CreateBatchPayment(list, filter);
            }
                );
        }