invoicing_payments_processing 1.1.80 → 1.1.83
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/balance.rb +26 -9
- data/lib/extend_client_by_invoicing_payments_processing.rb +16 -9
- data/lib/movement.rb +1 -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: d3c8a07288e91aab43e702ef271aff19c6aea13d
|
4
|
+
data.tar.gz: 25af23560fbbbe4f534dff69f497760e9a96da72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faeeefe7f6d2421305f39334613c030f42c5bec240249e04886c6392d4e95fc706a95db621284a150eb8b349b383d293790130cea9d8e5aa593bda74c240a7c3
|
7
|
+
data.tar.gz: bef0624e6681b9ceb017f6ce1ee0ba64004bac928a41916a9fbe85291b7367a8f51d1ce27da30f1a3e9a0f75a0d0afa6a3a64ae2020b12a0169cc8d5543ce374
|
data/lib/balance.rb
CHANGED
@@ -10,24 +10,41 @@ module BlackStack
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def calculate(use_stat_balance=true)
|
13
|
+
q1 = nil
|
14
|
+
q2 = nil
|
15
|
+
|
13
16
|
if !self.up_time.nil? || !use_stat_balance
|
14
|
-
|
15
|
-
"select cast(sum(cast(amount as numeric(18,12))) as numeric(18,6)) as amount
|
16
|
-
"from movement with (nolock) " +
|
17
|
+
q1 =
|
18
|
+
"select cast(sum(cast(amount as numeric(18,12))) as numeric(18,6)) as amount " +
|
19
|
+
"from movement with (nolock index(IX_movement__id_client__product_code__create_time__amount)) " +
|
20
|
+
"where id_client='#{self.client.id}' " +
|
21
|
+
"and product_code='#{self.product_code}' " +
|
22
|
+
"and create_time <= '#{self.up_time.to_time.to_sql}' "
|
23
|
+
|
24
|
+
q2 =
|
25
|
+
"select sum(credits) as credits " +
|
26
|
+
"from movement with (nolock index(IX_movement__id_client__product_code__create_time__credits)) " +
|
17
27
|
"where id_client='#{self.client.id}' " +
|
18
28
|
"and product_code='#{self.product_code}' " +
|
19
29
|
"and create_time <= '#{self.up_time.to_time.to_sql}' "
|
20
30
|
else
|
21
|
-
|
22
|
-
"select cast(sum(cast(amount as numeric(18,12))) as numeric(18,6)) as amount
|
23
|
-
"from stat_balance x with (nolock) " +
|
31
|
+
q1 =
|
32
|
+
"select cast(sum(cast(amount as numeric(18,12))) as numeric(18,6)) as amount " +
|
33
|
+
"from stat_balance x with (nolock index(IX_movement__id_client__product_code__create_time__amount)) " +
|
34
|
+
"where x.id_client='#{self.client.id}' " +
|
35
|
+
"and x.product_code='#{self.product_code}' "
|
36
|
+
|
37
|
+
q2 =
|
38
|
+
"select sum(credits) as credits " +
|
39
|
+
"from stat_balance x with (nolock index(IX_movement__id_client__product_code__create_time__credits)) " +
|
24
40
|
"where x.id_client='#{self.client.id}' " +
|
25
41
|
"and x.product_code='#{self.product_code}' "
|
26
42
|
end
|
27
43
|
#puts "Balance.calculate:q:#{q}:."
|
28
|
-
|
29
|
-
|
30
|
-
self.
|
44
|
+
row1 = DB[q1].first
|
45
|
+
row2 = DB[q2].first
|
46
|
+
self.amount = row1[:amount].to_f
|
47
|
+
self.credits = row2[:credits].to_f
|
31
48
|
# libero recursos
|
32
49
|
DB.disconnect
|
33
50
|
GC.start
|
@@ -60,15 +60,22 @@ module BlackStack
|
|
60
60
|
product_descriptors = BlackStack::InvoicingPaymentsProcessing::products_descriptor.clone
|
61
61
|
product_descriptors.select! { |hprod| hprod[:code] == product_code } if !product_code.nil?
|
62
62
|
product_descriptors.each { |hprod|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
].first
|
70
|
-
|
71
|
-
|
63
|
+
row1 = DB["
|
64
|
+
select isnull(sum(isnull(m.credits,0)),0) as credits
|
65
|
+
from movement m with (nolock index(IX_movement__id_client__product_code))
|
66
|
+
--from movement m with (nolock)
|
67
|
+
where m.id_client='#{c.id}'
|
68
|
+
and m.product_code='#{hprod[:code]}'
|
69
|
+
"].first
|
70
|
+
row2 = DB["
|
71
|
+
select isnull(sum(isnull(m.amount,0)),0) as amount
|
72
|
+
from movement m with (nolock index(IX_movement__id_client__product_code))
|
73
|
+
--from movement m with (nolock)
|
74
|
+
where m.id_client='#{c.id}'
|
75
|
+
and m.product_code='#{hprod[:code]}'
|
76
|
+
"].first
|
77
|
+
credits = row1[:credits]
|
78
|
+
amount = row2[:amount]
|
72
79
|
row = DB["SELECT * FROM stat_balance WHERE id_client='#{c.id}' AND product_code='#{hprod[:code]}'"].first
|
73
80
|
if row.nil?
|
74
81
|
DB.execute("INSERT INTO stat_balance (id_client, product_code, amount, credits) VALUES ('#{c.id}', '#{hprod[:code]}', #{amount.to_s}, #{credits.to_s})")
|
data/lib/movement.rb
CHANGED
@@ -176,7 +176,7 @@ module BlackStack
|
|
176
176
|
=end
|
177
177
|
q =
|
178
178
|
"select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
|
179
|
-
"from movement m with (nolock index(
|
179
|
+
"from movement m with (nolock index(IX_movement__id_client__product_code__create_time_desc__credits_asc)) " +
|
180
180
|
"where m.id_client='#{self.client.id.to_guid}' " +
|
181
181
|
"and isnull(m.credits,0) > 0 " +
|
182
182
|
"and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
|
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.83
|
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: 2022-
|
11
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|