invoicing_payments_processing 1.1.63 → 1.1.64
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/lib/extend_client_by_invoicing_payments_processing.rb +21 -2
- data/lib/movement.rb +25 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 504ea9259de82ef1ffc339b33a7fca1a4273b6a9
|
4
|
+
data.tar.gz: be390eb676c4cd0eeb5398681e6a6d02d2bcd272
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49240d883710395e708b20b382f95eb3b9c1fc1c3a1f87abcfc2afb9cd6b0088c74fcc0413dd23213b07fbbdf10987681725b19f265f532e08b741f91cfc7997
|
7
|
+
data.tar.gz: 9d6a4fbbae677537d13699075debbebf4e5ffe54b2dba6fbc7b51c5f80c9dbb7ee6d2086c1e3d3e163a7d18a474e04e56b0bc3a51c62b6c000c66bee840a0322
|
@@ -6,7 +6,26 @@ module BlackStack
|
|
6
6
|
class Client < Sequel::Model(:client)
|
7
7
|
one_to_many :paypal_subscriptions, :class=>:'BlackStack::PayPalSubscription', :key=>:id_client
|
8
8
|
one_to_many :customplans, :class=>:'BlackStack::CustomPlan', :key=>:id_client
|
9
|
-
|
9
|
+
|
10
|
+
# This method replace the line:
|
11
|
+
# one_to_many :movements, :class=>:'BlackStack::Movement', :key=>:id_client
|
12
|
+
#
|
13
|
+
# Because when you have a large number of records in the table movement, for a client,
|
14
|
+
# then the call to this attribute client.movements can take too much time and generates
|
15
|
+
# a query timeout exception.
|
16
|
+
#
|
17
|
+
# The call to this method may take too much time, but ti won't raise a query timeout.
|
18
|
+
#
|
19
|
+
def movements
|
20
|
+
ret = []
|
21
|
+
BlackStack::Movement.where(:id_client=>self.id).each { |o|
|
22
|
+
ret << o
|
23
|
+
print '.'
|
24
|
+
GC.start
|
25
|
+
DB.disconnect
|
26
|
+
}
|
27
|
+
ret
|
28
|
+
end
|
10
29
|
|
11
30
|
# how many minutes ago should have updated the table stat_balance with the amount and credits of this client, for each product.
|
12
31
|
def stat_balance_delay_minutes
|
@@ -137,7 +156,7 @@ module BlackStack
|
|
137
156
|
credits_paid = 0
|
138
157
|
|
139
158
|
#total_credits = 0.to_f - BlackStack::Balance.new(self.id, product_code).credits.to_f
|
140
|
-
#total_amount = 0.to_f - BlackStack::Balance.new(self.id, product_code).amount.to_f
|
159
|
+
#total_amount = 0.to_f - BlackStack::Balance.new(self.id, product_code).amount.to_f
|
141
160
|
|
142
161
|
self.movements.select { |o|
|
143
162
|
o.product_code.upcase == product_code.upcase
|
data/lib/movement.rb
CHANGED
@@ -138,7 +138,9 @@ module BlackStack
|
|
138
138
|
raise 'Movement must be either a payment or a bonus' if self.type != MOVEMENT_TYPE_ADD_PAYMENT && self.type != MOVEMENT_TYPE_ADD_BONUS
|
139
139
|
#puts
|
140
140
|
#puts "product_code:#{self.product_code}:."
|
141
|
+
|
141
142
|
# itero los pagos y bonos hechos por este mismo producto, desde el primer dia hasta este movimiento.
|
143
|
+
=begin
|
142
144
|
paid = 0
|
143
145
|
self.client.movements.select { |o|
|
144
146
|
(o.type == MOVEMENT_TYPE_ADD_PAYMENT || o.type == MOVEMENT_TYPE_ADD_BONUS) &&
|
@@ -149,14 +151,36 @@ module BlackStack
|
|
149
151
|
paid += (0.to_f - o.credits.to_f)
|
150
152
|
break if o.id.to_guid == self.id.to_guid
|
151
153
|
}
|
154
|
+
=end
|
155
|
+
paid = 0 - DB[
|
156
|
+
"select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
|
157
|
+
"from movement m with (nolock) " +
|
158
|
+
"where isnull(m.type, #{BlackStack::Movement::MOVEMENT_TYPE_ADD_PAYMENT.to_s}) in (#{BlackStack::Movement::MOVEMENT_TYPE_ADD_PAYMENT.to_s}, #{BlackStack::Movement::MOVEMENT_TYPE_ADD_BONUS.to_s}) " +
|
159
|
+
"and m.id_client='#{self.client.id.to_guid}' " +
|
160
|
+
"and isnull(m.credits,0) < 0 " +
|
161
|
+
"and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
|
162
|
+
"and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' "
|
163
|
+
].first[:n]
|
152
164
|
#puts "paid:#{paid.to_s}:."
|
165
|
+
|
166
|
+
=begin
|
153
167
|
# calculo los credito para este producto, desde el primer dia; incluyendo cosumo, expiraciones, ajustes.
|
154
168
|
consumed = self.client.movements.select { |o|
|
155
169
|
o.credits.to_f > 0 &&
|
156
170
|
o.product_code.upcase == self.product_code.upcase &&
|
157
171
|
o.create_time.to_time < registraton_time.to_time
|
158
172
|
}.inject(0) { |sum, o| sum.to_f + o.credits.to_f }.to_f
|
159
|
-
|
173
|
+
=end
|
174
|
+
consumed = DB[
|
175
|
+
"select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
|
176
|
+
"from movement m with (nolock) " +
|
177
|
+
"where m.id_client='#{self.client.id.to_guid}' " +
|
178
|
+
"and isnull(m.credits,0) > 0 " +
|
179
|
+
"and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
|
180
|
+
"and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' "
|
181
|
+
].first[:n]
|
182
|
+
#puts "consumed:#{consumed.to_s}:."
|
183
|
+
|
160
184
|
# calculo los creditos de este movimiento que voy a cancelar
|
161
185
|
credits = 0.to_f - self.credits.to_f
|
162
186
|
#puts "credits:#{credits.to_s}:."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invoicing_payments_processing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.64
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|