pricing_observer 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6de3e7fe38515e671b95aa179e1ff6b9e7f81fc
4
- data.tar.gz: ed9e58cc44de9b44dc183d8c97c9b85e98d93f77
3
+ metadata.gz: 3f0484f4c46d61a9bc1943a0da9a230cf45e7e92
4
+ data.tar.gz: 993a13bbd0fa6134af1b8d41fff0296da5f926fe
5
5
  SHA512:
6
- metadata.gz: c34d2f9d17cea0be066f7ed75414fe9026075f84be6adea064e1a6a9d3df44c164793956b95d8eb6f751ce2f60099dd1b052890a52ce26963e3857177d7f0cde
7
- data.tar.gz: 2107513d5c130f04722c0850e6ccacd437def2ad6fbbe6f9284839a61321730280794a36c06114b02a9839e43644f626f896ff425c290b1aa6b793de129bec5f
6
+ metadata.gz: c68cbd4e1d312e4f3c6be667a8950a1556b985d44a1b85d88baf4f0fa962dbaf737da38b56c2ea01494c180d5d322930858e2834cc4809d24453c5c8c778b0f3
7
+ data.tar.gz: 27d3fc366e97eda752f1b7c1aa3f50046700277ff34269b4a5110b62f82495da01039cea27be41e978f2f5ec2121ca61bfc9fb97e4b36d03e5c97d5fcd8c742b
@@ -17,10 +17,10 @@ class OrderSend
17
17
  end
18
18
 
19
19
  #notify's the observer when an desired condition is triggered
20
- def notify_observers
20
+ def notify_observers(check_store)
21
21
  @observers.each do |observer|
22
22
  puts "Notifying"
23
- observer.pricing_by_hit
23
+ observer.pricing_by_hit(check_store)
24
24
  puts "Notified the observer"
25
25
  end
26
26
  end
@@ -34,47 +34,48 @@ class Pricing
34
34
  puts "observer initialized"
35
35
  end
36
36
  #this is the logical pricing method that is triggered by the observer when ever the condition is met to be executed.
37
- def pricing_by_hit
38
- #order_record = OrderItem.last
39
- #prod = Product.find(order_record.product_id)
40
- puts("before product assumption")
41
- products = Product.all
42
- puts("after product assumption")
43
-
37
+ def pricing_by_hit(check_store)
38
+ #order_record = OrderItem.last
39
+ #prod = Product.find(order_record.product_id)
40
+ check_store.each do |store_with_id|
41
+ puts("before product assumption")
42
+ products = Product.where(store_detail_id: store_with_id)
43
+ puts("after product assumption")
44
+
44
45
  products.each do |prod|
45
- prod.price = 12
46
+ #prod.price = 43
46
47
  puts(prod.hit.inspect)
47
- case prod.hit
48
- when 1
49
- prod.offerPrice = prod.offerPrice + (prod.offerPrice/50)
50
- when 2
51
- prod.offerPrice = prod.offerPrice - (prod.offerPrice/100)
52
- when 3
53
- prod.offerPrice = prod.offerPrice - (prod.offerPrice/95)
54
- when 4
55
- prod.offerPrice = prod.offerPrice - (prod.offerPrice/90)
56
- when 5
57
- prod.offerPrice = prod.offerPrice - (prod.offerPrice/85)
58
- when 6
59
- prod.offerPrice = prod.offerPrice - (prod.offerPrice/80)
60
- when 7
61
- prod.offerPrice = prod.offerPrice - (prod.offerPrice/75)
62
- when 8
63
- prod.offerPrice = prod.offerPrice - (prod.offerPrice/70)
64
- when 9
65
- prod.offerPrice = prod.offerPrice - (prod.offerPrice/65)
66
- when 10
67
- prod.offerPrice = prod.offerPrice - (prod.offerPrice/60)
68
- else
69
- prod.offerPrice = 5
70
- end
71
- if(prod.offerPrice < 5)
72
- prod.offerPrice = 5
73
- elsif (prod.offerPrice > 12)
74
- prod.offerPrice = 5
75
- end
48
+ case prod.hit
49
+ when 1
50
+ prod.offerPrice = prod.offerPrice + (prod.offerPrice/4)
51
+ when 2
52
+ prod.offerPrice = prod.offerPrice - (prod.offerPrice/36)
53
+ when 3
54
+ prod.offerPrice = prod.offerPrice - (prod.offerPrice/32)
55
+ when 4
56
+ prod.offerPrice = prod.offerPrice - (prod.offerPrice/28)
57
+ when 5
58
+ prod.offerPrice = prod.offerPrice - (prod.offerPrice/24)
59
+ when 6
60
+ prod.offerPrice = prod.offerPrice - (prod.offerPrice/20)
61
+ when 7
62
+ prod.offerPrice = prod.offerPrice - (prod.offerPrice/16)
63
+ when 8
64
+ prod.offerPrice = prod.offerPrice - (prod.offerPrice/12)
65
+ when 9
66
+ prod.offerPrice = prod.offerPrice - (prod.offerPrice/8)
67
+ when 10
68
+ prod.offerPrice = prod.offerPrice - (prod.offerPrice/4)
69
+ else
70
+ prod.offerPrice = 18
71
+ end
72
+ if(prod.offerPrice < 15)
73
+ prod.offerPrice = 15
74
+ elsif(prod.offerPrice > 45)
75
+ prod.offerPrice = 30
76
+ end
76
77
  prod.save
77
78
  end
79
+ end
78
80
  end
79
-
80
81
  end
@@ -1,3 +1,3 @@
1
1
  module PricingObserver
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pricing_observer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kishore Kumar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-18 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler