invoicing_payments_processing 1.1.53 → 1.1.59
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/balance.rb +15 -8
- data/lib/bufferpaypalnotification.rb +1 -1
- data/lib/extend_client_by_invoicing_payments_processing.rb +42 -0
- data/lib/invoice.rb +2 -13
- data/lib/invoicing_payments_processing.rb +16 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18728dea987541ecbbed7da0945b9699d258d626
|
4
|
+
data.tar.gz: 324265ee99c3bd89c570527250b9d5b6b7a805fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d430dad7ca8f9dabc486352d1a169b56ef994bf515784d851b70e0a556baa495b52060d3905affc26c98a0f4ee3e9be0f630c7ba48c0e616a791181fb223116
|
7
|
+
data.tar.gz: 58b118d7c14d2ad05c4025996fc8b56f94e17624d00fe087998b648486e261468e60582c6b8dd85145d8b0f327317f3f9be14b53afeaa040ee951a88a6222152
|
data/lib/balance.rb
CHANGED
@@ -10,14 +10,21 @@ module BlackStack
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def calculate()
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
if !self.up_time.nil?
|
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
|
+
"where id_client='#{self.client.id}' " +
|
18
|
+
"and product_code='#{self.product_code}' " +
|
19
|
+
"and create_time < '#{self.up_time.to_time.to_sql}' "
|
20
|
+
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) " +
|
24
|
+
"where x.id_client='#{self.client.id}' " +
|
25
|
+
"and x.product_code='#{self.product_code}' "
|
26
|
+
end
|
27
|
+
|
21
28
|
row = DB[q].first
|
22
29
|
self.amount = row[:amount].to_f
|
23
30
|
self.credits = row[:credits].to_f
|
@@ -403,7 +403,7 @@ puts "self.invoice:#{self.invoice.to_s}:."
|
|
403
403
|
"SELECT TOP 1 i.id " +
|
404
404
|
"FROM buffer_paypal_notification b " +
|
405
405
|
"JOIN invoice i ON ( b.id=i.id_buffer_paypal_notification AND i.status=#{BlackStack::Invoice::STATUS_PAID.to_s} ) " +
|
406
|
-
"WHERE b.invoice='#{b.invoice
|
406
|
+
"WHERE b.invoice='#{b.invoice}' " +
|
407
407
|
"ORDER BY i.create_time DESC "
|
408
408
|
].first
|
409
409
|
if row.nil?
|
@@ -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
|
data/lib/invoice.rb
CHANGED
@@ -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
|
@@ -246,7 +235,7 @@ module BlackStack
|
|
246
235
|
end
|
247
236
|
|
248
237
|
# return url
|
249
|
-
"#{BlackStack::InvoicingPaymentsProcessing::
|
238
|
+
"#{BlackStack::InvoicingPaymentsProcessing::paypal_orders_url}/cgi-bin/webscr?" + URI.encode_www_form(values)
|
250
239
|
end
|
251
240
|
|
252
241
|
# retorna true si el estado de la factura sea NULL o UNPAID
|
@@ -13,10 +13,19 @@ module BlackStack
|
|
13
13
|
|
14
14
|
# static attributes
|
15
15
|
@@paypal_business_email = "sardi.leandro.daniel@gmail.com"
|
16
|
+
@@paypal_orders_url = BlackStack::InvoicingPaymentsProcessing::PAYPAL_ORDERS_URL
|
17
|
+
@@paypal_ipn_listener = "#{BlackStack::Pampa::api_url.to_s}/api1.3/accounting/paypal/notify_new_invoice.json"
|
18
|
+
|
16
19
|
@@products_descriptor = []
|
17
20
|
@@plans_descriptor = []
|
18
|
-
|
21
|
+
|
19
22
|
# getters & setters
|
23
|
+
def self.set_config(h)
|
24
|
+
@@paypal_business_email = h[:paypal_business_email]
|
25
|
+
@@paypal_orders_url = h[:paypal_orders_url]
|
26
|
+
@@paypal_ipn_listener = h[:paypal_ipn_listener]
|
27
|
+
end
|
28
|
+
|
20
29
|
def self.set_paypal_business_email(email)
|
21
30
|
@@paypal_business_email = email
|
22
31
|
end # def self.set_paypal_business_email
|
@@ -25,10 +34,14 @@ module BlackStack
|
|
25
34
|
@@paypal_business_email
|
26
35
|
end # def self.set_paypal_business_email
|
27
36
|
|
28
|
-
def self.
|
29
|
-
|
37
|
+
def self.paypal_orders_url()
|
38
|
+
@@paypal_orders_url
|
30
39
|
end
|
31
40
|
|
41
|
+
def self.paypal_ipn_listener()
|
42
|
+
@@paypal_ipn_listener
|
43
|
+
end
|
44
|
+
|
32
45
|
|
33
46
|
def self.set_products(h)
|
34
47
|
@@products_descriptor = h
|
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.
|
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-
|
11
|
+
date: 2020-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|