effective_orders 6.17.2 → 6.18.0

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
  SHA256:
3
- metadata.gz: 99c22cc9267f019464b0cbb247b2f8eabf68c08551d16f74a6cb9e154b4ce9e9
4
- data.tar.gz: a6e0b04da49e8e2d9b5a7e29c5c65f3f578f1ef4e0ac0a87bba973d4b4247899
3
+ metadata.gz: '0559a1dd68e0c43937ccf7a6e13c0f4e8f54c0bf79382744a360f5151b613340'
4
+ data.tar.gz: 1ae3981f93b86d70bc6706b7688351d3ea555aa9700265e9dc62616eb449f96c
5
5
  SHA512:
6
- metadata.gz: c561eb9f18162140d55623b381a1d39f0e97b303ce4dd0a929d313a8963e96390929231315c91891c720a6435cb6c55048d9a34af766df59be8fb76ddb307a73
7
- data.tar.gz: 83f804873fae8cbba1da4a62a98a613249d4b5af54797538102bab81205c4a7e386faf5a2cedc4b89f72f88e4bd59136fee43d803e8bc9b6fb0fcf5f0c5aa398
6
+ metadata.gz: 4e44abc94fabf240ca5d7c8d446c362f2aca1e59afffc55724753471499acec7fb9bf52d6e6a78469a7763f820c659dfb4a033a80bc09f6452d498fce9283b80
7
+ data.tar.gz: c648c5762abbb8b39842e1424a78631e614128404ffe73859232bc350d619ba4df5a5da1e22f3632bf357b94b4a8dd66ece50d1b080272903f5b124a500684ed
@@ -935,7 +935,13 @@ module Effective
935
935
  protected
936
936
 
937
937
  def get_subtotal
938
- present_order_items.map { |oi| oi.subtotal }.sum
938
+ subtotal = present_order_items.map { |oi| oi.subtotal }.sum
939
+
940
+ if subtotal.to_i < 0 && EffectiveOrders.no_refund?
941
+ return 0
942
+ end
943
+
944
+ subtotal
939
945
  end
940
946
 
941
947
  def get_tax_rate
@@ -950,7 +956,14 @@ module Effective
950
956
 
951
957
  def get_tax
952
958
  return 0 unless tax_rate.present?
953
- present_order_items.reject { |oi| oi.tax_exempt? }.map { |oi| (oi.subtotal * (tax_rate / 100.0)).round(0).to_i }.sum
959
+
960
+ tax = present_order_items.reject { |oi| oi.tax_exempt? }.map { |oi| (oi.subtotal * (tax_rate / 100.0)).round(0).to_i }.sum
961
+
962
+ if tax.to_i < 0 && EffectiveOrders.no_refund?
963
+ return 0
964
+ end
965
+
966
+ tax
954
967
  end
955
968
 
956
969
  def get_amount_owing
@@ -242,6 +242,8 @@ EffectiveOrders.setup do |config|
242
242
  # config.buyer_purchases_refund = false
243
243
  # config.send_refund_notification_to_admin = false
244
244
  #
245
+ # If you set config.refund = false, Negative order price is set to $0. Can checkout free.
246
+ #
245
247
  # You can call order.send_refund_notification! directly or implement a better one in your app
246
248
  config.refund = false
247
249
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.17.2'.freeze
2
+ VERSION = '6.18.0'.freeze
3
3
  end
@@ -127,6 +127,10 @@ module EffectiveOrders
127
127
  refund.kind_of?(Hash)
128
128
  end
129
129
 
130
+ def self.no_refund?
131
+ !refund?
132
+ end
133
+
130
134
  def self.buyer_purchases_refund?
131
135
  buyer_purchases_refund == true
132
136
  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: 6.17.2
4
+ version: 6.18.0
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: 2024-11-19 00:00:00.000000000 Z
11
+ date: 2024-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails