Exemplo n.º 1
0
 /**
  * 	Before Save
  *	@param newRecord new
  *	@return true if valid
  */
 protected override Boolean BeforeSave(Boolean newRecord)
 {
     MBank bank = GetBank();
     BankVerificationInterface verify = bank.GetVerificationClass();
     if (verify != null)
     {
         String errorMsg = verify.VerifyAccountNo(bank, GetAccountNo());
         if (errorMsg != null)
         {
             //log.saveError("Error", "@Invalid@ @AccountNo@ " + errorMsg);
             return false;
         }
         errorMsg = verify.VerifyBBAN(bank, GetBBAN());
         if (errorMsg != null)
         {
             //log.saveError("Error", "@Invalid@ @BBAN@ " + errorMsg);
             return false;
         }
         errorMsg = verify.VerifyIBAN(bank, GetIBAN());
         if (errorMsg != null)
         {
             //log.saveError("Error", "@Invalid@ @IBAN@ " + errorMsg);
             return false;
         }
     }
     return true;
 }
Exemplo n.º 2
0
        /**
         *  get Bank by RoutingNo
         *	@param ctx
         *	@param routingNo
         *	@return Array of banks with this RoutingNo
         */
        public static MBank[] GetByRoutingNo(Ctx ctx, String routingNo)
        {
            String       sql  = "SELECT * FROM C_Bank WHERE RoutingNo LIKE '" + routingNo + "' AND IsActive='Y'";
            List <MBank> list = new List <MBank>();
            DataTable    dt   = null;
            IDataReader  idr  = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, null);
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(new MBank(ctx, dr, null));
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            finally {
                dt = null;
            }

            MBank[] retValue = new MBank[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
        /**
         *  Get Routing No
         *	@return routing No
         */
        public new String GetRoutingNo()
        {
            MBank  bank = GetBank();
            String rt   = base.GetRoutingNo();

            if (bank != null)
            {
                rt = bank.GetRoutingNo();
            }
            return(rt);
        }
        /**
         *  Get Bank
         *	@return bank
         */
        public MBank GetBank()
        {
            int C_Bank_ID = GetC_Bank_ID();

            if (C_Bank_ID == 0)
            {
                return(null);
            }
            if (_bank == null)
            {
                _bank = new MBank(GetCtx(), C_Bank_ID, Get_TrxName());
            }
            return(_bank);
        }
Exemplo n.º 5
0
        /*	Get MBank from Cache
         *	@param ctx context
         *	@param C_Bank_ID id
         *	@return MBank
         */
        public static MBank Get(Ctx ctx, int C_Bank_ID)
        {
            int   key      = C_Bank_ID;
            MBank retValue = (MBank)_cache[key];

            if (retValue != null)
            {
                return(retValue);
            }
            retValue = new MBank(ctx, C_Bank_ID, null);
            if (retValue.Get_ID() != 0)
            {
                _cache.Add(key, retValue);
            }
            return(retValue);
        }
        /**
         *  Before Save
         *	@param newRecord new
         *	@return true
         */
        protected override bool BeforeSave(bool newRecord)
        {
            //	maintain routing on bank level
            if (IsACH() && GetBank() != null)
            {
                SetRoutingNo(null);
            }
            //	Verify Bank
            MBank bank = GetBank();

            if (bank != null)
            {
                BankVerificationInterface verify = bank.GetVerificationClass();
                if (verify != null)
                {
                    String errorMsg = verify.VerifyRoutingNo(bank.GetC_Country_ID(), GetRoutingNo());
                    if (errorMsg != null)
                    {
                        log.SaveError("Error", "@Invalid@ @RoutingNo@ " + errorMsg);
                        return(false);
                    }
                    //
                    errorMsg = verify.VerifyAccountNo(bank, GetAccountNo());
                    if (errorMsg != null)
                    {
                        log.SaveError("Error", "@Invalid@ @AccountNo@ " + errorMsg);
                        return(false);
                    }
                    errorMsg = verify.VerifyBBAN(bank, GetBBAN());
                    if (errorMsg != null)
                    {
                        log.SaveError("Error", "@Invalid@ @BBAN@ " + errorMsg);
                        return(false);
                    }
                    errorMsg = verify.VerifyIBAN(bank, GetIBAN());
                    if (errorMsg != null)
                    {
                        log.SaveError("Error", "@Invalid@ @IBAN@ " + errorMsg);
                        return(false);
                    }
                }
            }
            return(true);
        }
 /**
  *  Get Bank
  *	@return bank parent
  */
 public MBank GetBank()
 {
     return(MBank.Get(GetCtx(), GetC_Bank_ID()));
 }
        /**
         *  Before Save
         *	@param newRecord new
         *	@return true if valid
         */
        protected override Boolean BeforeSave(Boolean newRecord)
        {
            MBank bank = GetBank();
            BankVerificationInterface verify = bank.GetVerificationClass();

            if (verify != null)
            {
                String errorMsg = verify.VerifyAccountNo(bank, GetAccountNo());
                if (errorMsg != null)
                {
                    //log.saveError("Error", "@Invalid@ @AccountNo@ " + errorMsg);
                    return(false);
                }
                errorMsg = verify.VerifyBBAN(bank, GetBBAN());
                if (errorMsg != null)
                {
                    //log.saveError("Error", "@Invalid@ @BBAN@ " + errorMsg);
                    return(false);
                }
                errorMsg = verify.VerifyIBAN(bank, GetIBAN());
                if (errorMsg != null)
                {
                    //log.saveError("Error", "@Invalid@ @IBAN@ " + errorMsg);
                    return(false);
                }
            }

            //Issue ID- SI_0613 in Google Sheet Standard Issues.. On Bank account currency should not allow to change if any transcation made against bank.
            if (!newRecord && Is_ValueChanged("C_Currency_ID"))
            {
                string sql = "SELECT SUM(total) AS TOTAL FROM (SELECT COUNT(*) AS TOTAL FROM C_PAYMENT WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID()
                             + " UNION ALL SELECT COUNT(*) AS TOTAL FROM C_ELEMENTVALUE WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID()
                             + " UNION ALL  SELECT COUNT(*) AS TOTAL FROM C_BP_BANKACCOUNT WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID()
                             + " UNION ALL  SELECT COUNT(*) AS TOTAL  FROM C_BANKACCOUNT_ACCT  WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID()
                             + " UNION ALL  SELECT COUNT(*) AS TOTAL FROM C_BANKSTATEMENT WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID()
                             + " UNION ALL  SELECT COUNT(*) AS TOTAL  FROM C_PAYMENTPROCESSOR  WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID()
                             + " UNION ALL  SELECT COUNT(*) AS TOTAL  FROM C_CASHLINE WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID()
                             + " UNION ALL  SELECT COUNT(*) AS TOTAL FROM C_PAYSELECTION WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID()
                             + " UNION ALL  SELECT COUNT(*) AS TOTAL FROM C_BANKACCOUNTDOC WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID()
                             + " UNION ALL  SELECT COUNT(*) AS Total FROM C_BankAccountLine WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID();

                if (Env.IsModuleInstalled("VA026_")) // if Letter Of Credit Module is Installed..
                {
                    sql += " UNION ALL SELECT count(*) as Total FROM VA026_LCDETAIL WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID();
                }
                if (Env.IsModuleInstalled("VA027_")) // If Post dated Check Module is Installed..
                {
                    sql += " UNION ALL SELECT count(*) as total FROM VA027_POSTDATEDCHECK WHERE AD_Client_ID= " + GetAD_Client_ID() + " AND C_BANKACCOUNT_ID =" + GetC_BankAccount_ID();
                }

                sql += ")";

                if (Util.GetValueOfInt(DB.ExecuteScalar(sql)) > 0)
                {
                    log.SaveError("Error", Msg.GetMsg(GetCtx(), "CouldNotChnageCurrency"));
                    return(false);
                }

                // JID_1583: system will update the Opening balance value in Current Balance field
                if (newRecord && Get_ColumnIndex("OpenBalance") > 0)
                {
                    SetCurrentBalance(Util.GetValueOfDecimal(Get_Value("OpenBalance")));
                }
            }
            //End

            // JID_1583: system will update the Opening balance value in Current Balance field
            if (newRecord && Get_ColumnIndex("OpenBalance") > 0)
            {
                SetCurrentBalance(Util.GetValueOfDecimal(Get_Value("OpenBalance")));
            }
            return(true);
        }