rus_bank_rails 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f0fd1525cf299bd331f78a985466913d84451b6
4
- data.tar.gz: 722d5094392a14b1590ecafc295a60245f9afc22
3
+ metadata.gz: 905819ccb5dc8efc82c04dd40e39edcd8201bd5c
4
+ data.tar.gz: 9ed1cb53c589d217d9c45c1abd01c7946dbe2a62
5
5
  SHA512:
6
- metadata.gz: c67868106f6c36f1f10fbd2bace1f9c58da47934eb5801cc10a1594529f7e3f884856fdce9772ee5305f6d6731daeb6d44523979305d8d55439d179418c0c928
7
- data.tar.gz: dc57861a5d8c0928348fe4ba4d86d6815413c28e882f377edf8c57606f825d4fdd84534ed053776f933be84f826977d0299fa96ee7b45d9b22a86c4220fe3d12
6
+ metadata.gz: d036922420a2af1af99405c128b315305e969f3b753aa31ad2c013faae1f417adc01de4fef31e932d0a75719bc22742c62cf1c1fc246a1075c347f07fa5749bc
7
+ data.tar.gz: f86302b91ba26265de63cc1e1012da7814a89255208783ca557a091f220923c691585ce77b352ec396f4af15545d32f26d7bf047229a1ffffc6680c8692c67df
data/README.md CHANGED
@@ -29,19 +29,22 @@ Rails-обертка вокруг гема rus_bank - https://github.com/wildDAl
29
29
 
30
30
  $ rake db:migrate
31
31
 
32
- На этом все. Далее можно кастомизировать модель по своему усмотрению. Например, в модели можно переопределить поведение тех или иных методов гема. Например, логика определения, требуется ли возвращать банк из базы или тянуть из API ЦБ, построена на том факте, что справочник БИК вступает в действие в 0:00 по московскому времени на всей территории страны. Т.е. если дата обновления записи(по MSK) в бд не текущие сутки, то обновляем ее. Можно поменять эту логику, переопределив метод expire? в app/models/bank.rb своего приложения:
33
-
34
- def expire?(bank)
35
- bank.updated_at < 1.minute.ago # Например, обновляем все, что старше минуты
36
- end
37
-
38
- Подобным образом переопределям любое поведение гема.
32
+ На этом все.
39
33
 
40
34
  Пример использования:
41
35
 
42
36
  @bank = Bank.new
43
37
  internal_code = @bank.BicToIntCode(some_bank_bic)
44
38
 
39
+ Далее можно кастомизировать модель по своему усмотрению. Например, в модели можно переопределить поведение тех или иных методов гема. Например, логика определения, требуется ли возвращать банк из базы или тянуть из API ЦБ, построена на том факте, что справочник БИК вступает в действие в 0:00 по московскому времени на всей территории страны. Т.е. если дата обновления записи(по MSK) в бд не текущие сутки, то обновляем ее. Можно поменять эту логику, переопределив метод expire? в app/models/bank.rb своего приложения:
40
+
41
+ def expire?
42
+ self.updated_at < 1.minute.ago # Например, обновляем все, что старше минуты
43
+ end
44
+
45
+ Подобным образом переопределям любое поведение гема.
46
+
47
+
45
48
  Описание доступных методов тут - http://rubydoc.info/gems/rus_bank_rails/RusBankRails/ActsAsBank/LocalInstanceMethods
46
49
 
47
50
  ## Copyright
@@ -112,6 +112,13 @@ module RusBankRails
112
112
  lics
113
113
  end
114
114
 
115
+ ##
116
+ # Возвращает true, если банк действующий
117
+
118
+ def is_active?
119
+ (self.org_status != "лицензия отозвана") && !(self.get_licences_as_array_of_hashes.empty?)
120
+ end
121
+
115
122
  private
116
123
 
117
124
  ##
@@ -1,3 +1,3 @@
1
1
  module RusBankRails
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
Binary file
Binary file
@@ -2186,3 +2186,30 @@ Migrating to DeleteOldLicFromBanks (20140208123404)
2186
2186
  SQL (0.4ms) INSERT INTO "banks" ("bic", "created_at", "date_kgr_registration", "fact_adr", "internal_code", "licences", "main_date_reg", "main_reg_number", "org_full_name", "org_name", "org_status", "phones", "reg_code", "reg_number", "ssv_date", "updated_at", "ust_money", "ustav_adr") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["bic", "044585216"], ["created_at", Sat, 08 Feb 2014 12:47:51 UTC +00:00], ["date_kgr_registration", Tue, 12 May 1992], ["fact_adr", "125040, г. Москва, ул. Правды, д. 8, корпус 1"], ["internal_code", 450000650], ["licences", "---\n- :l_code: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n Nw==\n attributes: {}\n :lt: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n 0JPQtdC90LXRgNCw0LvRjNC90LDRjyDQu9C40YbQtdC90LfQuNGPINC90LAg\n 0L7RgdGD0YnQtdGB0YLQstC70LXQvdC40LUg0LHQsNC90LrQvtCy0YHQutC4\n 0YUg0L7Qv9C10YDQsNGG0LjQuQ==\n attributes: {}\n :l_date: !ruby/object:DateTime 2012-03-15 00:00:00.000000000 +04:00\n"], ["main_date_reg", Fri, 04 Oct 2002], ["main_reg_number", "1027700280937"], ["org_full_name", "Общество с ограниченной ответственностью \"Хоум Кредит энд Финанс Банк\""], ["org_name", "ХКФ БАНК"], ["org_status", "норм."], ["phones", "(495)785-82-25"], ["reg_code", 16], ["reg_number", 316], ["ssv_date", Wed, 10 Nov 2004], ["updated_at", Sat, 08 Feb 2014 12:47:51 UTC +00:00], ["ust_money", 4173000000], ["ustav_adr", "125040, г. Москва, ул. Правды, д. 8, корпус 1"]]
2187
2187
   (0.5ms) commit transaction
2188
2188
  Bank Load (0.2ms) SELECT "banks".* FROM "banks"
2189
+ Bank Load (0.4ms) SELECT "banks".* FROM "banks" WHERE "banks"."reg_number" = 3 LIMIT 1
2190
+ Bank Load (0.2ms) SELECT "banks".* FROM "banks" WHERE "banks"."bic" = '044525859' LIMIT 1
2191
+  (0.1ms) begin transaction
2192
+ SQL (2.9ms) UPDATE "banks" SET "updated_at" = ?, "licences" = ? WHERE "banks"."id" = 42 [["updated_at", Sun, 09 Feb 2014 15:10:50 UTC +00:00], ["licences", "--- []\n"]]
2193
+  (0.4ms) commit transaction
2194
+ Bank Load (0.2ms) SELECT "banks".* FROM "banks" WHERE "banks"."reg_number" = 1 LIMIT 1
2195
+ Bank Load (0.1ms) SELECT "banks".* FROM "banks" WHERE "banks"."bic" = '044525545' LIMIT 1
2196
+  (0.1ms) begin transaction
2197
+ SQL (0.3ms) UPDATE "banks" SET "licences" = ?, "updated_at" = ? WHERE "banks"."id" = 40 [["licences", "---\n- :l_code: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n Mw==\n attributes: {}\n :lt: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n 0JvQuNGG0LXQvdC30LjRjyDQvdCwINC/0YDQuNCy0LvQtdGH0LXQvdC40LUg\n 0LLQviDQstC60LvQsNC00Ysg0Lgg0YDQsNC30LzQtdGJ0LXQvdC40LUg0LTR\n gNCw0LPQvtGG0LXQvdC90YvRhSDQvNC10YLQsNC70LvQvtCy\n attributes: {}\n :l_date: !ruby/object:DateTime 2007-12-19 23:00:00.000000000 +03:00\n- :l_code: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n Nw==\n attributes: {}\n :lt: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n 0JPQtdC90LXRgNCw0LvRjNC90LDRjyDQu9C40YbQtdC90LfQuNGPINC90LAg\n 0L7RgdGD0YnQtdGB0YLQstC70LXQvdC40LUg0LHQsNC90LrQvtCy0YHQutC4\n 0YUg0L7Qv9C10YDQsNGG0LjQuQ==\n attributes: {}\n :l_date: !ruby/object:DateTime 2012-03-23 00:00:00.000000000 +04:00\n"], ["updated_at", Sun, 09 Feb 2014 15:22:00 UTC +00:00]]
2198
+  (0.4ms) commit transaction
2199
+ Bank Load (0.2ms) SELECT "banks".* FROM "banks" WHERE "banks"."reg_number" = 1 LIMIT 1
2200
+ Bank Load (0.1ms) SELECT "banks".* FROM "banks" WHERE "banks"."bic" = '044525545' LIMIT 1
2201
+  (0.1ms) begin transaction
2202
+ SQL (0.7ms) UPDATE "banks" SET "licences" = ?, "updated_at" = ? WHERE "banks"."id" = 40 [["licences", "---\n- :l_code: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n Mw==\n attributes: {}\n :lt: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n 0JvQuNGG0LXQvdC30LjRjyDQvdCwINC/0YDQuNCy0LvQtdGH0LXQvdC40LUg\n 0LLQviDQstC60LvQsNC00Ysg0Lgg0YDQsNC30LzQtdGJ0LXQvdC40LUg0LTR\n gNCw0LPQvtGG0LXQvdC90YvRhSDQvNC10YLQsNC70LvQvtCy\n attributes: {}\n :l_date: !ruby/object:DateTime 2007-12-19 23:00:00.000000000 +03:00\n- :l_code: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n Nw==\n attributes: {}\n :lt: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n 0JPQtdC90LXRgNCw0LvRjNC90LDRjyDQu9C40YbQtdC90LfQuNGPINC90LAg\n 0L7RgdGD0YnQtdGB0YLQstC70LXQvdC40LUg0LHQsNC90LrQvtCy0YHQutC4\n 0YUg0L7Qv9C10YDQsNGG0LjQuQ==\n attributes: {}\n :l_date: !ruby/object:DateTime 2012-03-23 00:00:00.000000000 +04:00\n"], ["updated_at", Sun, 09 Feb 2014 15:23:31 UTC +00:00]]
2203
+  (1.6ms) commit transaction
2204
+ Bank Load (0.2ms) SELECT "banks".* FROM "banks" WHERE "banks"."reg_number" = 2 LIMIT 1
2205
+ Bank Load (0.1ms) SELECT "banks".* FROM "banks" WHERE "banks"."bic" = '044030869' LIMIT 1
2206
+  (0.1ms) begin transaction
2207
+ SQL (0.3ms) UPDATE "banks" SET "licences" = ?, "updated_at" = ? WHERE "banks"."id" = 41 [["licences", "---\n- :l_code: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n Nw==\n attributes: {}\n :lt: !ruby/string:Nori::StringWithAttributes\n str: !binary |-\n 0JPQtdC90LXRgNCw0LvRjNC90LDRjyDQu9C40YbQtdC90LfQuNGPINC90LAg\n 0L7RgdGD0YnQtdGB0YLQstC70LXQvdC40LUg0LHQsNC90LrQvtCy0YHQutC4\n 0YUg0L7Qv9C10YDQsNGG0LjQuQ==\n attributes: {}\n :l_date: !ruby/object:DateTime 2012-09-10 00:00:00.000000000 +04:00\n"], ["updated_at", Sun, 09 Feb 2014 15:30:02 UTC +00:00]]
2208
+  (0.4ms) commit transaction
2209
+ Bank Load (0.2ms) SELECT "banks".* FROM "banks" WHERE "banks"."reg_number" = 3 LIMIT 1
2210
+ Bank Load (0.1ms) SELECT "banks".* FROM "banks" WHERE "banks"."bic" = '044525859' LIMIT 1
2211
+  (0.1ms) begin transaction
2212
+ SQL (0.3ms) UPDATE "banks" SET "updated_at" = ?, "licences" = ? WHERE "banks"."id" = 42 [["updated_at", Sun, 09 Feb 2014 15:42:31 UTC +00:00], ["licences", "--- []\n"]]
2213
+  (0.4ms) commit transaction
2214
+ Bank Load (0.2ms) SELECT "banks".* FROM "banks" WHERE "banks"."bic" = '044525545' LIMIT 1
2215
+ Bank Load (0.2ms) SELECT "banks".* FROM "banks" WHERE "banks"."bic" = '044525859' LIMIT 1