istox 0.2.8 → 0.2.11.pre.2
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 +4 -4
- data/Gemfile.lock +79 -83
- data/lib/istox/helpers/blockchain_service.rb +7 -5
- data/lib/istox/helpers/graphql_client.rb +1 -1
- data/lib/istox/helpers/order_book_prorate.rb +47 -21
- data/lib/istox/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db37b31d27d4eca7477f42c0b3ed3a9537c0b07f5b68610a0ee06aa6580f72eb
|
|
4
|
+
data.tar.gz: 8b4c48f8eaeff0fe5b772803330c86d0e9cf0a82cc782263539dc366fa2af69f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ece3d27d213be4c9f802ed74ad56686c3dd4201ea6dbe93cd844711cc88244aeccfa627e3282af22d76d1a61af2828264115e4f67c2fd6f608db17cf7d6aa7b3
|
|
7
|
+
data.tar.gz: 0e7d314764c2af3e381dc5ca0f6b114ad37ab6df77f3264609df25e17ed65ecab2677d617de908cb0d23d2ce01fb8dec92c75f5e3253a17dd87d8ee1199e443d
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
istox (0.2.
|
|
4
|
+
istox (0.2.10)
|
|
5
5
|
amazing_print
|
|
6
6
|
awesome_print
|
|
7
7
|
aws-sdk-sns (~> 1)
|
|
@@ -9,7 +9,6 @@ PATH
|
|
|
9
9
|
bunny (>= 2.12.0)
|
|
10
10
|
exponential-backoff (= 0.0.4)
|
|
11
11
|
graphlient
|
|
12
|
-
gruf
|
|
13
12
|
hashie (~> 3.5.7)
|
|
14
13
|
istox_gruf (~> 2.7.3)
|
|
15
14
|
listen (~> 3.0.5)
|
|
@@ -23,43 +22,43 @@ PATH
|
|
|
23
22
|
GEM
|
|
24
23
|
remote: https://rubygems.org/
|
|
25
24
|
specs:
|
|
26
|
-
actioncable (5.2.
|
|
27
|
-
actionpack (= 5.2.
|
|
25
|
+
actioncable (5.2.6)
|
|
26
|
+
actionpack (= 5.2.6)
|
|
28
27
|
nio4r (~> 2.0)
|
|
29
28
|
websocket-driver (>= 0.6.1)
|
|
30
|
-
actionmailer (5.2.
|
|
31
|
-
actionpack (= 5.2.
|
|
32
|
-
actionview (= 5.2.
|
|
33
|
-
activejob (= 5.2.
|
|
29
|
+
actionmailer (5.2.6)
|
|
30
|
+
actionpack (= 5.2.6)
|
|
31
|
+
actionview (= 5.2.6)
|
|
32
|
+
activejob (= 5.2.6)
|
|
34
33
|
mail (~> 2.5, >= 2.5.4)
|
|
35
34
|
rails-dom-testing (~> 2.0)
|
|
36
|
-
actionpack (5.2.
|
|
37
|
-
actionview (= 5.2.
|
|
38
|
-
activesupport (= 5.2.
|
|
39
|
-
rack (~> 2.0)
|
|
35
|
+
actionpack (5.2.6)
|
|
36
|
+
actionview (= 5.2.6)
|
|
37
|
+
activesupport (= 5.2.6)
|
|
38
|
+
rack (~> 2.0, >= 2.0.8)
|
|
40
39
|
rack-test (>= 0.6.3)
|
|
41
40
|
rails-dom-testing (~> 2.0)
|
|
42
41
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
43
|
-
actionview (5.2.
|
|
44
|
-
activesupport (= 5.2.
|
|
42
|
+
actionview (5.2.6)
|
|
43
|
+
activesupport (= 5.2.6)
|
|
45
44
|
builder (~> 3.1)
|
|
46
45
|
erubi (~> 1.4)
|
|
47
46
|
rails-dom-testing (~> 2.0)
|
|
48
47
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
49
|
-
activejob (5.2.
|
|
50
|
-
activesupport (= 5.2.
|
|
48
|
+
activejob (5.2.6)
|
|
49
|
+
activesupport (= 5.2.6)
|
|
51
50
|
globalid (>= 0.3.6)
|
|
52
|
-
activemodel (5.2.
|
|
53
|
-
activesupport (= 5.2.
|
|
54
|
-
activerecord (5.2.
|
|
55
|
-
activemodel (= 5.2.
|
|
56
|
-
activesupport (= 5.2.
|
|
51
|
+
activemodel (5.2.6)
|
|
52
|
+
activesupport (= 5.2.6)
|
|
53
|
+
activerecord (5.2.6)
|
|
54
|
+
activemodel (= 5.2.6)
|
|
55
|
+
activesupport (= 5.2.6)
|
|
57
56
|
arel (>= 9.0)
|
|
58
|
-
activestorage (5.2.
|
|
59
|
-
actionpack (= 5.2.
|
|
60
|
-
activerecord (= 5.2.
|
|
61
|
-
marcel (~> 0.
|
|
62
|
-
activesupport (5.2.
|
|
57
|
+
activestorage (5.2.6)
|
|
58
|
+
actionpack (= 5.2.6)
|
|
59
|
+
activerecord (= 5.2.6)
|
|
60
|
+
marcel (~> 1.0.0)
|
|
61
|
+
activesupport (5.2.6)
|
|
63
62
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
64
63
|
i18n (>= 0.7, < 2)
|
|
65
64
|
minitest (~> 5.1)
|
|
@@ -92,17 +91,17 @@ GEM
|
|
|
92
91
|
bullet (5.7.6)
|
|
93
92
|
activesupport (>= 3.0.0)
|
|
94
93
|
uniform_notifier (~> 1.11.0)
|
|
95
|
-
bunny (2.
|
|
94
|
+
bunny (2.18.0)
|
|
96
95
|
amq-protocol (~> 2.3, >= 2.3.1)
|
|
96
|
+
sorted_set (~> 1, >= 1.0.2)
|
|
97
97
|
byebug (11.1.3)
|
|
98
98
|
coderay (1.1.2)
|
|
99
|
-
concurrent-ruby (1.1.
|
|
99
|
+
concurrent-ruby (1.1.9)
|
|
100
100
|
crass (1.0.6)
|
|
101
101
|
database_cleaner (1.6.2)
|
|
102
102
|
debug_inspector (1.1.0)
|
|
103
103
|
diff-lcs (1.3)
|
|
104
|
-
|
|
105
|
-
erubi (1.9.0)
|
|
104
|
+
erubi (1.10.0)
|
|
106
105
|
exponential-backoff (0.0.4)
|
|
107
106
|
factory_bot (4.8.2)
|
|
108
107
|
activesupport (>= 3.0.0)
|
|
@@ -113,44 +112,39 @@ GEM
|
|
|
113
112
|
i18n (~> 0.5)
|
|
114
113
|
fakeredis (0.7.0)
|
|
115
114
|
redis (>= 3.2, < 5.0)
|
|
116
|
-
faraday (1.4.
|
|
115
|
+
faraday (1.4.2)
|
|
116
|
+
faraday-em_http (~> 1.0)
|
|
117
|
+
faraday-em_synchrony (~> 1.0)
|
|
117
118
|
faraday-excon (~> 1.1)
|
|
118
119
|
faraday-net_http (~> 1.0)
|
|
119
120
|
faraday-net_http_persistent (~> 1.1)
|
|
120
121
|
multipart-post (>= 1.2, < 3)
|
|
121
122
|
ruby2_keywords (>= 0.0.4)
|
|
123
|
+
faraday-em_http (1.0.0)
|
|
124
|
+
faraday-em_synchrony (1.0.0)
|
|
122
125
|
faraday-excon (1.1.0)
|
|
123
126
|
faraday-net_http (1.0.1)
|
|
124
127
|
faraday-net_http_persistent (1.1.0)
|
|
125
128
|
faraday_middleware (1.0.0)
|
|
126
129
|
faraday (~> 1.0)
|
|
127
|
-
ffi (1.15.
|
|
130
|
+
ffi (1.15.3)
|
|
128
131
|
globalid (0.4.2)
|
|
129
132
|
activesupport (>= 4.2.0)
|
|
130
|
-
google-protobuf (3.
|
|
133
|
+
google-protobuf (3.17.3)
|
|
131
134
|
googleapis-common-protos-types (1.0.6)
|
|
132
135
|
google-protobuf (~> 3.14)
|
|
133
136
|
graphlient (0.5.0)
|
|
134
137
|
faraday (>= 1.0)
|
|
135
138
|
faraday_middleware
|
|
136
139
|
graphql-client
|
|
137
|
-
graphql (1.12.
|
|
140
|
+
graphql (1.12.12)
|
|
138
141
|
graphql-client (0.16.0)
|
|
139
142
|
activesupport (>= 3.0)
|
|
140
143
|
graphql (~> 1.8)
|
|
141
|
-
grpc (1.
|
|
144
|
+
grpc (1.38.0)
|
|
142
145
|
google-protobuf (~> 3.15)
|
|
143
146
|
googleapis-common-protos-types (~> 1.0)
|
|
144
|
-
grpc-tools (1.
|
|
145
|
-
gruf (2.9.1)
|
|
146
|
-
activesupport (> 4)
|
|
147
|
-
concurrent-ruby (> 1)
|
|
148
|
-
e2mmap (~> 0.1)
|
|
149
|
-
grpc (~> 1.10)
|
|
150
|
-
grpc-tools (~> 1.10)
|
|
151
|
-
json (>= 2.3)
|
|
152
|
-
slop (~> 4.6)
|
|
153
|
-
thwait (~> 0.1)
|
|
147
|
+
grpc-tools (1.38.0)
|
|
154
148
|
hashie (3.5.7)
|
|
155
149
|
i18n (0.9.5)
|
|
156
150
|
concurrent-ruby (~> 1.0)
|
|
@@ -161,28 +155,26 @@ GEM
|
|
|
161
155
|
grpc-tools (~> 1.10)
|
|
162
156
|
slop (~> 4.6)
|
|
163
157
|
jmespath (1.4.0)
|
|
164
|
-
json (2.5.1)
|
|
165
158
|
listen (3.0.8)
|
|
166
159
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
167
160
|
rb-inotify (~> 0.9, >= 0.9.7)
|
|
168
|
-
loofah (2.
|
|
161
|
+
loofah (2.10.0)
|
|
169
162
|
crass (~> 1.0.2)
|
|
170
163
|
nokogiri (>= 1.5.9)
|
|
171
164
|
mail (2.7.1)
|
|
172
165
|
mini_mime (>= 0.1.1)
|
|
173
|
-
marcel (0.
|
|
174
|
-
mimemagic (~> 0.3.2)
|
|
166
|
+
marcel (1.0.1)
|
|
175
167
|
method_source (0.9.2)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
minitest (5.14.0)
|
|
168
|
+
mini_mime (1.1.0)
|
|
169
|
+
mini_portile2 (2.5.3)
|
|
170
|
+
minitest (5.14.4)
|
|
180
171
|
multi_json (1.14.1)
|
|
181
172
|
multipart-post (2.1.1)
|
|
182
|
-
nio4r (2.
|
|
183
|
-
nokogiri (1.
|
|
184
|
-
mini_portile2 (~> 2.
|
|
185
|
-
|
|
173
|
+
nio4r (2.5.7)
|
|
174
|
+
nokogiri (1.11.7)
|
|
175
|
+
mini_portile2 (~> 2.5.0)
|
|
176
|
+
racc (~> 1.4)
|
|
177
|
+
oj (3.11.6)
|
|
186
178
|
ougai (2.0.0)
|
|
187
179
|
oj (~> 3.10)
|
|
188
180
|
paranoia (2.4.3)
|
|
@@ -195,43 +187,45 @@ GEM
|
|
|
195
187
|
pry (~> 0.10)
|
|
196
188
|
pry-rails (0.3.9)
|
|
197
189
|
pry (>= 0.10.4)
|
|
198
|
-
|
|
190
|
+
racc (1.5.2)
|
|
191
|
+
rack (2.2.3)
|
|
199
192
|
rack-test (1.1.0)
|
|
200
193
|
rack (>= 1.0, < 3)
|
|
201
|
-
rails (5.2.
|
|
202
|
-
actioncable (= 5.2.
|
|
203
|
-
actionmailer (= 5.2.
|
|
204
|
-
actionpack (= 5.2.
|
|
205
|
-
actionview (= 5.2.
|
|
206
|
-
activejob (= 5.2.
|
|
207
|
-
activemodel (= 5.2.
|
|
208
|
-
activerecord (= 5.2.
|
|
209
|
-
activestorage (= 5.2.
|
|
210
|
-
activesupport (= 5.2.
|
|
194
|
+
rails (5.2.6)
|
|
195
|
+
actioncable (= 5.2.6)
|
|
196
|
+
actionmailer (= 5.2.6)
|
|
197
|
+
actionpack (= 5.2.6)
|
|
198
|
+
actionview (= 5.2.6)
|
|
199
|
+
activejob (= 5.2.6)
|
|
200
|
+
activemodel (= 5.2.6)
|
|
201
|
+
activerecord (= 5.2.6)
|
|
202
|
+
activestorage (= 5.2.6)
|
|
203
|
+
activesupport (= 5.2.6)
|
|
211
204
|
bundler (>= 1.3.0)
|
|
212
|
-
railties (= 5.2.
|
|
205
|
+
railties (= 5.2.6)
|
|
213
206
|
sprockets-rails (>= 2.0.0)
|
|
214
207
|
rails-dom-testing (2.0.3)
|
|
215
208
|
activesupport (>= 4.2.0)
|
|
216
209
|
nokogiri (>= 1.6)
|
|
217
210
|
rails-html-sanitizer (1.3.0)
|
|
218
211
|
loofah (~> 2.3)
|
|
219
|
-
railties (5.2.
|
|
220
|
-
actionpack (= 5.2.
|
|
221
|
-
activesupport (= 5.2.
|
|
212
|
+
railties (5.2.6)
|
|
213
|
+
actionpack (= 5.2.6)
|
|
214
|
+
activesupport (= 5.2.6)
|
|
222
215
|
method_source
|
|
223
216
|
rake (>= 0.8.7)
|
|
224
217
|
thor (>= 0.19.0, < 2.0)
|
|
225
218
|
rake (10.5.0)
|
|
226
|
-
rb-fsevent (0.
|
|
219
|
+
rb-fsevent (0.11.0)
|
|
227
220
|
rb-inotify (0.10.1)
|
|
228
221
|
ffi (~> 1.0)
|
|
222
|
+
rbtree (0.4.4)
|
|
229
223
|
redis (4.1.3)
|
|
230
224
|
redis-actionpack (5.2.0)
|
|
231
225
|
actionpack (>= 5, < 7)
|
|
232
226
|
redis-rack (>= 2.1.0, < 3)
|
|
233
227
|
redis-store (>= 1.1.0, < 2)
|
|
234
|
-
redis-activesupport (5.2.
|
|
228
|
+
redis-activesupport (5.2.1)
|
|
235
229
|
activesupport (>= 3, < 7)
|
|
236
230
|
redis-store (>= 1.3, < 2)
|
|
237
231
|
redis-namespace (1.8.1)
|
|
@@ -267,28 +261,30 @@ GEM
|
|
|
267
261
|
rspec-support (~> 3.8.0)
|
|
268
262
|
rspec-support (3.8.0)
|
|
269
263
|
ruby2_keywords (0.0.4)
|
|
270
|
-
|
|
271
|
-
|
|
264
|
+
set (1.0.1)
|
|
265
|
+
slop (4.9.1)
|
|
266
|
+
sorted_set (1.0.3)
|
|
267
|
+
rbtree
|
|
268
|
+
set (~> 1.0)
|
|
269
|
+
sprockets (4.0.2)
|
|
272
270
|
concurrent-ruby (~> 1.0)
|
|
273
271
|
rack (> 1, < 3)
|
|
274
|
-
sprockets-rails (3.2.
|
|
272
|
+
sprockets-rails (3.2.2)
|
|
275
273
|
actionpack (>= 4.0)
|
|
276
274
|
activesupport (>= 4.0)
|
|
277
275
|
sprockets (>= 3.0.0)
|
|
278
276
|
sqlite3 (1.3.13)
|
|
279
|
-
thor (
|
|
277
|
+
thor (1.1.0)
|
|
280
278
|
thread_safe (0.3.6)
|
|
281
|
-
thwait (0.2.0)
|
|
282
|
-
e2mmap
|
|
283
279
|
timecop (0.9.1)
|
|
284
|
-
tzinfo (1.2.
|
|
280
|
+
tzinfo (1.2.9)
|
|
285
281
|
thread_safe (~> 0.1)
|
|
286
282
|
uniform_notifier (1.11.0)
|
|
287
283
|
vault (0.16.0)
|
|
288
284
|
aws-sigv4
|
|
289
|
-
websocket-driver (0.7.
|
|
285
|
+
websocket-driver (0.7.5)
|
|
290
286
|
websocket-extensions (>= 0.1.0)
|
|
291
|
-
websocket-extensions (0.1.
|
|
287
|
+
websocket-extensions (0.1.5)
|
|
292
288
|
|
|
293
289
|
PLATFORMS
|
|
294
290
|
ruby
|
|
@@ -8,18 +8,18 @@ module Istox
|
|
|
8
8
|
@@blockchain_receipt_klass
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def self.request(sid:, action:, before:,
|
|
12
|
-
start(sid: sid, action: action, before: before, execute: execute, is_request: true, request_reason: request_reason)
|
|
11
|
+
def self.request(sid:, action:, before:, execute:, before_start: nil, request_reason: nil)
|
|
12
|
+
start(sid: sid, action: action, before: before, before_start: before_start, execute: execute, is_request: true, request_reason: request_reason)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def self.run(sid:, action:, before:, execute:)
|
|
16
|
-
start(sid: sid, action: action, before: before, execute: execute)
|
|
15
|
+
def self.run(sid:, action:, before:, execute:, before_start: nil)
|
|
16
|
+
start(sid: sid, action: action, before: before, before_start: before_start, execute: execute)
|
|
17
17
|
end
|
|
18
18
|
class << self
|
|
19
19
|
private
|
|
20
20
|
|
|
21
21
|
# before is the proc that will be executed before, must return the main model blockchain receipt will bind to
|
|
22
|
-
def start(sid:, action:, before:, execute:, is_request: false, request_reason: nil)
|
|
22
|
+
def start(sid:, action:, before:, execute:, before_start: nil, is_request: false, request_reason: nil)
|
|
23
23
|
# create blockchain receipt first
|
|
24
24
|
klass = blockchain_receipt_class
|
|
25
25
|
uuid = ::SecureRandom.uuid
|
|
@@ -33,6 +33,8 @@ module Istox
|
|
|
33
33
|
|
|
34
34
|
chainhub_processing = true
|
|
35
35
|
|
|
36
|
+
before_start.call(uuid) if before_start.present?
|
|
37
|
+
|
|
36
38
|
::ActiveRecord::Base.transaction do
|
|
37
39
|
# execute before proc, and get the model that blockchain receipt should bind to
|
|
38
40
|
model = before.call(uuid)
|
|
@@ -27,7 +27,7 @@ module Istox
|
|
|
27
27
|
private
|
|
28
28
|
|
|
29
29
|
def init_host(host_type, url)
|
|
30
|
-
client = Graphlient::Client.new(url, http: Graphlient::Adapters::HTTP::
|
|
30
|
+
client = Graphlient::Client.new(url, http: Graphlient::Adapters::HTTP::FaradayAdapter)
|
|
31
31
|
|
|
32
32
|
@@hosts[host_type] = client
|
|
33
33
|
end
|
|
@@ -18,33 +18,59 @@ module Istox
|
|
|
18
18
|
|
|
19
19
|
# process whitelist
|
|
20
20
|
whitelists.each do |whitelist|
|
|
21
|
-
|
|
21
|
+
whitelisted_investments = investments.select { |investment1| investment1[:account_id] == whitelist[:account_id] }
|
|
22
22
|
|
|
23
|
-
next unless
|
|
23
|
+
next unless whitelisted_investments.length.positive?
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
current_guarenteed_amount = ::BigDecimal.new(whitelist[:guaranteed_allocation].to_s)
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
whitelisted_investments.each do |whitelisted_investment|
|
|
28
|
+
granted_amount = [::BigDecimal.new(whitelisted_investment[:fiat_amount].to_s), current_guarenteed_amount].min
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
next unless granted_amount.positive?
|
|
31
|
+
|
|
32
|
+
current_guarenteed_amount = ::Istox::FMath.sub(current_guarenteed_amount, granted_amount).to_d
|
|
33
|
+
|
|
34
|
+
hard_cap = ::Istox::FMath.sub(hard_cap, granted_amount)
|
|
35
|
+
whitelisted_investment[:fiat_amount] = Istox::FMath.sub(whitelisted_investment[:fiat_amount], granted_amount)
|
|
36
|
+
whitelisted_investment[:is_vip] = true
|
|
37
|
+
whitelisted_investment[:granted_amount] = granted_amount.to_s
|
|
38
|
+
end
|
|
33
39
|
end
|
|
34
40
|
|
|
35
41
|
# sort by id asc
|
|
36
42
|
interests = investments.sort do |a, b|
|
|
37
43
|
a[:id] <=> b[:id]
|
|
38
44
|
end
|
|
45
|
+
|
|
46
|
+
## check whether each investment already had earlier investment from the same investor
|
|
47
|
+
interests = interests.map do |interest|
|
|
48
|
+
earlier_interest = interests.find do |i|
|
|
49
|
+
i[:account_id] == interest[:account_id] &&
|
|
50
|
+
i[:id] != interest[:id] && i[:id].to_i < interest[:id].to_i
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
interest[:has_earlier_interest] = earlier_interest.present?
|
|
54
|
+
|
|
55
|
+
interest
|
|
56
|
+
end
|
|
57
|
+
|
|
39
58
|
total_interests = 0
|
|
40
59
|
|
|
41
60
|
max_allowed_investor = Istox::FMath.round_down(::Istox::FMath.div(hard_cap, min_investment), 0).to_i
|
|
42
61
|
|
|
43
|
-
|
|
62
|
+
allowed_investor_ids = []
|
|
44
63
|
interests.each_with_index.map do |interest|
|
|
45
|
-
if interest[:
|
|
64
|
+
if !allowed_investor_ids.include?(interest[:account_id]) &&
|
|
65
|
+
interest[:fiat_amount].to_d.positive? && allowed_investor_ids.length < max_allowed_investor
|
|
66
|
+
allowed_investor_ids.push(interest[:account_id])
|
|
67
|
+
interest[:to_be_set_zero] = false
|
|
46
68
|
total_interests = ::Istox::FMath.add(total_interests, interest[:fiat_amount])
|
|
47
|
-
|
|
69
|
+
elsif allowed_investor_ids.include?(interest[:account_id]) && interest[:fiat_amount].to_d.positive?
|
|
70
|
+
interest[:to_be_set_zero] = false
|
|
71
|
+
total_interests = ::Istox::FMath.add(total_interests, interest[:fiat_amount])
|
|
72
|
+
else
|
|
73
|
+
interest[:to_be_set_zero] = true
|
|
48
74
|
end
|
|
49
75
|
end
|
|
50
76
|
|
|
@@ -52,18 +78,18 @@ module Istox
|
|
|
52
78
|
if total_interests.to_d > hard_cap.to_s.to_d
|
|
53
79
|
|
|
54
80
|
# prorate the interests
|
|
55
|
-
i = 0
|
|
56
81
|
interests = interests.each_with_index.map do |interest|
|
|
57
|
-
investment = if
|
|
82
|
+
investment = if interest[:fiat_amount].to_d.positive? && !interest[:to_be_set_zero]
|
|
58
83
|
result = ::Istox::FMath.round_down(::Istox::FMath.mul(::Istox::FMath.div(interest[:fiat_amount], total_interests),
|
|
59
84
|
hard_cap), 0)
|
|
60
85
|
|
|
61
86
|
result = result.to_d - result.to_d.modulo(invest_step.to_s.to_d)
|
|
62
87
|
|
|
63
88
|
# only set to min investment if is not vip
|
|
64
|
-
|
|
89
|
+
if result < min_investment.to_d && interest[:is_vip].blank? && !interest[:has_earlier_interest]
|
|
90
|
+
result = min_investment.to_d
|
|
91
|
+
end
|
|
65
92
|
|
|
66
|
-
i += 1
|
|
67
93
|
result
|
|
68
94
|
else
|
|
69
95
|
::BigDecimal.new('0').to_s
|
|
@@ -73,6 +99,7 @@ module Istox
|
|
|
73
99
|
id: interest[:id],
|
|
74
100
|
is_vip: interest[:is_vip],
|
|
75
101
|
granted_amount: interest[:granted_amount],
|
|
102
|
+
has_earlier_interest: interest[:has_earlier_interest],
|
|
76
103
|
investment: investment.to_s
|
|
77
104
|
}
|
|
78
105
|
end
|
|
@@ -86,10 +113,10 @@ module Istox
|
|
|
86
113
|
if new_total_interests.to_d > hard_cap.to_s.to_d
|
|
87
114
|
total_deducting = ::Istox::FMath.sub(new_total_interests, hard_cap)
|
|
88
115
|
interests.reverse_each do |interest|
|
|
89
|
-
next unless interest[:investment].to_d > min_investment.to_d || interest[:is_vip]
|
|
116
|
+
next unless interest[:investment].to_d > min_investment.to_d || interest[:is_vip] || interest[:has_earlier_interest]
|
|
90
117
|
|
|
91
118
|
# allow to deduct to zero if is vip
|
|
92
|
-
deductable = if interest[:is_vip]
|
|
119
|
+
deductable = if interest[:is_vip] || interest[:has_earlier_interest]
|
|
93
120
|
interest[:investment]
|
|
94
121
|
else
|
|
95
122
|
::Istox::FMath.sub(interest[:investment], min_investment)
|
|
@@ -110,6 +137,7 @@ module Istox
|
|
|
110
137
|
interest[:granted_amount].to_d.positive?
|
|
111
138
|
interest.delete(:is_vip)
|
|
112
139
|
interest.delete(:granted_amount)
|
|
140
|
+
interest.delete(:has_earlier_interest)
|
|
113
141
|
|
|
114
142
|
if include_refund_amount
|
|
115
143
|
original_investment = original_investments.find { |original_investment1| original_investment1[:id] == interest[:id] }
|
|
@@ -122,14 +150,12 @@ module Istox
|
|
|
122
150
|
|
|
123
151
|
final_interests = interests.each_with_index.map do |interest|
|
|
124
152
|
final_amount = if interest[:is_vip]
|
|
125
|
-
vip_fiat_amount =
|
|
153
|
+
vip_fiat_amount = !interest[:to_be_set_zero] ? interest[:fiat_amount] : '0'
|
|
126
154
|
::Istox::FMath.add(vip_fiat_amount, interest[:granted_amount])
|
|
127
155
|
else
|
|
128
|
-
|
|
156
|
+
!interest[:to_be_set_zero] ? interest[:fiat_amount] : '0'
|
|
129
157
|
end
|
|
130
158
|
|
|
131
|
-
max_allowed_investor -= 1 if interest[:fiat_amount].to_d.positive?
|
|
132
|
-
|
|
133
159
|
result = {
|
|
134
160
|
id: interest[:id],
|
|
135
161
|
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.2.
|
|
4
|
+
version: 0.2.11.pre.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Siong Leng
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-06-
|
|
11
|
+
date: 2021-06-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: amazing_print
|
|
@@ -517,7 +517,7 @@ files:
|
|
|
517
517
|
homepage: http://www.abc.com
|
|
518
518
|
licenses: []
|
|
519
519
|
metadata: {}
|
|
520
|
-
post_install_message:
|
|
520
|
+
post_install_message:
|
|
521
521
|
rdoc_options: []
|
|
522
522
|
require_paths:
|
|
523
523
|
- lib
|
|
@@ -528,12 +528,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
528
528
|
version: '0'
|
|
529
529
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
530
530
|
requirements:
|
|
531
|
-
- - "
|
|
531
|
+
- - ">"
|
|
532
532
|
- !ruby/object:Gem::Version
|
|
533
|
-
version:
|
|
533
|
+
version: 1.3.1
|
|
534
534
|
requirements: []
|
|
535
|
-
rubygems_version: 3.0.
|
|
536
|
-
signing_key:
|
|
535
|
+
rubygems_version: 3.0.1
|
|
536
|
+
signing_key:
|
|
537
537
|
specification_version: 4
|
|
538
538
|
summary: istox backend shared gem
|
|
539
539
|
test_files: []
|