gecko-ruby 0.7.1 → 0.8.0
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 +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +4 -0
- data/lib/gecko/record/order_line_item.rb +17 -0
- data/lib/gecko/version.rb +1 -1
- data/test/record/order_line_item_test.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb9de08507d0105e06a6d879856fa389834a6854e27947f24ed4ffd9fb84a64e
|
4
|
+
data.tar.gz: f869506161aa22431c4eed00e71b326678a45d612e4d15754bfaba831b954784
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b6eef606da5df282eba8fa943a73a6460d3a5a51cbd824158a6b76bdcef7cc2d817124735839b4ca0af866df6cb1075d348016c626a700767bd7445c4b6733a
|
7
|
+
data.tar.gz: 901d13594b029897e6de3033fa0f153b7ba9d1f0654fa233f5ec5580b9499a0f33c29680a21d4e90a2af30902ba77db12c652f7b74bda58ef3629db0e19a08ad
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.8.0 (2019-07-01)
|
2
|
+
- Add `discount_amount` attribute and `discounted_price` helper to `OrderLineItem`'s
|
3
|
+
- Drop support for Ruby 2.3
|
4
|
+
|
1
5
|
## 0.7.1 (2019-03-19)
|
2
6
|
- Add `Gecko::Record::Note` model.
|
3
7
|
- Fix issue with `find_many` which manifested as a bug in `has_many` definitions with cached records being duplicated when more than 100 children existed.
|
@@ -17,6 +17,8 @@ module Gecko
|
|
17
17
|
attribute :shippable, Boolean, readonly: true
|
18
18
|
|
19
19
|
attribute :discount, BigDecimal
|
20
|
+
attribute :discount_amount, BigDecimal
|
21
|
+
|
20
22
|
attribute :quantity, BigDecimal
|
21
23
|
attribute :price, BigDecimal
|
22
24
|
attribute :tax_rate_override, BigDecimal
|
@@ -24,6 +26,21 @@ module Gecko
|
|
24
26
|
attribute :position, Integer
|
25
27
|
|
26
28
|
attribute :image_url, String, readonly: true
|
29
|
+
|
30
|
+
def discounted_price
|
31
|
+
if discount_amount&.nonzero?
|
32
|
+
price - discount_amount
|
33
|
+
else
|
34
|
+
price * discount_multiplier
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def discount_multiplier
|
41
|
+
return 1 unless discount
|
42
|
+
1 - discount / 100
|
43
|
+
end
|
27
44
|
end
|
28
45
|
|
29
46
|
class OrderLineItemAdapter < BaseAdapter
|
data/lib/gecko/version.rb
CHANGED
@@ -15,4 +15,14 @@ class Gecko::OrderLineItemTest < Minitest::Test
|
|
15
15
|
def test_initializes_record
|
16
16
|
assert_instance_of(Gecko::Record::OrderLineItem, @record)
|
17
17
|
end
|
18
|
+
|
19
|
+
def test_discounted_price_with_discount
|
20
|
+
record = record_class.new(client, price: 20, discount: 20)
|
21
|
+
assert_equal(16, record.discounted_price)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_discounted_price_with_discount_amount
|
25
|
+
record = record_class.new(client, price: 20, discount_amount: 5)
|
26
|
+
assert_equal(15, record.discounted_price)
|
27
|
+
end
|
18
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gecko-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bradley Priest
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|