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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/istox/helpers/order_book_prorate.rb +16 -6
- data/lib/istox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86efea88fe9b160bd80eed0b64af89e8be72b002b5164c45cb75fb7b62eece6c
|
4
|
+
data.tar.gz: 19d1e8f79a6cda0ceaf2aa1c163d660c530becf138ae87218e1de21f14a5647d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 801854a5d2e6b2dff20ae204b774e7512a3acc8aa9a712903db1811fbc68841c236044dd0b980325143e3df56cc19cf40bf1c34e04d80a3b0008654afa2a61b9
|
7
|
+
data.tar.gz: 5bf57d11d786ab8b36696b8497aa9befffd14c03f6275c092edeaaab7eadcd492c9d04405ffbd67c90d55932ecc635e9beac4da3726ad1e0e761f71e04d923d1
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
37
|
-
|
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
|
-
|
45
|
-
|
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
|
-
|
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
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.
|
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-
|
11
|
+
date: 2020-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|