invoicing_payments_processing 1.1.76 → 1.1.80
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/invoice.rb +21 -13
- data/lib/movement.rb +2 -2
- 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: e09a21bacef2cf167afd383956f5e60118528b1c
|
4
|
+
data.tar.gz: f326089a00630e7eb3e91c4f06272c154794fa81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4631bac0fcc2b95a5babc0c65cadfea9efbd291c3ecaf56e03a58562c418e153e5c4163e6a49bb076b58f1d6610795c63768f0d29595b362f3982870694438d0
|
7
|
+
data.tar.gz: c8eb03127d5d5c9544bb6d9479dcec76b0d6a801aeea8a5217b64db6e82ee4a9b5058d4984b9a48e4c5480492b3165f791b0449d89c0588c878eecc5202437dd
|
data/lib/invoice.rb
CHANGED
@@ -201,7 +201,15 @@ module BlackStack
|
|
201
201
|
|
202
202
|
values[:a3] = 0
|
203
203
|
self.items.each { |i|
|
204
|
-
|
204
|
+
puts
|
205
|
+
puts
|
206
|
+
puts "i.id.to_s:#{i.id.to_s}:."
|
207
|
+
puts "i.id_invoice.to_s:#{i.id_invoice.to_s}:."
|
208
|
+
puts "i.units.to_i.to_s:#{i.units.to_i.to_s}:."
|
209
|
+
puts "i.plan_descriptor[:trial_credits].to_i.to_s:#{i.plan_descriptor[:trial_credits].to_i.to_s}:."
|
210
|
+
puts
|
211
|
+
puts
|
212
|
+
if trial1 && i.units.to_i!=i.plan_descriptor[:trial_credits].to_i
|
205
213
|
raise 'Cannot order more than 1 package and trial in the same invoice'
|
206
214
|
elsif trial1
|
207
215
|
values[:a3] += i.plan_descriptor[:fee].to_f
|
@@ -317,7 +325,7 @@ module BlackStack
|
|
317
325
|
#
|
318
326
|
BlackStack::Movement.where(:id_invoice_item => item.id).all { |mov|
|
319
327
|
#
|
320
|
-
mov.expire(self.billing_period_from, "Expiration of <a href='/
|
328
|
+
mov.expire(self.billing_period_from, "Expiration of <a href='/settings/record?rid=#{mov.id.to_guid}'>record:#{mov.id.to_guid}</a> because subscription renewal.") if mov.expiration_on_next_payment == true
|
321
329
|
#
|
322
330
|
DB.disconnect
|
323
331
|
GC.start
|
@@ -334,7 +342,7 @@ module BlackStack
|
|
334
342
|
# obtengo descriptor del producto
|
335
343
|
prod = BlackStack::InvoicingPaymentsProcessing.product_descriptor(plan[:product_code])
|
336
344
|
# registro el pago
|
337
|
-
BlackStack::Movement.new().parse(item, BlackStack::Movement::MOVEMENT_TYPE_ADD_PAYMENT, "Payment of <a href='/
|
345
|
+
BlackStack::Movement.new().parse(item, BlackStack::Movement::MOVEMENT_TYPE_ADD_PAYMENT, "Payment of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.", payment_time, item.id).save()
|
338
346
|
# agrego los bonos de este plan
|
339
347
|
if !plan[:bonus_plans].nil?
|
340
348
|
plan[:bonus_plans].each { |h|
|
@@ -348,7 +356,7 @@ module BlackStack
|
|
348
356
|
bonus.units = plan_bonus[:credits] * item.number_of_packages # agrego los creditos del bono, multiplicado por la cantiad de paquetes
|
349
357
|
bonus.amount = 0
|
350
358
|
bonus.item_number = plan_bonus[:item_number]
|
351
|
-
BlackStack::Movement.new().parse(bonus, BlackStack::Movement::MOVEMENT_TYPE_ADD_BONUS, "Bonus from the <a href='/
|
359
|
+
BlackStack::Movement.new().parse(bonus, BlackStack::Movement::MOVEMENT_TYPE_ADD_BONUS, "Bonus from the <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.", payment_time, item.id).save()
|
352
360
|
}
|
353
361
|
end # if !plan[:bonus_plans].nil?
|
354
362
|
#
|
@@ -615,11 +623,11 @@ module BlackStack
|
|
615
623
|
item1.save()
|
616
624
|
# hago el reembolso de este item
|
617
625
|
# si el balance quedo en negativo, entonces aplico otro ajuste
|
618
|
-
BlackStack::Movement.new().parse(item1, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Full Refund of <a href='/
|
626
|
+
BlackStack::Movement.new().parse(item1, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Full Refund of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.").save()
|
619
627
|
net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, u.product_code.to_s).amount.to_f
|
620
628
|
net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, u.product_code.to_s).credits.to_f
|
621
629
|
if net_amount <= 0 && net_credits < 0
|
622
|
-
adjust = self.client.adjustment(u.product_code.to_s, net_amount, net_credits, "Adjustment for Negative Balance After Refund of <a href='/
|
630
|
+
adjust = self.client.adjustment(u.product_code.to_s, net_amount, net_credits, "Adjustment for Negative Balance After Refund of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.")
|
623
631
|
adjust.id_invoice_item = item1.id
|
624
632
|
adjust.save
|
625
633
|
end # if net_amount < 0
|
@@ -640,11 +648,11 @@ module BlackStack
|
|
640
648
|
item2.detail = 'Bonus Refund'
|
641
649
|
item2.description = j[:description].to_s
|
642
650
|
item2.save()
|
643
|
-
BlackStack::Movement.new().parse(item2, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Bonus Refund of <a href='/
|
651
|
+
BlackStack::Movement.new().parse(item2, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Bonus Refund of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.").save()
|
644
652
|
net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).amount.to_f
|
645
653
|
net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).credits.to_f
|
646
654
|
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='/
|
655
|
+
adjust = self.client.adjustment(i[:product_code].to_s, net_amount, net_credits, "Adjustment for Negative Balance After Bonus Refund of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.")
|
648
656
|
adjust.id_invoice_item = item1.id
|
649
657
|
adjust.save
|
650
658
|
end # if net_amount < 0
|
@@ -676,11 +684,11 @@ module BlackStack
|
|
676
684
|
item1.detail = t.detail.to_s
|
677
685
|
item1.description = t.description.to_s
|
678
686
|
item1.save()
|
679
|
-
BlackStack::Movement.new().parse(item1, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Partial Refund of <a href='/
|
687
|
+
BlackStack::Movement.new().parse(item1, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Partial Refund of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.").save()
|
680
688
|
# agrego un ajuste por el redondeo a una cantidad entera de creditos
|
681
689
|
if float_units.to_f != units.to_f
|
682
690
|
adjustment_amount = unit_price.to_f * (units.to_f - float_units.to_f)
|
683
|
-
adjust = self.client.adjustment(t.product_code.to_s, adjustment_amount, 0, "Adjustment for Refund of <a href='/
|
691
|
+
adjust = self.client.adjustment(t.product_code.to_s, adjustment_amount, 0, "Adjustment for Refund of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.", BlackStack::Movement::MOVEMENT_TYPE_REFUND_ADJUSTMENT)
|
684
692
|
adjust.id_invoice_item = item1.id
|
685
693
|
adjust.save
|
686
694
|
end
|
@@ -688,7 +696,7 @@ module BlackStack
|
|
688
696
|
net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, t.product_code.to_s).amount.to_f
|
689
697
|
net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, t.product_code.to_s).credits.to_f
|
690
698
|
if net_amount < 0 && net_credits < 0
|
691
|
-
adjust = self.client.adjustment(t.product_code.to_s, net_amount, net_credits, "Adjustment for Negative Balance After Refund of <a href='/
|
699
|
+
adjust = self.client.adjustment(t.product_code.to_s, net_amount, net_credits, "Adjustment for Negative Balance After Refund of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.")
|
692
700
|
adjust.id_invoice_item = item1.id
|
693
701
|
adjust.save
|
694
702
|
end # if net_amount < 0
|
@@ -714,11 +722,11 @@ module BlackStack
|
|
714
722
|
item2.detail = 'Bonus Refund'
|
715
723
|
item2.description = j[:description].to_s
|
716
724
|
item2.save()
|
717
|
-
BlackStack::Movement.new().parse(item2, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Bonus Refund of <a href='/
|
725
|
+
BlackStack::Movement.new().parse(item2, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Bonus Refund of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.").save()
|
718
726
|
net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).amount.to_f
|
719
727
|
net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).credits.to_f
|
720
728
|
if net_amount <= 0 && net_credits < 0
|
721
|
-
adjust = self.client.adjustment(i[:product_code].to_s, net_amount, net_credits, "Adjustment for Negative Balance After Bonus Refund of <a href='/
|
729
|
+
adjust = self.client.adjustment(i[:product_code].to_s, net_amount, net_credits, "Adjustment for Negative Balance After Bonus Refund of <a href='/settings/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.")
|
722
730
|
adjust.id_invoice_item = item1.id
|
723
731
|
adjust.save
|
724
732
|
end # if net_amount < 0
|
data/lib/movement.rb
CHANGED
@@ -155,7 +155,7 @@ module BlackStack
|
|
155
155
|
=end
|
156
156
|
q =
|
157
157
|
"select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
|
158
|
-
"from movement m with (nolock) " +
|
158
|
+
"from movement m with (nolock index(IX_movement__type__id_client__product_code__create_time_desc__credits_desc)) " +
|
159
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
160
|
"and m.id_client='#{self.client.id.to_guid}' " +
|
161
161
|
"and isnull(m.credits,0) < 0 " +
|
@@ -176,7 +176,7 @@ module BlackStack
|
|
176
176
|
=end
|
177
177
|
q =
|
178
178
|
"select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
|
179
|
-
"from movement m with (nolock) " +
|
179
|
+
"from movement m with (nolock index(IX_movement__type__id_client__product_code__create_time_desc__credits_asc)) " +
|
180
180
|
"where m.id_client='#{self.client.id.to_guid}' " +
|
181
181
|
"and isnull(m.credits,0) > 0 " +
|
182
182
|
"and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
|
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.80
|
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:
|
11
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|