invoicing_payments_processing 1.1.66 → 1.1.71

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: 03f105a212299b603c5141bf1d86ade1acca82fa
4
- data.tar.gz: 43ddbb50a0fcbee4d4ae106a24d8696011924413
3
+ metadata.gz: 03642e6ff05908b903f7101dfb46527d1df67a40
4
+ data.tar.gz: fe13c8dbb7ef0a4ba3c04d69088f24edb755c15d
5
5
  SHA512:
6
- metadata.gz: 1b6ffbe7aa139fe61da64f82afc6655ea19d2212d66045b9d3f64ac3ea7eab39db713380f19edcbb02acb85ac5e1ffc185c2274b8743a0be0c807d8867a90c56
7
- data.tar.gz: 90f23ff431761cbf2717c52970168a8856c67cd925a8d52fedd20561eed9495e0ca5eea15816ae5cec6d7be00c98389c4517d49ed5aeb982f85f5b21dad94f5f
6
+ metadata.gz: 832296731ab80f51100056338d3f2a3672e7a63df3b225cf6aeb57b835fe1207ab14fb247ebc5f01a0a1ec2dc09c10b81d65a6e2dbfd285c38c85cdd40a71900
7
+ data.tar.gz: cad3907f4259afa7b890dc02e1bb2a06cdbfc68060491a597b2fda847940044895dd6c9d43bbcb66b979b11d8597ba7d4c3c7bc7f71c1a7576da801be08bc81a
@@ -42,27 +42,38 @@ module BlackStack
42
42
  # 3) haciendo coincidir el primer guid en el codigo de invoice, con el id del cliente
43
43
  def get_client()
44
44
  puts
45
- puts "BlackStack::BufferPayPalNotification::get_client"
46
- puts 'debug info:'
47
- puts "self.invoice:#{self.invoice.to_s}:."
45
+ puts "get_client: BlackStack::BufferPayPalNotification::get_client"
46
+ puts "get_client: self.invoice:#{self.invoice.to_s}:."
48
47
  # obtengo el cliente que machea con este perfil
49
48
  c = nil
50
49
  if c.nil?
50
+ puts 'get_client: a'
51
51
  if self.invoice.guid?
52
+ puts 'get_client: a1'
53
+ puts "get_client: #{self.invoice.to_s}"
52
54
  i = BlackStack::Invoice.where(:id=>self.invoice).first
53
- c = i.client if !i.nil?
55
+ if !i.nil?
56
+ c = i.client
57
+ puts 'get_client: a1a'
58
+ else
59
+ puts 'get_client: a1b'
60
+ end
54
61
  end
55
62
  end
56
63
  if c.nil?
64
+ puts 'get_client: b'
57
65
  iid = self.invoice.split(".").last.to_s
58
66
  if iid.guid?
67
+ puts 'get_client: b1'
59
68
  i = BlackStack::Invoice.where(:id=>iid).first
60
69
  c = i.client if !i.nil?
61
70
  end
62
71
  end
63
72
  if c.nil?
73
+ puts 'get_client: c'
64
74
  cid = self.invoice.split(".").first.to_s
65
75
  if cid.guid?
76
+ puts 'get_client: c1'
66
77
  c = BlackStack::Client.where(:id=>cid).first
67
78
  end
68
79
  end
@@ -32,11 +32,17 @@ module BlackStack
32
32
  end
33
33
 
34
34
  # how many minutes ago should have updated the table stat_balance with the amount and credits of this client, for each product.
35
+ # return a positive integer if either:
36
+ # 1. the client didn't update stats in the last 24 hours, or
37
+ # 2. the client has a new record in the table movements after its last update in the table stat_balance.
35
38
  def stat_balance_delay_minutes
36
39
  row = DB[
37
40
  "SELECT TOP 1 m.id " +
38
41
  "FROM client c WITH (NOLOCK) " +
39
- "JOIN movement m WITH (NOLOCK INDEX(IX_movement__id_client__create_time_desc)) ON ( c.id=m.id_client AND m.create_time > ISNULL(c.last_stat_balance_update_time, '1900-01-01') ) " +
42
+ "JOIN movement m WITH (NOLOCK INDEX(IX_movement__id_client__create_time_desc)) ON ( " +
43
+ " c.id=m.id_client AND " +
44
+ " ( m.create_time > ISNULL(c.last_stat_balance_update_time, '1900-01-01') OR ISNULL(c.last_stat_balance_update_time, '1900-01-01') < DATEADD(DD,-1,GETDATE()) ) " +
45
+ ") " +
40
46
  "WHERE c.id = '#{self.id}' " +
41
47
  "ORDER BY m.create_time DESC "
42
48
  ].first
@@ -625,29 +625,31 @@ module BlackStack
625
625
  end # if net_amount < 0
626
626
  # hago el reembolso de cada bono de este item
627
627
  # si el balance quedo en negativo, entonces aplico otro ajuste
628
- h[:bonus_plans].each { |bonus|
629
- i = BlackStack::InvoicingPaymentsProcessing::plans_descriptor.select { |obj| obj[:item_number] == bonus[:item_number] }.first
630
- j = BlackStack::InvoicingPaymentsProcessing::products_descriptor.select { |obj| obj[:code] == i[:product_code] }.first
631
- item2 = BlackStack::InvoiceItem.new()
632
- item2.id = guid()
633
- item2.id_invoice = self.id
634
- item2.unit_price = 0
635
- item2.units = -i[:credits]
636
- item2.amount = 0
637
- item2.product_code = i[:product_code].to_s
638
- item2.item_number = i[:item_number].to_s
639
- item2.detail = 'Bonus Refund'
640
- item2.description = j[:description].to_s
641
- item2.save()
642
- 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()
643
- net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).amount.to_f
644
- net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).credits.to_f
645
- if net_amount <= 0 && net_credits < 0
646
- 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>.")
647
- adjust.id_invoice_item = item1.id
648
- adjust.save
649
- end # if net_amount < 0
650
- }
628
+ if !h[:bonus_plans].nil?
629
+ h[:bonus_plans].each { |bonus|
630
+ i = BlackStack::InvoicingPaymentsProcessing::plans_descriptor.select { |obj| obj[:item_number] == bonus[:item_number] }.first
631
+ j = BlackStack::InvoicingPaymentsProcessing::products_descriptor.select { |obj| obj[:code] == i[:product_code] }.first
632
+ item2 = BlackStack::InvoiceItem.new()
633
+ item2.id = guid()
634
+ item2.id_invoice = self.id
635
+ item2.unit_price = 0
636
+ item2.units = -i[:credits]
637
+ item2.amount = 0
638
+ item2.product_code = i[:product_code].to_s
639
+ item2.item_number = i[:item_number].to_s
640
+ item2.detail = 'Bonus Refund'
641
+ item2.description = j[:description].to_s
642
+ item2.save()
643
+ 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()
644
+ net_amount = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).amount.to_f
645
+ net_credits = 0.to_f - BlackStack::Balance.new(self.client.id, i[:product_code].to_s).credits.to_f
646
+ if net_amount <= 0 && net_credits < 0
647
+ 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>.")
648
+ adjust.id_invoice_item = item1.id
649
+ adjust.save
650
+ end # if net_amount < 0
651
+ }
652
+ end # if !h[:bonus_plans].nil?
651
653
  # release resources
652
654
  DB.disconnect
653
655
  GC.start
@@ -63,7 +63,7 @@ module BlackStack
63
63
 
64
64
  def self.plan_descriptor(item_number)
65
65
  plan = BlackStack::InvoicingPaymentsProcessing::plans_descriptor.select { |h| h[:item_number].to_s == item_number.to_s }.first
66
- raise "Plan not found" if plan.nil?
66
+ raise "Plan not found (#{item_number.to_s})" if plan.nil?
67
67
  plan
68
68
  end
69
69
 
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.66
4
+ version: 1.1.71
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-13 00:00:00.000000000 Z
11
+ date: 2020-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket