invoicing_payments_processing 1.1.81 → 1.1.82
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
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb63d51d18a390bd5274c7eb67a3f20d2569b74e
|
4
|
+
data.tar.gz: 3fb279b56bd38f6a4643ea6b14816a38bf3c4c43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc4ac3abb4249acc9a116cc14ef68c3da9ae616b9bee804597a1c5064be6c7c599f4fcd50ee5438546f755ee665fc96d5005e7698cc782733d60e2bc36d3c178
|
7
|
+
data.tar.gz: 41dcd3bf594051421bb73886428f1abb8b02e3c037ee23438c33bb2d35e319d29bccf2c579b64b354f95d7ea7c4192a439cdee2b7b920baa3aac8913bd0b3e97
|
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
|