app/models/perfect_money_merchant/account.rb
# Obtain the most suitable deposit account from database
# @param [String] currency currency like 'usd' or 'eur'
# @return [String] PerfectMoney account code number
Obtain the most suitable deposit account from database
Obtain the most suitable deposit account from database
def obtain_deposit_account(currency)
				currency = currency.to_s.downcase
				unit = Account::Unit.
					joins(:account).
					where.not(perfect_money_merchant_accounts: { secret_key: nil }).
					where(currency: currency).
					order('balance ASC').take(1).first
				if unit
					unit.code_number
				else
					raise BasicError.new('no unit was found').tap do |exception|
						exception.add_error(:unit, :not_found)
					end
				end
			end
def obtain_deposit_account ( currency ) currency = currency . to_s . downcase unit = Account :: Unit . joins ( :account ) . where . not ( perfect_money_merchant_accounts : { secret_key : nil } ) . where ( currency : currency ) . order ( 'balance ASC' ) . take ( 1 ) . first if unit unit . code_number else raise BasicError . new ( 'no unit was found' ) . tap do | exception | exception . add_error ( :unit , :not_found ) end end end
Obtain the most suitable deposit account from database
Obtain the most suitable deposit account from database
PerfectMoney account code number
PerfectMoney account code number
String
currency
currency currency like 'usd' or 'eur'
currency currency like ' usd ' or ' eur '