trebbianno-ruby-api 0.0.6 → 0.0.7

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: 25494a201665c40fef982bbc2daaf79cfbf9b414
4
- data.tar.gz: 77e1a8f76a9c34d5a456cc5394db44309fa1cc68
3
+ metadata.gz: 598745b39be227014634557a6dd1046fb40c29d6
4
+ data.tar.gz: 982f64e02ee77688308c2518735713f000cf9cd0
5
5
  SHA512:
6
- metadata.gz: cce3225272723906ffeb841cf0bfef89063977e94fbe461094fd057109d2c0b635b256d4ba274fef712f6bdd5ffae00996acb4957a5a37bcc90e6ba0eebe12d7
7
- data.tar.gz: cf932ff0b3d92f2d7295ba3cf81811ce34c4ebc18b3045fe64fdc5fc60beb9c4d645a9a28248c4713a7a31375ea6e9941a927af8b3f618d147bec2941752c99f
6
+ metadata.gz: 3ac4788d00fca11de249a58be76df651da71e2c3612d501bc0820c36089fa3c16d190e1ceed765fd9d08baf2b99a369fb6da42f61f59e55536d7193100122b0a
7
+ data.tar.gz: 963d81cfb0fff3ae92566e04a328e0011553f8f796fb3c47cba76ec0efa65e3f318685adc0f2c7130781d22157d32651dc0acb02b3973c1356e679a1d2308054
@@ -67,12 +67,12 @@ module Trebbianno
67
67
  end
68
68
 
69
69
  def discount_percent(order)
70
- order[:item_discount].to_f.abs / line_item_count(order)
70
+ order[:item_discount].to_f.abs / line_item_total(order)
71
71
  end
72
72
 
73
- def line_item_count(order)
73
+ def line_item_total(order)
74
74
  order[:line_items].inject(0) do |sum, hash|
75
- sum + hash[:price]
75
+ sum + (hash[:price] * hash[:quantity].to_i)
76
76
  end
77
77
  end
78
78
 
@@ -1,3 +1,3 @@
1
1
  module Trebbianno
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -20,14 +20,14 @@
20
20
  <orderline>
21
21
  <ordernumber>R123123123</ordernumber>
22
22
  <sku>123332211</sku>
23
- <qty>1</qty>
24
- <unitprice>86.67</unitprice>
23
+ <qty>2</qty>
24
+ <unitprice>90.0</unitprice>
25
25
  </orderline>
26
26
  <orderline>
27
27
  <ordernumber>R123123123</ordernumber>
28
28
  <sku>123332212</sku>
29
29
  <qty>1</qty>
30
- <unitprice>173.33</unitprice>
30
+ <unitprice>180.0</unitprice>
31
31
  </orderline>
32
32
  </order>
33
33
  </orders>
@@ -39,7 +39,7 @@ describe Trebbianno::Order do
39
39
  end
40
40
 
41
41
  describe 'private#line_item_discount' do
42
- let(:discount) {[13.33, 26.67]}
42
+ let(:discount) {[10, 20]}
43
43
  it 'should calculate discount price for line item' do
44
44
  order_hash[:line_items].each_with_index do |item, index|
45
45
  discount_amount = order_client.send(:line_item_discount, item[:price], order_hash)
@@ -48,4 +48,12 @@ describe Trebbianno::Order do
48
48
  end
49
49
  end
50
50
 
51
+ describe 'private#line_item_total' do
52
+ let(:total) {400}
53
+ it 'should calculate total price for line items' do
54
+ total_amount = order_client.send(:line_item_total, order_hash)
55
+ expect(total_amount).to eq total
56
+ end
57
+ end
58
+
51
59
  end
@@ -89,7 +89,7 @@ def order_hash
89
89
  line_items: [
90
90
  {
91
91
  price: 100,
92
- quantity: "1",
92
+ quantity: "2",
93
93
  sku: "123332211",
94
94
  size: "XS"
95
95
  },
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trebbianno-ruby-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Grubbs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder