invoicing_payments_processing 1.1.67 → 1.1.72
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bufferpaypalnotification.rb +15 -4
- data/lib/extend_client_by_invoicing_payments_processing.rb +7 -1
- data/lib/invoice.rb +25 -23
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20c2d6fe3d2345b3468bb8d4903626e2efbde5f6
|
4
|
+
data.tar.gz: 303e1555e77d60b5b8e20c4aa7a7e62c76c271ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23dad2e9670797a5ce76978577e92ada0b9c8b41c3fad46c8ad4ffe7a6443011b011b0a1bdf3aaff8e07d874a34cf236fbc5561874d368f8a0ae97a989ad90a0
|
7
|
+
data.tar.gz: 2d272bdea48b9320799a7231ec9598de1fd1c6c11ae839c51a45f4b42a4d6334fd6a034aa266c971f73442f8c505667847352e719d2dbdf0ade234dfb102b4c1
|
@@ -42,27 +42,38 @@ module BlackStack
|
|
42
42
|
# 3) haciendo coincidir el primer guid en el codigo de invoice, con el id del cliente
|
43
43
|
def get_client()
|
44
44
|
puts
|
45
|
-
puts "BlackStack::BufferPayPalNotification::get_client"
|
46
|
-
puts
|
47
|
-
puts "self.invoice:#{self.invoice.to_s}:."
|
45
|
+
puts "get_client: BlackStack::BufferPayPalNotification::get_client"
|
46
|
+
puts "get_client: self.invoice:#{self.invoice.to_s}:."
|
48
47
|
# obtengo el cliente que machea con este perfil
|
49
48
|
c = nil
|
50
49
|
if c.nil?
|
50
|
+
puts 'get_client: a'
|
51
51
|
if self.invoice.guid?
|
52
|
+
puts 'get_client: a1'
|
53
|
+
puts "get_client: #{self.invoice.to_s}"
|
52
54
|
i = BlackStack::Invoice.where(:id=>self.invoice).first
|
53
|
-
|
55
|
+
if !i.nil?
|
56
|
+
c = i.client
|
57
|
+
puts 'get_client: a1a'
|
58
|
+
else
|
59
|
+
puts 'get_client: a1b'
|
60
|
+
end
|
54
61
|
end
|
55
62
|
end
|
56
63
|
if c.nil?
|
64
|
+
puts 'get_client: b'
|
57
65
|
iid = self.invoice.split(".").last.to_s
|
58
66
|
if iid.guid?
|
67
|
+
puts 'get_client: b1'
|
59
68
|
i = BlackStack::Invoice.where(:id=>iid).first
|
60
69
|
c = i.client if !i.nil?
|
61
70
|
end
|
62
71
|
end
|
63
72
|
if c.nil?
|
73
|
+
puts 'get_client: c'
|
64
74
|
cid = self.invoice.split(".").first.to_s
|
65
75
|
if cid.guid?
|
76
|
+
puts 'get_client: c1'
|
66
77
|
c = BlackStack::Client.where(:id=>cid).first
|
67
78
|
end
|
68
79
|
end
|
@@ -32,11 +32,17 @@ module BlackStack
|
|
32
32
|
end
|
33
33
|
|
34
34
|
# how many minutes ago should have updated the table stat_balance with the amount and credits of this client, for each product.
|
35
|
+
# return a positive integer if either:
|
36
|
+
# 1. the client didn't update stats in the last 24 hours, or
|
37
|
+
# 2. the client has a new record in the table movements after its last update in the table stat_balance.
|
35
38
|
def stat_balance_delay_minutes
|
36
39
|
row = DB[
|
37
40
|
"SELECT TOP 1 m.id " +
|
38
41
|
"FROM client c WITH (NOLOCK) " +
|
39
|
-
"JOIN movement m WITH (NOLOCK INDEX(IX_movement__id_client__create_time_desc)) ON (
|
42
|
+
"JOIN movement m WITH (NOLOCK INDEX(IX_movement__id_client__create_time_desc)) ON ( " +
|
43
|
+
" c.id=m.id_client AND " +
|
44
|
+
" ( m.create_time > ISNULL(c.last_stat_balance_update_time, '1900-01-01') OR ISNULL(c.last_stat_balance_update_time, '2200-01-01') < DATEADD(DD,-1,GETDATE()) ) " +
|
45
|
+
") " +
|
40
46
|
"WHERE c.id = '#{self.id}' " +
|
41
47
|
"ORDER BY m.create_time DESC "
|
42
48
|
].first
|
data/lib/invoice.rb
CHANGED
@@ -625,29 +625,31 @@ module BlackStack
|
|
625
625
|
end # if net_amount < 0
|
626
626
|
# hago el reembolso de cada bono de este item
|
627
627
|
# si el balance quedo en negativo, entonces aplico otro ajuste
|
628
|
-
h[:bonus_plans].
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
628
|
+
if !h[:bonus_plans].nil?
|
629
|
+
h[:bonus_plans].each { |bonus|
|
630
|
+
i = BlackStack::InvoicingPaymentsProcessing::plans_descriptor.select { |obj| obj[:item_number] == bonus[:item_number] }.first
|
631
|
+
j = BlackStack::InvoicingPaymentsProcessing::products_descriptor.select { |obj| obj[:code] == i[:product_code] }.first
|
632
|
+
item2 = BlackStack::InvoiceItem.new()
|
633
|
+
item2.id = guid()
|
634
|
+
item2.id_invoice = self.id
|
635
|
+
item2.unit_price = 0
|
636
|
+
item2.units = -i[:credits]
|
637
|
+
item2.amount = 0
|
638
|
+
item2.product_code = i[:product_code].to_s
|
639
|
+
item2.item_number = i[:item_number].to_s
|
640
|
+
item2.detail = 'Bonus Refund'
|
641
|
+
item2.description = j[:description].to_s
|
642
|
+
item2.save()
|
643
|
+
BlackStack::Movement.new().parse(item2, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Bonus Refund of <a href='/member/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.").save()
|
644
|
+
net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).amount.to_f
|
645
|
+
net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).credits.to_f
|
646
|
+
if net_amount <= 0 && net_credits < 0
|
647
|
+
adjust = self.client.adjustment(i[:product_code].to_s, net_amount, net_credits, "Adjustment for Negative Balance After Bonus Refund of <a href='/member/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.")
|
648
|
+
adjust.id_invoice_item = item1.id
|
649
|
+
adjust.save
|
650
|
+
end # if net_amount < 0
|
651
|
+
}
|
652
|
+
end # if !h[:bonus_plans].nil?
|
651
653
|
# release resources
|
652
654
|
DB.disconnect
|
653
655
|
GC.start
|