bscf-core 0.4.91 → 0.4.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee63abaa5257e9b71f51f6ad8579906148b2c41f83e9f445b46db78f5bd374ef
4
- data.tar.gz: a9852a7795f3bddba6975aede550472d2e6da1531a37fca4901e75b5354233f7
3
+ metadata.gz: 908d08703e3e77634fbd2ab0183f57024d9dd09442546d4a0d4932ad9c15ba48
4
+ data.tar.gz: 3e9ade887db90db51bf22ac59666fca5a5782fce00f37bdc2476fd7ff217a3d1
5
5
  SHA512:
6
- metadata.gz: 9c5f71f28c4384b72e5de37041fbf50b8005153df6a0ca56405876c7df5b4283432b086ea0d4bf4cd9477e7af3adccde5fe91c275a47a5361b711dd807039a55
7
- data.tar.gz: 94cbe632f83df4086dc54c1a39868e962d1587765188065fffd6c28b4803ae21c319aa925189002cf913e9c651ff153de61f665bf0f184b10ef2f37a8f7d04ac
6
+ metadata.gz: fc4a1184c0289a619158884b7fe2153b9475d9cdfa8f1d6f47481ac63afcb9277bd54835969a97557f48434f3f2e85a26eafe5360ed833361f0331368443a1b3
7
+ data.tar.gz: 4df7d9f8924009577920ec9d9648c4870132e44b0543eb8108a82fed89602f80074351b20bcdeb01358d7b045df3384149fef1b0470f961ef3e84634c809c99a
@@ -28,11 +28,27 @@ module Bscf
28
28
  },
29
29
  if: :password_required?
30
30
 
31
+ after_create :create_virtual_account
32
+
31
33
  private
32
34
 
33
35
  def password_required?
34
36
  new_record? || password.present?
35
37
  end
38
+
39
+ def create_virtual_account
40
+ VirtualAccount.create!(
41
+ user: self,
42
+ branch_code: "VA#{SecureRandom.hex(4).upcase}",
43
+ product_scheme: "SAVINGS",
44
+ voucher_type: "REGULAR",
45
+ balance: 0.0,
46
+ interest_rate: 2.5,
47
+ interest_type: :simple,
48
+ status: :pending,
49
+ cbs_account_number: "CBS#{SecureRandom.hex(4).upcase}"
50
+ )
51
+ end
36
52
  end
37
53
  end
38
54
  end
@@ -19,6 +19,20 @@ module Bscf
19
19
  approved: 1,
20
20
  rejected: 2
21
21
  }
22
+
23
+ after_save :update_virtual_account_status, if: :saved_change_to_kyc_status?
24
+
25
+ private
26
+
27
+ def update_virtual_account_status
28
+ return unless user&.virtual_account.present?
29
+
30
+ if kyc_status == 'approved'
31
+ user.virtual_account.update(status: :active)
32
+ elsif kyc_status == 'rejected'
33
+ user.virtual_account.update(status: :suspended)
34
+ end
35
+ end
22
36
  end
23
37
  end
24
38
  end
@@ -1,3 +1,5 @@
1
+ require "httparty"
2
+
1
3
  module Bscf
2
4
  module Core
3
5
  class GebetaMapsService
@@ -19,11 +21,8 @@ module Bscf
19
21
  destinations_str = destinations.map { |lat, lon| "{#{lat},#{lon}}" }.join(",")
20
22
  json_param = "[#{destinations_str}]"
21
23
 
22
- response = self.class.get("/route/onm", query: {
23
- origin: origin_str,
24
- json: json_param,
25
- apiKey: @api_key
26
- })
24
+ url = "https://mapapi.gebeta.app/api/route/onm?origin=#{origin_str}&json=#{json_param}&apiKey=#{@api_key}"
25
+ response = HTTParty.get(url)
27
26
 
28
27
  handle_response(response)
29
28
  end
@@ -34,7 +33,7 @@ module Bscf
34
33
  if response.success?
35
34
  JSON.parse(response.body)
36
35
  else
37
- Rails.logger.error("[GebetaMapsService] Request failed: #{response.code} - #{response.body}")
36
+ Rails.logger.error("Gebeta Maps API error: #{response.code} - #{response.body}")
38
37
  {}
39
38
  end
40
39
  end
@@ -1,5 +1,5 @@
1
1
  module Bscf
2
2
  module Core
3
- VERSION = "0.4.91"
3
+ VERSION = "0.4.93"
4
4
  end
5
5
  end
@@ -2,13 +2,13 @@ FactoryBot.define do
2
2
  factory :voucher, class: 'Bscf::Core::Voucher' do
3
3
  association :issued_by, factory: :user
4
4
 
5
- after(:build) do |voucher|
6
- create(:virtual_account, user: voucher.issued_by, balance: 1000.0) unless voucher.issued_by.virtual_account
5
+ before(:create) do |voucher|
6
+ create(:virtual_account, user: voucher.issued_by, balance: 10000.0)
7
7
  end
8
8
 
9
9
  full_name { Faker::Name.name }
10
10
  phone_number { Faker::PhoneNumber.cell_phone }
11
- amount { Faker::Number.decimal(l_digits: 3, r_digits: 2) }
11
+ amount { 100 }
12
12
  expires_at { 30.days.from_now }
13
13
  status { :pending }
14
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bscf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.91
4
+ version: 0.4.93
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat
@@ -394,7 +394,6 @@ files:
394
394
  - spec/factories/bscf/core/vehicles.rb
395
395
  - spec/factories/bscf/core/virtual_account_transactions.rb
396
396
  - spec/factories/bscf/core/virtual_accounts.rb
397
- - spec/factories/bscf/core/voucher.rb
398
397
  - spec/factories/bscf/core/vouchers.rb
399
398
  - spec/factories/bscf/core/wholesaler_products.rb
400
399
  homepage: https://mksaddis.com/
File without changes