invoicing_payments_processing 1.1.29 → 1.1.34
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/invoice.rb +55 -27
- 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: 3f6d8cf264ed1fc60388ab5c360b3cfbb8fb9bbb
|
4
|
+
data.tar.gz: 7809b0efc41be10f4db464c4a37860abd6ebba02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed2466965d78a825e7f4d991f62a8a57a61775d59f6fffc2dc0bffe53204312e676059607668463a6b6a558a52c68b4a3859e49587ea1c343ee8f41943d5323c
|
7
|
+
data.tar.gz: ba1ef476b3106b96f6957c02e85421f719dc1b224fae248d144b1f282841e3c5fe5a05534c9aece1ac84fcba7ab7613b662cd31811e497ff77ae7b840bab130c
|
data/lib/invoice.rb
CHANGED
@@ -10,10 +10,16 @@ module BlackStack
|
|
10
10
|
|
11
11
|
many_to_one :buffer_paypal_notification, :class=>:'BlackStack::BufferPayPalNotification', :key=>:id_buffer_paypal_notification
|
12
12
|
many_to_one :client, :class=>:'BlackStack::Client', :key=>:id_client
|
13
|
-
many_to_one :paypal_subscription, :class=>:'BlackStack::PayPalSubscription', :key=>:id_paypal_subscription
|
13
|
+
#many_to_one :paypal_subscription, :class=>:'BlackStack::PayPalSubscription', :key=>:id_paypal_subscription
|
14
14
|
many_to_one :previous, :class=>:'BlackStack::Invoice', :key=>:id_previous_invoice
|
15
15
|
one_to_many :items, :class=>:'BlackStack::InvoiceItem', :key=>:id_invoice
|
16
16
|
|
17
|
+
def paypal_subscription
|
18
|
+
return nil if self.subscr_id.nil?
|
19
|
+
return nil if self.subscr_id.to_s.size == 0
|
20
|
+
return BlackStack::PayPalSubscription.where(:subscr_id=>self.subscr_id.to_s).first
|
21
|
+
end
|
22
|
+
|
17
23
|
# compara 2 planes, y retorna TRUE si ambos pueden coexistir en una misma facutra, con un mismo enlace de PayPal
|
18
24
|
def self.compatibility?(h, i)
|
19
25
|
return false if h[:type]!=i[:type]
|
@@ -60,6 +66,7 @@ module BlackStack
|
|
60
66
|
#
|
61
67
|
def set_subscription(s)
|
62
68
|
self.subscr_id = s.subscr_id
|
69
|
+
self.delete_time = nil
|
63
70
|
self.save
|
64
71
|
# aplico la mismam modificacion a todas las factuas que le siguieron a esta
|
65
72
|
BlackStack::Invoice.where(:id_previous_invoice=>self.id).all { |j|
|
@@ -246,6 +253,15 @@ module BlackStack
|
|
246
253
|
def canBePaid?
|
247
254
|
self.status == nil || self.status == BlackStack::Invoice::STATUS_UNPAID
|
248
255
|
end
|
256
|
+
|
257
|
+
# retorna true si el estado de la factura sea NULL o UNPAID
|
258
|
+
def canBeDeleted?
|
259
|
+
if self.paypal_subscription.nil?
|
260
|
+
return self.status == nil || self.status == BlackStack::Invoice::STATUS_UNPAID
|
261
|
+
else # !self.paypal_subscription.nil?
|
262
|
+
return (self.status == nil || self.status == BlackStack::Invoice::STATUS_UNPAID) && !self.paypal_subscription.active
|
263
|
+
end # if self.paypal_subscription.nil?
|
264
|
+
end
|
249
265
|
|
250
266
|
# actualiza el registro en la tabla invoice segun los parametros.
|
251
267
|
# en este caso la factura se genera antes del pago.
|
@@ -298,6 +314,7 @@ module BlackStack
|
|
298
314
|
end
|
299
315
|
# marco la factura como pagada
|
300
316
|
self.status = BlackStack::Invoice::STATUS_PAID
|
317
|
+
self.delete_time = nil
|
301
318
|
self.save
|
302
319
|
# expiracion de creditos de la factura anterior
|
303
320
|
i = self.previous
|
@@ -325,19 +342,21 @@ module BlackStack
|
|
325
342
|
# registro el pago
|
326
343
|
BlackStack::Movement.new().parse(item, BlackStack::Movement::MOVEMENT_TYPE_ADD_PAYMENT, "Invoice Payment", payment_time, item.id).save()
|
327
344
|
# agrego los bonos de este plan
|
328
|
-
plan[:bonus_plans].
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
345
|
+
if !plan[:bonus_plans].nil?
|
346
|
+
plan[:bonus_plans].each { |h|
|
347
|
+
plan_bonus = BlackStack::InvoicingPaymentsProcessing.plan_descriptor(h[:item_number])
|
348
|
+
raise "bonus plan not found" if plan_bonus.nil?
|
349
|
+
bonus = BlackStack::InvoiceItem.new
|
350
|
+
bonus.id = guid()
|
351
|
+
bonus.id_invoice = self.id
|
352
|
+
bonus.product_code = plan_bonus[:product_code]
|
353
|
+
bonus.unit_price = 0
|
354
|
+
bonus.units = plan_bonus[:credits] * item.number_of_packages # agrego los creditos del bono, multiplicado por la cantiad de paquetes
|
355
|
+
bonus.amount = 0
|
356
|
+
bonus.item_number = plan_bonus[:item_number]
|
357
|
+
BlackStack::Movement.new().parse(bonus, BlackStack::Movement::MOVEMENT_TYPE_ADD_BONUS, 'Payment Bonus', payment_time, item.id).save()
|
358
|
+
}
|
359
|
+
end # if !plan[:bonus_plans].nil?
|
341
360
|
#
|
342
361
|
DB.disconnect
|
343
362
|
GC.start
|
@@ -401,25 +420,34 @@ module BlackStack
|
|
401
420
|
# le seteo la fecha de hoy
|
402
421
|
self.billing_period_from = now()
|
403
422
|
#puts
|
404
|
-
#puts
|
423
|
+
#puts
|
424
|
+
# si el plan tiene un segundo trial, y
|
425
|
+
# es la primer factura, entonces:
|
426
|
+
# => se trata del segundo pago por segundo trial
|
427
|
+
if h[:trial2_fee] != nil && prev1.nil?
|
428
|
+
#puts 'b'
|
429
|
+
units = h[:trial2_credits].to_i
|
430
|
+
unit_price = h[:trial2_fee].to_f / h[:trial2_credits].to_f
|
431
|
+
billing_period_to = DB["SELECT DATEADD(#{h[:trial2_period].to_s}, +#{h[:trial2_units].to_s}, '#{self.billing_period_from.to_s}') AS [now]"].map(:now)[0].to_s
|
432
|
+
|
433
|
+
# si el plan tiene un segundo trial, y
|
434
|
+
# es la segunda factura, entonces:
|
435
|
+
# => se trata del segundo pago por segundo trial
|
436
|
+
if h[:trial2_fee] != nil && !prev1.nil? && prev2.nil?
|
437
|
+
#puts 'b'
|
438
|
+
units = h[:trial_credits].to_i
|
439
|
+
unit_price = h[:trial_fee].to_f / h[:trial_credits].to_f
|
440
|
+
billing_period_to = DB["SELECT DATEADD(#{h[:trial_period].to_s}, +#{h[:trial_units].to_s}, '#{self.billing_period_from.to_s}') AS [now]"].map(:now)[0].to_s
|
441
|
+
|
405
442
|
# si el plan tiene un primer trial, y
|
406
443
|
# es la primer factura, entonces:
|
407
444
|
# => se trata del primer pago por trial
|
408
|
-
|
445
|
+
elsif h[:trial_fee] != nil && prev1.nil? && !self.disabled_for_trial_ssm
|
409
446
|
#puts 'a'
|
410
447
|
units = h[:trial_credits].to_i
|
411
448
|
unit_price = h[:trial_fee].to_f / h[:trial_credits].to_f
|
412
449
|
billing_period_to = DB["SELECT DATEADD(#{h[:trial_period].to_s}, +#{h[:trial_units].to_s}, '#{self.billing_period_from.to_s}') AS [now]"].map(:now)[0].to_s
|
413
|
-
|
414
|
-
# si el plan tiene un segundo trial, y
|
415
|
-
# es la segunda factura, entonces:
|
416
|
-
# => se trata del segundo pago por segundo trial
|
417
|
-
elsif h[:trial2_fee] != nil && !prev1.nil? && prev2.nil?
|
418
|
-
#puts 'b'
|
419
|
-
units = h[:trial2_credits].to_i
|
420
|
-
unit_price = h[:trial2_fee].to_f / h[:trial2_credits].to_f
|
421
|
-
billing_period_to = DB["SELECT DATEADD(#{h[:trial2_period].to_s}, +#{h[:trial2_units].to_s}, '#{self.billing_period_from.to_s}') AS [now]"].map(:now)[0].to_s
|
422
|
-
|
450
|
+
|
423
451
|
# si el plan tiene un fee, y
|
424
452
|
elsif h[:fee].to_f != nil && h[:type] == BlackStack::InvoicingPaymentsProcessing::BasePlan::PAYMENT_SUBSCRIPTION
|
425
453
|
#puts 'c'
|
@@ -524,7 +552,7 @@ module BlackStack
|
|
524
552
|
self.id_previous_invoice = i.id
|
525
553
|
self.subscr_id = i.subscr_id
|
526
554
|
self.disabled_for_add_remove_items = true
|
527
|
-
|
555
|
+
|
528
556
|
i.items.each { |t|
|
529
557
|
self.add_item(t.item_number, t.number_of_packages)
|
530
558
|
#
|
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.34
|
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
|
+
date: 2020-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|