invoicing_payments_processing 1.1.34 → 1.1.44

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: 3f6d8cf264ed1fc60388ab5c360b3cfbb8fb9bbb
4
- data.tar.gz: 7809b0efc41be10f4db464c4a37860abd6ebba02
3
+ metadata.gz: 80d3ca746b1107a72f4c17d306270b5f6fe93824
4
+ data.tar.gz: a4ad5aa3f8dbf0afe51cd032c327dd4782d319e3
5
5
  SHA512:
6
- metadata.gz: ed2466965d78a825e7f4d991f62a8a57a61775d59f6fffc2dc0bffe53204312e676059607668463a6b6a558a52c68b4a3859e49587ea1c343ee8f41943d5323c
7
- data.tar.gz: ba1ef476b3106b96f6957c02e85421f719dc1b224fae248d144b1f282841e3c5fe5a05534c9aece1ac84fcba7ab7613b662cd31811e497ff77ae7b840bab130c
6
+ metadata.gz: bf0f15d5ad94dad4dc66466d74211847b66103b79c2fb974ca54c51bd8f12a7837b84de6a42399ffbf928d866f2faf08814d731ae649389db96cf3aabd33cd37
7
+ data.tar.gz: 297e7a2c8d260d1122d95877ac53a4ded685fc4b0339acabb3b6daea869419ffbea7fe049e35594b9a3a03eb3d84a0d397d15c5bd8534e506260caf7a0c5f54e
@@ -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()
@@ -211,7 +211,7 @@ module BlackStack
211
211
  trial2 = allow_trials && plan_descriptor[:trial2_fee]!=nil && plan_descriptor[:trial2_period]!=nil && plan_descriptor[:trial2_units]!=nil
212
212
 
213
213
  values[:a3] = 0
214
- self.items.each { |i|
214
+ self.items.each { |i|
215
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
@@ -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
- 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
-
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)
27
+ elsif (t==MOVEMENT_TYPE_CANCELATION)
28
28
  return "Service"
29
- elsif (self.type==MOVEMENT_TYPE_EXPIRATION)
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.34
4
+ version: 1.1.44
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