invoicing_payments_processing 1.1.58 → 1.1.59

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffa569d58e22432b0ad9f214a6e83faef4f424c0
4
- data.tar.gz: 2dc2ab0fc91b4b7350985678eefb3865bbba9e2c
3
+ metadata.gz: 18728dea987541ecbbed7da0945b9699d258d626
4
+ data.tar.gz: 324265ee99c3bd89c570527250b9d5b6b7a805fd
5
5
  SHA512:
6
- metadata.gz: fdd78f088152e5373a9eff70f66d7ab5629dd290349e84e8d9aa7c91ebb0ad3530ab2c97efda541ad0c56de463b932f05fa9f3f9f6f2231009779fe83ac940b7
7
- data.tar.gz: 20252301b10406afce4d398ebf1e5bcd9965b985b84afcbd5be6b98519661ad97d7e42bdf9aeebbefa66845babd6197e56f3b4102aa94d66904329beae5acb5f
6
+ metadata.gz: 7d430dad7ca8f9dabc486352d1a169b56ef994bf515784d851b70e0a556baa495b52060d3905affc26c98a0f4ee3e9be0f630c7ba48c0e616a791181fb223116
7
+ data.tar.gz: 58b118d7c14d2ad05c4025996fc8b56f94e17624d00fe087998b648486e261468e60582c6b8dd85145d8b0f327317f3f9be14b53afeaa040ee951a88a6222152
@@ -8,6 +8,48 @@ module BlackStack
8
8
  one_to_many :customplans, :class=>:'BlackStack::CustomPlan', :key=>:id_client
9
9
  one_to_many :movements, :class=>:'BlackStack::Movement', :key=>:id_client
10
10
 
11
+ # how many minutes ago should have updated the table stat_balance with the amount and credits of this client, for each product.
12
+ def stat_balance_delay_minutes
13
+ row = DB[
14
+ "SELECT TOP 1 m.id " +
15
+ "FROM client c WITH (NOLOCK) " +
16
+ "JOIN movement m WITH (NOLOCK INDEX(IX_movement__id_client__create_time_desc)) ON ( c.id=m.id_client AND m.create_time > ISNULL(c.last_stat_balance_update_time, '1900-01-01') ) " +
17
+ "WHERE c.id = '#{self.id}' " +
18
+ "ORDER BY m.create_time DESC "
19
+ ].first
20
+
21
+ if row.nil?
22
+ return 0
23
+ else
24
+ return DB["SELECT DATEDIFF(MI, m.create_time, GETDATE()) AS n FROM movement m WITH (NOLOCK) WHERE m.id='#{row[:id]}'"].first[:n]
25
+ end
26
+ end
27
+
28
+ # update the table stat_balance with the amount and credits of this client, for each product.
29
+ def update_stat_balance(product_code=nil)
30
+ c = self
31
+ product_descriptors = BlackStack::InvoicingPaymentsProcessing::products_descriptor
32
+ product_descriptors.select! { |hprod| hprod[:code] == product_code } if !product_code.nil?
33
+ product_descriptors.each { |hprod|
34
+ row = DB[
35
+ "select isnull(sum(isnull(m.credits,0)),0) as credits, isnull(sum(isnull(m.amount,0)),0) as amount " +
36
+ # "from movement m with (nolock index(IX_movement__id_client__product_code)) " +
37
+ "from movement m with (nolock) " +
38
+ "where m.id_client='#{c.id}' " +
39
+ "and m.product_code='#{hprod[:code]}' "
40
+ ].first
41
+ credits = row[:credits]
42
+ amount = row[:amount]
43
+ row = DB["SELECT * FROM stat_balance WHERE id_client='#{c.id}' AND product_code='#{hprod[:code]}'"].first
44
+ if row.nil?
45
+ DB.execute("INSERT INTO stat_balance (id_client, product_code, amount, credits) VALUES ('#{c.id}', '#{hprod[:code]}', #{amount.to_s}, #{credits.to_s})")
46
+ else
47
+ DB.execute("UPDATE stat_balance SET amount=#{amount.to_s}, credits=#{credits.to_s} WHERE id_client='#{c.id}' AND product_code='#{hprod[:code]}'")
48
+ end
49
+ DB.execute("UPDATE client SET last_stat_balance_update_time=GETDATE() WHERE [id]='#{c.id}'")
50
+ }
51
+ end
52
+
11
53
  # crea/actualiza un registro en la tabla movment, reduciendo la cantidad de creditos y saldo que tiene el cliente, para el producto indicado en product_code.
12
54
  def consume(product_code, number_of_credits=1, description=nil)
13
55
  # create the consumtion
@@ -85,18 +85,7 @@ module BlackStack
85
85
  def allowedToAddRemoveItems?
86
86
  return (self.status == STATUS_UNPAID || self.status == nil) && (self.disabled_for_add_remove_items == false || self.disabled_for_add_remove_items == nil)
87
87
  end
88
-
89
- # envia un email transaccional con informacion de facturacion, y pasos a seguir despues del pago
90
- def notificationSubject()
91
- "We Received Your Payment"
92
- end
93
-
94
- #
95
- def notificationBody()
96
- "<p>We received your payment for a total of $#{("%.2f" % self.total()).to_s}.</p>" +
97
- "<p>You can find your invoice <a href='#{CS_HOME_PAGE}/member/invoice?iid=#{self.id.to_guid}'><b>here</b></a></p>"
98
- end
99
-
88
+
100
89
  #
101
90
  def number()
102
91
  self.id.to_guid
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.58
4
+ version: 1.1.59
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: 2020-11-06 00:00:00.000000000 Z
11
+ date: 2020-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket