invoicing_payments_processing 1.1.36 → 1.1.45

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: 965a8f6366881eb0e4bc2bfc47bc1afe2ce09e11
4
- data.tar.gz: a9b9c23cfed343171d9e815574cb56659e652bf4
3
+ metadata.gz: 96b6b82545bec9e8ad6436566f423590c675896b
4
+ data.tar.gz: 14c8e6fd2576d65d28d3bb47a464374140ed2b28
5
5
  SHA512:
6
- metadata.gz: 261a8ac7175609664b8580f69259a96e39cc8f495ed448ed6dcc4d8e1ad8e87e7f9f297e1b4ff461b21c0d95ea92a9f958b39199977ff9c73c11a0448a08ae9a
7
- data.tar.gz: aee9ab4c785dcc5072b008ed1547debd27763a5283b6088dc7013f9f92649cc7856a79cd1be54446e92115dfc333e91e09bc0635e2634172c7143f180e879170
6
+ metadata.gz: 7d9d89e381365acb4bcde6021370f8486c3ede55d82821b8d4af7ded903bee26c008a7515cc2793dbd8a7c4f750921918f5964860d76e702ca49e033e163a58c
7
+ data.tar.gz: 15048cf0e56f42e72eeab5ba7a6f6ec75f40f6c3fbe8631d983eb496918e92ce27986094a488ed1e0a0e9de668c5439ed523340dfce7be03d48082f14f9fb538
@@ -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.getPaid(b.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()
@@ -212,7 +212,7 @@ module BlackStack
212
212
 
213
213
  values[:a3] = 0
214
214
  self.items.each { |i|
215
- if ( !trial2 && trial1 && i.units!=i.plan_descriptor[:trial_credits] ) || ( trial2 && trial1 && i.units!=i.plan_descriptor[:trial2_credits] )
215
+ if trial1 && i.units!=i.plan_descriptor[:trial_credits]
216
216
  raise 'Cannot order more than 1 package and trial in the same invoice'
217
217
  elsif trial1
218
218
  values[:a3] += i.plan_descriptor[:fee].to_f
@@ -315,6 +315,11 @@ module BlackStack
315
315
  # marco la factura como pagada
316
316
  self.status = BlackStack::Invoice::STATUS_PAID
317
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.to_time - self.billing_period_from.to_time
320
+ self.billing_period_from = payment_time
321
+ self.billing_period_to = self.billing_period_to.to_time + diff
322
+ end
318
323
  self.save
319
324
  # expiracion de creditos de la factura anterior
320
325
  i = self.previous
@@ -421,33 +426,24 @@ module BlackStack
421
426
  self.billing_period_from = now()
422
427
  #puts
423
428
  #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
- elsif 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
-
442
429
  # si el plan tiene un primer trial, y
443
430
  # es la primer factura, entonces:
444
431
  # => se trata del primer pago por trial
445
- elsif h[:trial_fee] != nil && prev1.nil? && !self.disabled_for_trial_ssm
432
+ if h[:trial_fee] != nil && prev1.nil? && !self.disabled_for_trial_ssm
446
433
  #puts 'a'
447
434
  units = h[:trial_credits].to_i
448
435
  unit_price = h[:trial_fee].to_f / h[:trial_credits].to_f
449
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
450
437
 
438
+ # si el plan tiene un segundo trial, y
439
+ # es la segunda factura, entonces:
440
+ # => se trata del segundo pago por segundo trial
441
+ elsif h[:trial2_fee] != nil && !prev1.nil? && prev2.nil?
442
+ #puts 'b'
443
+ units = h[:trial2_credits].to_i
444
+ unit_price = h[:trial2_fee].to_f / h[:trial2_credits].to_f
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
446
+
451
447
  # si el plan tiene un fee, y
452
448
  elsif h[:fee].to_f != nil && h[:type] == BlackStack::InvoicingPaymentsProcessing::BasePlan::PAYMENT_SUBSCRIPTION
453
449
  #puts 'c'
@@ -15,20 +15,25 @@ module BlackStack
15
15
  MOVEMENT_TYPE_ADJUSTMENT = 6 # it can be recalculated
16
16
  MOVEMENT_TYPE_REFUND_ADJUSTMENT = 7 # it cannot be recalculated
17
17
 
18
- def typeName()
19
- if (self.type==MOVEMENT_TYPE_ADD_PAYMENT)
18
+ def self.typeName(t)
19
+ if (t==MOVEMENT_TYPE_ADD_PAYMENT)
20
20
  return "Payment"
21
- elsif (self.type==MOVEMENT_TYPE_ADD_BONUS)
21
+ elsif (t==MOVEMENT_TYPE_ADD_BONUS)
22
22
  return "Bonus"
23
- elsif (self.type==MOVEMENT_TYPE_REASSIGN_BALANCE)
23
+ elsif (t==MOVEMENT_TYPE_REASSIGN_BALANCE)
24
24
  return "Reassignation"
25
- elsif (self.type==MOVEMENT_TYPE_REFUND_BALANCE)
25
+ elsif (t==MOVEMENT_TYPE_REFUND_BALANCE)
26
26
  return "Refund"
27
- elsif (self.type==MOVEMENT_TYPE_CANCELATION)
28
- return "Service"
29
- elsif (self.type==MOVEMENT_TYPE_EXPIRATION)
27
+ elsif (t==MOVEMENT_TYPE_CANCELATION)
28
+ return "Consumption"
29
+ elsif (t==MOVEMENT_TYPE_EXPIRATION)
30
30
  return "Expiration"
31
31
  end
32
+ '(unknown)'
33
+ end
34
+
35
+ def typeName()
36
+ BlackStack::Movement::typeName(self.type)
32
37
  end
33
38
 
34
39
  def typeColorName()
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.36
4
+ version: 1.1.45
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