Example #1
0
        /// <summary>
        /// Perrform Process.
        /// </summary>
        /// <returns>Message</returns>
        protected override String DoIt()
        {
            log.Info("Record_ID=" + GetRecord_ID());
            //	get Payment
            MPayment pp = new MPayment(GetCtx(), GetRecord_ID(), Get_TrxName());
            //	Validate Number
            String msg = MPaymentValidate.ValidateCreditCardNumber(pp.GetCreditCardNumber(), pp.GetCreditCardType());

            if (msg != null && msg.Length > 0)
            {
                throw new ArgumentException(Msg.GetMsg(GetCtx(), msg));
            }
            msg = MPaymentValidate.ValidateCreditCardExp(pp.GetCreditCardExpMM(), pp.GetCreditCardExpYY());
            if (msg != null && msg.Length > 0)
            {
                throw new ArgumentException(Msg.GetMsg(GetCtx(), msg));
            }
            if (pp.GetCreditCardVV().Length > 0)
            {
                msg = MPaymentValidate.ValidateCreditCardVV(pp.GetCreditCardVV(), pp.GetCreditCardType());
                if (msg != null && msg.Length > 0)
                {
                    throw new ArgumentException(Msg.GetMsg(GetCtx(), msg));
                }
            }

            //  Process it
            bool ok = pp.ProcessOnline();

            pp.Save();
            if (!ok)
            {
                throw new Exception(pp.GetErrorMessage());
            }
            return("OK");
        }
Example #2
0
        /// <summary>
        /// Check Mandatory
        /// </summary>
        /// <returns>true if all mandatory items are OK</returns>
        private bool CheckMandatory(PaymentInputValues inputs)
        {
            if (details == null)
            {
                details = new TabDetails();
            }
            bool          dataOK = true;
            StringBuilder msg    = new StringBuilder();

            try
            {
                //	log.config( "VPayment.checkMandatory");

                String PaymentRule = inputs.cmbPayment;
                if (PaymentRule == null)
                {
                    return(false);
                }
                //  only Payment Rule
                if (inputs.OnlyRule)
                {
                    return(true);
                }

                DateTime?DateAcct         = inputs._DateAcct;
                int      C_PaymentTerm_ID = inputs._C_PaymentTerm_ID;
                int      C_CashBook_ID    = inputs._C_CashBook_ID;
                String   CCType           = inputs.CCType;
                //
                int C_BankAccount_ID = 0;

                /***********************
                 *	Mandatory Data Check
                 */

                //	B (Cash)		(Currency)
                if (PaymentRule.Equals(MOrder.PAYMENTRULE_Cash))
                {
                    C_CashBook_ID = inputs.cmbBCashBook;
                    DateAcct      = Convert.ToDateTime(inputs.bDateField);
                }

                //	K (CreditCard)  Type, Number, Exp, Approval
                else if (PaymentRule.Equals(MOrder.PAYMENTRULE_CreditCard))
                {
                    CCType = inputs.cmbKType;
                    //
                    String error = MPaymentValidate.ValidateCreditCardNumber(inputs.txtKNumber, CCType);
                    if (error.Length != 0)
                    {
                        //txtKNumber.Background = new SolidColorBrush(GlobalVariable.MANDATORY_TEXT_BACK_COLOR);
                        if (error.IndexOf("?") == -1)
                        {
                            msg.Append(Msg.GetMsg(ctx, error) + Environment.NewLine);
                            //  ShowMessage.Error("", true, Msg.GetMsg(Envs.GetContext(), error, true).ToString());
                            dataOK = false;
                        }
                        else    //  warning
                        {
                            //if (!ShowMessage.Ask("", true, error))
                            //{
                            dataOK = false;
                            //}
                        }
                    }
                    error = MPaymentValidate.ValidateCreditCardExp(inputs.txtKExp);
                    if (error.Length != 0)
                    {
                        //txtKExp.Background = new SolidColorBrush(GlobalVariable.MANDATORY_TEXT_BACK_COLOR);
                        msg.Append(Msg.GetMsg(ctx, error) + Environment.NewLine);
                        //ShowMessage.Error("", true, Msg.GetMsg(Envs.GetContext(), error, true).ToString());
                        dataOK = false;
                    }
                }

                //	T (Transfer)	BPartner_Bank
                else if (PaymentRule.Equals(X_C_Order.PAYMENTRULE_DirectDeposit) ||
                         PaymentRule.Equals(X_C_Order.PAYMENTRULE_DirectDebit))
                {
                    string bpba = inputs.cmbTAccount;
                    if (bpba == null || bpba == "")
                    {
                        msg.Append(Msg.GetMsg(ctx, "PaymentBPBankNotFound") + Environment.NewLine);
                        //   details.ErrorMsg = Msg.GetMsg(ctx, "PaymentBPBankNotFound");
                        //cmbTAccount.Background = new SolidColorBrush(GlobalVariable.MANDATORY_TEXT_BACK_COLOR);
                        //ShowMessage.Error("", true, Msg.GetMsg(Envs.GetContext(), "PaymentBPBankNotFound", true).ToString());
                        dataOK = false;
                    }
                }       //	Direct

                //	P (PaymentTerm)	PaymentTerm
                else if (PaymentRule.Equals(X_C_Order.PAYMENTRULE_OnCredit))
                {
                    C_PaymentTerm_ID = inputs.cmbPTerm;
                }

                //	S (Check)		(Currency) CheckNo, Routing
                else if (PaymentRule.Equals(MOrder.PAYMENTRULE_Check))
                {
                    //	cmbSCurrency.SelectedItem;
                    C_BankAccount_ID = inputs.cmbSBankAccount;

                    String error = MPaymentValidate.ValidateRoutingNo(inputs.txtSRouting);
                    if (error.Length != 0)
                    {
                        msg.Append(Msg.GetMsg(ctx, error) + Environment.NewLine);
                        //    txtSRouting.Background = new SolidColorBrush(GlobalVariable.MANDATORY_TEXT_BACK_COLOR);
                        //   ShowMessage.Error("", true, Msg.GetMsg(Envs.GetContext(), error, true).ToString());
                        dataOK = false;
                    }
                    error = MPaymentValidate.ValidateAccountNo(inputs.txtSNumber);
                    if (error.Length != 0)
                    {
                        msg.Append(Msg.GetMsg(ctx, error) + Environment.NewLine);
                        // txtSNumber.Background = new SolidColorBrush(GlobalVariable.MANDATORY_TEXT_BACK_COLOR);
                        // ShowMessage.Error("", true, Msg.GetMsg(Envs.GetContext(), error, true).ToString());
                        dataOK = false;
                    }
                    error = MPaymentValidate.ValidateCheckNo(inputs.txtSCheck);
                    if (error.Length != 0)
                    {
                        msg.Append(Msg.GetMsg(ctx, error) + Environment.NewLine);
                        // txtSCheck.Background = new SolidColorBrush(GlobalVariable.MANDATORY_TEXT_BACK_COLOR);
                        // ShowMessage.Error("", true, Msg.GetMsg(Envs.GetContext(), error, true).ToString());
                        dataOK = false;
                    }
                }
                else
                {
                    //log.Log(Level.SEVERE, "Unknown PaymentRule " + PaymentRule);
                    return(false);
                }

                //  find Bank Account if not qualified yet
                if ("KTSD".IndexOf(PaymentRule) != -1 && C_BankAccount_ID == 0)
                {
                    String tender = MPayment.TENDERTYPE_CreditCard;
                    if (PaymentRule.Equals(MOrder.PAYMENTRULE_DirectDeposit))
                    {
                        tender = MPayment.TENDERTYPE_DirectDeposit;
                    }
                    else if (PaymentRule.Equals(MOrder.PAYMENTRULE_DirectDebit))
                    {
                        tender = MPayment.TENDERTYPE_DirectDebit;
                    }
                    else if (PaymentRule.Equals(MOrder.PAYMENTRULE_Check))
                    {
                        tender = MPayment.TENDERTYPE_Check;
                    }
                    //	Check must have a bank account
                    if (C_BankAccount_ID == 0 && "S".Equals(PaymentRule))
                    {
                        msg.Append(Msg.GetMsg(ctx, "PaymentNoProcessor") + Environment.NewLine);
                        //  ShowMessage.Error("", true, Msg.GetMsg(Envs.GetContext(), "PaymentNoProcessor", true).ToString());
                        dataOK = false;
                    }
                }
            }
            catch (Exception ex)
            {
                msg.Append(Msg.GetMsg(ctx, ex.Message) + Environment.NewLine);
                //    log.Severe(ex.ToString());
            }
            //log.Config("OK=" + dataOK);
            details.ErrorMsg = msg.ToString();
            return(dataOK);
        }