diff --git a/app/assets/javascripts/fund_source.js.coffee b/app/assets/javascripts/fund_source.js.coffee index 6d57141831..74c1ef5655 100644 --- a/app/assets/javascripts/fund_source.js.coffee +++ b/app/assets/javascripts/fund_source.js.coffee @@ -5,7 +5,6 @@ Selectize.define 'option_destroy', -> (e) -> $target = $(e.target) if $target.hasClass('fa-trash-o') - console.log $target.parent() $.ajax url: "/fund_sources/#{encodeURIComponent($target.parent().data('fs-uid'))}" type: 'DELETE' diff --git a/app/controllers/concerns/deposits/ctrl_bankable.rb b/app/controllers/concerns/deposits/ctrl_bankable.rb index 857ad09f23..88e9c670ff 100644 --- a/app/controllers/concerns/deposits/ctrl_bankable.rb +++ b/app/controllers/concerns/deposits/ctrl_bankable.rb @@ -10,7 +10,7 @@ def new @deposit = model_kls.new member: current_user, account: @account, member: current_user @fund_sources = current_user.fund_sources.with_channel(@channel.id) @assets = model_kls.where(member: current_user).order('id desc').first(10) - gon.banks = ::Bank.fetch + gon.banks = model_kls.bank_hash end def create diff --git a/app/controllers/concerns/withdraws/ctrl_bankable.rb b/app/controllers/concerns/withdraws/ctrl_bankable.rb index a9b5528b4e..496aa8db85 100644 --- a/app/controllers/concerns/withdraws/ctrl_bankable.rb +++ b/app/controllers/concerns/withdraws/ctrl_bankable.rb @@ -13,7 +13,7 @@ def new @fund_sources = current_user.fund_sources.with_channel(channel.id) @assets = model_kls.without_aasm_state(:submitting).where(member: current_user).order('id desc').first(10) - gon.banks = ::Bank.fetch + gon.banks = model_kls.bank_hash end def create diff --git a/app/models/bank.rb b/app/models/bank.rb deleted file mode 100644 index f5b496463b..0000000000 --- a/app/models/bank.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Bank < ActiveYaml::Base - set_root_path "#{Rails.root}/config" - set_filename "banks" - - def self.fetch - all.reduce({}){|memo, bank| memo[bank.code] = bank.name; memo} - end -end diff --git a/app/models/concerns/deposits/bankable.rb b/app/models/concerns/deposits/bankable.rb index d0b67cb066..c44feaf3e8 100644 --- a/app/models/concerns/deposits/bankable.rb +++ b/app/models/concerns/deposits/bankable.rb @@ -9,8 +9,13 @@ module Bankable delegate :receive_fund_holder_text, :receive_fund_uid_text, :receive_fund_extra_text, to: :channel - enumerize :fund_extra, in: channel.banks, scope: true, \ - i18n_scope: ["deposit_channel.#{name.demodulize.underscore}.banks", 'banks'] + enumerize :fund_extra, in: channel.banks, scope: true, i18n_scope: 'banks' + end + + module ClassMethods + def bank_hash + enumerized_attributes['fund_extra'].options.inject({}) {|k, v| k[v[1]] = v[0]; k} + end end end end diff --git a/app/models/concerns/withdraws/bankable.rb b/app/models/concerns/withdraws/bankable.rb index 9871a571fd..eeb693f200 100644 --- a/app/models/concerns/withdraws/bankable.rb +++ b/app/models/concerns/withdraws/bankable.rb @@ -9,9 +9,13 @@ module Bankable alias_attribute :remark, :id - enumerize :fund_extra, in: channel.banks, scope: true, \ - i18n_scope: ["withdraw_channel.#{name.demodulize.underscore}.banks", 'banks'] + enumerize :fund_extra, in: channel.banks, scope: true, i18n_scope: 'banks' + end + module ClassMethods + def bank_hash + enumerized_attributes['fund_extra'].options.inject({}) {|k, v| k[v[1]] = v[0]; k} + end end end end diff --git a/config/banks.yml b/config/banks.yml deleted file mode 100644 index 6173e15992..0000000000 --- a/config/banks.yml +++ /dev/null @@ -1,45 +0,0 @@ -- id: 1 - code: icbc - name: 工商银行 -- id: 2 - code: cbc - name: 建设银行 -- id: 3 - code: bc - name: 中国银行 -- id: 4 - code: bcm - name: 交通银行 -- id: 5 - code: abc - name: 农业银行 -- id: 6 - code: cmb - name: 招商银行 -- id: 7 - code: cmbc - name: 民生银行 -- id: 8 - code: cncb - name: 中信银行 -- id: 9 - code: hxb - name: 华夏银行 -- id: 10 - code: cib - name: 兴业银行 -- id: 11 - code: spdb - name: 浦东发展银行 -- id: 12 - code: bob - name: 北京银行 -- id: 13 - code: ceb - name: 光大银行 -- id: 14 - code: sdb - name: 深圳发展银行 -- id: 15 - code: gdb - name: 广东发展银行 diff --git a/config/deposit_channels.yml b/config/deposit_channels.yml index 032655a4c1..6e183b24fa 100644 --- a/config/deposit_channels.yml +++ b/config/deposit_channels.yml @@ -8,4 +8,4 @@ key: bank currency: cny sort_order: 2 - banks: ["icbc", "cbc", "bc", "bcm", "abc", "cmb", "cmbc", "cncb", "hxb", "cib", "spdb", "bob", "cncb", "ceb", "sdb", "pab", "gdb"] + banks: ["icbc", "cbc", "bc", "bcm", "abc", "cmb", "cmbc", "cncb", "hxb", "cib", "spdb", "bob", "ceb", "sdb", "pab", "gdb"] diff --git a/config/locales/banks/en.yml b/config/locales/banks/en.yml new file mode 100644 index 0000000000..7c42b0dd71 --- /dev/null +++ b/config/locales/banks/en.yml @@ -0,0 +1,18 @@ +en: + banks: + icbc: Industryand Commercial Bank of China + cbc: Construction Bank of China + bc: Bank of China + bcm: Bank of Communications + abc: Agriculture Bank of China + cmb: China Merchants Bank Ltd + cmbc: China Minsheng Banking Co., Ltd + cncb: China CITIC Bank + hxb: Hua Xia Bank Co., Ltd. + cib: Industrial Bank Co., Ltd + spdb: Shanghai Pudong Development Bank + bob: Bank of Beijing + ceb: China Everbright Bank CO.LTD + sdb: Shenzhen Development Bank + pab: Ping An Bank Co., Ltd. + gdb: Guangdong Development Bank diff --git a/config/locales/banks/zh-CN.yml b/config/locales/banks/zh-CN.yml new file mode 100644 index 0000000000..979bd57445 --- /dev/null +++ b/config/locales/banks/zh-CN.yml @@ -0,0 +1,18 @@ +zh-CN: + banks: + icbc: 工商银行 + cbc: 建设银行 + bc: 中国银行 + bcm: 交通银行 + abc: 农业银行 + cmb: 招商银行 + cmbc: 民生银行 + cncb: 中信银行 + hxb: 华夏银行 + cib: 兴业银行 + spdb: 浦东发展银行 + bob: 北京银行 + ceb: 光大银行 + sdb: 深圳发展银行 + pab: 平安银行 + gdb: 广东发展银行 diff --git a/config/locales/en.yml b/config/locales/en.yml index 4d984117dd..dff5c16df4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -132,8 +132,3 @@ en: 'yes': 'Yes' 'no': 'No' - banks: - bc: Bank of China - abc: Agriculture Bank of China - cbc: Construction Bank of China - icbc: Industryand Commercial Bank of China diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 63bbe14675..2eb08ad966 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -144,21 +144,3 @@ zh-CN: 'yes': 是 'no': 否 - banks: - cmbc: 招商银行 - bc: 中国银行 - icbc: 工商银行 - cbc: 建设银行 - abc: 农业银行 - cmb: 招商银行 - cmbc: 民生银行 - bcm: 交通银行 - cncb: 中信银行 - hxb: 华夏银行 - cib: 兴业银行 - spdb: 浦东发展银行 - bob: 北京银行 - ceb: 光大银行 - sdb: 深圳发展银行 - gdb: 广东发展银行 - pab: 平安银行 diff --git a/config/withdraw_channels.yml b/config/withdraw_channels.yml index 4e844d38f2..8f6e5574ea 100644 --- a/config/withdraw_channels.yml +++ b/config/withdraw_channels.yml @@ -15,5 +15,5 @@ fee: 0.003 proportion: true inuse: true - banks: ["icbc", "cbc", "bc", "bcm", "abc", "cmb", "cmbc", "cncb", "hxb", "cib", "spdb", "bob", "cncb", "ceb", "sdb", "pab", "gdb"] + banks: ["icbc", "cbc", "bc", "bcm", "abc", "cmb", "cmbc", "cncb", "hxb", "cib", "spdb", "bob", "ceb", "sdb", "pab", "gdb"] type: WithdrawChannelBank