invoicing_payments_processing 1.1.79 → 1.1.82

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/balance.rb +26 -9
  3. data/lib/movement.rb +2 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bc4d1525e38dde0ee2bbd75d5d9e0998b8428bb
4
- data.tar.gz: e4ced70f73f3cfd8e567d76cd46571ca74f99609
3
+ metadata.gz: bb63d51d18a390bd5274c7eb67a3f20d2569b74e
4
+ data.tar.gz: 3fb279b56bd38f6a4643ea6b14816a38bf3c4c43
5
5
  SHA512:
6
- metadata.gz: 974ae0f07fc60ef3a79aac1ba71ef318fd6243159bb11e2c94a0a4ead79ec0093473b7144dc65c1856da48231b35576596634723e4ddd57fdaf69374768bac28
7
- data.tar.gz: 579d1efbe81561d8c93f7a2f5f6408e934e767422fbfacadb6954a34c5057dbb8f6c4efc3cae15f332f3f8b3effcca487251f2e5532b909cd0b98dc7e697cd13
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
data/lib/movement.rb CHANGED
@@ -155,7 +155,7 @@ module BlackStack
155
155
  =end
156
156
  q =
157
157
  "select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
158
- "from movement m with (nolock) " +
158
+ "from movement m with (nolock index(IX_movement__type__id_client__product_code__create_time_desc__credits_desc)) " +
159
159
  "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}) " +
160
160
  "and m.id_client='#{self.client.id.to_guid}' " +
161
161
  "and isnull(m.credits,0) < 0 " +
@@ -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) " +
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.79
4
+ version: 1.1.82
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-01-11 00:00:00.000000000 Z
11
+ date: 2022-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket