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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86a4f7535e5766ae1bff99cbabd94b9b134c381c255a8f745ef6e63f5685f7cb
4
- data.tar.gz: e55dd3dd359e7e46bd5bedb251eece208e36cabefef22caaa8c57e3eb84ee9c1
3
+ metadata.gz: 02717fdbe9f5c91a4c6331982a1af5dd676fc06ababd575d0df0d8d80d2c5849
4
+ data.tar.gz: de81310a27bedc63d827cc0aaaff6073afa5c634136bceabe2ad7e286964b8c3
5
5
  SHA512:
6
- metadata.gz: 968a79995bdd6ea7bb51d170145dc375fa6db28095238fad9f18c3e18b6126b4179e692715ae02f68fa707f9c94506418039250691dbf771e690ebe6413784d1
7
- data.tar.gz: 0a346ecf19463553ebf8ee7ced123067ac750809036de53ba09775fb72a8d870572bfb49d2d8a16d91a9e41c10ed3aff5bdf4d31f97861ee477cc66399688061
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
- order_items.each { |oi| oi.purchasable&.update_column(:purchased_order_id, self.id) }
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)
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.6.2'.freeze
2
+ VERSION = '6.6.3'.freeze
3
3
  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.6.2
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-02 00:00:00.000000000 Z
11
+ date: 2023-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails