istox 0.1.120.pre.1 → 0.1.120.pre.2

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
  SHA256:
3
- metadata.gz: d7115c09fd48a24d96b6a7018f3cfc0cd1f83ea98ba6eae8515f935148fa39cb
4
- data.tar.gz: 77b3be7bc1d761ba51141dabc8677793b001c4fedde9b1c7b11900aa724938ed
3
+ metadata.gz: 86efea88fe9b160bd80eed0b64af89e8be72b002b5164c45cb75fb7b62eece6c
4
+ data.tar.gz: 19d1e8f79a6cda0ceaf2aa1c163d660c530becf138ae87218e1de21f14a5647d
5
5
  SHA512:
6
- metadata.gz: fddbc0a6b9471fea4bd53ceb9ce9878e070fddd715b567bbde9e33e9661ce8b1763e9f4c6e75f7d031d784fb96938e6cc539d38a72e14193f8ec22cece7b5a22
7
- data.tar.gz: 47afe434053f98ce27cea5088b15522df50ecdbbf12e230845b62d8d1ceda67fb52f1d24e9f86fa972d65cb52b00db6cf59b5e104fe4716d7357659434bc4fda
6
+ metadata.gz: 801854a5d2e6b2dff20ae204b774e7512a3acc8aa9a712903db1811fbc68841c236044dd0b980325143e3df56cc19cf40bf1c34e04d80a3b0008654afa2a61b9
7
+ data.tar.gz: 5bf57d11d786ab8b36696b8497aa9befffd14c03f6275c092edeaaab7eadcd492c9d04405ffbd67c90d55932ecc635e9beac4da3726ad1e0e761f71e04d923d1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.119)
4
+ istox (0.1.120.pre.1)
5
5
  awesome_print
6
6
  binding_of_caller
7
7
  bunny (>= 2.12.0)
@@ -33,23 +33,30 @@ module Istox
33
33
 
34
34
  max_allowed_investor = Istox::FMath.round_down(::Istox::FMath.div(hard_cap, min_investment), 0).to_i
35
35
 
36
- interests.each_with_index.map do |interest, i|
37
- total_interests = ::Istox::FMath.add(total_interests, interest[:fiat_amount]) if i < max_allowed_investor
36
+ b = 0
37
+ interests.each_with_index.map do |interest|
38
+ if interest[:fiat_amount].to_d.positive? && b < max_allowed_investor
39
+ total_interests = ::Istox::FMath.add(total_interests, interest[:fiat_amount])
40
+ b += 1
41
+ end
38
42
  end
39
43
 
40
44
  # only need to handle when oversubscribe
41
45
  if total_interests.to_d > hard_cap.to_s.to_d
42
46
 
43
47
  # prorate the interests
44
- interests = interests.each_with_index.map do |interest, i|
45
- investment = if i < max_allowed_investor
48
+ i = 0
49
+ interests = interests.each_with_index.map do |interest|
50
+ investment = if i < max_allowed_investor && interest[:fiat_amount].to_d.positive?
46
51
  result = ::Istox::FMath.round_down(::Istox::FMath.mul(::Istox::FMath.div(interest[:fiat_amount], total_interests),
47
52
  hard_cap), 0)
53
+
48
54
  result = result.to_d - result.to_d.modulo(invest_step.to_s.to_d)
49
55
 
50
56
  # only set to min investment if is not vip
51
57
  result = min_investment.to_d if result < min_investment.to_d && interest[:is_vip].blank?
52
58
 
59
+ i += 1
53
60
  result
54
61
  else
55
62
  ::BigDecimal.new('0').to_s
@@ -105,14 +112,17 @@ module Istox
105
112
  end
106
113
 
107
114
  else
115
+
108
116
  final_interests = interests.each_with_index.map do |interest|
109
117
  final_amount = if interest[:is_vip]
110
- ::Istox::FMath.add(interest[:fiat_amount], interest[:granted_amount])
118
+ vip_fiat_amount = max_allowed_investor.positive? ? interest[:fiat_amount] : '0'
119
+ ::Istox::FMath.add(vip_fiat_amount, interest[:granted_amount])
111
120
  else
112
121
  max_allowed_investor.positive? ? interest[:fiat_amount] : '0'
113
122
  end
114
123
 
115
- max_allowed_investor -= 1
124
+ max_allowed_investor -= 1 if interest[:fiat_amount].to_d.positive?
125
+
116
126
  result = {
117
127
  id: interest[:id],
118
128
  investment: ::BigDecimal.new(final_amount.to_s).to_s
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.120-1'.freeze
2
+ VERSION = '0.1.120-2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.120.pre.1
4
+ version: 0.1.120.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-14 00:00:00.000000000 Z
11
+ date: 2020-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print