invoicing_payments_processing 1.1.64 → 1.1.69
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 +4 -4
- data/lib/bufferpaypalnotification.rb +8 -3
- data/lib/extend_client_by_invoicing_payments_processing.rb +7 -3
- data/lib/invoice.rb +25 -23
- data/lib/invoicing_payments_processing.rb +1 -1
- data/lib/movement.rb +16 -11
- 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: 8a2630a4138eed9ce9bff82ca451f20580270ed4
|
4
|
+
data.tar.gz: d3889d1e0d0d880681b7bbc289c28b2032a349c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c3138defd98ac56b073e3b004eb81586bef46c462a2d9746512fd77e65ecd7b0595eff0b57e0163fec87d4ddc8604f349592abf55cd67424fedb02c4697c6c7
|
7
|
+
data.tar.gz: 26c8b39c421aa4fb18aa21f70d8ced37a117dd5d3263a2718e6d669575972b77fe93c7b9aff3ec1bdc26e982ffd1e43ed060e1bf62be4e761630823e8e1cb390
|
@@ -42,27 +42,32 @@ 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'
|
52
53
|
i = BlackStack::Invoice.where(:id=>self.invoice).first
|
53
54
|
c = i.client if !i.nil?
|
54
55
|
end
|
55
56
|
end
|
56
57
|
if c.nil?
|
58
|
+
puts 'get_client: b'
|
57
59
|
iid = self.invoice.split(".").last.to_s
|
58
60
|
if iid.guid?
|
61
|
+
puts 'get_client: b1'
|
59
62
|
i = BlackStack::Invoice.where(:id=>iid).first
|
60
63
|
c = i.client if !i.nil?
|
61
64
|
end
|
62
65
|
end
|
63
66
|
if c.nil?
|
67
|
+
puts 'get_client: c'
|
64
68
|
cid = self.invoice.split(".").first.to_s
|
65
69
|
if cid.guid?
|
70
|
+
puts 'get_client: c1'
|
66
71
|
c = BlackStack::Client.where(:id=>cid).first
|
67
72
|
end
|
68
73
|
end
|
@@ -17,12 +17,16 @@ module BlackStack
|
|
17
17
|
# The call to this method may take too much time, but ti won't raise a query timeout.
|
18
18
|
#
|
19
19
|
def movements
|
20
|
+
i = 0
|
20
21
|
ret = []
|
21
22
|
BlackStack::Movement.where(:id_client=>self.id).each { |o|
|
22
23
|
ret << o
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
i += 1
|
25
|
+
if i == 1000
|
26
|
+
i = 0
|
27
|
+
GC.start
|
28
|
+
DB.disconnect
|
29
|
+
end
|
26
30
|
}
|
27
31
|
ret
|
28
32
|
end
|
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
|
@@ -63,7 +63,7 @@ module BlackStack
|
|
63
63
|
|
64
64
|
def self.plan_descriptor(item_number)
|
65
65
|
plan = BlackStack::InvoicingPaymentsProcessing::plans_descriptor.select { |h| h[:item_number].to_s == item_number.to_s }.first
|
66
|
-
raise "Plan not found" if plan.nil?
|
66
|
+
raise "Plan not found (#{item_number.to_s})" if plan.nil?
|
67
67
|
plan
|
68
68
|
end
|
69
69
|
|
data/lib/movement.rb
CHANGED
@@ -137,48 +137,53 @@ module BlackStack
|
|
137
137
|
# the movment must be a payment or a bonus
|
138
138
|
raise 'Movement must be either a payment or a bonus' if self.type != MOVEMENT_TYPE_ADD_PAYMENT && self.type != MOVEMENT_TYPE_ADD_BONUS
|
139
139
|
#puts
|
140
|
+
#puts "id:#{self.id.to_guid}:."
|
140
141
|
#puts "product_code:#{self.product_code}:."
|
141
|
-
|
142
142
|
# itero los pagos y bonos hechos por este mismo producto, desde el primer dia hasta este movimiento.
|
143
143
|
=begin
|
144
|
-
|
144
|
+
paid1 = 0
|
145
145
|
self.client.movements.select { |o|
|
146
146
|
(o.type == MOVEMENT_TYPE_ADD_PAYMENT || o.type == MOVEMENT_TYPE_ADD_BONUS) &&
|
147
147
|
o.credits.to_f < 0 &&
|
148
148
|
o.product_code.upcase == self.product_code.upcase &&
|
149
149
|
o.create_time.to_time < registraton_time.to_time
|
150
150
|
}.sort_by { |o| o.create_time }.each { |o|
|
151
|
-
|
151
|
+
paid1 += (0.to_f - o.credits.to_f)
|
152
152
|
break if o.id.to_guid == self.id.to_guid
|
153
153
|
}
|
154
|
+
#puts "paid1:#{paid1.to_s}:."
|
154
155
|
=end
|
155
|
-
|
156
|
+
q =
|
156
157
|
"select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
|
157
158
|
"from movement m with (nolock) " +
|
158
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}) " +
|
159
160
|
"and m.id_client='#{self.client.id.to_guid}' " +
|
160
161
|
"and isnull(m.credits,0) < 0 " +
|
161
162
|
"and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
|
162
|
-
"and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' "
|
163
|
-
|
163
|
+
"and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' " +
|
164
|
+
"and m.create_time <= (select m2.create_time from movement m2 with (nolock) where m2.id='#{self.id.to_guid}') "
|
165
|
+
paid = 0 - DB[q].first[:n]
|
166
|
+
#puts "q:#{q.to_s}:."
|
164
167
|
#puts "paid:#{paid.to_s}:."
|
165
|
-
|
166
168
|
=begin
|
167
169
|
# calculo los credito para este producto, desde el primer dia; incluyendo cosumo, expiraciones, ajustes.
|
168
|
-
|
170
|
+
consumed1 = self.client.movements.select { |o|
|
169
171
|
o.credits.to_f > 0 &&
|
170
172
|
o.product_code.upcase == self.product_code.upcase &&
|
171
173
|
o.create_time.to_time < registraton_time.to_time
|
172
174
|
}.inject(0) { |sum, o| sum.to_f + o.credits.to_f }.to_f
|
175
|
+
#puts "consumed1:#{consumed1.to_s}:."
|
173
176
|
=end
|
174
|
-
|
177
|
+
q =
|
175
178
|
"select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
|
176
179
|
"from movement m with (nolock) " +
|
177
180
|
"where m.id_client='#{self.client.id.to_guid}' " +
|
178
181
|
"and isnull(m.credits,0) > 0 " +
|
179
182
|
"and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
|
180
|
-
"and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' "
|
181
|
-
|
183
|
+
"and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' " #+
|
184
|
+
# "and m.id <> '#{self.id.to_guid}' "
|
185
|
+
consumed = DB[q].first[:n]
|
186
|
+
#puts "q:#{q.to_s}:."
|
182
187
|
#puts "consumed:#{consumed.to_s}:."
|
183
188
|
|
184
189
|
# calculo los creditos de este movimiento que voy a cancelar
|
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.69
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|