invoicing_payments_processing 1.1.65 → 1.1.70
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/invoice.rb +25 -23
- data/lib/invoicing_payments_processing.rb +1 -1
- data/lib/movement.rb +15 -12
- 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: f05d882295f7b20a1fb839c214ee3ea4b6d188f4
|
4
|
+
data.tar.gz: 624b138f5198234726a5fbe6f1c435269906d8bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae17e1103cf879ae064712f5dba900548e1fed506c716975113cd4987d58dd4fb2f71f668d70292cc2f528c2631456e443455f74c3a334cb98e52089e953dedd
|
7
|
+
data.tar.gz: 8d6ccf3797a3988488e7a2d3a826ce45e04465c8090a256a51fc33f51b11ddde2a314c13b87c1b5717b9ea6300b63b47ce86a7acc7ce461f38ef1fa0d327ef77
|
@@ -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
|
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,22 +137,23 @@ 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}) " +
|
@@ -160,27 +161,29 @@ module BlackStack
|
|
160
161
|
"and isnull(m.credits,0) < 0 " +
|
161
162
|
"and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
|
162
163
|
"and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' " +
|
163
|
-
"and m.
|
164
|
-
].first[:n]
|
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}:."
|
165
167
|
#puts "paid:#{paid.to_s}:."
|
166
|
-
|
167
168
|
=begin
|
168
169
|
# calculo los credito para este producto, desde el primer dia; incluyendo cosumo, expiraciones, ajustes.
|
169
|
-
|
170
|
+
consumed1 = self.client.movements.select { |o|
|
170
171
|
o.credits.to_f > 0 &&
|
171
172
|
o.product_code.upcase == self.product_code.upcase &&
|
172
173
|
o.create_time.to_time < registraton_time.to_time
|
173
174
|
}.inject(0) { |sum, o| sum.to_f + o.credits.to_f }.to_f
|
175
|
+
#puts "consumed1:#{consumed1.to_s}:."
|
174
176
|
=end
|
175
|
-
|
177
|
+
q =
|
176
178
|
"select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
|
177
179
|
"from movement m with (nolock) " +
|
178
180
|
"where m.id_client='#{self.client.id.to_guid}' " +
|
179
181
|
"and isnull(m.credits,0) > 0 " +
|
180
182
|
"and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
|
181
|
-
"and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' "
|
182
|
-
"and m.id <> '#{self.id.to_guid}' "
|
183
|
-
].first[:n]
|
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}:."
|
184
187
|
#puts "consumed:#{consumed.to_s}:."
|
185
188
|
|
186
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.70
|
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
|