effective_orders 6.6.2 → 6.6.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/concerns/acts_as_purchasable.rb +3 -1
- data/app/models/effective/order.rb +15 -4
- 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: 02717fdbe9f5c91a4c6331982a1af5dd676fc06ababd575d0df0d8d80d2c5849
|
4
|
+
data.tar.gz: de81310a27bedc63d827cc0aaaff6073afa5c634136bceabe2ad7e286964b8c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8792b83fbfc309b9c351665c8f4a3cf34e3d87014c27465c8211d98ae7e1623b16a34cdea8199fab78647b060e75e38f53b89189d955317188e9a630543015d7
|
7
|
+
data.tar.gz: a514c76ef7b8ccba74b3ae81bb2da0a9534193044471811d2a09a9ca65b93d6caa86aa57e27cf90f05041b9a6ef9e591b9f6a224c63b5455e4ca3db60bc1d077
|
@@ -9,6 +9,8 @@
|
|
9
9
|
# add_column :resources, :price, :integer
|
10
10
|
# add_column :resources, :tax_exempt, :boolean, default: false
|
11
11
|
# add_column :resources, :qb_item_name, :string
|
12
|
+
#
|
13
|
+
# You can also optionally add :purchased_at :datetime, and purchased_by_id and purchased_by_type
|
12
14
|
|
13
15
|
module ActsAsPurchasable
|
14
16
|
extend ActiveSupport::Concern
|
@@ -104,7 +106,7 @@ module ActsAsPurchasable
|
|
104
106
|
end
|
105
107
|
|
106
108
|
def purchased_at
|
107
|
-
purchased_order.try(:purchased_at)
|
109
|
+
self[:purchased_at] || purchased_order.try(:purchased_at)
|
108
110
|
end
|
109
111
|
|
110
112
|
def purchased_by?(user)
|
@@ -459,7 +459,7 @@ module Effective
|
|
459
459
|
end
|
460
460
|
|
461
461
|
def purchasables
|
462
|
-
present_order_items.map { |order_item| order_item.purchasable }
|
462
|
+
present_order_items.map { |order_item| order_item.purchasable }.compact
|
463
463
|
end
|
464
464
|
|
465
465
|
def subtotal
|
@@ -596,8 +596,8 @@ module Effective
|
|
596
596
|
# Call this as a way to skip over non consequential orders
|
597
597
|
# And mark some purchasables purchased
|
598
598
|
# This is different than the Mark as Paid payment processor
|
599
|
-
def mark_as_purchased!
|
600
|
-
purchase!(skip_buyer_validations: true, email: false, skip_quickbooks: true)
|
599
|
+
def mark_as_purchased!(current_user: nil)
|
600
|
+
purchase!(skip_buyer_validations: true, email: false, skip_quickbooks: true, current_user: current_user)
|
601
601
|
end
|
602
602
|
|
603
603
|
# Effective::Order.new(items: Product.first, user: User.first).purchase!(email: false)
|
@@ -882,7 +882,18 @@ module Effective
|
|
882
882
|
end
|
883
883
|
|
884
884
|
def update_purchasables_purchased_order!
|
885
|
-
|
885
|
+
purchasables.each do |purchasable|
|
886
|
+
columns = {
|
887
|
+
purchased_order_id: id,
|
888
|
+
purchased_at: (purchased_at if purchasable.respond_to?(:purchased_at=)),
|
889
|
+
purchased_by_id: (purchased_by_id if purchasable.respond_to?(:purchased_by_id=)),
|
890
|
+
purchased_by_type: (purchased_by_type if purchasable.respond_to?(:purchased_by_type=))
|
891
|
+
}.compact
|
892
|
+
|
893
|
+
purchasable.update_columns(columns)
|
894
|
+
end
|
895
|
+
|
896
|
+
true
|
886
897
|
end
|
887
898
|
|
888
899
|
def run_purchasable_callbacks(name)
|
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.6.
|
4
|
+
version: 6.6.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: 2023-08-
|
11
|
+
date: 2023-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|