effective_products 0.3.7 → 0.3.8

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: 2b339a0aac52ca7f1cb0723ea8807061a5bfe58a593b735cb7fd3963fbb3b365
4
- data.tar.gz: 11bb3d70210a7cd213440f95f758cc9219de554d1610fbea2393124150a5d48b
3
+ metadata.gz: 8126cdc9fd87848c7da280fb0e2ecc23cd4c83beb1f5efbb07aa2b0d7ebdbb1f
4
+ data.tar.gz: 71481f64c82b4a422bfc7b348e286cf8099c50adf6b897774e3a4ea76890f43e
5
5
  SHA512:
6
- metadata.gz: 4b6b20349a62da271c83a550ef954134b5e7b5f4ba38e2fc4cdbe79f2553c577470968b294cf39f9894c5e20ed2e0a07ddff8dc06da3265010d9f2258ebb185e
7
- data.tar.gz: 26b65e114b40e52abcb62d7153c6f95b3bcc7c8dfc52259a8227353f0a4af8c51947ff50d11741525d41b773c75dfbcf91767d0be0829f741f03e82070fb2260
6
+ metadata.gz: b4c894fff91b9dc09933d3ed0d461c7698f33f5f8f45ed964ec07d622a7a78bf42650cc9a283522984f7a6e1df7bb705ea3a4fed4310ada9c6828128c688e753
7
+ data.tar.gz: 36ebdab52e77a293f8f5905a6cb1b0a531442bdb5f7303d57937c452d09a0fd650663c6a5042f19f50271a8c816312391a9b5ae124ebf3696b4da08d7c28fb03
@@ -72,15 +72,15 @@ module Effective
72
72
  validates :shipping_address, presence: true, unless: -> { category == 'Digital-only' }
73
73
 
74
74
  validate(if: -> { name.present? && name_confirmation.present? }) do
75
- self.errors.add(:name_confirmation, "doesn't match name") unless name == name_confirmation
75
+ errors.add(:name_confirmation, "doesn't match name") unless name == name_confirmation
76
76
  end
77
77
 
78
78
  validate(if: -> { category.present? }) do
79
- self.errors.add(:category, "is not included") unless EffectiveProducts.stamp_categories.include?(category)
79
+ errors.add(:category, "is not included") unless EffectiveProducts.stamp_categories.include?(category)
80
80
  end
81
81
 
82
82
  validate(if: -> { admin_action }) do
83
- self.errors.add(:owner_id, "must have a membership") unless owner && owner.try(:membership).present?
83
+ errors.add(:owner_id, "must have a membership") unless owner && owner.try(:membership).present?
84
84
  end
85
85
 
86
86
  def to_s
@@ -114,19 +114,25 @@ module Effective
114
114
 
115
115
  # This is the Admin Save and Mark Paid action
116
116
  def mark_paid!
117
- update!(admin_action: true) # Make sure we have an owner with a membership
118
- raise('expected an user with a membership category') unless owner && owner.try(:membership).present?
117
+ assign_attributes(admin_action: true)
119
118
 
120
- category = owner.membership.categories.first
119
+ category = owner&.membership&.categories&.first
121
120
 
122
- assign_attributes(
123
- price: category.stamp_fee,
124
- tax_exempt: category.stamp_fee_tax_exempt,
125
- qb_item_name: category.stamp_fee_qb_item_name
126
- )
121
+ if category.present?
122
+ assign_attributes(
123
+ price: category.stamp_fee,
124
+ tax_exempt: category.stamp_fee_tax_exempt,
125
+ qb_item_name: category.stamp_fee_qb_item_name
126
+ )
127
+ end
127
128
 
128
- submitted!
129
- Effective::Order.new(items: self, user: owner).mark_as_purchased!
129
+ submitted! # Will fail with invalid owner membership anyway
130
+
131
+ if category.present?
132
+ Effective::Order.new(items: self, user: owner).mark_as_purchased!
133
+ end
134
+
135
+ true
130
136
  end
131
137
 
132
138
  end
@@ -5,11 +5,7 @@
5
5
  = f.text_field :name_confirmation, hint: 'must match name'
6
6
 
7
7
  - collection = local_assigns[:parent].try(:stamp_categories) || EffectiveProducts.stamp_categories
8
-
9
- - if collection.length == 1
10
- = f.hidden_field :category, value: collection.first
11
- - else
12
- = f.select :category, collection
8
+ = f.select :category, collection
13
9
 
14
10
  %h4 Shipping address
15
11
  = effective_address_fields(f, :shipping)
@@ -1,3 +1,3 @@
1
1
  module EffectiveProducts
2
- VERSION = '0.3.7'.freeze
2
+ VERSION = '0.3.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_products
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
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-07-15 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails