invoicing_payments_processing 1.1.81 → 1.1.82

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/balance.rb +26 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9804c975a5b794fb9777ab72cd8cdea113ff411
4
- data.tar.gz: fc9936374a7279db9842d73e00ac8ccc9722deb5
3
+ metadata.gz: bb63d51d18a390bd5274c7eb67a3f20d2569b74e
4
+ data.tar.gz: 3fb279b56bd38f6a4643ea6b14816a38bf3c4c43
5
5
  SHA512:
6
- metadata.gz: 8ffe00fdff8e0e9a0438b845170cecd7cf90f80b5eb91740c352647d8b961f9646e6e12eef5faf774c97aad94ef426a82878794e3894a23afcd55239422771d7
7
- data.tar.gz: e44864018776d2be5b4f333cee6907a142b9203e48e33cb9957a7b53e9fbd5d247d516dc5383246827807b3872dd10b5d8ae1d6e9c9f3a304f2ec46e3ca9f2c7
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
- q =
15
- "select cast(sum(cast(amount as numeric(18,12))) as numeric(18,6)) as amount, sum(credits) as credits " +
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
- q =
22
- "select cast(sum(cast(amount as numeric(18,12))) as numeric(18,6)) as amount, sum(credits) as credits " +
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
- row = DB[q].first
29
- self.amount = row[:amount].to_f
30
- self.credits = row[:credits].to_f
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoicing_payments_processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.81
4
+ version: 1.1.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi