invoicing_payments_processing 1.1.31 → 1.1.41

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91c8cdb3f2b07357df4ed4d7e53b42f3d13ccce9
4
- data.tar.gz: 60242afcacd6a836b87324255b0a39af9cad79e7
3
+ metadata.gz: 8b262508f5bb5461883af0c385256bc6011ed4aa
4
+ data.tar.gz: f57520e8d02e50ecdd5638d5392680223bb0e77c
5
5
  SHA512:
6
- metadata.gz: 9c0951c13e1665cb9c5b5e16a5fa1024667fcd2178701d7c9f8ab8ab620a95837b45f5a8375c283eeb36dff9f240159deac6a5864d0be3ab75f6fbae0f2d4133
7
- data.tar.gz: 6cb8ab4e9a8332c7d934a3629e673a0869a62076a03dc2177987e1eec1e515a56f981b1cfdac44e33efc5c50c98f4b5b8fb67dd868dd2057f4e1c6e83e331503
6
+ metadata.gz: be69442d3cb147180d5a373f3bf1a71e81221de43957440df516751e954a1cdcd859da86685b8e76ab95fada8f63cd43044fec24dbc469b0c2daf33c866353b4
7
+ data.tar.gz: 9c6ee401ce0094ba5c08f8476a65e10f3720ac0350dcf43cd627f78e0b326897b2cd9c8c8d1d3f283e0a0ce81c9e3f89edc5199467f5e04ca92982a86f9b6802
@@ -236,6 +236,9 @@ module BlackStack
236
236
  def self.process(params)
237
237
  DB.transaction do
238
238
  # verifico que no existe ya una notificacion
239
+ puts
240
+ puts
241
+ puts "params2:#{params.to_s}:."
239
242
  b = BlackStack::BufferPayPalNotification.where(:id=>params['id']).first
240
243
  if b.nil?
241
244
  # proceso la notificacion
@@ -299,7 +302,7 @@ module BlackStack
299
302
 
300
303
  # marco la factura como pagada
301
304
  # registro contable - bookkeeping
302
- i.getPaid() if i.canBePaid?
305
+ i.getPaidb.create_time) if i.canBePaid?
303
306
 
304
307
  # crea una factura para el periodo siguiente (dia, semana, mes, anio)
305
308
  j = BlackStack::Invoice.new()
@@ -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|
@@ -204,7 +211,7 @@ module BlackStack
204
211
  trial2 = allow_trials && plan_descriptor[:trial2_fee]!=nil && plan_descriptor[:trial2_period]!=nil && plan_descriptor[:trial2_units]!=nil
205
212
 
206
213
  values[:a3] = 0
207
- self.items.each { |i|
214
+ self.items.each { |i|
208
215
  if trial1 && i.units!=i.plan_descriptor[:trial_credits]
209
216
  raise 'Cannot order more than 1 package and trial in the same invoice'
210
217
  elsif trial1
@@ -308,6 +315,11 @@ module BlackStack
308
315
  # marco la factura como pagada
309
316
  self.status = BlackStack::Invoice::STATUS_PAID
310
317
  self.delete_time = nil
318
+ if self.previous.nil? # si es la primer factura de una suscripcion, o no es una suscripcion
319
+ diff = payment_time - self.billing_period_from
320
+ self.billing_period_from = payment_time
321
+ self.billing_period_to += diff
322
+ end
311
323
  self.save
312
324
  # expiracion de creditos de la factura anterior
313
325
  i = self.previous
@@ -413,7 +425,7 @@ module BlackStack
413
425
  # le seteo la fecha de hoy
414
426
  self.billing_period_from = now()
415
427
  #puts
416
- #puts
428
+ #puts
417
429
  # si el plan tiene un primer trial, y
418
430
  # es la primer factura, entonces:
419
431
  # => se trata del primer pago por trial
@@ -422,7 +434,7 @@ module BlackStack
422
434
  units = h[:trial_credits].to_i
423
435
  unit_price = h[:trial_fee].to_f / h[:trial_credits].to_f
424
436
  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
425
-
437
+
426
438
  # si el plan tiene un segundo trial, y
427
439
  # es la segunda factura, entonces:
428
440
  # => se trata del segundo pago por segundo trial
@@ -431,7 +443,7 @@ module BlackStack
431
443
  units = h[:trial2_credits].to_i
432
444
  unit_price = h[:trial2_fee].to_f / h[:trial2_credits].to_f
433
445
  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
434
-
446
+
435
447
  # si el plan tiene un fee, y
436
448
  elsif h[:fee].to_f != nil && h[:type] == BlackStack::InvoicingPaymentsProcessing::BasePlan::PAYMENT_SUBSCRIPTION
437
449
  #puts 'c'
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.31
4
+ version: 1.1.41
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-21 00:00:00.000000000 Z
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket