effective_orders 6.5.1 → 6.5.3

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: 50e50d0522839732f2b09182eed975cfc98db1f63d45702bc36e64a41469d218
4
- data.tar.gz: 670ca09718feb451ec82a7afd756a8ce836133142f6054270df26963b99443d9
3
+ metadata.gz: 71798da0cd20778fab3e106211f2e7b0ef691f38ba568e9161739b6016a54c18
4
+ data.tar.gz: 5261409794ba913635a2966cc6afc7086f4e31e3cc80aea214716270d65536fc
5
5
  SHA512:
6
- metadata.gz: 227bd996aa9b95c20413c674527f4bf55cd9464ddecab2f11560bb42eb08094b41d619dfe5b9458a0670a346db7ad4d2763b3aa5b6eaa567fc18a45b8711d596
7
- data.tar.gz: 9a34850eeedb567162e452bd5d9165eabf1a34fd151d0fa16b6eb808b813d761d1c558b29de408fd230dbc2361845d629da844258d2470b10c15f85491f7be0b
6
+ metadata.gz: 9ed613f93dba098d010277e6bf8cd0eeeba6ef9e3f66d417e5010558c31f1132250e1ee83afe9b9f9a1b8356d60e0118a8178ddba4208e0b4927b9eabec8a955
7
+ data.tar.gz: c19f20987bfb6e0431eba2a0b5e45b70f824202c9a894223891a7f93d5bf16504271918a501153249bd54183aa3f0c04ff1e4b9126666aafcad9dafa7ed9118d
@@ -112,6 +112,7 @@ module Effective
112
112
  before_validation { assign_user_address }
113
113
  before_validation { assign_billing_name }
114
114
  before_validation { assign_billing_email }
115
+ before_validation { assign_order_item_values }
115
116
  before_validation { assign_order_values }
116
117
  before_validation { assign_order_charges }
117
118
  end
@@ -582,6 +583,12 @@ module Effective
582
583
  false
583
584
  end
584
585
 
586
+ # Called by effective_memberships to update prices from purchasable fees
587
+ # Not called internally
588
+ def update_purchasable_attributes
589
+ present_order_items.each { |oi| oi.update_purchasable_attributes }
590
+ end
591
+
585
592
  # Call this as a way to skip over non consequential orders
586
593
  # And mark some purchasables purchased
587
594
  # This is different than the Mark as Paid payment processor
@@ -840,12 +847,14 @@ module Effective
840
847
  end
841
848
  end
842
849
 
843
- # This overwrites the prices, taxes, surcharge, etc on every save.
850
+ # These two overwrites the prices, taxes, surcharge, etc on every save.
844
851
  # Does not get run from the before_validate on purchase.
845
- def assign_order_values
852
+ def assign_order_item_values
846
853
  # Copies prices from purchasable into order items
847
854
  present_order_items.each { |oi| oi.assign_purchasable_attributes }
855
+ end
848
856
 
857
+ def assign_order_values
849
858
  # Calculated from each item
850
859
  self.subtotal = get_subtotal()
851
860
 
@@ -37,7 +37,17 @@ module Effective
37
37
 
38
38
  # This method is called in a before_validation in order.assign_order_values()
39
39
  def assign_purchasable_attributes
40
- assign_attributes(name: purchasable.purchasable_name, price: purchasable.price, tax_exempt: purchasable.tax_exempt) if purchasable
40
+ return unless purchasable.present?
41
+
42
+ self.name ||= purchasable.purchasable_name
43
+ self.price ||= purchasable.price
44
+ self.tax_exempt = purchasable.tax_exempt if self.tax_exempt.nil?
45
+ end
46
+
47
+ def update_purchasable_attributes
48
+ if purchasable.present? && !marked_for_destruction?
49
+ assign_attributes(name: purchasable.purchasable_name, price: purchasable.price, tax_exempt: purchasable.tax_exempt)
50
+ end
41
51
  end
42
52
 
43
53
  def build_purchasable(atts = {})
@@ -48,7 +48,7 @@ class CreateEffectiveOrders < ActiveRecord::Migration[4.2]
48
48
 
49
49
  t.string :name
50
50
  t.integer :quantity
51
- t.integer :price, :default => 0
51
+ t.integer :price
52
52
  t.boolean :tax_exempt
53
53
 
54
54
  t.timestamps
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.5.1'.freeze
2
+ VERSION = '6.5.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.5.1
4
+ version: 6.5.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-06-05 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -340,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
340
340
  - !ruby/object:Gem::Version
341
341
  version: '0'
342
342
  requirements: []
343
- rubygems_version: 3.1.2
343
+ rubygems_version: 3.4.10
344
344
  signing_key:
345
345
  specification_version: 4
346
346
  summary: Quickly build an online store with carts, orders, automatic email receipts