effective_orders 4.4.2 → 4.4.3
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/app/models/effective/order.rb +13 -6
- data/lib/effective_orders/version.rb +1 -1
- 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: 53a918aa7baad340d52b29cbee1606af5d82f823dc4f66ba94463e697f8beeb6
|
4
|
+
data.tar.gz: f27dd98180e0cc5d01ec02bbb9a693ec16b01c1874aae1f7f050b8aaf8631e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79cc98eaa1bc9dc98d267e61f30045acaf2e7a4b70119706d93559b4afbf49018bb4d5161a6dc38a1fa9626815557589d57d8fb36b7710e3d02827de5be5c8ae
|
7
|
+
data.tar.gz: dc79e38e4cbfa81a1feb580dc18fbaf0dab4da8f212c659332be24acc19f08228541ea48fac35e2a2fd60e8fc2004bb589933b971af1ca98a568d277332d3839
|
@@ -79,6 +79,12 @@ module Effective
|
|
79
79
|
}, unless: -> { (free? && EffectiveOrders.free?) || (refund? && EffectiveOrders.refund?) }
|
80
80
|
end
|
81
81
|
|
82
|
+
validate(if: -> { tax_rate.present? }) do
|
83
|
+
if (tax_rate > 100.0 || (tax_rate < 0.25 && tax_rate > 0.0000))
|
84
|
+
errors.add(:tax_rate, "is invalid. expected a value between 100.0 (100%) and 0.25 (0.25%) or 0")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
82
88
|
# User validations -- An admin skips these when working in the admin/ namespace
|
83
89
|
with_options unless: -> { pending? || skip_buyer_validations? } do
|
84
90
|
validates :tax_rate, presence: { message: "can't be determined based on billing address" }
|
@@ -437,12 +443,13 @@ module Effective
|
|
437
443
|
protected
|
438
444
|
|
439
445
|
def get_tax_rate
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
end
|
446
|
+
rate = instance_exec(self, &EffectiveOrders.order_tax_rate_method).to_f
|
447
|
+
|
448
|
+
if (rate > 100.0 || (rate < 0.25 && rate > 0.0000))
|
449
|
+
raise "expected EffectiveOrders.order_tax_rate_method to return a value between 100.0 (100%) and 0.25 (0.25%) or 0 or nil. Received #{rate}. Please return 5.25 for 5.25% tax."
|
445
450
|
end
|
451
|
+
|
452
|
+
rate
|
446
453
|
end
|
447
454
|
|
448
455
|
def get_tax
|
@@ -454,7 +461,7 @@ module Effective
|
|
454
461
|
|
455
462
|
def assign_order_totals
|
456
463
|
self.subtotal = order_items.map { |oi| oi.subtotal }.sum
|
457
|
-
self.tax_rate = get_tax_rate()
|
464
|
+
self.tax_rate = get_tax_rate() unless (tax_rate || 0) > 0
|
458
465
|
self.tax = get_tax()
|
459
466
|
self.total = subtotal + (tax || 0)
|
460
467
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|