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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e09a21bacef2cf167afd383956f5e60118528b1c
4
- data.tar.gz: f326089a00630e7eb3e91c4f06272c154794fa81
3
+ metadata.gz: d3c8a07288e91aab43e702ef271aff19c6aea13d
4
+ data.tar.gz: 25af23560fbbbe4f534dff69f497760e9a96da72
5
5
  SHA512:
6
- metadata.gz: 4631bac0fcc2b95a5babc0c65cadfea9efbd291c3ecaf56e03a58562c418e153e5c4163e6a49bb076b58f1d6610795c63768f0d29595b362f3982870694438d0
7
- data.tar.gz: c8eb03127d5d5c9544bb6d9479dcec76b0d6a801aeea8a5217b64db6e82ee4a9b5058d4984b9a48e4c5480492b3165f791b0449d89c0588c878eecc5202437dd
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
- 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
@@ -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
- row = DB[
64
- "select isnull(sum(isnull(m.credits,0)),0) as credits, isnull(sum(isnull(m.amount,0)),0) as amount " +
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
- credits = row[:credits]
71
- amount = row[:amount]
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(IX_movement__type__id_client__product_code__create_time_desc__credits_asc)) " +
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.80
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-04-13 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket