invoicing_payments_processing 1.1.49 → 1.1.50
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 +3 -1
- data/lib/extend_client_by_invoicing_payments_processing.rb +3 -3
- data/lib/invoice.rb +61 -5
- 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: d1d5cea3030eeebca8abd0f7cded9898a4a08dd5
|
4
|
+
data.tar.gz: cd33004f6351894488bed5230a70f563f4056a93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e031aa9fef8a49e27578d6f8394935a99b65ba3ee7493e181390dd1351c00eab3f7688ccb11453a4de830fbae625b26ff08c1f48044f0d3190a3e669136f60bc
|
7
|
+
data.tar.gz: 60a4e90521009931f1f71123c424b696fceb3aec9bcaf7078bd9a8791b0586739c7caafcc17261421963e76ef2284d2914053b700f5dd529360e17704ff8aa00
|
@@ -316,10 +316,12 @@ module BlackStack
|
|
316
316
|
j.next(i)
|
317
317
|
|
318
318
|
# creo el milestone con todo el credito pendiente que tiene esta subscripcion
|
319
|
+
=begin
|
320
|
+
# deprecated
|
319
321
|
buff_payment = i.buffer_paypal_notification
|
320
322
|
buff_signup = BlackStack::BufferPayPalNotification.where(:txn_type=>"subscr_signup", :subscr_id=>buff_payment.subscr_id).first
|
321
323
|
subs = buff_signup == nil ? nil : BlackStack::PayPalSubscription.where(:id_buffer_paypal_notification => buff_signup.id).first
|
322
|
-
|
324
|
+
=end
|
323
325
|
elsif (b.txn_type == BlackStack::BufferPayPalNotification::TXN_TYPE_SUBSCRIPTION_SIGNUP)
|
324
326
|
# crear un registro en la tabla paypal_subscriptions
|
325
327
|
if BlackStack::PayPalSubscription.load(b.to_hash) != nil
|
@@ -35,7 +35,7 @@ module BlackStack
|
|
35
35
|
total_amount = 0.to_f - BlackStack::Balance.new(self.id, product_code).amount.to_f
|
36
36
|
sleep(2) # delay to ensure the time of the bonus movement will be later than the time of the consumption movement
|
37
37
|
if total_credits < 0
|
38
|
-
self.adjustment(product_code, total_amount, total_credits, 'Adjustment Because Quota Has Been Exceeded.')
|
38
|
+
self.adjustment(product_code, total_amount, total_credits, 'Adjustment Because Quota Has Been Exceeded (1).')
|
39
39
|
end
|
40
40
|
# recaculate amounts in both consumptions and expirations - CANCELADO - Se debe hacer offline
|
41
41
|
#self.recalculate(product_code)
|
@@ -97,7 +97,7 @@ module BlackStack
|
|
97
97
|
|
98
98
|
self.movements.select { |o|
|
99
99
|
o.product_code.upcase == product_code.upcase
|
100
|
-
}.sort_by { |o| o.create_time }.each { |o|
|
100
|
+
}.sort_by { |o| [o.create_time, o.type] }.each { |o| # se ordena por o.create_time, pero tmabien por o.type para procesar primero los pagos y bonos
|
101
101
|
#if o.credits.to_f < 0 # payment or bonus
|
102
102
|
# if o.credits.to_f > 0 && ( o.type==BlackStack::Movement::MOVEMENT_TYPE_CANCELATION || o.type==BlackStack::Movement::MOVEMENT_TYPE_EXPIRATION ) # consumption or expiration
|
103
103
|
# consumption or expiration or bonus
|
@@ -118,7 +118,7 @@ module BlackStack
|
|
118
118
|
total_credits = credits_paid
|
119
119
|
total_amount = amount_paid
|
120
120
|
if total_credits < 0
|
121
|
-
self. adjustment(product_code, total_amount, total_credits, 'Adjustment Because Quota Has Been Exceeded.', BlackStack::Movement::MOVEMENT_TYPE_ADJUSTMENT, o.create_time)
|
121
|
+
self. adjustment(product_code, total_amount, total_credits, 'Adjustment Because Quota Has Been Exceeded (2).', BlackStack::Movement::MOVEMENT_TYPE_ADJUSTMENT, o.create_time)
|
122
122
|
amount_paid = 0.to_f
|
123
123
|
credits_paid = 0.to_i
|
124
124
|
end
|
data/lib/invoice.rb
CHANGED
@@ -624,21 +624,47 @@ module BlackStack
|
|
624
624
|
item1.detail = u.detail.to_s
|
625
625
|
item1.description = u.description.to_s
|
626
626
|
item1.save()
|
627
|
+
# hago el reembolso de este item
|
628
|
+
# si el balance quedo en negativo, entonces aplico otro ajuste
|
627
629
|
BlackStack::Movement.new().parse(item1, BlackStack::Movement::MOVEMENT_TYPE_REFUND_BALANCE, "Full Refund of <a href='/member/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.").save()
|
628
|
-
# si el balance quedo en negativo, entonces aplico otro ajuste
|
629
630
|
net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, u.product_code.to_s).amount.to_f
|
630
631
|
net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, u.product_code.to_s).credits.to_f
|
631
|
-
if net_amount
|
632
|
+
if net_amount <= 0 && net_credits < 0
|
632
633
|
adjust = self.client.adjustment(u.product_code.to_s, net_amount, net_credits, "Adjustment for Negative Balance After Refund of <a href='/member/invoice?iid=#{self.id.to_guid}'>invoice:#{self.id.to_guid}</a>.")
|
633
634
|
adjust.id_invoice_item = item1.id
|
634
635
|
adjust.save
|
635
636
|
end # if net_amount < 0
|
637
|
+
# hago el reembolso de cada bono de este item
|
638
|
+
# si el balance quedo en negativo, entonces aplico otro ajuste
|
639
|
+
h[:bonus_plans].each { |bonus|
|
640
|
+
i = BlackStack::InvoicingPaymentsProcessing::plans_descriptor.select { |obj| obj[:item_number] == bonus[:item_number] }.first
|
641
|
+
j = BlackStack::InvoicingPaymentsProcessing::products_descriptor.select { |obj| obj[:code] == i[:product_code] }.first
|
642
|
+
item2 = BlackStack::InvoiceItem.new()
|
643
|
+
item2.id = guid()
|
644
|
+
item2.id_invoice = self.id
|
645
|
+
item2.unit_price = 0
|
646
|
+
item2.units = -i[:credits]
|
647
|
+
item2.amount = 0
|
648
|
+
item2.product_code = i[:product_code].to_s
|
649
|
+
item2.item_number = i[:item_number].to_s
|
650
|
+
item2.detail = 'Bonus Refund'
|
651
|
+
item2.description = j[:description].to_s
|
652
|
+
item2.save()
|
653
|
+
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()
|
654
|
+
net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).amount.to_f
|
655
|
+
net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).credits.to_f
|
656
|
+
if net_amount <= 0 && net_credits < 0
|
657
|
+
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>.")
|
658
|
+
adjust.id_invoice_item = item1.id
|
659
|
+
adjust.save
|
660
|
+
end # if net_amount < 0
|
661
|
+
}
|
636
662
|
# release resources
|
637
663
|
DB.disconnect
|
638
664
|
GC.start
|
639
665
|
} # i.items.each { |u|
|
640
666
|
# reembolso parcial de una factura con un unico item
|
641
|
-
elsif i.items.size == 1
|
667
|
+
elsif i.items.size == 1 # and we know that: total < -payment_gross, so it is a partial refund
|
642
668
|
t = i.items.first
|
643
669
|
#
|
644
670
|
amount = -payment_gross.to_f
|
@@ -675,9 +701,39 @@ module BlackStack
|
|
675
701
|
adjust.id_invoice_item = item1.id
|
676
702
|
adjust.save
|
677
703
|
end # if net_amount < 0
|
704
|
+
|
678
705
|
# recalculo todos los consumos y expiraciones - CANCELADO - Debe hacerse offline
|
679
|
-
# self.client.recalculate(t.product_code.to_s)
|
680
|
-
|
706
|
+
# => self.client.recalculate(t.product_code.to_s)
|
707
|
+
|
708
|
+
# si el cliente se quedo sin saldo luego del reembolso parcial
|
709
|
+
if net_amount <= 0
|
710
|
+
# hago el reembolso de cada bono de este item
|
711
|
+
# si el balance quedo en negativo, entonces aplico otro ajuste
|
712
|
+
h[:bonus_plans].each { |bonus|
|
713
|
+
i = BlackStack::InvoicingPaymentsProcessing::plans_descriptor.select { |obj| obj[:item_number] == bonus[:item_number] }.first
|
714
|
+
j = BlackStack::InvoicingPaymentsProcessing::products_descriptor.select { |obj| obj[:code] == i[:product_code] }.first
|
715
|
+
item2 = BlackStack::InvoiceItem.new()
|
716
|
+
item2.id = guid()
|
717
|
+
item2.id_invoice = self.id
|
718
|
+
item2.unit_price = 0
|
719
|
+
item2.units = -i[:credits]
|
720
|
+
item2.amount = 0
|
721
|
+
item2.product_code = i[:product_code].to_s
|
722
|
+
item2.item_number = i[:item_number].to_s
|
723
|
+
item2.detail = 'Bonus Refund'
|
724
|
+
item2.description = j[:description].to_s
|
725
|
+
item2.save()
|
726
|
+
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()
|
727
|
+
net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).amount.to_f
|
728
|
+
net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).credits.to_f
|
729
|
+
if net_amount <= 0 && net_credits < 0
|
730
|
+
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>.")
|
731
|
+
adjust.id_invoice_item = item1.id
|
732
|
+
adjust.save
|
733
|
+
end # if net_amount < 0
|
734
|
+
}
|
735
|
+
end
|
736
|
+
else # we know that: i.items.size > 1 && total < -payment_gross
|
681
737
|
raise "Refund amount is not matching with the invoice total (#{total.to_s}) and the invoice has more than 1 item."
|
682
738
|
end
|
683
739
|
# release resources
|
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.50
|
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-10-
|
11
|
+
date: 2020-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|