effective_orders 6.17.1 → 6.18.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1694915aa5c646859677437bf8eef6227c2301dd850928cb4d7c179fcf74a17a
4
- data.tar.gz: 702d26261725a04e5ef44ae247aa98719204f2090d99f0e7326ec91422f792a2
3
+ metadata.gz: '0559a1dd68e0c43937ccf7a6e13c0f4e8f54c0bf79382744a360f5151b613340'
4
+ data.tar.gz: 1ae3981f93b86d70bc6706b7688351d3ea555aa9700265e9dc62616eb449f96c
5
5
  SHA512:
6
- metadata.gz: eace5c4d6ab80404524a861323b58dff8e7f84af4714ec3001eb29724faf545dda03312a5c92b362364512e93113051c601428455a43689be8912d0318192a96
7
- data.tar.gz: c63d78cc2e5e97c66f4995124753722bcd55ba7ed7edc2b28ccf58bf62dc710ad02298339fc8935fc115284efabffda2ac5280ee971ed5d8b88054a134b90ddf
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
@@ -4,7 +4,7 @@
4
4
 
5
5
  %p
6
6
  = succeed('.') do
7
- - distance = distance_of_time_in_words(Time.zone.now, order.delayed_payment_date)
7
+ - distance = distance_of_time_in_words(Time.zone.now, order.delayed_payment_date.beginning_of_day)
8
8
 
9
9
  The payment date for this order
10
10
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  %p
11
11
  = succeed('.') do
12
- - distance = distance_of_time_in_words(Time.zone.now, order.delayed_payment_date)
12
+ - distance = distance_of_time_in_words(Time.zone.now, order.delayed_payment_date.beginning_of_day)
13
13
 
14
14
  The payment date for this order
15
15
 
@@ -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.1'.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.1
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-13 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